Skip to content

refactor: migrate the final ffai/ families — sdpa, quant, stragglers - #27

Merged
TheTom merged 5 commits into
devfrom
ek/kernel-reorg-sdpa-quant
Jun 22, 2026
Merged

refactor: migrate the final ffai/ families — sdpa, quant, stragglers#27
TheTom merged 5 commits into
devfrom
ek/kernel-reorg-sdpa-quant

Conversation

@ekryski

@ekryski ekryski commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

The final consolidation: empties ffai/ entirely and folds the last families into kernels/.

What moved

  • kernels/sdpa/ (new, 26 files) — all attention: bidirectional / decode / multi / prefill (head-dims d32–d512, relpos/windowed/conformer/2pass/batched/sink), the quantized + block-scaled flash forms, AURA compressed-domain attention (flash/score/value), DSv4 compressed-sparse-attention (CSA) decode + Lightning Indexer + compressor, head-gate, and the mlx scaled_dot_product_attention + sdpa_vector.
  • kernels/quant/ — unifies the host SSOT (codec/format/gguf, moved from src/quant/) with the dequant GPU kernels (gguf_dequant_*, aura encode/dequant, dequant_gather, fp8_block/mxfp4 dequant, dequant_q4, block_scaled_dequant). All 228 crate::quant:: refs repointed.
  • kernels/ops/ — activation stragglers (leaky_relu, gelu_erf, gate_up_swiglu_fused, swiglu_limit).
  • kernels/hyper_connections/ (new) — manifold-constrained hyper-connections (mhc, mhc_sinkhorn_split).

Naming

ffai_mt_; bare kernels (aura_, flash_quantized_sdpa, sdpa_decode_{2pass,batched}_, dequant_gather variants) → mt_; dsv4_ model prefix dropped (csa/indexer/compressor/mhc/swiglu_limit are the operations). aura kept (codec/technique, per plan §2).

Cleanup

Pruned the dead mlx/conv.rs + mlx/shared.rs stubs and the now-empty ffai/ module. ffai/ is gone; only mlx/steel/ (steel attn/conv templates) remains as a separate template-infra concern.

Verification

cargo build --workspace, clippy --all-targets -D warnings clean, full tile test = 1394 suites / 4125 tests / 0 failed, 1272 kernels codegen. Consumer-test imports + AURA MSL snapshots updated.

Stacked on #26 (the §7 format-axis fold-out).

@github-actions github-actions Bot added the ignore-for-release Hidden from release notes label Jun 14, 2026
@github-actions

github-actions Bot commented Jun 14, 2026

Copy link
Copy Markdown

Commit message hygiene check

All commit messages and PR text are clean. ✅

@TheTom

TheTom commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@ekryski clean, ffai/ fully drained, 228 crate::quant:: refs + the codegen crate repointed to kernels::quant::. Two notes: (1) this deletes the same mlx/{conv,shared}.rs as #19, coordinate ordering; (2) see the bench-CI follow-up I flagged on #28, it applies to the post-drain state. Approve.

@TheTom
TheTom force-pushed the ek/kernel-format-axis-fold branch from 29d92dd to 0f871c8 Compare June 22, 2026 21:29
ekryski added 5 commits June 22, 2026 16:29
…s family

Move the leftover activation kernels into kernels/ops/ (leaky_relu, gelu_erf,
gate_up_swiglu_fused, + dsv4_swiglu_limit -> swiglu_limit) and the manifold-
constrained hyper-connection kernels into a new kernels/hyper_connections/
family (mhc, mhc_sinkhorn_split). Drop ffai_/dsv4_ prefixes -> mt_ (dsv4 is a
model name; mhc/swiglu_limit are the operations).

Verified 1272 kernels codegen; swiglu_limit (3) + mhc (18) tests pass; clippy clean.
Move all 26 attention kernels from mlx/ + ffai/ into a new kernels/sdpa/ family:
the bidirectional / decode / multi / prefill paths (head-dims d32..d512, relpos /
windowed / conformer / 2pass / batched / sink variants), the quantized +
block-scaled flash forms, the AURA compressed-domain attention (flash + score +
value), the DSv4 compressed-sparse-attention (CSA) decode + Lightning Indexer +
compressor, the head-gate, and the mlx scaled_dot_product_attention + sdpa_vector.

Naming: ffai_ -> mt_; bare aura_*/flash_quantized_sdpa/sdpa_decode_{2pass,batched}_*
-> mt_; dsv4_ model prefix dropped (csa/indexer/compressor are the operations).
Fixed consumer-test imports + the AURA MSL snapshots (renamed kernel).

Verified 1272 kernels codegen; sdpa in-file tests (160) + external suites pass;
clippy -D warnings clean.
… ffai/

Move src/quant/ (codec, format, gguf host SSOT) into kernels/quant/ and migrate
the dequant GPU kernels there too: aura_{dequant_rotated,encode}, dequant_gather
(+block_scaled), gguf_dequant_* (+iq2xxs extract), dsv4_{fp8_block,mxfp4}_dequant
-> {fp8_block,mxfp4}_dequant, ffai_dequant_q4 -> dequant_q4, mlx block_scaled_dequant.
Repointed all 228 crate::quant:: refs (incl the relative quant:: inside the §7
test setups' use crate::{} blocks) -> crate::kernels::quant::. Dropped ffai_/dsv4_
prefixes -> mt_. Pruned the dead mlx conv.rs/shared.rs stubs and the now-empty
ffai/ module. Updated consumer-test imports + AURA MSL snapshots.

ffai/ is fully migrated (folder removed); only mlx/steel/ (steel attn/conv
templates) remains. Verified: 1272 kernels codegen; quant tests (gguf/dequant/
aura/...) pass; clippy -D warnings clean.
@TheTom
TheTom force-pushed the ek/kernel-reorg-sdpa-quant branch from 0be5a16 to e043987 Compare June 22, 2026 21:29
@TheTom
TheTom changed the base branch from ek/kernel-format-axis-fold to dev June 22, 2026 21:29
@TheTom
TheTom merged commit 27cdc41 into dev Jun 22, 2026
8 of 21 checks passed
@ekryski
ekryski deleted the ek/kernel-reorg-sdpa-quant branch July 13, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release Hidden from release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants