Repository navigation
fix(cuda): reject mid-buffer KV slices in the cuDNN decode test - #3138
Merged
Merged
Conversation
On CUDA, Llama 4 Scout decoded garbage after a prompt longer than 8192 tokens. A chunked layer's decode window is a slice that starts partway into the cache buffer. The overlay's `is_kv_cache_slice` checked only that the widened view matched the allocation's size, so the window passed, `unslice_kv` rebased it to the buffer start, and cuDNN attended to the keys at the front of the buffer once the window reached `kv_cache_step` (256). `kv_cache_slice_extent` already had the base-offset check; `is_kv_cache_slice` now has it too, and the comment that called the case hypothetical is corrected. Validation on GB10: Scout with an 8720-token prompt answers correctly with and without prefill chunking, and a teacher-forced decode after that prefill shows 0/149 decided disagreements against the deterministic SDPA reference. The new `chunked_decode_over_a_long_mid_buffer_window_matches_the_chunk_mask` test fails without the fix (relative rms 1.12) and passes with it. Refs #3133
This was referenced Nov 17, 2026
inureyes
added a commit
that referenced
this pull request
Nov 17, 2026
This was referenced Nov 17, 2026
Member
Author
|
Correction to the validation notes above (the merged report is fixed in #3149).
|
inureyes
added a commit
that referenced
this pull request
Nov 18, 2026
…3149) Issue #3133 measured the 2026-11 MLA and prefill-memory changes on CUDA (GB10). Absorbed decode on CUDA takes the composed path, which on Metal had cost about 10% at 512 tokens before the fused kernel. On GB10 it decodes within run-to-run noise of the decompressed path at 512 tokens (medians +0.3 to +2.6% over three five-run cells), about 20% faster behind 2K and 2.4x behind 16K, with 0 decided disagreements in the teacher-forced trace, so #3102's switch rule holds. `mla::default_absorbs_on` now makes the unset `MLXCEL_MLA_ABSORBED` absorb where the fused kernel runs and on CUDA; ROCm, the CPU backend and Metal with the kernel off keep the decompressed default. `kv_arch` already reads `mla::absorbed_enabled()`, so V2-Lite at 32K now estimates 972.0 MiB of KV on CUDA instead of 8.44 GiB. Adds the GB10 results (decode, prefill peak, traces, gate) under `docs/benchmark_results/`, updates the MLA and environment docs and the CHANGELOG, and corrects the #3138 report: its Scout reference was a single-pass prefill trace, not the deterministic SDPA path, and the 8001-token run's last three steps already showed the defect. Closes #3133
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.
On CUDA, Llama 4 Scout decoded garbage (
Itemfollowed by U+FFFD runs) after a prompt longer than 8192 tokens, found while measuring #3133.MLXCEL_SDPA_DETERMINISTIC=1hid it, which pointed at the cuDNN dispatch.A chunked layer's decode window is a slice that starts partway into the cache buffer. The overlay's
is_kv_cache_sliceonly checked that the widened view matched the allocation's size, so the window passed.unslice_kvthen rebased it to the buffer start, and cuDNN attended to the keys at the front of the buffer once the window reachedkv_cache_step(256).kv_cache_slice_extentalready rejected a non-zerokv.offset()but called the case hypothetical.is_kv_cache_slicenow carries the same check, and that comment is corrected.Validation (GB10, sm_121)
--temp 0: correct answer and identical output withMLXCEL_PREFILL_CHUNK=0and the default chunking. Before the fix, both were garbage, and so were builds from before perf(models): fold the remaining hand-masked MLA prefills into SDPA #3114 and perf(models): run attention-sink prefill in MLX causal and window mode #3119.chunked_decode_over_a_long_mid_buffer_window_matches_the_chunk_mask: chunk 512, f16, an 800-token prefill, then decode over a window of 289 or more keys. It fails without the fix (relative rms 1.12) and passes with it. Allcache::attendtests pass on CUDA.cache::paged_detachhas two tests that trip adebug_assertatpaged_detach.rs:1095, with or without this commit. They pass undertest-fast.Refs #3133