Skip to content

fix(deps): validate mlx 0.32.3 for the exact paths - #171

Merged
krcm0209 merged 3 commits into
mainfrom
deps/mlx-0.32.3
Oct 11, 2026
Merged

krcm0209 merged 3 commits into
mainfrom
deps/mlx-0.32.3

Conversation

@krcm0209

@krcm0209 krcm0209 commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Stage 1 of #167: move mlx to 0.32.3 and validate the exact paths on it. mlx-vlm main already requires mlx 0.32.3, so the mlx-vlm release that carries the packed gated-delta prefill kernel (Neywa-Labs/mlx-vlm#2442, stage 2) will need this first. mlx-vlm stays at 0.7.2.

Change

  • verifyattn.VALIDATED_MLX gains 0.32.3. 0.32.2 stays in the set, so a tool environment still on it keeps the exact paths.
  • pyproject.toml pins mlx==0.32.3, and the lock moves mlx and mlx-metal to 0.32.3.
  • Comments and docs refer to the releases in VALIDATED_MLX instead of naming them, so the next bump has one set to extend, and one test name no longer names a version. The bump checklist (the comment on VALIDATED_MLX and CLAUDE.md) now names all three mirrors to re-read: the SDPA dispatch plan() follows, is_nax_available() (mirrored by nax.py) and BaseNAXFrag::get_coord() (mirrored by kernels/nax.h). Some of these comments sit in projkernel.py, tileattn.py, int8prefill.py and kernels/nax.h, which the fork store hashes; editing them costs nothing, because the mlx version is already in the fork key.

Re-read, v0.32.2 → v0.32.3

  • scaled_dot_product_attention.cpp. For head dim 256, GQA 6 and 1–8 rows, everything plan() mirrors is unchanged:

    • has_fused_kernel and the tail of use_fallback;
    • the one-pass/two-pass rule and the two-pass block table (s, d and the rest);
    • 65536 keys as the last threshold;
    • how MLX_SDPA_BLOCKS is read.

    The new paths need head dim 512, the asymmetric (96, 64) head-dim pair, more than 8 query rows (prefill only), or the two-pass GQA kernels: factor 8 at head dims 64 and 128 (renamed, with a batch-index fix) and new factors 12 and 16 at head dim 128. None of them is reachable at head dim 256 and GQA 6 with 1–8 rows.

  • sdpa_vector.h. Lines 1–324 are byte-identical. The one hunk is inside sdpa_vector_2pass_1_gqa, which head dim 256 never reaches.

  • NAX mirrors. is_nax_available() and BaseNAXFrag::get_coord() are unchanged, so nax.py and kernels/nax.h still mirror them.

  • Custom kernels. custom_kernel.cpp and the metal_kernel binding are unchanged. mlx/fast.cpp only adds gated_delta_update, which neither sous nor mlx-vlm 0.7.2 calls.

  • Projection-kernel pin. nn.QuantizedLinear.__call__ hashes the same, so the pin holds.

  • Thread-local streams.

What moves anyway

Gate (M5 Pro unless noted)

The rule was written down before any M5 run. Each speed comparison ran main, branch, branch, main, each run in its own process; the decode, parity and daemon runs each used their own isolated daemon (own config, data directory and fork store), never the maintainer's. A harness defect was fixed only by re-running that job; no threshold moved.

# Criterion Result
1 Load PASS. Every drafted branch load line has verify_attention=active, attention_tile=active, projection_kernel=active, positions=engine and draft_block=5, and routes 336 int8 projections. The drafter-off parity run has the same tile, kernel and positions, with verify_attention=off and no draft_block, as expected without a drafter. The projection kernel's warm-up and probe take 3.76 s cold (bar 10) and 0.32 s warm (bar 1).
2 Suites PASS. Non-model tests: 2316 passed on both trees on the M5, and on the M2 2277 passed and 39 skipped, the same skips as main. Model tests on the branch, each file in its own process: test_engine_vlm (24), test_verifyattn_model, test_tileattn_model, test_projkernel_model, test_int8prefill_model (2), test_api_model (3) and test_engine_lm (8) all passed.
3 Kernel timings Projection kernel: PASS. Per-forward sum is 0.974–1.000x main at T = 1..8 (bar ≤ 1.02). Attention tile: 14 of 15 cells pass (bar ≤ 1.03); ruled a pass. The cell at 131072 keys and T = 3 came in at 1.065x. See below.
4 Prefill (16K, 64K) PASS. 16384 tokens: 1.022x main (95% CI 1.003–1.043). 65536 tokens: 1.002x (0.987–1.018). Bar: CI lower end ≥ 0.98. Peak memory is the same, 19.93 and 23.41 GiB.
5 Decode PASS. Greedy, drafter on, #155's 64 turns: pooled 1.048x main (95% CI 1.015–1.086; bar: lower end ≥ 0.98). The median per-turn ratio is 1.000. The pooled gain comes from the 64–128K turns, where the two releases wrote different text and the branch's drafted better (3.61 tokens per round against 3.44 overall). Read it as "not slower", not as a speedup.
6 Parity PASS. Greedy, drafter on vs off, 69 turns: 69/69 identical, with cache histories equal on 69/69. The one-row kernel served every turn and declined nothing.
7 Daemon (M5 and M2) PASS on both. scripts/api_smoke.py, plus a run through the daemon's main mlx threads (endpoint pool, session, model load, preload, idle sweep, status and unload): two turns of one conversation, idle unload then reload, /sous/unload twice, a /sous/hold preload, a decode under /sous/status polled at 10 Hz, two sous stops, and fork restores from disk in both daemon lives. One pid per life; no stream, thread or crash errors. count_tokens, /sous/events and a stalled-session retirement were not exercised.

The tile cell. In one gate run, kt-tile-br1, that cell was slow for every variant in the process: the tile at 37.76 ms, the stock grouped baseline at 105.2 ms against 73–89 in the other runs. The other branch run was the fastest of all four, at 30.16 ms. T = 1 and T = 8 ran at normal speed in every one of these processes.

Two report-only repeats at 131072 keys:

  • Three main/branch pairs. Two of the three branch runs hit the slow mode (32.05 ms with an 88.0 ms baseline, and 37.00 ms with 107.2); none of the main runs did.
  • Ten interleaved pairs on a quiet machine. The branch measured 30.39 ms (mean) against main's 30.57, so 0.994x. The slow mode hit main once and the branch never.

Counting a process as slow when its stock baseline reached 88 ms, the slow mode hit the branch in 3 of 15 processes and main in 2 of 15. The maintainer ruled criterion 3 a pass on these repeats.

Report only.

  • On the M2 (Qwen3.5-9B with its DFlash drafter), a prefill comparison at 4K and 16K was dominated by run-to-run drift: every run was slower than the one before, and main ran 103 tok/s in its first run and 89 in its last. That fits thermal throttling on the fanless M2, though no temperature was recorded. Peak memory was the same on both releases.
  • The M2's first cold turn hits a Metal out-of-memory error inside the drafter-context capture on main too. The error is caught and the turn is served. It's the 16 GB M2's capacity, not this change.

After merge

Reinstall the M5 tool environment with uv tool install --reinstall (the pins carry 0.32.3). Expect one cold rebuild of each fork store. #167 stays open for stage 2.

Refs #167

🤖 Generated with Claude Code

krcm0209 and others added 3 commits October 7, 2026 15:22
mlx-vlm main already requires mlx 0.32.3, so the release that carries the
packed gated-delta prefill kernel (Neywa-Labs/mlx-vlm#2442) will too (#167).
This moves the mlx pin and lock to 0.32.3 and adds it to
verifyattn.VALIDATED_MLX, keeping 0.32.2 for tool environments still on it.

Re-read against v0.32.2..v0.32.3:
- scaled_dot_product_attention.cpp: for head dim 256, GQA 6 and 1-8 rows,
  has_fused_kernel, use_fallback's tail, the one-pass/two-pass rule and the
  two-pass block table (s, d and the rest) are unchanged; 65536 keys is still
  the last threshold and MLX_SDPA_BLOCKS is read the same way. The new paths
  need head dim 512, qL > 8 (prefill only) or the GQA 8/12/16 kernels at
  head dims 64/128.
- sdpa_vector.h: lines 1-324 are byte-identical; the only hunk is inside
  sdpa_vector_2pass_1_gqa, which head dim 256 never reaches.
- device.cpp is_nax_available() and steel/gemm/nax.h BaseNAXFrag::get_coord()
  are unchanged, so nax.py and kernels/nax.h still mirror them.
- custom_kernel.cpp and the metal_kernel binding are unchanged; mlx/fast.cpp
  only adds gated_delta_update, which neither sous nor mlx-vlm 0.7.2 calls.
- nn.QuantizedLinear.__call__ hashes the same, so the projection kernel's
  mlx pin holds.
- Thread-local streams: a fresh thread still gets its default stream lazily
  (#4514 changes only the compile-cache lookup), clear_streams clears the
  same state and now drops the GIL, and #4462/#4576 are unreachable from
  sous's threads.

Prefill attention changes on both GPU families (#4487 on NAX, #4505's fused
path for qL == kL >= 2048 elsewhere) and compiled sigmoid uses precise exp
(#4461), so prefill KV and greedy text may differ from 0.32.2; the mlx
version is in the fork key, so every fork store starts cold once.

Co-Authored-By: Claude <noreply@anthropic.com>
Naming the releases by hand in nine comments and docs meant every mlx
bump had to edit each of them, and the three probe docstrings asserted
the exception-path deadlock was seen on 0.32.3 without a re-check. The
prose now refers to the set the gates read, and the deadlock note is
version-free as projkernel's other mention already was.

Co-Authored-By: Claude <noreply@anthropic.com>
nax.py and kernels/nax.h now say their mirrors of is_nax_available() and
BaseNAXFrag::get_coord() hold across the releases in VALIDATED_MLX, but the
instruction for extending the set named only scaled_dot_product_attention.cpp,
so a bump that followed it could make both claims false without anyone
re-reading those functions.

Co-Authored-By: Claude <noreply@anthropic.com>
@krcm0209
krcm0209 merged commit bc3b496 into main Oct 11, 2026
9 checks passed
@krcm0209
krcm0209 deleted the deps/mlx-0.32.3 branch October 11, 2026 18:39
This was referenced Oct 11, 2026
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.

1 participant