Repository navigation
feat: survey speculative exactness and make Inkling verify exact - #3415
Merged
Merged
Conversation
PR #3405 found five reasons an Inkling 2 verify block differed from decode, two of them invisible to the 8-token startup probe. This surveys the other drafter-capable families on an M3 Ultra at widths 2, 4 and 8, after short prompts and after 600 and 2100 tokens, and fixes the one family whose cause is dense gemv/gemm. - Survey: the quantized gated families (Qwen 3.5, Qwen3.8-Flash-Next, Gemma 4 12B and 31B, GLM-4.7-Flash, LFM2) are exact on the narrow quantized kernel at every width and context length, and their drafter-on text equals classic text on a prompt past the prefill chunk. Gemma 4 26B A4B declines in its MoE feed-forward. The ungated token-only verify round differs on every model it takes. Table in docs/benchmark_results/speculative-exactness-survey-m3ultra-2026-11-25.md. - Diagnostic: the Gemma 4 probe trace becomes models::speculative_exactness_diag (capture, locate, report), used by the Gemma 4 and Inkling startup probes, the DeepSeek V3 layer loop, the survey test and the Inkling 2 per-visit test. - Inkling: dense products go through mlxcel_core::row_invariant, and inside a verify block the short convolutions, the experts and sliding attention past the window run per position. The probe now passes on the bf16 0.6B checkpoint, where it declined at layer 0 before. Decode is 244.4 tok/s with the kernel against 239.3 without (8 ABAB pairs). MLXCEL_INKLING_ROW_INVARIANT=0 restores the old products. - Probe: models::speculative_exactness_draws owns the draw plan. Families with a sliding layer (Inkling, Laguna, Muse Glimmer, Gemma 4 as before) add one draw past the window; the others run the draws they ran before. MLXCEL_MTP_PROBE_LONG_CONTEXT moves the gate. - Kernel: row_invariant_matvec indexes its inputs instead of taking device pointers, because MLX binds an array of fewer than 8 elements as constant and the Metal library then failed to build (a tiny test model's row). Validated with the narrow lib selections for the touched families, clippy and the contract checks. Not measured: MTP throughput on Inkling and the long draw on Laguna and Muse Glimmer checkpoints, none of which is on disk. Refs #3409
…eculative-exactness-survey
…eculative-exactness-survey
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
Surveys block-versus-chain exactness across the drafter-capable families on an M3 Ultra (widths 2, 4, 8; short prompts, 600 and 2100 tokens) and makes Inkling's verify block byte-identical to decode, the one family whose cause was dense gemv/gemm.
docs/benchmark_results/speculative-exactness-survey-m3ultra-2026-11-25.md): Qwen 3.5, Qwen3.8-Flash-Next, Gemma 4 12B and 31B, GLM-4.7-Flash and LFM2 are exact on the narrow quantized kernel at every width and context length, and drafter-on text equals classic text past the prefill chunk. Gemma 4 26B A4B declines in its MoE feed-forward and stays declined. The ungated token-only verify round (prompt lookup) differs on every model it takes; on DeepSeek V3 from the layer 0 output, where a single query takes the absorbed MLA path. No adoption there.models::speculative_exactness_diag(capture,locate,report), generalized from the Gemma 4 trace and the Inkling 2 per-visit test, which now uses it.mlxcel_core::row_invariant; inside a verify block the short convolutions, experts and sliding attention past the window run per position. The probe passes on bf16inkling-0.6bwhere it declined at layer 0. Decode 244.4 tok/s with the kernel, 239.3 without (8 ABAB pairs).MLXCEL_INKLING_ROW_INVARIANT=0is the A/B switch.MLXCEL_MTP_PROBE_LONG_CONTEXToverrides.row_invariant_matvecfailed to build its Metal library for inputs of fewer than 8 elements.Not measured
MTP throughput on Inkling and whether quantized Inkling-Small passes (those checkpoints were off limits; 0.6B has no MTP head). The long draw on real Laguna and Muse Glimmer checkpoints (none on disk). Inkling 2's probe is untouched (#3410 owns that code).
deepseek-v4-flashskipped.Test plan
coverage_tests, corerow_invariantandinkling--lib --tests --bins), fmt and the contract checks; the issue's broad commands are left to the gateCloses #3409