Skip to content

Nemotron 3.5 Bolt (nemotron_h_puzzle) on Metal — serves end to end - #1038

Closed
trickyfalcon wants to merge 19 commits into
ashhart:mainfrom
bytebunkerlabs:nemotron-h-puzzle
Closed

trickyfalcon wants to merge 19 commits into
ashhart:mainfrom
bytebunkerlabs:nemotron-h-puzzle

Conversation

@trickyfalcon

@trickyfalcon trickyfalcon commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Draft, opened early per #962 so the design can be steered before the kernels harden. The native Metal backend for nemotron_h_puzzle (Nemotron 3.5 Bolt 74B-A9B), on current main, which already parses the Puzzle config and serves it on CUDA; this adds the Metal side. It serves the published checkpoint end to end (bytebunker/NVIDIA-Nemotron-3.5-Bolt-74B-A9B-MLX-4bit): on an M3 Max (128 GB) it loads in ~6 s and decodes at ~40 tok/s.

Receipts (M3 Max, applegpu_g15, the published MLX-4bit build)

Pinned checkpoint: config.json sha256 7279c7543826…, index 3b6189b91b55…, all nine shards hashed in the fidelity report (--hash-weights). Reference: MLX 0.32.3, mlx-lm 0.32.0. Engine: this branch.

Check Result
Per-op bits vs MLX (check_mlx_ops.py --ops bolt_gemv,bolt_route,bolt_combine) 236/236 bit-identical: gate gemv at every expert count (240/304/368/432/496), both latent projections, the bf16 lm_head, group_expert_select at k 9, and the latent combine; MLX's own metallib kernel replayed at each shape agrees too
Per row every row of a 2/9/16-row pass (64 for the combine) equals its own one-row MLX op, bit for bit
Kernel contract (tf-kernel-contract --only bolt --offline) 8 Bolt kernels pass gates 1-4 at their served shapes (bm4/bm8 gemv incl. the 131072 x 4096 head, route at E 240-496, the 9-pick combine, group norm MP 16/128, both add norms); 8 planted controls red at their gates; gate-5 records with M1/M2 limits
concurrent == solo (xpu_concurrent_receipt.py) pass at 1, 2, 4 and 8 streams, 2 rounds each, greedy and seeded streams
resumed == fresh (xpu_resume_receipt.py, CONTRIBUTING.md, two turns) pass: turn 2 resumed from 1,502 cached tokens has the same token_sha as on a server with --prompt-cache-gib 0, greedy and seeded
drafted == plain n/a: the checkpoint ships no MTP weights (num_nextn_predict_layers: 0)
Lightning unchanged test-golden 0 unexpected; Lightning 30B-A3B MLX-4bit (d9d758fb) on main and on this branch: 16/16 replies the same token_sha (8 prompts x greedy/seeded)
Admission an expert count off the router gemv's 4-row tile, a per-layer top-k above its expert count, missing/quantized/transposed latent projections, an M5 (tensor units) and --speed-up are refused before any weight is read
zig build test, test-bolt-host, tf-metal-tests pass

Each stage against float64, from the native's own input to that stage (tf-nemotron-forward --stages, tools/zig/nemotron_stages.py; argparse's source, 256 prompt rows then 32 decode rows, all 88 layers; bf16 ulps of the row's RMS; MLX's own bf16 result on the same input in brackets):

mixer stage prompt rows: native p99 / max (MLX p99) decode rows: native p99 / max (MLX p99) rel RMS
all input norm 0.98 / 31.8 0.98 / 30.9 0.0017
mamba in_proj 1.71 / 32.5 (1.73) 1.69 / 23.9 (2.73) 0.0031
mamba conv 1.48 / 62.6 1.48 / 55.2 0.0020
mamba scan (gated) 0.66 / 155.0 0.68 / 88.8 0.0024
mamba group norm 1.74 / 63.4 1.75 / 54.4 0.0023
mamba out_proj 2.27 / 39.5 (2.69) 2.28 / 35.0 (3.92) 0.0045
attention qkv 2.15 / 18.0 (2.65) 2.16 / 17.9 (3.82) 0.0039
attention attention 1.24 / 15.7 1.23 / 15.7 0.0017
attention o_proj 3.23 / 40.2 (3.66) 2.92 / 30.1 (5.20) 0.0053
moe gate 0.88 / 2.0 (0.88) 0.87 / 2.0 (0.87) 0.0016
moe route weights 0.00 / 0.0 0.00 / 0.0 0.0000
moe shared expert 4.61 / 513.2 (5.17) 4.93 / 226.3 (8.29) 0.0077
moe into (fc1_latent) 0.97 / 8.0 (0.97) 0.97 / 4.0 (0.97) 0.0017
moe routed experts 5.30 / 794.1 (8.62) 5.23 / 770.1 (8.45) 0.0074
moe combine 0.97 / 8.0 0.97 / 7.9 0.0017
moe out (fc2_latent) 0.98 / 29.9 (0.98) 0.98 / 15.8 (0.98) 0.0017
all residual 1.00 / 46.4 1.00 / 36.5 0.0018
all next norm 0.98 / 31.8 0.98 / 30.9 0.0017

Route picks: 1 of 11,520 differ (prompt), an exact fp32 tie broken by the lower id as mlx-lm's stable sort does.

Teacher-forced logits vs mlx-lm serial (tools/zig/nemotron_fidelity.py, prompt rows; decode rows give the same logits bit for bit). The run fails on a differing token past the largest margin at which mlx-lm's own chunk32/full runs flip on that fixture, on more than twice their count plus 2, or on an NLL past twice mlx-lm's own spread; it passes:

fixture tokens top-1 KL mean / p99 / max differing (max margin) mlx chunk32 vs serial: top-1, KL mean, differing (max margin) NLL native / mlx serial
fibonacci-raw 15 0.933 0.0040 / 0.010 / 0.010 1 (1 ulps) 1.000, 0.0068, 0 (0 ulps) 2.892 / 2.841
gpu-chat-no-think 35 0.943 0.0106 / 0.083 / 0.109 2 (1 ulps) 0.971, 0.0078, 1 (1 ulps) 5.717 / 5.724
public-contribution-guide-512 512 0.924 0.0092 / 0.036 / 0.081 39 (1 ulps) 0.936, 0.0095, 33 (2 ulps) 2.936 / 2.951
python-stdlib-2048 2048 0.986 0.0053 / 0.065 / 0.875 28 (6 ulps) 0.987, 0.0051, 26 (6 ulps) 0.365 / 0.364

What's in it

  • Refusals before load: a puzzle layer whose top-k exceeds its own expert count; a latent projection that is missing, quantized, transposed or not bf16 (and experts stored over hidden); Bolt on a tensor-unit chip (M5), before any weight is read.
  • Per-layer loader: each MoE layer's own expert count and width; routed experts in the 1024 latent through the runtime-dim row kernels; fc1/fc2_latent_proj and the unquantized bf16 lm_head read in place.
  • The latent MoE on the shared ops (bolt.zig), in mlx_lm's NemotronHMoE order: gate gemv → tf_route_topk → fc1_latent_proj → routed experts → tf_moe_combine_rows_lanes8 → fc2_latent_proj → + shared → + residual. The gemvs, route and combine come from ops/ and the prefill set compiles them with MLX's options; the hand-written route, dense and combine kernels are gone.
  • ops/gemv.metal gains MLX's bm4/bm8 bn1 gemv (tf_gemv_bf16_bm{4,8}_tm4) beside its bn8 one. Bolt's 9-pick combine is its own tf_moe_combine_rows_lanes8 (col_reduce_small's 8 lanes past 8 picks); the shared tf_moe_combine is unchanged. Bolt's scratch and its bf16 head are Bolt-only.
  • Bolt-width instantiations of the generated Mamba tree conv/scan, gated group norm and add_norm kernels, hand-authored in gen_nemotron_kernels.py's style (that generator isn't in the public repo).
  • Tools: bolt_op_cases.py (per-op cases), tests/contract/metal_bolt.zig (the kernel contract), forward.Tap + tf-nemotron-forward --decode-from/--stages + nemotron_stages.py (staged float64), nemotron_fidelity.py (teacher-forced logits, prompt and decode rows, gated against mlx-lm's own spread).

Not yet / next

  • Kernel contract: the Bolt-width Mamba tree conv/scan instantiations are not registered yet.
  • M5 lane kernels: refused for now; Bolt variants of the lane kernels are a follow-up.
  • Fused prefill (prefill_mixers) for the latent MoE; prompts run through the decode kernels 16 rows at a time.
  • Streams don't batch yet (aggregate ~40 tok/s across 1–8 streams).

Deferred, with their gates kept

  • Image input (RADIO): text backbone only; the multimodal checkpoint is not listed as qualified, and the RADIO image receipts stay a shipping gate.
  • The MTP draft head (no MTP weights in this checkpoint); drafted == plain applies once a checkpoint carries them.

@trickyfalcon trickyfalcon changed the title Nemotron 3.5 Bolt (nemotron_h_puzzle) on Metal — part 1: per-layer MoE loader Nemotron 3.5 Bolt (nemotron_h_puzzle) on Metal — per-layer loader + latent MoE forward Oct 18, 2026
@trickyfalcon trickyfalcon changed the title Nemotron 3.5 Bolt (nemotron_h_puzzle) on Metal — per-layer loader + latent MoE forward Nemotron 3.5 Bolt (nemotron_h_puzzle) on Metal — serves end to end Oct 18, 2026
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thanks @trickyfalcon. The common lane host and latent combination order are now in place, and your M3 Max receipts help.

Please keep it as a draft while you reject top-k above any layer's expert count, add the latent-tensor negatives, and refuse unsupported tensor-unit chips before loading. The M5 path can reach unloaded row pipelines and Lightning-sized kernels. Reuse the shared GPU core for reusable operations and retain RADIO images as a shipping gate.

The fidelity table exceeds its quoted RMS floor on two fixtures; please correct that claim and attach pinned KL, per-operation bit/row, Lightning and session-equivalence receipts. Drafting is correctly marked inapplicable without MTP weights.

Posted by Ash's AI Assistant Synthena

@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Thanks. All of that is in, and it stays a draft.

  • Top-k per layer: a puzzle layer whose top-k exceeds its own expert count is refused while the config is read. The old check compared against the largest layer only.
  • Latent-tensor negatives: a missing, quantized, transposed or non-bf16 fc1/fc2_latent_proj is refused with its name, and experts stored over hidden are refused too. Each case has a test.
  • Tensor-unit chips: Bolt is refused on M5 before any weight is read, so the Lightning-sized lane kernels and the unloaded row pipelines can't be reached.
  • Shared GPU core: the hand-written route, dense and combine kernels are gone. Bolt's gate, latent projections and bf16 head use ops/gemv.metal, which now also has MLX's bm4/bm8 bn1 variant. Routing uses tf_route_topk, and the combine uses tf_moe_combine_rows. One fix came out of this: past 8 picks, col_reduce_small splits the picks over 8 lanes and adds pick 8 onto pick 0. The combine now does the same; at 8 picks or fewer its sums are unchanged.
  • RADIO: kept as a shipping gate.

Receipts, on the M3 Max with the pinned checkpoint:

  • Per op: 236/236 cases are bit-identical to MLX 0.32.3 at Bolt's shapes. Every row of a 1–16 row pass equals its own one-row MLX op, and MLX's metallib replay agrees.
  • Sessions: concurrent == solo at 2 and 4 streams, greedy and seeded. Resumed == fresh, greedy and seeded: a turn resumed from 1,502 cached tokens matches the same turn on a server with no cache.
  • Lightning: test-golden has 0 unexpected differences. Lightning 30B served from main and from this branch gives the same tokens on 32/32 requests.
  • KL: pinned KL per position is now in the fidelity table.

I corrected the fidelity claim. Native RMS is above mlx-lm's chunk spread on two fixtures. Switching to the exact ops didn't move that, because the rest of the M1–M4 decode path isn't MLX-exact, and the model spreads one-ULP differences to that size. So the per-op table is the bit claim, and the fidelity table bounds the whole-model effect. Details are in the updated description.

@ashhart

ashhart commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Thanks @trickyfalcon. The per-layer top-k bound, latent-tensor negatives, early tensor-unit refusal and shared-op reuse address our earlier source asks. Please also make Model.load release the Metal device and queue it creates before that refusal; its current error path releases neither. Keep this draft for RADIO images and the full numerical/session gate. Your M3 results are useful; please attach the updated pinned KL/fidelity table and raw operator, row-invariance, Lightning and session receipts. We'll retain the unchanged numerical bars and run the integrated M3 acceptance and config-only M5 refusal/cleanup cells before shipping this backend.

Posted by Ash's AI Assistant Synthena

@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Thanks. Model.load now releases the device and queue on every refusal (2667794): each gets an errdefer as soon as it's created. A new test counts the device's references before and after a refused load. It fails without the fix and passes with it. The Bolt-on-M5 refusal can't fire on an M3, so the test refuses on the time-step clamp instead. That check runs right after the tensor-unit check, inside the same cleanup. Your config-only M5 cell covers the refusal itself.

It stays a draft for RADIO and the full gate. The raw receipts are below, all from the M3 Max on the pinned checkpoint. The fix only touches the load error path, so these runs still stand.

Per operator and row invariance: check_mlx_ops.py --ops bolt_gemv,bolt_route,bolt_combine (236/236)
OK   gemv      L1.gate E=240 K=4096 N=240 rows=1 s0     gemv bm1 bn8 sn32 tm4 tn4           mlx     3.28 us  ours     3.35 us  (1.021x) 
OK   gemv      L1.gate E=240 K=4096 N=240 rows=1 s1     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=1 s2     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=2 s0     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=2 s1     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=2 s2     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=9 s0     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=9 s1     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=9 s2     gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=16 s0    gemv bm1 bn8 sn32 tm4 tn4           ours    19.69 us 
OK   gemv      L1.gate E=240 K=4096 N=240 rows=16 s1    gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L1.gate E=240 K=4096 N=240 rows=16 s2    gemv bm1 bn8 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=1 s0     gemv bm4 bn1 sn32 tm4 tn4           mlx     7.51 us  ours     7.24 us  (0.963x) 
OK   gemv      L8.gate E=304 K=4096 N=304 rows=1 s1     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=1 s2     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=2 s0     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=2 s1     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=2 s2     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=9 s0     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=9 s1     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=9 s2     gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=16 s0    gemv bm4 bn1 sn32 tm4 tn4           ours    21.25 us 
OK   gemv      L8.gate E=304 K=4096 N=304 rows=16 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L8.gate E=304 K=4096 N=304 rows=16 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=1 s0    gemv bm4 bn1 sn32 tm4 tn4           mlx     7.52 us  ours     7.20 us  (0.958x) 
OK   gemv      L37.gate E=368 K=4096 N=368 rows=1 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=1 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=2 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=2 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=2 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=9 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=9 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=9 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=16 s0   gemv bm4 bn1 sn32 tm4 tn4           ours    26.81 us 
OK   gemv      L37.gate E=368 K=4096 N=368 rows=16 s1   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L37.gate E=368 K=4096 N=368 rows=16 s2   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=1 s0    gemv bm4 bn1 sn32 tm4 tn4           mlx     7.55 us  ours     7.24 us  (0.960x) 
OK   gemv      L21.gate E=432 K=4096 N=432 rows=1 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=1 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=2 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=2 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=2 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=9 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=9 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=9 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=16 s0   gemv bm4 bn1 sn32 tm4 tn4           ours    30.66 us 
OK   gemv      L21.gate E=432 K=4096 N=432 rows=16 s1   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L21.gate E=432 K=4096 N=432 rows=16 s2   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=1 s0    gemv bm4 bn1 sn32 tm4 tn4           mlx     7.56 us  ours     7.29 us  (0.963x) 
OK   gemv      L48.gate E=496 K=4096 N=496 rows=1 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=1 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=2 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=2 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=2 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=9 s0    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=9 s1    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=9 s2    gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=16 s0   gemv bm4 bn1 sn32 tm4 tn4           ours    35.40 us 
OK   gemv      L48.gate E=496 K=4096 N=496 rows=16 s1   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      L48.gate E=496 K=4096 N=496 rows=16 s2   gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=1 s0  gemv bm4 bn1 sn32 tm4 tn4           mlx    10.54 us  ours    10.76 us  (1.021x) 
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=1 s1  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=1 s2  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=2 s0  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=2 s1  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=2 s2  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=9 s0  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=9 s1  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=9 s2  gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=16 s0 gemv bm4 bn1 sn32 tm4 tn4           ours    69.70 us 
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=16 s1 gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc1_latent_proj K=4096 N=1024 rows=16 s2 gemv bm4 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=1 s0  gemv bm8 bn1 sn32 tm4 tn4           mlx     6.70 us  ours     6.33 us  (0.946x) 
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=1 s1  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=1 s2  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=2 s0  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=2 s1  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=2 s2  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=9 s0  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=9 s1  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=9 s2  gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=16 s0 gemv bm8 bn1 sn32 tm4 tn4           ours    61.71 us 
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=16 s1 gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      fc2_latent_proj K=1024 N=4096 rows=16 s2 gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=1 s0        gemv bm8 bn1 sn32 tm4 tn4           mlx  2824.12 us  ours  2846.31 us  (1.008x) 
OK   gemv      lm_head K=4096 N=131072 rows=1 s1        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=1 s2        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=2 s0        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=2 s1        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=2 s2        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=9 s0        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=9 s1        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=9 s2        gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=16 s0       gemv bm8 bn1 sn32 tm4 tn4           ours 10194.65 us 
OK   gemv      lm_head K=4096 N=131072 rows=16 s1       gemv bm8 bn1 sn32 tm4 tn4          
OK   gemv      lm_head K=4096 N=131072 rows=16 s2       gemv bm8 bn1 sn32 tm4 tn4          
OK   route     E=240 k=9 rows=1 p0                      group_expert_select (fusions, sort, take, sum)  ours    21.56 us 
OK   route     E=240 k=9 rows=1 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=1 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=1 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=1 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=1 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=2 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=9 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p0                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p1                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p2                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p3                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p4                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=240 k=9 rows=16 p5                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=1 p0                      group_expert_select (fusions, sort, take, sum)  ours    26.64 us 
OK   route     E=304 k=9 rows=1 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=1 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=1 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=1 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=1 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=2 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=9 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p0                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p1                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p2                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p3                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p4                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=304 k=9 rows=16 p5                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=1 p0                      group_expert_select (fusions, sort, take, sum)  ours    32.52 us 
OK   route     E=368 k=9 rows=1 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=1 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=1 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=1 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=1 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=2 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=9 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p0                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p1                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p2                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p3                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p4                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=368 k=9 rows=16 p5                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=1 p0                      group_expert_select (fusions, sort, take, sum)  ours    38.19 us 
OK   route     E=432 k=9 rows=1 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=1 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=1 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=1 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=1 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=2 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=9 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p0                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p1                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p2                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p3                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p4                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=432 k=9 rows=16 p5                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=1 p0                      group_expert_select (fusions, sort, take, sum)  ours    44.71 us 
OK   route     E=496 k=9 rows=1 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=1 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=1 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=1 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=1 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=2 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p0                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p1                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p2                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p3                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p4                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=9 p5                      group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p0                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p1                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p2                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p3                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p4                     group_expert_select (fusions, sort, take, sum) 
OK   route     E=496 k=9 rows=16 p5                     group_expert_select (fusions, sort, take, sum) 
OK   combine   k=9 latent=1024 rows=1 p0                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=1 p1                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=1 p2                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=1 p3                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=2 p0                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=2 p1                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=2 p2                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=2 p3                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=9 p0                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=9 p1                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=9 p2                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=9 p3                v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=16 p0               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=16 p1               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=16 p2               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=16 p3               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=64 p0               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=64 p1               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=64 p2               v_copy, g2_Multiply, col_reduce_small, v_copy 
OK   combine   k=9 latent=1024 rows=64 p3               v_copy, g2_Multiply, col_reduce_small, v_copy 

236/236 cases bit-identical
Pinned KL / fidelity: nemotron_fidelity.py --hash-weights (the model path is shortened to its folder name)
{
 "mlx": "0.32.3",
 "mlx_lm": "0.32.0",
 "pins": {
  "model": "NVIDIA-Nemotron-3.5-Bolt-74B-A9B-MLX-4bit",
  "config_sha256": "7279c754382619fd2d849835d78c3137ce27a972efb1eadb86c61585af405985",
  "index_sha256": "3b6189b91b55b18edd3be8f512d6b901686b2eb0370d1685266e91e79d01eba0",
  "shards": {
   "model-00001-of-00009.safetensors": "7e50d79de713d0ff7bc3be41ef52c8cd3c3e35cc3331f03a91b0916d30088639",
   "model-00002-of-00009.safetensors": "999d37fa98e8926af495b59250808c4dcb01e7272ade97387aeb5a6ebfd9d78a",
   "model-00003-of-00009.safetensors": "c75f5fe7261db2374b8e23cdd2cb1827140799ac13fa536cccbdb9d242be61da",
   "model-00004-of-00009.safetensors": "4da61085cc4f0505569412ee72d2c853b819c0f2f2c8ce85470149d8437b2864",
   "model-00005-of-00009.safetensors": "6f03752282c67af6b2b2e8e3c66d63a13cbd4cd2c19f8e622f40a0a7c9299caf",
   "model-00006-of-00009.safetensors": "6aafcfc9d99618addbecf93b6ef6f1adc8114941e9ca4a0c1ba3cbf54fbb4d9d",
   "model-00007-of-00009.safetensors": "87238841e0aad4279e95908268d34e3ed1b5da5de0d04ce99fb4f8c45af67c35",
   "model-00008-of-00009.safetensors": "3e94ea58a946e1d54521ef18baa6c73e61066f68588fb2b46726ede3aac24dba",
   "model-00009-of-00009.safetensors": "c19f22b58b4c42a739374585623d16addf2de352022b9d8a440ba131ba5ff720"
  },
  "engine_commit": "ce28820e47c16988f56288ad64ad464e0738184a",
  "engine_dirty": true
 },
 "fixtures": [
  {
   "fixture": "fibonacci-raw",
   "tokens": 15,
   "token_sha256": "b7769551532c0ad8b9a1b8124e3bb9e3edcf8cca5d64125c020edb80d824adbb",
   "native_nll": 2.8919690871110246,
   "mlx_serial_nll": 2.8406177388455425,
   "mlx_chunk32_nll": 2.8742868031743534,
   "mlx_full_nll": 2.8742868031743534,
   "native_vs_serial": {
    "top1_agreement": 0.9333333333333333,
    "max_abs": 1.5,
    "rms": 0.2695379667229362,
    "finite": true,
    "kl_mean": 0.003982284659141044,
    "kl_p99": 0.009924088716917365,
    "kl_max": 0.010204187780618004
   },
   "native_vs_chunk32": {
    "top1_agreement": 0.9333333333333333,
    "max_abs": 4.125,
    "rms": 0.6525186847388184,
    "finite": true,
    "kl_mean": 0.006040667485176172,
    "kl_p99": 0.01711581182153379,
    "kl_max": 0.01742250315447551
   },
   "mlx_chunk32_vs_serial": {
    "top1_agreement": 1.0,
    "max_abs": 3.125,
    "rms": 0.4436320970441915,
    "finite": true,
    "kl_mean": 0.006796612407219586,
    "kl_p99": 0.019070950104862386,
    "kl_max": 0.01995933719745038
   },
   "mlx_full_vs_serial": {
    "top1_agreement": 1.0,
    "max_abs": 3.125,
    "rms": 0.4436320970441915,
    "finite": true,
    "kl_mean": 0.006796612407219586,
    "kl_p99": 0.019070950104862386,
    "kl_max": 0.01995933719745038
   }
  },
  {
   "fixture": "gpu-chat-no-think",
   "tokens": 35,
   "token_sha256": "34c41fc50825b5fd887436ed1f9f2ae69d710777a221f94b1d5cbb5717737fe4",
   "native_nll": 5.716686995554169,
   "mlx_serial_nll": 5.724390312130104,
   "mlx_chunk32_nll": 5.765810753377128,
   "mlx_full_nll": 5.717642529948139,
   "native_vs_serial": {
    "top1_agreement": 0.9428571428571428,
    "max_abs": 1.25,
    "rms": 0.1893557441630768,
    "finite": true,
    "kl_mean": 0.010642203432166349,
    "kl_p99": 0.08333138989714994,
    "kl_max": 0.10881155142696898
   },
   "native_vs_chunk32": {
    "top1_agreement": 0.9714285714285714,
    "max_abs": 1.375,
    "rms": 0.21460021831939105,
    "finite": true,
    "kl_mean": 0.00901477917118718,
    "kl_p99": 0.04355610256285816,
    "kl_max": 0.047731224040055864
   },
   "mlx_chunk32_vs_serial": {
    "top1_agreement": 0.9714285714285714,
    "max_abs": 1.75,
    "rms": 0.19092943749106223,
    "finite": true,
    "kl_mean": 0.007755403077574087,
    "kl_p99": 0.030876112146067048,
    "kl_max": 0.03177423913459955
   },
   "mlx_full_vs_serial": {
    "top1_agreement": 0.9714285714285714,
    "max_abs": 1.75,
    "rms": 0.23128675328521206,
    "finite": true,
    "kl_mean": 0.0072931219236618315,
    "kl_p99": 0.031277037836049904,
    "kl_max": 0.03227898497237537
   }
  },
  {
   "fixture": "public-contribution-guide-512",
   "tokens": 512,
   "token_sha256": "b0206242758037798cce991293f0f600a7c5113d6b652705b43ada0bd2b192ce",
   "native_nll": 3.2981265319963677,
   "mlx_serial_nll": 3.306361377972774,
   "mlx_chunk32_nll": 3.2939761279482083,
   "mlx_full_nll": 3.3011254621412025,
   "native_vs_serial": {
    "top1_agreement": 0.91796875,
    "max_abs": 8.25,
    "rms": 0.4013358564352756,
    "finite": true,
    "kl_mean": 0.010945506139855322,
    "kl_p99": 0.04042149809126025,
    "kl_max": 0.09108781051450346
   },
   "native_vs_chunk32": {
    "top1_agreement": 0.921875,
    "max_abs": 9.4375,
    "rms": 0.39862855150561066,
    "finite": true,
    "kl_mean": 0.010753584871592985,
    "kl_p99": 0.047534459930563815,
    "kl_max": 0.1400134702895854
   },
   "mlx_chunk32_vs_serial": {
    "top1_agreement": 0.947265625,
    "max_abs": 4.25,
    "rms": 0.26151797632237317,
    "finite": true,
    "kl_mean": 0.009838347827565704,
    "kl_p99": 0.03959047257870294,
    "kl_max": 0.05834875115422212
   },
   "mlx_full_vs_serial": {
    "top1_agreement": 0.9453125,
    "max_abs": 8.8125,
    "rms": 0.4033499529019144,
    "finite": true,
    "kl_mean": 0.010674325096614975,
    "kl_p99": 0.042492825393599755,
    "kl_max": 0.06645138175069834
   }
  },
  {
   "fixture": "python-stdlib-2048",
   "tokens": 2048,
   "token_sha256": "5a42facb3a83f6c531383a19c57a666bf245328afc4138b97029ad2be1afadab",
   "native_nll": 0.36548583462730677,
   "mlx_serial_nll": 0.36374177519935724,
   "mlx_chunk32_nll": 0.36367116087373574,
   "mlx_full_nll": 0.36616538895453143,
   "native_vs_serial": {
    "top1_agreement": 0.986328125,
    "max_abs": 11.0625,
    "rms": 0.557423203819268,
    "finite": true,
    "kl_mean": 0.005274513941993687,
    "kl_p99": 0.06450120232168344,
    "kl_max": 0.875234221777027
   },
   "native_vs_chunk32": {
    "top1_agreement": 0.98974609375,
    "max_abs": 10.5,
    "rms": 0.5284347706154673,
    "finite": true,
    "kl_mean": 0.004072006140364548,
    "kl_p99": 0.0500922697477258,
    "kl_max": 0.11082624491880542
   },
   "mlx_chunk32_vs_serial": {
    "top1_agreement": 0.9873046875,
    "max_abs": 11.875,
    "rms": 0.4840688789466054,
    "finite": true,
    "kl_mean": 0.0051351756370919535,
    "kl_p99": 0.06548356509049968,
    "kl_max": 0.6026136509687315
   },
   "mlx_full_vs_serial": {
    "top1_agreement": 0.98828125,
    "max_abs": 11.1875,
    "rms": 0.5309294850846997,
    "finite": true,
    "kl_mean": 0.005368460118554758,
    "kl_p99": 0.06725235402622899,
    "kl_max": 0.5935126875951473
   }
  }
 ]
}
concurrent == solo: xpu_concurrent_receipt.py, 2 and 4 streams
round 1: 2/2 concurrent replies == solo; 384 tokens in 9.6 s = 40.2 tok/s aggregate (solo, one after another: 37.5)
round 2: 2/2 concurrent replies == solo; 384 tokens in 9.6 s = 40.0 tok/s aggregate (solo, one after another: 37.5)
round 3: 2/2 concurrent replies == solo; 384 tokens in 9.6 s = 40.1 tok/s aggregate (solo, one after another: 37.5)
CONCURRENT == SOLO: PASS
round 1: 4/4 concurrent replies == solo; 768 tokens in 19.0 s = 40.3 tok/s aggregate (solo, one after another: 38.9)
round 2: 4/4 concurrent replies == solo; 768 tokens in 19.5 s = 39.3 tok/s aggregate (solo, one after another: 38.9)
round 3: 4/4 concurrent replies == solo; 768 tokens in 20.9 s = 36.7 tok/s aggregate (solo, one after another: 38.9)
CONCURRENT == SOLO: PASS
resumed == fresh: xpu_resume_receipt.py, cached server then --prompt-cache-gib 0
# cached
{"sampling": "greedy", "turn1": {"sha": "8351ea926665", "prompt": 1508, "cached": 0, "prefill_s": 14.557032}, "turn2": {"sha": "e54437d714b4", "prompt": 1580, "cached": 1502, "prefill_s": 0.863641417}}
{"sampling": "seeded", "turn1": {"sha": "cc1f8a2a3a78", "prompt": 1508, "cached": 1502, "prefill_s": 0.086221167}, "turn2": {"sha": "235fa147bcc0", "prompt": 1606, "cached": 1502, "prefill_s": 1.138095875}}
# fresh
{"sampling": "greedy", "turn1": {"sha": "8351ea926665", "prompt": 1508, "cached": 0, "prefill_s": 15.623639125}, "turn2": {"sha": "e54437d714b4", "prompt": 1580, "cached": 0, "prefill_s": 13.90681975}}
{"sampling": "seeded", "turn1": {"sha": "cc1f8a2a3a78", "prompt": 1508, "cached": 0, "prefill_s": 12.926058917}, "turn2": {"sha": "235fa147bcc0", "prompt": 1606, "cached": 0, "prefill_s": 13.742770125}}
Lightning 30B-A3B (d9d758fb): main vs this branch, token_sha per request (32/32 equal)
# main
{
 "p0-greedy-chat": "5ae8a877bf7a",
 "p0-greedy-raw": "434cb488a3e9",
 "p0-seeded-chat": "ca84ce37feaf",
 "p0-seeded-raw": "154bb8b237f1",
 "p1-greedy-chat": "b18a343f6d01",
 "p1-greedy-raw": "2ca4bcfac5c6",
 "p1-seeded-chat": "75ad7305d004",
 "p1-seeded-raw": "994dfa915cf0",
 "p2-greedy-chat": "2f212f7460d7",
 "p2-greedy-raw": "6ce81e25bb38",
 "p2-seeded-chat": "4aac7cb43ab7",
 "p2-seeded-raw": "11ccbd49c519",
 "p3-greedy-chat": "ebd63876f10b",
 "p3-greedy-raw": "866008e96b3a",
 "p3-seeded-chat": "bb7b0f3e6107",
 "p3-seeded-raw": "ae3c33a23e79",
 "p4-greedy-chat": "99f683d98b2a",
 "p4-greedy-raw": "eb0c21a3d01c",
 "p4-seeded-chat": "80d51dfae249",
 "p4-seeded-raw": "341615eefe95",
 "p5-greedy-chat": "15ffafbac276",
 "p5-greedy-raw": "878d1d439cda",
 "p5-seeded-chat": "6a59107e2c89",
 "p5-seeded-raw": "bbf7d21d4f9e",
 "p6-greedy-chat": "689eaf56d4b3",
 "p6-greedy-raw": "b269199162ce",
 "p6-seeded-chat": "92fbbb26fe47",
 "p6-seeded-raw": "4fcf8b6c20b4",
 "p7-greedy-chat": "104a1428c2f1",
 "p7-greedy-raw": "fbf60b9de08e",
 "p7-seeded-chat": "e8ce18600195",
 "p7-seeded-raw": "3f7c0c8cec66"
}

# this branch
{
 "p0-greedy-chat": "5ae8a877bf7a",
 "p0-greedy-raw": "434cb488a3e9",
 "p0-seeded-chat": "ca84ce37feaf",
 "p0-seeded-raw": "154bb8b237f1",
 "p1-greedy-chat": "b18a343f6d01",
 "p1-greedy-raw": "2ca4bcfac5c6",
 "p1-seeded-chat": "75ad7305d004",
 "p1-seeded-raw": "994dfa915cf0",
 "p2-greedy-chat": "2f212f7460d7",
 "p2-greedy-raw": "6ce81e25bb38",
 "p2-seeded-chat": "4aac7cb43ab7",
 "p2-seeded-raw": "11ccbd49c519",
 "p3-greedy-chat": "ebd63876f10b",
 "p3-greedy-raw": "866008e96b3a",
 "p3-seeded-chat": "bb7b0f3e6107",
 "p3-seeded-raw": "ae3c33a23e79",
 "p4-greedy-chat": "99f683d98b2a",
 "p4-greedy-raw": "eb0c21a3d01c",
 "p4-seeded-chat": "80d51dfae249",
 "p4-seeded-raw": "341615eefe95",
 "p5-greedy-chat": "15ffafbac276",
 "p5-greedy-raw": "878d1d439cda",
 "p5-seeded-chat": "6a59107e2c89",
 "p5-seeded-raw": "bbf7d21d4f9e",
 "p6-greedy-chat": "689eaf56d4b3",
 "p6-greedy-raw": "b269199162ce",
 "p6-seeded-chat": "92fbbb26fe47",
 "p6-seeded-raw": "4fcf8b6c20b4",
 "p7-greedy-chat": "104a1428c2f1",
 "p7-greedy-raw": "fbf60b9de08e",
 "p7-seeded-chat": "e8ce18600195",
 "p7-seeded-raw": "3f7c0c8cec66"
}

@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Rebased onto main (da275a3), so it merges cleanly again. It stays a draft.

The only conflict was build.zig: metalTargets moved into zig/build/metal_targets.zig, so tf-nemotron-forward is now registered in engine_programs there.

Re-run on the M3 Max after the rebase:

  • zig build native -Dcpu=apple_m1, test, test-bolt-host, tf-metal-tests (7/7): pass
  • test-golden: 306/319 and 26/26, 0 unexpected differences
  • check_mlx_ops.py --ops bolt_gemv,bolt_route,bolt_combine: 236/236 bit-identical
  • lean: 0 new
  • concurrent == solo at 2 streams: pass
  • The same two-turn conversation as the earlier receipts (xpu_resume_receipt.py, greedy and seeded) gives the same token_sha on all four turns as before the rebase. Turn 2 resumed from 1,502 cached tokens and still matches the earlier fresh-server run, so resumed == fresh holds too.

@drowzeys

Copy link
Copy Markdown
Contributor

A reference point for this work, not a competing PR: we have served Nemotron 3.5 Bolt 74B-A9B 24GB on Metal since 1.0.12 through a different route, a Metal port of MiaAI-Lab's DGX Spark engine (libbolt, Objective-C++ and Metal behind the Bolt lane backend). Since you asked for a native Zig port, we are keeping it out of a PR; the branch is drowzeys/TensorFold:upstream/bolt-metal (one commit on b34f9e78), in case its numbers help your gate.

On an M5 Ultra, with that checkpoint's packed weights (IQ2_XXS experts, NVFP4 Mamba projections, Q8_0 attention):

  • Parity against fp32 reference logits: KL 0.00016 (code) / 0.00026 (a shot list); top-1 100% on one-token steps and verify windows.
  • Through tensorfold-native with LiLiCorr drafts: 72 / 100 / 90 tok/s on prose / code / a shot list (llama.cpp Metal: 57).
  • In a voice agent, first token ≈ 60 ms on short turns after a warm prompt cache.

Happy to run your branch on the same prompts and post the comparison, if that would help.

@BlivionIaG BlivionIaG mentioned this pull request Oct 26, 2026
2 tasks done
@ashhart

ashhart commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Review of the current head rebased onto main e9b69ed. It applies cleanly. We added one small fix-up: nemotron_h_puzzle now joins the one-Mac --speed-up refusal (the flag was silently ignored on this path), with the existing refusal test extended. Before device qualification:

  1. Kernel contract. The forward uses new bm4/bm8 BF16 GEMVs, Bolt group norm and add-norm instances, and route/combine at latent shapes (nemotron/bolt.zig:12, :31, :63; group_norm_xs_bolt.metal:7), but none are in the canonical Metal runner or registry. ops.json, bolt_norm and the MLX op script are good comparisons, not the gates. Please add the served dimensions with NaN/Inf, alias/guard, FP64 and accumulator cases, planted controls and launch records. Also say which generator reproduces the new generated-style variants.
  2. Fidelity. Per-op byte matches don't qualify the Mamba, attention and projection arithmetic around them, and nemotron_fidelity.py only fails on non-finite logits. Please supply real-weight staged FP64 error by mixer and projection, prompt and decode rows separately, and every teacher-forced differing token with its margin.
  3. Shape admission. Any expert count and any width divisible by 128 is admitted (config_bolt.zig:17). E=241 reaches the four-row GEMV clamp, where the final tile (237) overlaps 236..239 (bolt.zig:13, ops/gemv.metal:12). Refuse unsupported tails before load, or add a non-overlapping tail with a contract case.
  4. Other families. Lightning keeps its MoE branch, but new scratch is allocated unconditionally, BF16 heads are accepted without a Bolt-only condition, and the shared combine's order changes above eight picks. Please gate these to Bolt so Nemotron Lightning stays byte-identical, and include 1/2/4/8 solo vs concurrent equality on Bolt.

Weights are read as stored and M5 is refused before loading, both good. RADIO images are deferred, so please don't list the multimodal checkpoint as qualified yet.

@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Thanks for the review. All four are addressed, and the branch is rebased onto current main (59044397, no conflicts). I've also mirrored your fix-up: nemotron_h_puzzle now joins the one-Mac --speed-up refusal, with the refusal test extended (2ec96b3). Five new commits on top of the previous head.

1. Kernel contract (6e45558). zig/tests/contract/metal_bolt.zig registers Bolt's kernels with the canonical runner at the shapes bolt.zig serves them:

  • tf_gemv_bf16_bm4_tm4 and _bm8_tm4: the router gate at 304–496 experts, into, out, and the bf16 lm_head at 131072 × 4096.
  • tf_route_topk at every Bolt expert count, top-k 9. Picks are exact against float64, with planted exact ties and the last partial 32-expert slice winning row 0. Weights are within the bound. The NaN rule is stated (MLX's sort).
  • The 9-pick latent combine.
  • group_norm_xs_bolt (MP 16 and 128), add_norm_xs_bolt and add_norm_moe_xs_bolt. OUT is checked as float64 ranges through its bf16 points; HN bit for bit; XS bit for bit as the f32 sum of the kernel's own outputs, with padded rows zero.

Gate 4 stresses each kernel with integer inputs that are exact in fp32 in any order.

There are eight planted controls, each a one-line mutation of the kernel's own source, and each is red at the gate it targets:

Control Gate
gemv summed in half sums
gemv losing its K tail shapes
route dropping the last partial slice (the bug the pad fix closed) shapes
route comparing NaN as a number nonfinite
combine dropping pick 8 shapes
add norm writing HN without its delta shapes
group norm summing 63 of 64 shapes
group norm over half its group shapes

Gate 5 records live in core/contract/bolt_records.zig; the M1/M2 limits come from --offline and are all 1024.

On the generator: there isn't one for these. The add-norm instantiations at <4096,512> and <4096,512,1>, the Bolt tree conv/scan instantiations and group_norm_xs_bolt are hand-authored in gen_nemotron_kernels.py's style, and that script isn't in the public repo. If you'd rather they come from it, I'm happy to send the template parameters.

tf-kernel-contract --only bolt --offline DIR   (M3 Max, applegpu_g15)
SUMMARY 8 kernels: 8 pass gates 1-4, 0 fail, 0 known findings; 8 controls: 8 red as planted, 0 missed; 1 limit problems

The one limit problem is upstream's own glm gather glm_rows_bf16_nax record (M1/M2 recorded 0, 0), not one of these. The Bolt-width Mamba tree conv and scan aren't registered yet; they're next.

2. Fidelity (8ce648a).

  • Stage tap. forward.Tap is an optional look at each stage a forward writes. It's null in the engine, which then encodes nothing more. Logits are byte-identical with and without it.
  • Forward tool. tf-nemotron-forward --decode-from N --stages DIR dumps every stage of every layer.
  • tools/zig/nemotron_stages.py recomputes each stage in float64 from the dequantized checkpoint and the native's own input to that stage, so each error is the stage's own. It reports the error in bf16 ulps of the row's RMS, so cancelling outputs don't read as huge. Prompt rows and decode rows are reported apart. Every projection also gets MLX's own bf16 result on the same input as a floor.

On argparse's source, 256 prompt rows then 32 decode rows, all 88 layers:

mixer stage prompt rows: native p99 / max (MLX p99) decode rows: native p99 / max (MLX p99) rel RMS
all input norm 0.98 / 31.8 0.98 / 30.9 0.0017
mamba in_proj 1.71 / 32.5 (1.73) 1.69 / 23.9 (2.73) 0.0031
mamba conv 1.48 / 62.6 1.48 / 55.2 0.0020
mamba scan (gated) 0.66 / 155.0 0.68 / 88.8 0.0024
mamba group norm 1.74 / 63.4 1.75 / 54.4 0.0023
mamba out_proj 2.27 / 39.5 (2.69) 2.28 / 35.0 (3.92) 0.0045
attention qkv 2.15 / 18.0 (2.65) 2.16 / 17.9 (3.82) 0.0039
attention attention 1.24 / 15.7 1.23 / 15.7 0.0017
attention o_proj 3.23 / 40.2 (3.66) 2.92 / 30.1 (5.20) 0.0053
moe gate 0.88 / 2.0 (0.88) 0.87 / 2.0 (0.87) 0.0016
moe route weights 0.00 / 0.0 0.00 / 0.0 0.0000
moe shared expert 4.61 / 513.2 (5.17) 4.93 / 226.3 (8.29) 0.0077
moe into (fc1_latent) 0.97 / 8.0 (0.97) 0.97 / 4.0 (0.97) 0.0017
moe routed experts 5.30 / 794.1 (8.62) 5.23 / 770.1 (8.45) 0.0074
moe combine 0.97 / 8.0 0.97 / 7.9 0.0017
moe out (fc2_latent) 0.98 / 29.9 (0.98) 0.98 / 15.8 (0.98) 0.0017
all residual 1.00 / 46.4 1.00 / 36.5 0.0018
all next norm 0.98 / 31.8 0.98 / 30.9 0.0017

Errors in bf16 ulps of the row's RMS. Route picks: prompt 1 of 10,240 differ, decode 0 of 1,280.

  • Projections. Every quantized projection is at or below MLX's own error on the same input. The MLX-exact ops (gate, into, out) match MLX's error exactly.
  • Route picks. 1 of 11,520 differs: layer 1, row 73. Its fp32 keys tie exactly (4.820835590 for experts 32 and 44), and the stable order takes 32, as MLX does. Float64 separates them by 5.1e-8, under one fp32 ulp.
  • Maxima. The largest errors (shared and routed experts) are at outputs that cancel. MLX's maxima there are as large (885 and 802 row-ulps).

nemotron_fidelity.py now runs each fixture twice, prompt rows and decode rows. On Metal these give the same logits bit for bit, because Bolt prompts take the decode kernels 16 rows at a time. It lists every teacher-forced token whose top-1 differs from mlx-lm serial, with mlx-lm's margin, and it now fails on:

  • a non-finite logit;
  • a differing token whose margin is above the largest at which mlx-lm's own chunk32 or full run flips on that fixture;
  • more differing tokens than twice mlx-lm's own count plus 2;
  • an NLL further from mlx-lm serial than twice mlx-lm's own spread.
fixture tokens top-1 KL mean / p99 / max differing (max margin) mlx chunk32 vs serial: top-1, KL mean, differing (max margin) NLL native / mlx serial
fibonacci-raw 15 0.933 0.0040 / 0.010 / 0.010 1 (1 ulps) 1.000, 0.0068, 0 (0 ulps) 2.892 / 2.841
gpu-chat-no-think 35 0.943 0.0106 / 0.083 / 0.109 2 (1 ulps) 0.971, 0.0078, 1 (1 ulps) 5.717 / 5.724
public-contribution-guide-512 512 0.924 0.0092 / 0.036 / 0.081 39 (1 ulps) 0.936, 0.0095, 33 (2 ulps) 2.936 / 2.951
python-stdlib-2048 2048 0.986 0.0053 / 0.065 / 0.875 28 (6 ulps) 0.987, 0.0051, 26 (6 ulps) 0.365 / 0.364

On python-stdlib, mlx-lm's own chunk32 run flips 26 positions, the largest at 6 ulps (position 22). The native flips 28, 17 of them the same positions, also at most 6 ulps. Every differing token, with its margin, is in fidelity.json (attached below).

3. Shape admission (f78f745). Expert counts off the router gemv's 4-row tile are refused before load (config_bolt.offTile). The test covers 241, 242, 243 (refused) and 244 (accepted). Bolt's own counts are all multiples of 16.

4. Lightning stays byte-identical (d197480).

  • x_lat, ey_lat and ones are allocated for Bolt only.
  • A bf16 lm_head without scales is read as a dense head for Bolt only (weights.denseHead, tested both ways). Every other family keeps the quantized head and is refused without one, as before.
  • tf_moe_combine_at is back to main's order for every caller. Bolt's order past 8 picks is a separate tf_moe_combine_rows_lanes8, still bit-identical to MLX: check_mlx_ops.py --ops bolt_gemv,bolt_route,bolt_combine gives 236/236.
  • Lightning 30B-A3B on main vs this head: 16/16 replies byte-identical (8 prompts × greedy/seeded).
  • Bolt solo vs concurrent passes at 1, 2, 4 and 8 streams, two rounds each, greedy and seeded streams. Aggregate is ~40 tok/s throughout, since streams don't batch yet.

zig build test, test-golden (322/335, 0 unexpected), test-bolt-host and tf-metal-tests (7/7) pass on the rebased head.

The multimodal checkpoint stays unlisted: the text backbone only here, with RADIO still a shipping gate.

receipts

tf-kernel-contract --only bolt --offline DIR (gates and controls):

PASS nonfinite metal bolt gemv tf_gemv_bf16_bm4_tm4: 4096 non-finite and 1024 finite outputs match the float64 classes
PASS repeat metal bolt gemv tf_gemv_bf16_bm4_tm4: five runs byte-identical (2048 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt gemv tf_gemv_bf16_bm4_tm4: 12 shapes within the float64 bound (worst 0.980 of the bound), 0 edges refused by the kernel
PASS sums metal bolt gemv tf_gemv_bf16_bm4_tm4: exact sums at k 4096, where fp16 sums would miss by 914x and bf16 by 6400x
PASS nonfinite metal bolt gemv tf_gemv_bf16_bm8_tm4: 16384 non-finite and 4096 finite outputs match the float64 classes
PASS repeat metal bolt gemv tf_gemv_bf16_bm8_tm4: five runs byte-identical (8192 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt gemv tf_gemv_bf16_bm8_tm4: 13 shapes within the float64 bound (worst 0.986 of the bound), 0 edges refused by the kernel
PASS sums metal bolt gemv tf_gemv_bf16_bm8_tm4: exact sums at k 4096, where fp16 sums would miss by 1771x and bf16 by 16435x
PASS nonfinite metal bolt route tf_route_topk: the stated rule holds: a NaN logit sorts after every number (MLX's sort) and is picked only when fewer than 9 numbers remain; +Inf and -Inf saturate the sigmoid to 1 and 0; a row whose picks hold a NaN has NaN weights
PASS repeat metal bolt route tf_route_topk: five runs byte-identical (576 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt route tf_route_topk: 7 shapes exact by its own check (worst 0.000 of the bound), 0 edges refused by the kernel
PASS sums metal bolt route tf_route_topk: within its bound at k 496; fp16 sums would miss 27x, bf16 218.8x (nine terms in (0, 1), then a division: no accumulator's error is provably 100x the bound)
PASS nonfinite metal bolt combine tf_moe_combine_rows_lanes8: 4 non-finite and 8188 finite outputs match the float64 classes
PASS repeat metal bolt combine tf_moe_combine_rows_lanes8: five runs byte-identical (32768 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt combine tf_moe_combine_rows_lanes8: 6 shapes within the float64 bound (worst 0.989 of the bound), 0 edges refused by the kernel
PASS sums metal bolt combine tf_moe_combine_rows_lanes8: exact sums at k 1024, where fp16 sums would miss by infx and bf16 by 6816000x
PASS nonfinite metal bolt group norm tf_nemotron_group_norm_xs_bolt_16: the stated rule holds: outputs equal the float64 reference's bytes
PASS repeat metal bolt group norm tf_nemotron_group_norm_xs_bolt_16: five runs byte-identical (262144 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt group norm tf_nemotron_group_norm_xs_bolt_16: 2 shapes exact by its own check (worst 0.000 of the bound), 0 edges refused by the kernel
PASS sums metal bolt group norm tf_nemotron_group_norm_xs_bolt_16: within its bound at k 1024; fp16 sums would miss 442362x, bf16 518.9x (a bf16 row follows the sum of squares as ss^-1/2, so a bf16 sum's error is a few output ulps)
PASS nonfinite metal bolt group norm tf_nemotron_group_norm_xs_bolt_128: the stated rule holds: outputs equal the float64 reference's bytes
PASS repeat metal bolt group norm tf_nemotron_group_norm_xs_bolt_128: five runs byte-identical (1048576 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt group norm tf_nemotron_group_norm_xs_bolt_128: 1 shapes exact by its own check (worst 0.000 of the bound), 0 edges refused by the kernel
PASS sums metal bolt group norm tf_nemotron_group_norm_xs_bolt_128: within its bound at k 1024; fp16 sums would miss 156090x, bf16 259.5x (a bf16 row follows the sum of squares as ss^-1/2, so a bf16 sum's error is a few output ulps)
PASS nonfinite metal bolt add norm tf_nemotron_add_norm_xs_bolt: the stated rule holds: outputs equal the float64 reference's bytes
PASS repeat metal bolt add norm tf_nemotron_add_norm_xs_bolt: five runs byte-identical (131072 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt add norm tf_nemotron_add_norm_xs_bolt: 2 shapes exact by its own check (worst 0.000 of the bound), 0 edges refused by the kernel
PASS sums metal bolt add norm tf_nemotron_add_norm_xs_bolt: within its bound at k 4096; fp16 sums would miss 67122x, bf16 92.3x (a bf16 row follows the sum of squares as ss^-1/2, so a bf16 sum's error is a few output ulps)
PASS nonfinite metal bolt add norm tf_nemotron_add_norm_moe_xs_bolt: the stated rule holds: outputs equal the float64 reference's bytes
PASS repeat metal bolt add norm tf_nemotron_add_norm_moe_xs_bolt: five runs byte-identical (131072 bytes), inputs and guards untouched, no overlap
PASS shapes metal bolt add norm tf_nemotron_add_norm_moe_xs_bolt: 2 shapes exact by its own check (worst 0.000 of the bound), 0 edges refused by the kernel
PASS sums metal bolt add norm tf_nemotron_add_norm_moe_xs_bolt: within its bound at k 4096; fp16 sums would miss 25388x, bf16 19.8x (a bf16 row follows the sum of squares as ss^-1/2, so a bf16 sum's error is a few output ulps)
CONTROL control: bolt gemv summed in half: red at sums, as planted
CONTROL control: bolt gemv losing its K tail: red at shapes, as planted
CONTROL control: bolt route dropping the last partial 32-expert slice: red at shapes, as planted
CONTROL control: bolt route comparing NaN as a number: red at nonfinite, as planted
CONTROL control: bolt combine dropping pick 8: red at shapes, as planted
CONTROL control: bolt add norm writing HN without its delta: red at shapes, as planted
CONTROL control: bolt group norm summing 63 of 64: red at shapes, as planted
CONTROL control: bolt group norm over half its group: red at shapes, as planted
SUMMARY 8 kernels: 8 pass gates 1-4, 0 fail, 0 known findings; 8 controls: 8 red as planted, 0 missed; 1 limit problems; gates 23032 ms, limits 13120 ms

Route pick that differs from float64 (nemotron_stages.py): layer 1, row 73, native 32 vs float64 44, float64 gap 5.1e-8, fp32 keys tie (4.820835590).

Every differing teacher-forced token, position:margin in bf16 ulps (prompt rows; decode rows are bit-identical), * = mlx-lm's own chunk32 run flips there too:

fibonacci-raw: 2:1
gpu-chat-no-think: 1:0, 10:1*
public-contribution-guide-512: 1:1, 8:0, 16:0, 31:0, 43:0*, 52:0*, 69:0, 80:1*, 85:0, 95:1*, 98:1, 116:0, 158:1*, 210:0, 215:1*, 243:1, 246:1, 258:1*, 260:1*, 296:1*, 307:0*, 321:1, 336:0, 346:1*, 355:0*, 361:0, 384:1, 410:1*, 412:1, 441:0*, 456:0*, 458:1*, 460:1*, 482:0*, 490:1*, 491:0, 495:0, 496:0*, 500:1
python-stdlib-2048: 22:6*, 38:0*, 168:3*, 373:1, 458:1*, 462:3, 506:1, 521:2, 568:1*, 571:0*, 735:0, 866:3, 946:1*, 947:0*, 948:0, 950:1*, 1145:0*, 1206:1*, 1228:1*, 1242:1, 1244:0*, 1307:0*, 1410:0, 1498:1*, 1507:1*, 1513:4, 1573:0, 1693:1*

@ashhart

ashhart commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks @trickyfalcon, and for mirroring the --speed-up fix-up. All four points are answered: Bolt's kernels are in the canonical runner at their served shapes with eight planted controls, the staged float64 table and every differing token with its margin are in, expert counts off the router's 4-row tile are refused before load, and Bolt's scratch, bf16 head and 9-pick combine are now Bolt's alone, with Lightning's 16 replies byte-identical to main in your run.

On the generator: thanks for the offer, but there's no need to send the parameters. Keep the Bolt instantiations as they are.

The branch now conflicts with main in zig/src/core/contract/registry.zig, so please rebase when you push the Bolt-width Mamba tree conv and scan records.

@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Thanks. I've rebased onto current main (dd0a9cc5). The registry.zig conflict was just the two record lists, nemotron_experts_records / moss_image_records and bolt_records; I kept both. On top of that, one new commit registers the Bolt-width Mamba tree conv and scan.

tf_tree_conv_bolt and tf_tree_scan_bolt (zig/tests/contract/metal_bolt_mamba.zig) run at the shapes Bolt serves them. That means one stream's chain of 1 to 16 rows: a decode step, or a prompt chunk of up to fused_rows. There are no replayed rows or trees, because the checkpoint has no draft head. The tables come from layers.Tables.of, over the same segment backend.zig builds. The state is read from the stream's slot and stored to a fresh one. init checks the two instantiations' template arguments against nemotron_tree.metal.

  • The outputs. XBC and Y are checked against float64 as intervals through their bf16 points:

    • the conv's fma chain within gamma(4);
    • the scan's recurrence op by op, with the dot within gamma(35): a lane's 4 states, then simd_sum, whose order Metal doesn't state;
    • fast math's exp, log and divide within 2^-16.
  • What check() also requires:

    • RAW, DTRAW and the stored conv taps bit for bit;
    • the stored scan state within its interval;
    • the other slots and the tree states untouched.
  • Gate 4. The stress inputs are integers that are exact in fp32 in any order:

    • conv: w0 = big + r against w1 = -big;
    • scan: A 0 and B 0, with each state's term cancelled by a rotated partner's.

    bf16 and fp16 sums of them leave the bound.

Six controls, each red at its gate:

Control Gate
conv dropping its oldest tap shapes
conv storing the wrong taps shapes
conv summed in half sums
scan without its D skip shapes
scan not decaying its state shapes
scan summing its dot in half sums
tf-kernel-contract --only bolt --offline DIR   (M3 Max, applegpu_g15)
SUMMARY 10 kernels: 10 pass gates 1-4, 0 fail, 0 known findings; 14 controls: 14 red as planted, 0 missed; 1 limit problems

Gate 5: both launches are 256 threads with no threadgroup memory, and M1/M2 take 1024 each, as recorded in bolt_records.zig. The one limit problem is still main's glm gather glm_rows_bf16_nax record (M1/M2 recorded 0, 0). The new pair passes gates 1–4 at seeds 1, 2, 3, 77 and 9001 as well as the default.

No kernel source or engine code changes in this commit. zig build test, test-bolt-host, test-kernel-contract and tf-metal-tests pass.

@ashhart

ashhart commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks @trickyfalcon for the rebase and for registering the Bolt-width tree conv and scan with their six controls. The branch applies cleanly to main again, and the contract summary (10 kernels through gates 1-4, 14 controls red) covers what we asked for. Next we will run the integrated M3 acceptance and the config-only M5 refusal and cleanup cells on our side. RADIO images stay deferred, so the multimodal checkpoint stays unlisted for now. We'll follow up here once those runs are in.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Hi @trickyfalcon, a status note: this is waiting on us. Your rebase and the Bolt-width kernels with their six controls
covered what we asked; what's left is our M3 acceptance run and the M5 refusal and cleanup cells. Those need the Bolt checkpoint on our Macs, which we don't hold yet, so we'll fetch it first. Nothing is needed from
you, and if main moves under the branch before then, we can do the rebase; say so here.

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Hi @trickyfalcon, our M5 Ultra cell is in, along with a trial rebase of your 18 commits onto today's main.

On the M5 (config files only, no weights):

  • Refusal works: loading Bolt stops with BoltNeedsRowKernels ("runs on Apple GPUs without tensor units (M1 to M4); its M5 lane kernels are not built yet") in 0.72 s, before any weight file is opened, as model.zig orders it.
  • Cleanup mostly holds: across 50 refused loads in one process, the Metal device's reference count stays at 27, the queue's at 1, and the device's allocation is flat.
  • One open question: the process's resident memory grows by 1.33 MiB over those 50 loads, about 27 KB each. Could something host-side on the refusal path not be freed? A config buffer or the parsed JSON are the likely places.
  • A test to fix: the PR's own refused-config cleanup test fails here, at model.zig:199, expecting a device retain count of 7 and finding 25. Comparing the count before and after the refused load, instead of an absolute 7, would make it hold on every chip.

The rebase onto today's main: the conflicts are only registration lists (native/metal.zig, core/contract/registry.zig, tests/contract/metal_main.zig). Main's entries stay, and Bolt's go at the current ends. But main's rules have tightened since your base, and the result doesn't pass them yet:

  1. File sizes: metal_bolt.zig is 943 lines and metal_bolt_mamba.zig 691, and the registry collector reaches 621 with Bolt's records. Each needs a split to stay at 600 or under.
  2. Lean: the lean checker counts 65 new findings, and seven comments run past 120 columns.
  3. Host build: the contract registry's host build fails at zig/tests/contract/metal_limits.zig:253, because the host-only source stub has no nemotron_tree member. It needs Bolt's sources added there.
  4. Changelog: please add one line for the PR under ## Unreleased.
  5. Commit messages: please drop any tool or session trailers.

If you'd like our rebase as a starting point, with the conflicts already settled, say so and we'll push it to a branch for you. After that, what's left on our side is the integrated M3 acceptance run, which we'll do once the rules above pass.

  • Synthena (Ash's Agent)

Part 1 of the native Metal backend for nemotron_h_puzzle (Nemotron 3.5
Bolt 74B-A9B), opened early per ashhart#962 so the loader can
be reviewed before the latent kernels harden. v1.1.0 already parses the
Puzzle config (bolt, per-layer moe[]) and serves it on CUDA; this is the
Metal weight loader for it.

weights.zig: the Metal MoE loader now reads each layer's own expert count
and width (per-layer in nemotron_h_puzzle, uniform otherwise), runs the
routed experts in the moe_latent_size latent rather than hidden, and
carries the two bf16 latent projections fc1/fc2_latent_proj (new Moe.into
and .out, a plain-bf16 Dense referenced in place; the Lightning path keeps
them null and is unchanged). moe() takes the layer's experts, width and
latent; its two callers pass the per-layer values for bolt, the globals
otherwise.

config.zig: checkShapes gains a bolt branch (checkBoltShapes) for Bolt's
dimensions (hidden 4096, 1024 latent, 5376 shared expert, top-k 9, per-
layer expert counts 240-496 and widths 1536-2560).

weights_test.zig: a two-layer puzzle block loads per layer - each keeps
its own expert count and width, the experts read the latent, and both
latent projections are present.

No forward or kernels yet; those follow as commits on this branch. The
Lightning path is byte-for-byte unchanged (zig build test test-golden: 0
unexpected golden differences).
The latent path for Nemotron 3.5 Bolt, mirroring cuda_latent.zig run(): the
normed input projects into the moe_latent_size latent, the routed experts
run up/down in the latent, each pick projects back to hidden, then add_norm
combines the picks by weight with the shared expert (kept in hidden) and the
residual. Per-pick out-projection is valid because the projection is linear.
Hand-authored (the nemotron kernel generator is not in the public repo).

state.zig: two latent-width scratch buffers (x_lat, ey_lat).

weights.zig: the routed experts load through the runtime-dim row kernels for
the Puzzle (latent > 0), which read each layer's own expert count and width
at K = latent; the baked 4/64 lane kernels serve only the Lightning inner
width.

New Metal kernels (zig/kernels/metal/nemotron):
- route_bolt: the router top-k at runtime NE and K, so one kernel serves
  every Puzzle layer's own expert count. Same scoring as route.metal (sigmoid
  of the gate logit plus the correction bias, normalised and scaled) but the
  per-lane slices are ceil(NE / 32) with an e < NE guard, so the last partial
  slice is kept (every Bolt expert count is NE % 32 == 16, which the baked
  route.metal would drop).
- dense_bf16: a bf16 write-matmul (y = x R^T, no accumulate) for the gate and
  the two full-precision latent projections fc1/fc2_latent_proj.
- add_norm_moe_xs_bolt: the combine + shared + residual + next-norm kernel at
  <4096, 512, 9> (896 does not divide 4096; 512 does).

layers.bolt_moe + forward dispatch (c.bolt): gate (dense_bf16) -> route_bolt
-> shared up/down (hidden, the Lightning path) -> into (dense_bf16) -> routed
experts up/down in the latent (indexed row kernels) -> out per pick
(dense_bf16) -> add_norm_moe_xs_bolt.

Lightning is unchanged: the dispatch takes bolt_moe only when c.bolt, and
zig build test test-golden holds 0 unexpected golden differences. Remaining
to RUN end to end: Bolt-dim variants of the shared up_relu2 and the mamba
kernels, and the GPU kernel-contract tests (route_bolt first).
…t slice

tf-metal-tests now dispatches route_bolt at a real Bolt expert count
(NE=240, NE % 32 == 16) and checks its picks and weights against a CPU
reference. Row 0 plants its top nine logits on experts 224..232 - in the
last partial slice [224,240) that the baked NE/32 striping dropped - and the
kernel returns exactly those, so the pad-to-32 fix is proven on device.
Weights match the reference (sigmoid + bias, normalised, scaled) within 1e-3.

route_bolt.metal and dense_bf16.metal join the metallib source list, which
compiles and validates their MSL at build time (the engine still loads them
from the runtime kernel registry).
dense_bf16: the bf16 write-matmul (gate and latent projections) checked
against an fp32 CPU reference over the same bf16 inputs, to a bf16 output
tolerance.

add_norm_moe_xs_bolt: the <4096, 512, 9> instantiation, checked on the case
with no routed picks (WE = 0) and no shared expert (SH = 0), where the block
reduces to OUT = rmsnorm(H) * W with W = 1; HN is unchanged and XS is the
per-group sum of OUT.

add_norm_moe_xs.metal joins the metallib source list so the instantiation
compiles at build time and tf-metal-tests can load it. tf-metal-tests: 9 of
9 pass on an M-series Mac.
The Metal engine now opens, loads and serves the published Bolt checkpoint
(bytebunker/NVIDIA-Nemotron-3.5-Bolt-74B-A9B-MLX-4bit, 40.3 GiB) on an
M-series Mac without tensor units, where every projection runs on the
runtime-dim row kernels. On an M3 Max (128 GB) it loads in 6.3 s and decodes
at ~41 tok/s.

Checked on that build:
- greedy tokens are identical to mlx_lm 0.32.3 (token_sha256 equal) on the
  prompts tried;
- concurrent == solo at two and four streams;
- resumed == fresh: a chat turn resumed from the prompt cache (at 915 of 959
  tokens) equals the same turn prefilled on a fresh server.

What Bolt needed beyond the latent MoE:
- metal.zig: register the nemotron_h_puzzle family and open it.
- weights.zig / forward.zig: a full-precision bf16 lm_head (MLX quantizes a
  module only where {path}.scales exists, and Bolt's lm_head has none) is
  read in place and projected by dense_bf16.
- Mamba at Bolt's widths (inner 128 x 64 = 8192, in_proj 18560): the tree
  conv and scan instantiated at <8192, 8, 128, 4, 18560, 8192> and
  <128, 64, 8, 128, 8192, 18560, 18432, 1048576>, and the gated group norm
  at XD 8192 / GS 1024 (group_norm_xs_bolt.metal, one per padded row count).
- add_norm_xs at <4096, 512>, and the hidden row sums at the model's width.
- backend.zig: prompts run through the decode kernels in fused_rows chunks;
  the fused prefill kernels are not yet built for the latent MoE.

All Bolt kernels are hand-authored instantiations of the generated ones (the
generator is not in the public repo). Lightning is unchanged: zig build test
test-golden holds 0 unexpected golden differences; tf-metal-tests 9 of 9.
…does

bolt_moe now follows mlx_lm's NemotronHMoE order and roundings: the picks
are summed by weight in the latent ((y * scores).sum(-2) in fp32, one bf16
rounding), the sum is projected back to hidden once by fc2_latent_proj,
then the shared expert and the residual are added (bf16(y + shared), then
bf16(h + y)). It replaces the per-pick out-projection, which was equal in
exact arithmetic but rounded differently, and costs nine times the
fc2_latent_proj work.

- combine_latent.metal: the latent combine, with add_norm_moe_xs's
  routed-sum order (a sequential fma over the picks).
- add_norm_moe_xs_bolt is now <4096, 512, 1>: one pick of weight 1 (exact
  under the fma) carries the projected MoE output into add_norm; Scratch
  gains a ones buffer for it.
- tf-metal-tests: combine_latent bit-exact against a host fma reference;
  10 of 10 pass.

On the published Bolt checkpoint (M3 Max), greedy output is token-exact
with mlx_lm 0.32.3 on 7 of 8 comparison prompts (was 5 of 8); the eighth
diverges at an exact tie in mlx_lm's own logits. concurrent == solo (x2,
x4) and resumed == fresh still hold; decode ~42-43 tok/s. Lightning
unchanged (test-golden 0 unexpected).
…orward)

Nemotron had no fidelity tool; this adds one on the qwen35/lfm2 pattern.

- tf-nemotron-forward MODEL TOKENS.npy OUT.bin: native teacher-forced bf16
  logits for every position, the ids run through the decode kernels
  fused_rows rows a forward (Lightning or Bolt).
- tools/zig/nemotron_fidelity.py: teacher-forced NLL, top-1 agreement and
  logit RMS of the native logits against mlx-lm run one row at a time, in
  32-row chunks and whole, with mlx-lm's own chunked-vs-serial variation as
  the floor. Every native pass runs before mlx-lm loads, so a 74B
  checkpoint is never held twice. The long fixture is the running Python's
  json.decoder and argparse sources (public, deterministic).

Bolt on an M3 Max (mlx 0.32.3, mlx-lm 0.32.0), native vs mlx-lm serial,
with mlx-lm's own chunk32-vs-serial floor in brackets:

  fixture                tokens  top-1            logit RMS       NLL native / mlx
  fibonacci-raw              15  0.933 (1.000)    0.181 (0.444)   2.890 / 2.841
  gpu-chat-no-think          35  0.971 (0.971)    0.179 (0.191)   5.715 / 5.724
  contribution-guide-512    512  0.922 (0.947)    0.322 (0.262)   3.293 / 3.306
  python-stdlib-2048       2048  0.988 (0.987)    0.494 (0.484)   0.362 / 0.364
A config refused after the device opens (Bolt on a tensor-unit chip, a bad
shape, a time-step clamp) returned without releasing either. A test counts
the device's references across a refused load.
The flag was silently ignored on this path; Bolt is now refused like Nemotron, before any load, with the refusal test extended.
…load

At E = 241 the gemv's last tile (237) clamps back over 236..239, so those rows would be written twice. Counts not a multiple of 4 are refused before the device opens; Bolt's own counts (240-496, all multiples of 16) pass.
…combine are Bolt's own

- x_lat, ey_lat and ones are allocated for nemotron_h_puzzle only (null otherwise).
- A bf16 lm_head without scales is read as a dense head for Bolt only; every other family keeps the quantized head it always loaded and is refused without one, as before (weights.denseHead, tested both ways).
- tf_moe_combine_at is back to upstream's order for every caller. Bolt's col_reduce_small order past 8 picks is a new tf_moe_combine_rows_lanes8 (bit-equal to the shared one at k <= 8); bolt_combine still 236/236 bit-identical with the gemv and route cases.
…rols and M1/M2 records

tests/contract/metal_bolt.zig registers Bolt's Metal kernels with the canonical runner, at the shapes nemotron/bolt.zig serves them:
- tf_gemv_bf16_bm4_tm4 and _bm8_tm4 (the router gate at 304-496 experts, into, out, the bf16 lm_head at 131072 x 4096), dense input family, float64 bound;
- tf_route_topk at every Bolt expert count, top-k 9: picks exact against float64 (planted exact ties, the last partial 32-expert slice winning row 0), weights within the bound, a stated NaN rule (MLX's sort);
- tf_moe_combine_rows_lanes8 at k 9 over the 1,024 latent;
- tf_nemotron_group_norm_xs_bolt (MP 16 and 128), tf_nemotron_add_norm_xs_bolt and _moe_xs_bolt: OUT as float64 ranges through its bf16 points, HN bit for bit, XS bit for bit as the f32 sum of the kernel's own outputs, padded rows zero.
Gate 4 stresses each with integer inputs exact in fp32 in any order (fp16 overflows, bf16 misses).

Eight planted controls, each a one-line mutation of the kernel's own source, red at the gate named: gemv summed in half (sums), gemv losing its K tail (shapes), route dropping the last partial 32-expert slice (shapes), route comparing NaN as a number (nonfinite), combine dropping pick 8 (shapes), add norm writing HN without its delta, group norm summing 63 of 64, group norm over half its group (shapes).

Gate 5: core/contract/bolt_records.zig, threads and threadgroup bytes as bolt.zig launches them, M1/M2 limits from --offline (all 1024).

tf-kernel-contract --only bolt --offline DIR on an M3 Max: 8 kernels pass gates 1-4, 8 controls red as planted, 28 launch checks pass.
…, prompt and decode rows apart

forward.Tap: an optional look at a forward's stages (h and x in and out of each layer, Mamba's in_proj, conv, gated
scan, group norm, attention's qkv and output, the MoE's gate, picks, weights, shared expert, into, routed experts,
combine and out). Null in the engine, which then encodes nothing more: logits with and without it are byte-identical,
and Lightning's replies on main and this head match 16/16 (greedy and seeded).

tf-nemotron-forward --decode-from N runs rows from N one a forward (decode) after fused_rows chunks (prompt);
--stages DIR copies every stage of every layer of every forward out (stages.bin, stages.jsonl).

tools/zig/nemotron_stages.py recomputes each stage in float64 from the dequantized checkpoint and the native's own
input to that stage, so each stage's error is its own, and reports it in bf16 ulps of the row's RMS, prompt and decode
rows apart; every projection also gets MLX's own bf16 result on the same input (quantized_matmul) as the floor. Route
picks are compared exactly; each differing pick is listed with float64's gap and whether its fp32 keys tie.

tools/zig/nemotron_fidelity.py runs the native twice a fixture (prompt rows, then decode rows), lists every
teacher-forced token whose top-1 differs from mlx-lm serial with mlx-lm's margin, and fails: on a non-finite logit, on a
differing token whose margin is above the largest at which mlx-lm's own chunk32 or full run flips on that fixture (or
--tie-ulps), on more differing tokens than twice mlx-lm's own count plus 2, or on an NLL further from mlx-lm serial than
twice mlx-lm's own spread.
…ns, with planted controls and M1/M2 records

tf_tree_conv_bolt and tf_tree_scan_bolt run gates 1-4 as Bolt serves them: one stream's chain of 1 to 16 rows (a
decode step or a prompt chunk; no replayed rows or trees, since the checkpoint has no draft head), its tables from
layers.Tables.of over the segment backend.zig builds, the state read from the stream's slot and stored to a fresh one.
init checks the two instantiations' template arguments against nemotron_tree.metal.

XBC and Y are checked against float64 as intervals through their bf16 points: the conv's fma chain within gamma(4),
the scan's recurrence op by op with the dot within gamma(35) (a lane's 4 states, then simd_sum in an unstated order),
fast math's exp, log and divide within 2^-16. check() also requires RAW, DTRAW and the stored conv taps bit for bit,
the stored scan state within its interval, the other slots and the tree states untouched. Gate 4's integers are exact
in fp32 in any order (conv: w0 = big + r against w1 = -big; scan: A 0, B 0, each state's term cancelled by a rotated
partner's), and bf16 and fp16 sums of them leave the bound.

Six controls, each red at its gate: the conv dropping its oldest tap, storing the wrong taps, summing in half; the
scan without its D skip, not decaying its state, summing its dot in half. Gate 5 records both launches (256 threads,
no threadgroup memory) with the M1/M2 limits from --offline.
…st launch map, a clean refusal

The contract's Bolt files are split along their kernels: metal_bolt.zig keeps gemv, route and combine, its norms
move to metal_bolt_norm.zig, the Mamba scan to metal_bolt_scan.zig. Bolt registers through one hook,
metal_bolt_main.zig, so metal_main.zig is back to main's size plus two lines.

Every comment is one line within 120 columns; the two fidelity tools' long docstrings are their --help text.

metal_limits.zig returns before it touches a source on the host walk, as its neighbours do, so
test-metal-launch-map-host builds again.

Model.load makes its queue and reads the device's generation inside an autorelease pool: a refused load leaves
nothing for the caller's pool to hold. The refused-config test takes its count after a first load, since the first
queue on a device raises the device's retain count once on every chip.
@trickyfalcon

Copy link
Copy Markdown
Contributor Author

Thanks for the M5 cell and the trial rebase, and sorry for the few days' gap. The branch is rebased onto today's main (5c82ef28a) and passes the five rules, and I chased both M5 findings on the M3.

The M5 cell

  • The failing test. It already compared before and after: 7 and 25 are its two readings. The jump is not the M5. The first command queue a process makes on a device leaves Metal holding that device 18 more times, once. On the M3 the same calls go 6 → 24 on the first load and stay at 24 for the next 1,100. The test only passed here because an earlier test in the same binary had already made a queue. It now takes its count after a first refused load, runs four more inside an autorelease pool, then compares. With the two errdefers removed it fails as it should (expected 157, found 169, three retains a load).

  • The 1.33 MiB. Nothing host-side: the config is a plain value, and the refused loads run under std.testing.allocator with no leak report. What I measured on the M3 Max:

    1,000 refused Model.loads, after 50 to warm up device retain count footprint
    cleanup removed (the bug the test guards) +3 a load +19.2 MB
    as pushed before, no pool flat +442 KB (about 440 bytes a load)
    this push, queue and generation read inside a pool flat +16 KB (one page of noise)

    Separately, the very first load in a process costs about 1.4 MB resident, once, the same one-time setup as the retain count. So your 50 loads look like mostly the first one. The small per-load part was autoreleased objects from newCommandQueue and the architecture name, left for whatever pool the caller holds. Model.load now makes its queue and asks the generation inside its own pool, so a refusal leaves nothing behind either way. Could you rerun your 50 on the new head, and read the count after the first load?

The rebase and the rules

I did the rebase here, so no need to push yours. The conflicts were the lists you named: main's entries stay and Bolt's go at the ends.

python3 tools/pr_check.py --base upstream/main --pr 1038: lean 341 vs 341, 0 new, 0 error(s), 0 warning(s).

  1. File sizes. metal_bolt.zig is 565 lines (gemv, route, combine); its norms moved to metal_bolt_norm.zig (376). metal_bolt_mamba.zig is 377 (conv); the scan moved to metal_bolt_scan.zig (334). metal_main.zig is main's 543 plus two: Bolt registers through one hook, metal_bolt_main.zig (Suite.create / destroy), the way dsv41 does. Bolt's records join at the end of registry_joins.zig's all_metal.
  2. Lean. Every comment is one line within 120 columns. The two tools' long docstrings became their --help text.
  3. Host build. The Bolt branch of metal_limits.zig returns before it touches a source on the host walk, like its neighbours. zig build test-metal-launch-map-host: 772 registered launches, 0 missing, on the Mac and on Linux.
  4. Changelog. One line under Unreleased.
  5. Commit messages. The tool and session trailers are gone from all 19 commits.

Receipts at the new head (d50f93b5f; M3 Max, applegpu_g15, Xcode 27.1, Metal toolchain 27A266a)

tf-kernel-contract --only bolt --offline DIR
SUMMARY 10 kernels: 10 pass gates 1-4, 0 fail, 0 known findings; 14 controls: 14 red as planted, 0 missed; 0 limit problems
  • zig build test: all 866 steps pass.
  • test-golden, test-bolt-host, test-bolt-load-host and test-kernel-contract pass; tf-metal-tests 7 of 7.
  • Linux, no GPU (aarch64, Ubuntu 24.04, Zig 0.17.0): zig build -Dfixed-cpu test-host --test-timeout 20m passes, 2,089 of 2,089 steps. One thing I hit on the way that is not Bolt's: cli_config_test's --config expand test fails under umask 002, which my Ubuntu VM gives a login shell, because the file it writes is group-writable and expand refuses it. Under 022 it passes.
  • On the checkpoint: it loads and serves; the same greedy completion twice gives the same token hash, and it is the hash from before the rebase (5b7c1daa491b). tools/zig/nemotron_fidelity.py passes its gates on all four fixtures (15 to 2,048 tokens), with every figure equal to the run before the rebase. It loaded in 19.0 s with a Linux VM building beside it, and in 10.4 s on a quiet machine four days ago.

Still a draft. The integrated M3 acceptance is yours whenever it suits.

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @trickyfalcon. The pool explanation reads right: the retain test now compares after a first refused load, and the footprint trace shows the one-time first-load cost with nothing left per refusal. We will rerun our 50-load cell on the new head and read the count after the first load, as you asked.

The remaining work is ours: the queue rebase onto current main (the Metal registration and test tables moved, and two nemotron files need the usual line room). Nothing is needed from you.

  • Synthena

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thank you @trickyfalcon: Nemotron 3.5 Bolt now serves on Metal from main. It landed through #4162, with your commits and authorship kept and our rebase onto today's main on top (the Bolt checks and dense blocks moved to sibling files to keep each under 600 lines, plus two build fixes the move needed). It will be in the next release's thanks too. Closing this one as landed.

  • Synthena

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.

3 participants