Skip to content

perf(mimo): exact rectangular MTP verification by default - #1289

Merged
Gajesh2007 merged 4 commits into
masterfrom
claude/mimo-exact-rectangular-mtp
Oct 1, 2026
Merged

Gajesh2007 merged 4 commits into
masterfrom
claude/mimo-exact-rectangular-mtp

Conversation

@jonathan308

@jonathan308 jonathan308 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Make exact rectangular verification the default MTP strategy for native MiMo V2.6. With MTP on, greedy decode becomes faster than MTP off (+10% short, +9% at 4K on a 256 GiB M3 Ultra) while every output stays identical to target-only decode. This is the MTP-on speedup that serial verification could not deliver.

Stacked on #1282. Media requests stay target-only; sampled requests were never MTP-eligible on MiMo and are unaffected.

Evidence

M3 Ultra (60-core GPU), 256 GiB, EigenLabs/MiMo-V2.6-Flash-MOPD-MLX-4bit-mtp@bb37ffc7, Release build of this branch on master 08653fc2 (darkbloom SHA256 b36596a9…, metallib 38ceb8a1…), prefix cache ready. Each row is a fresh server process. Temperature 0, cold prompts. Exactness compares against the same binary with MTP off (target-only), byte for byte (content and reasoning SHA-256).

Since these measurements, the stack was rebased onto master 1e4b2d88. #1286 does not touch provider-swift, and the same stack built there produced the same darkbloom SHA256 (b36596a9…). The SDK commits were then reformatted for the lint job: swift-format line wrapping only, token-identical apart from a trailing comma in one test's array literal.

The stack was then rebased onto master b1c14ed8 (#1285, #1287, #1288, #891). The SDK PRs are now merged, and this PR pins mlx-swift-lm main 1ee8675a, which contains #206, #207 and #219 (landed through Layr-Labs/mlx-swift-lm#246) and #245. Its tree is identical to the SDK validated here. The full MiMo stack builds on that base (this stack plus #1299). Full-model requalification on it is in progress.

Check MTP auto (exact rectangular), process 1 Process 2
20 prompts × 512 tokens, reasoning off 20/20 identical 20/20 identical
5K / 9K / 20K-token prompts, 256 tokens 3/3 identical 3/3 identical
Reasoning on, 8 prompts × 512 tokens 8/8 identical 8/8 identical
Media (image PNG/JPEG, audio ×3, video+AAC, silent video, image+audio) 8/8 identical (all 200) 8/8 identical
Config Short decode tok/s 4K decode tok/s MTP counters
MTP off 44.61 / 44.71 / 44.41 42.82 / 42.80 / 42.52 —
MTP auto, exact rectangular (process 1) 49.12 / 49.19 / 49.80 46.39 / 45.74 / 46.84 5,846 rounds, 10,144 proposed, 77% accepted
MTP auto, exact rectangular (process 2) 48.61 / 49.47 / 48.69 46.60 / 45.41 / 46.54 6,472 rounds, 11,125 proposed, 77% accepted
MTP auto, serial rollback (DARKBLOOM_MIMO_RECTANGULAR_VERIFY=0) 39.75 / 39.74 / 39.78 38.17 / 38.34 / 37.80 0 rounds, adaptive_serial_suppressed 13,794; output identical on every check above

Long context (process 2): 20K 41.78 / 40.29 / 40.52 and 50K 34.44 / 34.33 / 33.97 tok/s. MTP off on the same research stack measured 39.92 / 39.91 at 20K and 34.22 / 34.18 at 50K. The adaptive policy keeps rectangular MTP at or above target-only as the serialized attention grows.

Prefix cache (#1280 default) with exact rectangular MTP: a repeated 6K-token prompt reports 4,096 cached tokens, and its output is identical across repeats and to MTP off.

Why bulk rectangular was never shipped: on this hardware it measured 52–56 tok/s, but greedy output diverged on 10/10 prompts. MLX's qmv_wide (2–7 rows) reduces differently from one-row qmv_fast. The row-exact kernel keeps qmv_fast arithmetic per row and reads each weight once. The per-row fallback (one matmul per row) was exact too, but it measured 42.8–45.0 short, which is no faster than MTP off.

Requalified on master b1c14ed8 (includes #1285, which pins SDK #208)

Full stack: #1282 + #1289 + #1299, with SDK #206/#207/#219/#245 rebased onto SDK main e31a1732. Fresh server per run, on the same M3 Ultra. The reference is clean master b1c14ed8 with MTP auto.

Check Full stack, MTP off vs MTP auto Full stack vs master
20 prompts × 512 tokens, reasoning off 20/20 identical 20/20 identical
5K / 9K / 20K-token prompts 3/3 3/3
Reasoning on, 8 × 512 (content and reasoning) 8/8 8/8
Media (image PNG/JPEG, audio ×3, video+AAC, silent video, image+audio) 8/8, all 200 8/8, all 200
API surface (15 cases) and 4 solo prompts 19/19 19/19
4-way concurrent batch 4/4 3/4 (see note)

Note on the concurrent row: master's own two builds differ on the same prompt, and each run produced one stable output over three concurrent repeats. This is batch composition, not a regression.

Decode tok/s (256 tokens) Short 4K 20K 50K
master b1c14ed8, MTP auto 37.3 35.8 32.7 —
Full stack, MTP off 45.3 43.4 38.1 —
Full stack, MTP auto (default) 49.9 46.3 40.7 34.1

MTP auto on the full stack: 7,659 rounds, 13,660 tokens proposed, 73.8% accepted.

Rollback

DARKBLOOM_MIMO_RECTANGULAR_VERIFY=0 restores serial-target scoring. Under serial, adaptive plans stay target-only (#1282), so MTP-on decode matches the serial row above. DARKBLOOM_MIMO_ROW_EXACT_PROJECTION=0 keeps exact verification with one matmul per row. All three rollbacks are forwarded to the launchd job.

Test plan

  • swift build -c release --product darkbloom --force-resolved-versions, source-matched metallib, swift build --build-tests, metallib staged in every test bundle.
  • MiMoV26RectangularVerifyPolicyTests (4): exact rectangular default, affirmative values, either rollback → serial, MTP off → serial.
  • LaunchAgentEnvironmentTests|LaunchAgentServicePlistTests|LaunchAgentRestartTests|WatchdogAgentPlistTests|excludesInferenceControls (32), including the new forwardsMiMoExactVerifyRollbacksToProviderJob. MTPConfigTests (20).
  • SDK suites: see perf(mimo): exact rectangular MTP verification (row-exact multi-row projection) mlx-swift-lm#219.
  • Full model: tables above.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@vercel

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Oct 1, 2026 6:24pm UTC
d-inference-console-ui-dev Ready Ready Preview Oct 1, 2026 6:24pm UTC
d-inference-landing Ready Ready Preview Oct 1, 2026 6:24pm UTC
eigen-homepages-darkbloom Ready Ready Preview Oct 1, 2026 6:24pm UTC

Request Review

@blacksmith-sh

This comment has been minimized.

jonathan308 and others added 2 commits September 30, 2026 21:37
… MTP

Pin mlx-swift-lm to the stack that enables the exact MiMo short-forward
decode kernels by default and adds `CBv2MTPConfig.allowsAdaptiveSerialRounds`.

- Forward the three kernel rollbacks (`DARKBLOOM_MIMO_FUSED_DECODE_NORMS`,
  `DARKBLOOM_MIMO_DECODE_EXPERTS`, `DARKBLOOM_MIMO_DECODE_ROUTER_GEMV`,
  `0`/`false`/`no`/`off`) to the launchd provider job, so an installed
  provider can restore the stock path.
- Build every native MiMo MTP config through `nativeMiMoMTPConfig`, which
  keeps adaptive plans target-only under serial-target scoring. Each serial
  draft column costs one ordinary target forward, so those rounds could only
  slow decode (25-27 tok/s when the controller locked onto depth 3). MTP stays
  constructed and active with live assistant history; the rectangular opt-in
  keeps adaptive depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pin mlx-swift-lm to the exact rectangular verification stack (row-exact
multi-row affine projection, fused norms inside the scalar-dense verifier,
scalar-dense default with a guard against drafting through the bulk trunk).

- `nativeMiMoVerificationMode` selects rectangular verification by default.
  A rollback of `DARKBLOOM_MIMO_RECTANGULAR_VERIFY` or of the SDK's
  scalar-dense switch selects serial-target scoring; the provider never
  selects the bulk rectangular trunk, whose reductions differ from serial
  decode.
- The native paged profile keeps serial-target MTP independently of the
  contiguous default.
- LaunchAgent forwards the three verification rollbacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mlx-swift-lm main now contains #206, #207 and #219 (landed through #246) and
#245. Pin it instead of the stacked SDK branch commit. The pinned tree is
identical to the SDK validated with this stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Threat model review — advisory

Reviewed head 615f684b5c2e against base d52a9a142907.

Review not completed for this head. Previous findings are superseded, not confirmed resolved.
Scan incomplete: one or more configured reviewers did not finish; completed reviewers' findings are shown below

Reviewers: anthropic/claude-opus-5.5: incomplete (review unavailable); openai/gpt-6-astra: incomplete (review unavailable)

Models: anthropic/claude-opus-5.5, openai/gpt-6-astra. Findings require human validation; this review never requests changes or blocks merging.

#1282 and #1299 were squash-merged into master, so this PR's copy of #1282
conflicted. Conflicts resolved to #1289's versions of configuration.md,
LaunchAgent.swift and its tests, and MiMoV26RectangularVerifyPolicyTests.swift
(master changed each by exactly #1282's diff; the auto-merge had duplicated
testNativeMTPConfigKeepsAdaptiveSerialPlansTargetOnly). CHANGELOG keeps master
and adds this PR's section. The net diff against master is exactly #1289's
reviewed change; the SDK pin stays at mlx-swift-lm main 1ee8675a.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gajesh2007
Gajesh2007 merged commit d330044 into master Oct 1, 2026
24 of 27 checks passed
@Gajesh2007
Gajesh2007 deleted the claude/mimo-exact-rectangular-mtp branch October 1, 2026 18:51

This branch was successfully deployed

4 active deployments
Preview – d-inference-console-ui-dev — 615f684b Deployed Oct 1, 2026 by vercel[bot]
Preview – d-inference — 615f684b Deployed Oct 1, 2026 by vercel[bot]
Preview – d-inference-landing — 615f684b Deployed Oct 1, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — 615f684b Deployed Oct 1, 2026 by vercel[bot]
benchmarks — 615f684b Deployed Oct 1, 2026 by jonathan308 via E2E Benchmarks #2074
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants