Repository navigation
docs(cache): record #370 fused-V attempt regression, keep Turbo4Asym on dequant-SDPA - #378
Merged
Merged
Conversation
…on dequant-SDPA #370 proposed fusing the Turbo4Asym V dequant into the attention kernel to reach int8/delegated decode speed. Turbo4Asym is the all-cold case of Turbo4Delegated, so the attempt routed it through the existing delegated steel-envelope fused kernel (cold_offset=offset, hot_offset=0). Parity held (RMS < 5e-3 over 16 decode steps), but the M1 Ultra benchmark on qwen2.5-7b-4bit measured a 3-7x decode regression, not a win: mode 4K 16K 32K fp16 94.83 68.95 50.62 turbo4-asym dequant-SDPA 28.61 22.76 14.55 (0.30/0.33/0.29x) turbo4-asym steel (attempt) 10.68 4.41 2.15 (0.11/0.06/0.04x) turbo4-delegated 63.50 48.38 34.64 (0.67/0.70/0.68x) The hand-written fused kernel is slower than native SDPA over a materialized V, and Turbo4Delegated's 0.7x comes from its default dequant-SDPA path, not the steel envelope (which is delegated's slow fallback). The #370 premise did not hold and there is no fused-asym path worth shipping. Decision (ADR 0002 addendum): keep Turbo4Asym on the exact dequant-SDPA path and steer the fp16-K + 4-bit-V speed use case to Turbo4Delegated, which the --recommend-quant advisor already promotes. The remaining asym-vs-delegated gap is the hot/cold split, not V-dequant fusion, and is left as-is by design. No code change: the fused-kernel wiring was reverted after the benchmark. Adds the measured sweep under benchmarks/turbo_kv/ as the evidence.
be-free-snowboy
pushed a commit
to freestylejs/snowbrain-mlxcel
that referenced
this pull request
Oct 27, 2026
…4Asym on dequant-SDPA (lablup#378) lablup#370 proposed fusing the Turbo4Asym V dequant into the attention kernel to reach int8/delegated decode speed. Turbo4Asym is the all-cold case of Turbo4Delegated, so the attempt routed it through the existing delegated steel-envelope fused kernel (cold_offset=offset, hot_offset=0). Parity held (RMS < 5e-3 over 16 decode steps), but the M1 Ultra benchmark on qwen2.5-7b-4bit measured a 3-7x decode regression, not a win: mode 4K 16K 32K fp16 94.83 68.95 50.62 turbo4-asym dequant-SDPA 28.61 22.76 14.55 (0.30/0.33/0.29x) turbo4-asym steel (attempt) 10.68 4.41 2.15 (0.11/0.06/0.04x) turbo4-delegated 63.50 48.38 34.64 (0.67/0.70/0.68x) The hand-written fused kernel is slower than native SDPA over a materialized V, and Turbo4Delegated's 0.7x comes from its default dequant-SDPA path, not the steel envelope (which is delegated's slow fallback). The lablup#370 premise did not hold and there is no fused-asym path worth shipping. Decision (ADR 0002 addendum): keep Turbo4Asym on the exact dequant-SDPA path and steer the fp16-K + 4-bit-V speed use case to Turbo4Delegated, which the --recommend-quant advisor already promotes. The remaining asym-vs-delegated gap is the hot/cold split, not V-dequant fusion, and is left as-is by design. No code change: the fused-kernel wiring was reverted after the benchmark. Adds the measured sweep under benchmarks/turbo_kv/ as the evidence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#370 asked to fuse the
Turbo4AsymV dequant into the attention kernel so it reaches int8/delegated decode speed (0.7-0.8x fp16), or to document thatTurbo4Delegatedis the recommended fast fp16-K + 4-bit-V mode withTurbo4Asymas the exact/simple fallback. I took the first route, benchmarked it on real hardware, and it does not work, so this PR lands the documented decision backed by the measurement.What was tried
Turbo4Asymis structurally the all-cold case ofTurbo4Delegated(FP16 K, every visible V token 4-bit packed, no hot FP16 tail). So the attempt routed asym decode through the existing delegated steel-envelope fused kernel (attention_turbo4_delegated_steel) withcold_offset = offset, hot_offset = 0. The kernel fuses the cold-V dequant into the attention accumulate and never materializes V.Turbo4Asymdecode through the steel kernel matched the dequant-SDPA reference at RMS < 5e-3 (threshold 0, no skip).qwen2.5-7b-4bit, decode tok/s:The fused kernel makes asym 3x slower at 4K and 7x slower at 32K.
Why
Turbo4Delegated's 0.66-0.80x does not come from the steel kernel. The delegated decode path defaults to dequant-SDPA (turbo4_delegated_dequant_sdpa_enabled()is on by default and returns before the steel try); the steel envelope is delegated's slow fallback. The premise that motivated perf(cache): fuse V dequant into Turbo4Asym attention (reach int8/delegated decode speed) #370 (delegated is fast because it fuses V dequant into the kernel) was wrong.There is no fuse-into-native-SDPA option, because MLX's SDPA consumes a dense V.
Decision
Keep
Turbo4Asymon the exact dequant-SDPA path (the simple, fully-quantized-V, untouched-K option at ~0.3-0.5x). For the fp16-K + 4-bit-V use case that wants speed, useTurbo4Delegated(~4x V compression at ~0.7x decode), which the--recommend-quantadvisor already promotes (post-#376), so no advisor change is needed. The remaining asym-vs-delegated gap is the hot/cold split, not V-dequant fusion, and is left as-is by design.Changes
docs/turbo-kv-cache.md: point the fp16-K speed use case atturbo4-delegated; record the perf(cache): fuse V dequant into Turbo4Asym attention (reach int8/delegated decode speed) #370 outcome.scripts/bench_kv_cache.sh: update the stale "fused kernel tracked in perf(cache): fuse V dequant into Turbo4Asym attention (reach int8/delegated decode speed) #370" comment.benchmarks/turbo_kv/2026-06-21_..._370_asym_fused_attempt.csv: the committed measurement.No code change: the fused-kernel wiring was reverted after the benchmark. Validation is the real-checkpoint benchmark above.
Closes #370