Skip to content

feat: survey speculative exactness and make Inkling verify exact - #3415

Merged
inureyes merged 5 commits into
mainfrom
feature/issue-3409-speculative-exactness-survey
Nov 24, 2026
Merged

inureyes merged 5 commits into
mainfrom
feature/issue-3409-speculative-exactness-survey

Conversation

@inureyes

Copy link
Copy Markdown
Member

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.

  • Survey (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.
  • Diagnostic: models::speculative_exactness_diag (capture, locate, report), generalized from the Gemma 4 trace and the Inkling 2 per-visit test, which now uses it.
  • Inkling: dense products through 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 bf16 inkling-0.6b where it declined at layer 0. Decode 244.4 tok/s with the kernel, 239.3 without (8 ABAB pairs). MLXCEL_INKLING_ROW_INVARIANT=0 is the A/B switch.
  • Probe: a shared draw plan adds one draw past the sliding window for Inkling, Laguna and Muse Glimmer; families without a window run the same draws as before. MLXCEL_MTP_PROBE_LONG_CONTEXT overrides.
  • Kernel fix: row_invariant_matvec failed 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-flash skipped.

Test plan

  • Seeded-mismatch, sliding-window and unchanged-cost unit tests; tiny Inkling test that differs without the change and is equal with it; ignored real-checkpoint test of the same
  • Narrow lib selections for the touched families, coverage_tests, core row_invariant and inkling
  • clippy (--lib --tests --bins), fmt and the contract checks; the issue's broad commands are left to the gate

Closes #3409

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
@inureyes inureyes added status:review Under review type:performance Performance improvements priority:medium Medium priority area:models Model architectures, weights, loading, metadata area:inference Generation, sampling, decoding (incl. speculative, DRY) platform:macos macOS (Apple Silicon) specific labels Nov 24, 2026
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 24, 2026
@inureyes
inureyes marked this pull request as ready for review November 24, 2026 22:58
@inureyes
inureyes merged commit 40b129d into main Nov 24, 2026
32 of 34 checks passed
@inureyes
inureyes deleted the feature/issue-3409-speculative-exactness-survey branch November 24, 2026 22:58
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 platform:macos macOS (Apple Silicon) specific priority:medium Medium priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: Survey speculative exactness across drafter models, adopt row_invariant

1 participant