Skip to content

update: batch decode for mixed-cache model families - #2672

Merged
inureyes merged 4 commits into
mainfrom
update/issue-2569-batched-cache-families
Oct 27, 2026
Merged

inureyes merged 4 commits into
mainfrom
update/issue-2569-batched-cache-families

Conversation

@inureyes

@inureyes inureyes commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Ministral3, ExaOne4, Mellum, Laguna and Step3p5 now use isolated sequence-owned caches and native batched decode; Step3p7 delegates embedding/text admission and decode. Scalar graphs remain unchanged. Review added atomic identity validation and paged shadow-memory accounting.

Focused isolation/native/delegation/DFlash tests, the integrated 12-test coverage gate, formatting and targeted clippy passed. On M3 Ultra 512 GB, all four measured checkpoints have identical greedy output and B=1 traces versus baseline. B=4 decided-position disagreement is zero for all four.

Model Baseline / branch aggregate tok/s at concurrency 4 B=4 top-1 disagreement
ExaOne 1.2B 226.1 / 434.0 2/256
Ministral 3B text view 115.5 / 203.3 3/256
Laguna XS.2 94.1 / 170.6 21/256
Mellum2 12B 52.3 / 81.8 0/256

Warm B=1 medians: ExaOne 272.3→271.0, Laguna 109.1→109.9 tok/s, with overlapping ranges. Ministral uses unchanged weights in a text-only config view because the original VLM loader selects another tower. Mellum uses a fixed Rust corpus: the baseline document corpus produces a non-finite NLL, a pre-existing limitation disclosed in the report. Step3p5/Step3p7 are synthetically validated only; no local checkpoint. Bilingual reports and benchmark JSON record all ladders and methods.

Closes #2569. Part of #2574.

@inureyes inureyes added status:review Under review type:performance Performance improvements priority:high High priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) modeltype:text Text-only language model modeltype:vlm Vision-language model arch:dense Dense transformer decoder arch:moe Sparse mixture-of-experts decoder labels Oct 27, 2026
@inureyes
inureyes force-pushed the update/issue-2569-batched-cache-families branch from 16a2cef to 4cb5917 Compare October 27, 2026 07:40
Give Ministral 3, ExaOne 4, Mellum, Laguna and Step 3.5 sequence-owned caches and native multirow decode while preserving the single-row path. Delegate Step 3.7 embedding prefill and text decode to the same sequence-local backbone state.

Exercise wrapped windows, position scaling, attention gates, sinks and concurrent admission with nonzero synthetic weights. Reuse the model-owned cache harness correction from #2568.

Refs #2569
Reject malformed tensor, cache-row, and sequence-id cardinalities before routing can mutate caches. Apply duplicate and missing-state validation to the multi-token and masked per-row fallback while preserving B=1 lazy state creation and the existing single-row graph.

Cover all five converted families with state-integrity regressions for rejected batches.

Refs #2569
Model-owned mixed caches left the server's paged shadow tables at zero length, so block accounting and configured budgets did not track active full or sliding KV. Mirror each layer's visible length for all five wrappers and delegate the same hook through Step3p7.

Add focused paged-override regressions for the text families and the VLM delegation path.

Refs #2569
@inureyes
inureyes force-pushed the update/issue-2569-batched-cache-families branch from 4cb5917 to 0fb22d0 Compare October 27, 2026 07:58
Record the four checkpoint ladders, exact single-row parity, review hardening and coverage evidence. Preserve the Ministral text-view setup, Mellum corpus limitation and unmeasured Step3p5/Step3p7 scope in bilingual reports and compact benchmark data.
@inureyes inureyes added status:done Completed and removed status:review Under review labels Oct 27, 2026
@inureyes
inureyes marked this pull request as ready for review October 27, 2026 08:15
@inureyes
inureyes merged commit ffea911 into main Oct 27, 2026
31 checks passed
@inureyes
inureyes deleted the update/issue-2569-batched-cache-families branch October 27, 2026 08:57
inureyes added a commit that referenced this pull request Oct 31, 2026
…2802)

tests/step3p7_parity.rs is a separate integration binary, so the suite's ctor pin (pin_full_precision_f32_matmuls_for_tests in src/lib.rs) is #[cfg(test)] and never reaches it. Under MLX's default TF32 GEMMs (cuBLAS CUBLAS_COMPUTE_32F_FAST_TF32) the B=2 batched decode and the B=1 solo decode take different f32 GEMM shapes and round differently: max abs error 8.07e-4/1.16e-3 against the 1e-5 bound (5.96e-7/4.47e-7 with MLX_ENABLE_TF32=0). The test failed deterministically 3/3 on GB10 since its introduction in #2672, whose validation ran on M3 Ultra only.

Add a #[ctor::ctor(unsafe)] that sets MLX_ENABLE_TF32=0 only when unset, mirroring src/lib.rs and the per-binary pattern in tests/cuda_sdpa_determinism.rs. The 1e-5 bound is unchanged; widening the tolerance to about 2e-3 is rejected because the project treats TF32 output as not f32 evidence and 1e-3 would hide a real row-mixing bug at this logit scale.

Validation on CUDA (GB10, --test-threads=1 under gpu-lock): all 8 tests pass with no env override, and an explicit operator MLX_ENABLE_TF32=1 still overrides the pin (the batched-decode test fails at the same line-583 assertion, proving the operator setting wins). No real-checkpoint check is possible: no Step-3 / step3p7 checkpoint exists under models/ or in ~/models-101/manifest.tsv. Metal is unaffected (no TF32 there); NAX-class Apple GPUs (generation 17) apply TF32 by default per src/lib.rs and would likely fail the same way without the pin, not verified.

Closes #2793
@inureyes inureyes added this to the 0.8 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:dense Dense transformer decoder arch:moe Sparse mixture-of-experts decoder area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata modeltype:text Text-only language model modeltype:vlm Vision-language model priority:high High priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(models): move RefCell-cache wrappers to per-sequence batched decode

1 participant