Skip to content

update: extend exact token-only verify to remaining MLA and dense families - #3424

Merged
inureyes merged 3 commits into
mainfrom
update/issue-3421-mla-dense-verify-scope
Nov 25, 2026
Merged

inureyes merged 3 commits into
mainfrom
update/issue-3421-mla-dense-verify-scope

Conversation

@inureyes

Copy link
Copy Markdown
Member

Summary

Extends the opt-in exact token-only verify scope (MLXCEL_MLA_ROW_INVARIANT=1, #3420) to the families #3418 left open. With the variable unset no forward enters a row-invariant scope, so the default path is unchanged (decode ABAB below).

  • DeepSeek V3.2: every verify-block row runs the decode step's single DSA query over its prefix of the stored [latent | indexer key] window with its own indexer top-k; projections (indexer included), gate and LM head row-invariant; float experts per position.
  • DeepSeek V2 (in): a verify block appends and attends one row at a time on both the latent and the decompressed layout.
  • Llama3Model (K2 Horizon) and Arcee: the fused QKV split goes through row_invariant::linear_whole_block (the layer's own forward outside a scope); inside one the fused rope and compiled MLP launchers give way to the composed graph, and a block attends one row at a time.
  • OLMoE: a verify block runs routing and experts per position (the fused single-token MoE kernel) and attends per row.
  • MLA path stats count a per-row verify block once per layer (mla::stats::as_one_call).

Open points: Kimi Linear, Kimi K3 and LongCat are out. The token-only round refuses them (model-owned KDA or n-gram state without a verify rewind), so no block forms and the KDA layers never see one; the survey reports "not run" on every cell and a test per family pins the refusal. DeepSeek V2 is in: it takes the round and carries the same split.

Measurements (M3 Ultra)

Survey, engine path, widths 2/4/8 at 8/600/2100 tokens: off, every cell differs on both kernels (first difference layer 0 output). On: afm-4.5b and k2-horizon-0.9b equal on bf16 (9/9); deepseek-v2-lite and olmoe equal with MLXCEL_QMV_WIDE=0 (9/9). Decode ABAB against main, variable unset, same tokens: K2 Horizon 211.50 vs 211.80, OLMoE 410.21 (421.24 without a cold first run) vs 421.21, V2-Lite 173.28 vs 174.58 tok/s. Details in docs/benchmark_results/speculative-exactness-followup-m3ultra-2026-11-25.md section 3.

Not done: deepseek-v3.2-4bit not loaded (tiny-model test only); the diagnostic names the first layer, not the op inside it; prompt-lookup throughput with the variable on was not measured for these families.

Test plan

  • Tiny-model block-versus-chain tests for V3.2, V2, Llama 3, Arcee, OLMoE (float and 4-bit), widths 2/4/8/12; each fails without the scope
  • Extended path-count test in deepseek_v3_verify_block_tests.rs plus V3.2 and V2 equivalents
  • Narrow selectors: models::llama3 models::arcee models::olmoe models::deepseek_v2 models::deepseek_v32 models::deepseek_v3 models::kimi_linear models::longcat coverage_tests, core mla::stats row_invariant qkv
  • Contract checks, clippy (lib/tests/bins and mlxcel-core), fmt; broad gate left to the orchestrator

Closes #3421

…ilies

A token-only verify block (prompt lookup, a full-model drafter) still parted from single-token decode on DeepSeek V3.2, DeepSeek V2, Llama 3 (K2 Horizon), Arcee and OLMoE. Under the existing opt-in MLXCEL_MLA_ROW_INVARIANT=1 these now enter the row-invariant scope: dense projections take the row-invariant product, a verify block attends one row at a time as its decode steps do (V3.2 with each row's own indexer top-k), float experts and OLMoE's MoE run per position, and the Llama-class fused rope and compiled MLP launchers give way to the composed graph inside the scope. With the variable unset no forward enters a scope.

Kimi Linear, Kimi K3 and LongCat stay out: the token-only round refuses them, so no block forms; tests pin the refusal. A per-row MLA verify block now records one path-stat entry per layer instead of one per row.

Validated with tiny-model block-versus-chain tests per family (widths 2, 4, 8, 12), the survey on seven local checkpoints (Arcee and K2 Horizon equal on bf16, V2 and OLMoE equal with MLXCEL_QMV_WIDE=0), and decode ABAB against main with no regression.

Closes #3421
@inureyes inureyes added status:review Under review type:performance Performance improvements priority:low Low priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) labels Nov 25, 2026
Bilingual report for the exact token-only verify scope on the remaining MLA and dense families.
…-dense-verify-scope

# Conflicts:
#	docs/environment-variables.md
@inureyes
inureyes marked this pull request as ready for review November 25, 2026 03:42
@inureyes
inureyes merged commit 37447eb into main Nov 25, 2026
15 checks passed
@inureyes
inureyes deleted the update/issue-3421-mla-dense-verify-scope branch November 25, 2026 03:43
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:inference Generation, sampling, decoding (incl. speculative, DRY) area:models Model architectures, weights, loading, metadata priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: Extend exact token-only verify scope to remaining MLA and dense families

1 participant