Repository navigation
Conversation
4397128 to
5e55677
Compare
|
Built and tested head
(Scope note: did not run the 1K–256K context sweep, HumanEval/MBPP, or a pack with an embedded DFlash2 |
|
Follow-up on 1K–256K Context Sweep (
|
| Context rung | Decode | Prefill | TTFT | Speculation |
|---|---|---|---|---|
~1k |
120.6 tok/s |
2,162 tok/s |
476 ms |
3.43 tok/step |
~4.1k |
168.7 tok/s |
2,720 tok/s |
1.5 s |
4.92 tok/step |
~16.5k |
144.7 tok/s |
3,135 tok/s |
5.3 s |
4.36 tok/step |
~32.8k |
137.2 tok/s |
2,878 tok/s |
11.4 s |
8.00 tok/step |
~65.5k |
117.8 tok/s |
2,584 tok/s |
25.3 s |
4.27 tok/step |
~131.2k |
120.6 tok/s |
2,038 tok/s |
64.4 s |
4.47 tok/step |
~270.7k |
91.2 tok/s |
1,327 tok/s |
204.0 s |
4.47 tok/step |
HumanEval + MBPP (llmprobe --eval-only --eval-suite code --concurrency 4 --reasoning off, T=0, 58 s)
| Suite | Score |
|---|---|
| Overall | 78/100 (78%) |
| HumanEval | 46/50 (92%) |
| MBPP | 32/50 (64%) |
Run.finish and the KDA hybrid's finish ran a one-slot `.last_row` prompt's head over its last 32 rows (`head_tail`). MLX picks its matmul kernel and K split by row count, so a last-row prompt could return other bytes than the same row of the all-rows forward, which `Caps.prompt_last_row` promises. `.last_row` is now the slice of the head's call over every row, as an `.all_rows` ask runs it. `head_tail`, both `head_tail_rows` and the `qmm_rows_min` floor are gone. The engine frees an interior prompt chunk's logits without evaluating them, and with prompt checkpoints the final prompt forward is at most 31 rows.
With thinking off, Inkling's template renders only a "Thinking effort level: 0" line, and Inkling 2 could then think through all of max_tokens. contentChannelTail now ends the render with `<|message_model|><|content_text|>` (Inkling 2) or `<|content_text|>` (Inkling Small, whose render ends at `<|message_model|>`) when thinking is off and the request has no tools.
…s stored per release A greedy or seeded request on a served drafter that groups now runs its own rounds and is nobody's company (`native_group.roundsAlone`, `MLX_SERVE_GREEDY_SOLO_ROUNDS`), so its text does not follow other requests. The paths that still can are in docs/known-issues.md. The round ladder is timed once per key (build and MLX build, chip, RAM, model folder, the server's MLX_ variables) and read back by later boots (`ladder_store.zig`, `MLX_SERVE_ROUNDS_LADDER`, =0 off), so two boots of one build verify the same draft counts.
…U epilogue `sortedGateUpInterleaved`: the mapped gate_up's epilogue applies the expert's scale and the soft-capped SwiGLU to the rounded gate (even) and up (odd) products, so a prompt chunk's activation is one launch.
…elines at load Default on (=0 gives main's path): TRUNK_Q8 (the dense trunk at 8-bit affine g64 at load, the bytes tests/convert_inkling2.py --bits 8 writes), PREP_STRIDED (prep reads a joined projection's parts in place), GATHER_ROWMAP and GU_ACT (a NAX prompt chunk's gate_up through the sorted pairs' row map, the SwiGLU in its epilogue), GATE_MM (past packed_rows, a later pass's message gates as one tiled f32 kernel), STREAM_ROW (the norm kernel at one threadgroup a row), PREFILL_ASYNC (a prompt's eval points as async evals) and PIPELINES_AT_LOAD (this build, machine and composition's first launches replayed at load). Opt-in for an A/B against main's code: NAX_PREFILL (relative_attention_nax.metal, Stéphane Busso's, for the prompt-row read; off: relattn_nax.metal), with BIAS_IN_ATTN under it.
…_Q8, opt-in) The Markov chain's fold held as int8 a vocab row with a scale each (`Drafter.quantizeFoldRows`, `markov_fold_q8_row.metal`), and the step's RNN reading its block-row and newest-mix share from `kappa`, made once a block (`markov_step_rnn.metal`). Opt-in for an A/B against main's group-64 8-bit fold (`MLX_SERVE_INKLING2_MARKOV_Q8`). Drafts are proposals, so the trunk's picks stand. It acts only on a pack without a DFlash2 drafter/.
…y reads and the levers rounds_contract.zig: commit_conv, accept_tree, sample_tree_mass/_search/_draw, dflash_conv, dflash_top16_shard and _merge, dflash_edges, dflash_tree. group_contract.zig: relsplit_nax, relsplit_lanes. trunk_contract.zig: gate's prompt arm. contract.zig: gate_mm, prep's strided reads, the norm at one threadgroup a row, relative_attention_nax (NAX_PREFILL) and MARKOV_Q8's two kernels. Each has a float64 reference or the kernel it replaces, and a planted control.
relative_attention_nax.metal's flash read (with the in-read relative bias) won its A/B against main's relattn_nax on the ddalcu 8-bit pack with DFlash2 (coding test, 23,077-token prompt, 1,024 greedy tokens, 8 runs, M5 Max): prefill 3,938.9 -> 4,088.9 tok/s (+3.81%), TTFT 5.87 -> 5.65 s, peak -0.2 GB, PPL 8.3295 -> 8.3303. Decode moved -1.95% with the text (the same 8 rows and round time). =0 serves main's read.
MLX_SERVE_GREEDY_SOLO_ROUNDS is now opt-in. On by default it held greedy multi-user decode at about 147-151 tok/s from 2 to 8 users on an M5 Max (bench.sh, the 8-bit pack with DFlash2), where grouped rounds reach 275. Off, a greedy request groups as on main; =1 keeps its text the one it gets alone. known-issues says so.
A pack with drafter/ serves DFlash2 and one without serves the bundled MTP head, and nothing in the log said which: the engine's sidecar check logs that it declines drafter/, which reads as if the pack ran without it.
… solo rounds' docs say opt-in With NAX_PREFILL on, a prompt that relative_attention_nax cannot serve (not bf16 at head dim 128, or no tensor units) skipped main's relattn_nax and fell to relattn. It now takes main's read. The engine rules and the gotcha still described rounding alone as the default; they now say it is opt-in, and its env entry's release is 26.12.1.
…atched slots keep main's path PREP_STRIDED, STREAM_ROW, GATE_MM, GATHER_ROWMAP, GU_ACT and PREFILL_ASYNC keyed on the forward's rows, so batched decode at 9-32 slots and grouped verifies (past 64 rows at 11 DFlash2 lanes on NAX) took arms measured only on prompt chunks; GATHER_ROWMAP's prompt call also lifted the condition that keeps MLX's verify bits. Each lever now asks kernels.Load, which visit and sequence read from the forward's mode: a prompt chunk, or a step (decode, verify, grouped verify, batched slots) that runs main's path. Every lever logs its engagement once, and tests read the flag: the gate, norm and prep kernels at 12, 36 and 72 step rows and the experts at 72 on NAX take main's bytes with the levers on, and through the forward 12 batched slots and a 6 x 6 grouped verify engage none.
…ames a layout it declines GATHER_ROWMAP and GU_ACT gated on a hand list (an FP4 bank, bf16 rows). They now ask gather_qmm_nax.bankLayoutOk, the bank half of the kernel's own `supported` (NVFP4 g16, MXFP4 g32, affine 2, 3, 4 and 8 bits at g32, 64 and 128 with bf16 scales and biases), so a q4 pack's affine experts take it; MXFP8, affine 5 and 6 bits and other scale dtypes keep MLX's gather and log `[inkling2] MLX_SERVE_INKLING2_GATHER_ROWMAP declined: <layout>` once. The SDK's interleaved SwiGLU epilogue test runs every layout the check takes, not NVFP4 g16 alone.
…D off or once its record is complete Every launch hashed its kernel, template arguments and dtypes and scanned up to 1024 keys (`pipes.saw`), with the switch off too, in a dispatch-bound one-row decode. The lookup now runs only while a record is open (`Pipes.watching`) or replays. A record closes after 4096 forwards with no first launch: it ends with a `#closed` line, and a process that replays a closed record never looks a launch up. Test: off, open, closed and replayed-closed records.
… run on Metal only; the fit key test holds off macOS TRUNK_Q8 and PREFILL_ASYNC were not Metal-gated, so they changed Inkling 2's CUDA path unmeasured, and PIPELINES_AT_LOAD made its folder there for kernels that never launch. TRUNK_Q8 (config.trunkQ8) and PREFILL_ASYNC (plugin.prefillAsync) now need a Metal build and the record needs the kernels on; another backend keeps main's dense trunk and synchronous eval points. The fit key test asserted the executable's digest, which off macOS is the zero placeholder by design; it now asserts that placeholder there.
…orm and prep are held to main's bytes norm.metal's stream-row change kept every thread's D / TG elements (`mine[J][D / TG]`) on every path and read them back by a runtime index, so the one-row decode norm (ROW 0) indexed a private array that grows as an M1 or M2 narrows the threadgroup. ROW 0 now keeps the one element it writes, as main did, and ROW 1 keeps its elements by a loop of constant trip count; STREAM_ROW takes a row only while a thread keeps at most four (`row_elems`, pre and mid's bound), so a narrowed threadgroup gets the D / TG grid. Main's norm.metal and prep.metal are held as test-only sources: the norm writes their bytes at 1, 8, 16 and 512 rows (both modes, with and without the router, f32 and bf16), and the contiguous prep at 1 (log-scaled or not), 8, 16 and 512 rows on a sliding and a global layer.
… from float64 than the paths they replace The prompt read's proofs compared relative_attention_nax with MLX's attention and its two bias arms with each other; GATE_MM's compared it with an f32 CPU reference. Both are now measured against float64 beside the old path: the read as served (in-read bias) against main's relattn_nax at 24 heads over 8, R 1,024, sliding 1,024 and global, 100 and 128 rows behind 1,100 keys and a global 128 rows at 16,384 keys, with a planted control, the projected bias printed beside it; the gates against the GATE_MM=0 arm at 96, 100 and 128 rows, no farther in l2 and max where that arm's matmuls are TF32 (NAX), within 1e-5 of the peak everywhere, with a planted control. The contract's global read serves 9 rows at 16,384 keys.
… kv-off and 8-bit views Under `--kv-quant 8` every prompt read takes the cache's dequantized bf16 view, and kv-off takes a strided view of the cache's buffer; no test ran the changed reads on either. Through the SDK's KVCache (the keys before a chunk, then the chunk), at the release's shapes, sliding 1,024 and global, 100 and 128 rows: on the kv-off view main's relattn_nax and NAX_PREFILL's two bias arms write the bytes they write on contiguous K and V, and on the 8-bit view NAX_PREFILL's read as served (in-read bias) is no farther from the float64 read of the view's values than main's read.
…projected-bias arm is removed At 0, BIAS_IN_ATTN served a third read: relative_attention_nax over a bias projected and rounded to bf16 before the read, where main's relattn_nax makes it in f32. That arm is removed with the code only it reached (relativeNaxTiles, the kernel's BIA=0 branch and its template argument). The tensor-unit read now has one gate, `relnaxTakes` (both levers on, tensor units, bf16 at head dim 128, 16 relative dims), which the read asks too, and every prompt it does not take, either lever at 0 included, reads main's relattn_nax: the one fallback, in place of a hand gate beside it. Test: with BIAS_IN_ATTN=0 a prompt read is main's bytes and the tensor-unit read does not engage; with it on it engages. The flash-read test runs the in-read bias; the in-read against projected float64 test is gone with the arm.
…d arm's The two arms round in a different order at the same precision. On an M5 Ultra at 96 rows GATE_MM measured l2 2.4% over the old arm and max 15% under, which the both-metrics-no-farther bar failed. The planted control still fails the new bar.
…what M1 and M2 compile The offline contract (metal-tt for M1 and M2) found both records the PR added stating 1024. prep_strided's instantiations compile for 928 on both. relsplit_lanes' compile for 96 or more, and the bf16 tree read of one split at 5 rows of 4 lanes behind 30 keys for 64, under its 96-thread launch: recorded as 96 with that shape's cap at 64. The kernel is dispatched only in a drafter's verify, and a drafter loads on Apple9+ only (plugin.draftsOn), so its launch records min_gen 15 (first served on M3), the field the contract keeps for the families a kernel is dispatched on: gate 5 checks it from M3, and the records stay what M1 and M2 compile. The planted control shares the lanes record and now passes offline because that record is true (96 against its 512).
…ion class A relative band between the two arms failed twice on one element: at 100 rows GATE_MM's max error was 8.1% over the old TF32 arm's, at 96 rows 15% under. Both arms now sit within 1e-6 of the peak in max and 1e-6 x sqrt(n) x peak in l2, GATE_MM within 2x of the old arm in each; the planted control stays outside.
|
Thanks for the numbers. The fix is one commit ( On the two open points:
|
…2K (8-bit pack; bf16 ends at 256K)
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review Not validated: the PR adds to
Validated on M5 Max (36 GB), macOS 27.2.1, head
Generated by Claude Code |
Each loaded the bf16 release pack and ran two 3,300-row prompts. - "a prompt's norm kernel at one threadgroup a row serves the same logits": the norm kernel byte tests hold the served row norm to main's norm bytes at the release's width (1, 8, 16 and 512 rows, routed and not, f32 and bf16), the kernel contract holds the row norm to the three-threadgroup norm's bytes (random and stress fills), and the pipeline-record test shows a prompt's rows launch the row kernel. - "a prompt's reads with the in-read bias keep the top token": it asserted only the top token; the float64 distance tests at the release's shapes (contiguous and 8-bit cache views) are the read's precision bar, and the bit-for-bit test covers the reads it declines. The test-only stream_row hook served only the first test and goes with it.
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review The delta since
The Still blocking, unchanged since the last review: no non-NAX (M1-M4) run. No conflicts with main. Generated by Claude Code |
Each release-pack test opened its own 45 GB copy of the pack. The tests now ask test_loads.hold for a load: the first test that asks opens it, and a later test that asks with the same key takes the one held. The key is the loader's type, the test's parts (the pack directory, dense or 8-bit trunk) and every registered INKLING2 variable as it reads at the ask, so a load made under one lever value never serves a test that asks under another. - One load is held at a time: an ask with another key frees the held load first, and a test that keeps its own load calls test_loads.drop before it opens one. - A held load lives on the C allocator (std.testing.allocator checks each test for leaks) until the next ask with another key, a drop, or the process's exit. - A table load taken from the slot gets its slots' drafter state back as a fresh load leaves it (Loaded.freshSlots: no open verify, every ring, context and calibration dropped), so a test that reuses a slot id never starts from another test's calibration. - Own loads: the drafter's full-layer test (it switches spec.full and restores it), the TRUNK_Q8 bytes test (it reads trunkQ8Tensors, the last load's count), and the served prefix-cache test on INKLING2_PACK (its own engine load; it now drops the held load first). - Order: the SwiGLU test moves next to the other dense-trunk tests and the TRUNK_Q8 bytes test moves after the 8-bit-head test, so each configuration's tests run back to back. No assertion changes. INKLING2_RELEASE loads per binary go from 10 to 5 (own 2, dense 1, 8-bit 1, engine 1); INKLING2_DFLASH2_PACK loads go from 4 to 1.
|
Interim evidence for the non-NAX paths. This is not an M1–M4 run. Setup. Both arms ran on an M5 Ultra with
MLX's own internal kernels may still use the M5's tensor units. So this run checks the portable code paths' correctness and their speed relative to main. It does not show M1–M4 timing or their threadgroup limits, so the tester's M1–M4 run is still the real check. Since Paths that ran (serve logs):
Tests on Standard cell (8-bit pack, p01/p14/p21 at about 22-23K tokens, 1,024 tokens, A B B A A B, spec on; average of 3):
Reading the cells:
|
|
Status for review:
The open gate is a run on a real M1-M4 Mac, and none of my machines is one. Could someone with an M1, M2, M3 or M4 Mac (48 GB or more for the 8-bit pack; peak is about 31 GB) run these on this branch and post the output? scripts/build-mlx.sh # this PR adds an MLX patch
zig build test -Doptimize=ReleaseSafe -Dtest-filter=inkling2
zig build -Doptimize=ReleaseFastThen serve
The same request on main gives the baseline. If the 8-bit pack is too large for the machine, the test line alone helps: the kernel tests run without a pack. |
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review The delta since
Non-blocking: nothing calls Still blocking, unchanged: no non-NAX (M1-M4) run. No conflicts with main. Generated by Claude Code |
…the key walks env.vars' declarations by name
…clarations, as env.zig does
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review The delta since The Still blocking, unchanged: there is no non-NAX (M1-M4) run. No conflicts with main ( Generated by Claude Code |
|
Gates on the head
Still open: an M1–M4 run (see the request above) and the maintainer's MLX patch build. |
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review Not validated, same reason as before: it still adds Validated on M5 Max (36 GB), macOS 27.2.1, head
Generated by Claude Code |
…their own change ddalcu#1330 no longer patches MLX. The async-against-sync eval point test stays and reads the pool as it is.
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review The delta since Still blocking, unchanged: no non-NAX (M1-M4) run. No conflicts with main Generated by Claude Code |
❌ 🔴 NEEDS WORK🤖 MLXServe-PRBot — code review The code builds and the tests pass here and on an M1. It still can't land, for two reasons:
Validated on M5 Max (36 GB), macOS 27.2.1, head
Generated by Claude Code |
prep_strided, gate_mm, stream_row and prefill_async now ask verifyQmmNaxAvailable(), the device check the row map and the tensor-unit read already use. A GPU without NAX serves a prompt on main's path, byte for byte. Tests that assert one of these paths engages skip off NAX, the contract checks the tiled gates' and row norm's wrappers only on NAX, and a new proof forces the GPU-family fallback and checks that no prompt path engages and that the logits equal main's path (kernels.test_main gains gate_mm, prep_strided and stream_row).
|
Thanks for the M1 run. That answers correctness off NAX. 1. Non-NAX speed. The head
2. Regression gate. It needs the 8-bit pack |
✅ 🟢 APPROVED🤖 MLXServe-PRBot approved — reviewed at head The delta since
No non-NAX speed claim is left to prove: those Macs run main's code. The perf table only has to cover NAX. No conflicts with main Static review only — merge waits for the local PRBot's build/test validation. Generated by Claude Code |
✅ 🟢 APPROVED🤖 MLXServe-PRBot approved — reviewed at head The delta since Validated on M5 Max (36 GB), macOS 27.2.1, head
Generated by Claude Code |
…#1330 + ddalcu#1401 + ddalcu#1402) for acceptance The one conflict is plugins/inkling2/kernels.zig's all_kernels list: the union of ddalcu#1401's DFlash2 heads and conv-norm kernels and ddalcu#1402's PF_INT8 kernels.
|
Closing in favour of #1401 (#1401), so that one PR gets the review, as the review on #1401 asked. #1401's head contains every commit of this PR (head |
What changed / why
Merge order: this PR should merge after #1256. #1256 deletes core's
nax_tiles.metalandnax_attention.metal, which this PR'srelative_attention_nax.metalincludes. Once #1256 lands, I repoint those includes at TurboNAX's copies in this PR (no numbers change).This PR makes Inkling 2 Mini read prompts faster on Apple GPUs. From 4K-token prompts up, prefill is 8.5% to 16.6%
higher than main on the M5 Max and the M5 Ultra, with spec decode on and off. Time to first token (TTFT) is lower than
main's at every prompt size. At 1K and 2K, greedy prefill is 4% to 14% higher, and the first request a fresh server gets is
also faster than main's first request (M5 Ultra). Decode is level with main: at
1905d995, on the same text, this PR was within 0.1% ofmain with spec on and with spec off, and a step benchmark on the same input gave the same forward time. At the head (
48f90fb0), the stepbenchmark on the same input gives 10.669 ms per one-row forward against main
c3390fd85's 10.680, and 18.909 against 18.878 at 8 rows. Decode speed work goes in a separate PR.The new tensor-unit prompt kernel had a race, found during this PR, that made greedy text change between fresh
servers. The PR fixes it, and every greedy sweep cell now writes one text on 4 fresh servers.
The head is
48f90fb0:1905d995with mainc3390fd85merged in (b6b5b6a7), and two commits on top.b194d93aeremoves the eight prompt switches. The MLX allocator fill hook and its pool-fill test have moved to their ownchange, #1407, so this PR does not patch MLX. Main already has thinking on by default and the faster multi-user DFlash2 rounds. Each run below names the
commit it built.
1905d995has the same tree as211b5490, which its runs built. The sweeps, the first-prompt runs,EvalPlus and PPL ran at
a3a94835on main0d117e4fd.211b5490differs froma3a94835only in per-launchbookkeeping, with identical output. Greedy is temperature 0; card is temperature 1.0 and top_p 1.0, with no top_k sent. The prompt speedups have
no switches. Each path runs wherever its code gate allows: prompt rows only, the NAX device check, the shape and the bank
layout. Main's path runs everywhere else.
TRUNK_Q8,MARKOV_Q8andMLX_SERVE_GREEDY_SOLO_ROUNDSstay opt-in.<|message_model|><|content_text|>), so the model answers instead of thinking.MLX_settings) and read back after a restart (MLX_SERVE_ROUNDS_LADDER=0turns it off).MLX_SERVE_GREEDY_SOLO_ROUNDS=1makes a greedy or seeded request round alone.--warmup-fullload is unchanged.relnax: the prompt rows' attention through Stéphane Busso'srelative_attention_nax.metal.gather_rowmapandgu_act: the experts' gate_up through a row map, with a SwiGLU epilogue in the SDK's NAX gather.prep_strided: prep reads a joined projection's parts in place, by row strides.gate_mm: a prompt's message gates run on the matrix units.stream_row: the norm gives each prompt row one threadgroup.prefill_async: a prompt's eval points run async. Each of the four needsverifyQmmNaxAvailable(), the device check the tensor-unit paths use. M1-M4 serve main's path for a prompt, byte for byte. A decode step's norm and prep launch main's kernels (norm_step.metalandprep_step.metalhold main's bytes). The row norm and the strided prep run only for a prompt's rows.PIPELINES_AT_LOAD: a record of first-launch pipelines, built again at the next load. The record takes first launches only before ready (the replay, the eager warm-up, the rounds' timing or the warm prompt) and closes at ready. After ready, a launch tests one bool for it.TRUNK_Q8=1quantizes a bf16 trunk at load to the converter's 8-bit bytes (the same bytes as the 8-bit pack).TRUNK_Q8opt-in, so the release serves its bf16 trunkModelTablefield,ready. The engine calls it once per load, after the load's own requests and before it marks the server ready. Inkling 2 closes its pipeline record in it. A table built before the field (an outside plugin on the previous kit) still loads, andreadyOfreads the hook as absent.NAX_PREFILL,BIAS_IN_ATTN,GATE_MM,GATHER_ROWMAP,GU_ACT,PREP_STRIDED,STREAM_ROW,PREFILL_ASYNC) are gone fromenv.zig. A served build reads each remainingMLX_SERVE_INKLING2_*switch andMLX_SERVE_GREEDY_SOLO_ROUNDSonce per process; a test build reads them live, so theenv.overridetests hold. Tests that compare a whole forward against main's path use a test-only seam (kernels.test_main), which is false at compile time in a served build.Caps.repeatable_prefill(Inkling 2) pins its prompt chunk from the machine's ceiling and the pack's bill, never live memory. A greedy or seeded prompt that does not fit keeps its width, waits up to 10 s for room, and then the engine refuses it withPrefillDoesNotFit. Every prompt logs one[repro]line (engines/mlx/repro.zig: a digest of the build, OS build, machine, pack andMLX_set, and one of the plan).MARKOV_Q8, an int8 fold, from #1323 (credit CerebralCoding). It acts only on a pack without a DFlash2drafter/.drafter: dflash2ordrafter: the bundled mtp head). Kernel contract cases for the round kernels,relsplit_nax,relsplit_lanes,gate's prompt arm,gate_mm, prep's strided reads, both norm kernels,relative_attention_naxandMARKOV_Q8's two kernels.The kernel rules (root AGENTS.md "A kernel serves every GPU family, KV layout and load"; engines/mlx AGENTS.md "A
kernel change is checked beyond its speed")
relnaxTakes(tensor units, bf16, head dim 128, 16 relative dims). Every prompt it does not take reads main'srelattn_nax. The row map and its epilogue needverifyQmmNaxAvailable(), and so do the strided prep, the row norm, the tiled gates and the async eval points: M1-M4 serve main's path for a prompt.inkling2 kernels: a prompt read the tensor-unit read does not take is main's relattn_nax, bit for bit;inkling2 proof: off NAX a prompt takes main's path, byte for byte(the GPU-family fallback forced: none of the prompt paths engages, and the logits are main's path's bytes)kernels.Load. Decode, verify, grouped verify and batched slots run main's path, and each path logs[inkling2] <path> engagedonce....a verify's or batched slots' rows take main's gate, norm and prep;...a verify's rows past 64 keep MLX's gather;inkling2 proof: batched slots and a grouped verify take main's path1905d995against main's 10.671, and 18.877 against 18.890 at 8 rows; at the head: At the head48f90fb0against mainc3390fd85: 10.669 against 10.680 ms (one row), 18.909 against 18.878 ms (8 rows). The pipeline record closes at ready, so after ready its cost is one bool test per launch. At1905d995, with the prompt switches at 0 so that both arms write the same text, decode was 103.60 tok/s on main and 103.52 with spec off (-0.08%), and 194.77 and 194.64 with DFlash2 (-0.07%).inkling2 kernels: a step's norm launches main's kernel, a prompt's rows the row kernel;...the norm kernel writes main's norm bytes at every load;...the prep kernel writes main's prep bytes on contiguous projections;...the pipeline record takes first launches before ready and none after;...a launch does no pipeline-record work once the record is off or completegate_mmagainst float64 beside the paths they replace, each with a planted control....the tensor-unit prompt read is no farther from float64 than main's relattn_nax;...a prompt's message gates on the matrix units are in the projected arm's precision class...a prompt's reads of an 8-bit cache's view are no farther from float64 than main's readgather_qmm_nax.bankLayoutOk. Other banks keep MLX's gather and log[inkling2] gather_rowmap declined: <layout>once....the row map takes the expert layouts its kernel decodes and declines the others by name;segmented NAX sorted gather: a bank layout the mapped kernels do not decode is not takenverifyQmmNaxAvailable(), and so does each test that asserts a prompt path engages. The contract counts its.naxcases as skipped, and checks the tiled gates' and the row norm's wrappers only on NAX.TRUNK_Q8, async prompt eval points and the pipeline record need a Metal build. Elsewhere the trunk stays dense and eval points stay synchronous.inkling2 config: the 8-bit trunk is opt-in and made on a Metal build only;inkling2: a prompt's eval points run async on Metal only, and never for a step; CIcudajobs on this pusha3a94835(the head's kernel code) are 46 PASS, 8 FAIL and 15 INCONCLUSIVE, with no FAIL on arelnax,relsplitorrelslotsline and none on a q8 line. Main'srelsplitandrelslotsrecords stated 1024, and they now record what M1 and M2 compile (576 and 832). The 8 FAIL lines are all main'sdflash_attnbf16 record (1024, where M1 and M2 compile 512), which this PR does not touch; a drafter loads on M3 and later. The INCONCLUSIVE lines are the round kernelsdflash_edges,dflash_treeandtop16_shard, which this PR does not change.relsplit_lanes' tree read at 5 rows of 4 lanes compiles for 64 threads under a 96-thread launch; it serves only a drafter's verify, and a drafter loads on M3 and later.MLX_SERVE_KERNEL_CONTRACT_OFFLINE)drafter/) is not measured at this head.Determinism
This PR had a bug that main does not have. On a fresh server, greedy text at prompts of 16K tokens and more changed from
run to run, with speculation off too, on the M5 Max and the M5 Ultra. The first token's logprobs differed between
servers, so the cause is in the prompt path. It followed the tensor-unit read in a prompt chunk that reads keys an
earlier chunk wrote. An 8K prompt in two 4,096-row chunks gave different first-token logprobs on fresh servers, and one
16,384-row chunk did not. With the tensor-unit read switched off (the
NAX_PREFILL=0switch of that time), 16Krepeated, and with async eval points also off, 32K too.
The cause was a race in
relative_attention_nax.metal. Each SIMD group stages its block's bias tile in threadgroupmemory, and lanes then read values other lanes wrote. Only SIMD-group barriers inside a branch ordered that exchange.
A sliding read behind earlier keys stages on every visible block. On random repeats, 8 rows of one head came out
different: rows 8-15 of a group's 16, the last rows each lane writes. The fix puts a threadgroup barrier before and
after the staging, and every SIMD group reaches both barriers on a block that group 0 stages. Repeating the same read 24
times in one process gave different bytes in 3 of 3 processes before the fix and in none after it. Blocks that stage no
bias tile (far and plain blocks) keep the old code. With the barriers on every block, prefill fell behind past 32K
(-3.2% at 64K and -7.8% at 256K, spec on).
The tests below check that a request's bytes depend only on what its
[repro]line names. The pool-fill test (T1, everybuffer MLX's allocator hands out starting as NaN or as a finite pattern) needs an MLX patch and lives in #1407 with it;
the runs below that name T1 ran with it at
48f90fb0.inkling2 pack: a prompt's logits and cache are the same bytes whatever the buffer pool held (INKLING2_RELEASE)inkling2 pack: a prompt's async eval points leave the bytes synchronous ones leave (INKLING2_RELEASE)inkling2 kernels: the tensor-unit prompt read behind an earlier chunk's keys repeats bit for bitrelative_attention_naxbehind 4,096 and 8,192 keys at ragged and whole row and key counts, global and sliding 1,024, 24 runs per case: every run equals the first. Red at the kernel before the fix in 3 of 3 processes.[repro]plan ata3a94835, and the same text at the head. Sweeps on both boxes (1K-512K, 4 fresh servers per cell, this PR and main): every greedy cell has one text, and every card cell has one text per seed.How I verified it (M5 Max 128 GB and M5 Ultra 512 GB, macOS 27.2.1)
Main
0d117e4fdis the control in every comparison. Packs: ddalcu/Inkling-2-Mini-MLX-8bit (8-bit trunk, its DFlash2drafter/) and the releasethinkingmachines/Inkling-2-Mini with the same
drafter/(bf16 trunk, no switch). Spec off isMLX_SERVE_DSV4_DSPARK=0(the engine's switch for native drafters). Card sends no top_k becausegeneration_config.json names none. Thinking is on as served (on by default since main
8dfc6126).Main moved to
c3390fd85during the final runs (#1365 memory ceiling owner, #1385 Inkling 2 GGUFs, #1350, #1384, #1346, #1335, b5ed47a). The merge commitb6b5b6a7brings main in on top of1905d995. With #1365, the repeatable prompt's chunk pin reads main's single context-ceiling owner (--gpu-ceiling-gib/--memory-preset), still never live memory. Checks ofb6b5b6a7on the M5 Ultra against mainc3390fd85:-Dtest-filter=inkling2, main's four-Dunitsbinaries)abi,prefill_chunk,admission,warm,served_context,inkling2,load)loadtests intest-media,lm_head mxfp8: a dense head loads ...andEmbeddingGemma 2: a checkpoint missing its head ..., which fail the same way on mainc3390fd851905d995, chunk width 4,096Gates:
a3a948351905d995(built as211b5490)zig build test, full suite withINKLING2_RELEASE, passed / skipped / failed0d117e4fdon the same box: the deepseek_v41 DSpark-rounds test (3 of 3 runs on main) and disk_tiervolumeSpace.zig build test -Dtest-filter=inkling2withINKLING2_RELEASE(T1 and T2 included), passed / skipped / failedzig build test -Dtest-filter="kernel contract"-Dtest-filter="repeats bit for bit", the tensor-unit read repeat test included), 3 fresh processes[repro]plana3a94835TRUNK_Q8=1on the release) / bf16 trunkPPL references on the same corpus: ddalcu main's bf16 trunk gave 8.3381, and mlx-lm PR 2086 gives 8.3318 on the
release.
Prefill. The context sweep below gives this comparison. Each point is the mean of 4 fresh servers, 8-bit pack, greedy;
card's change against main is within 2 percentage points of greedy's at every size.
At 512K, greedy prefill (main / this PR) on the M5 Ultra is 2,323 / 2,610 tok/s with spec on (+12.4%) and 2,318 / 2,611 with spec off
(+12.6%), and TTFT is 225.9 / 201.1 s. On the M5 Max it is 937 / 1,017 tok/s (+8.5%), TTFT 559.8 / 515.9 s. The M5 Max
512K point ran with spec on only, so its spec-off cells read "not run".
Greedy TTFT is 6% to 51% lower than main's at every size on both boxes, spec on and off. The largest drops are at 1K-8K with
spec on, on the M5 Ultra, where main's TTFT is 0.2-0.3 s longer than its prompt time.
TTFT, this PR vs main (s, 8-bit pack, greedy, mean of 4 fresh servers)
The first request on a fresh server. M5 Ultra,
a3a94835, 8-bit pack with DFlash2, 4 fresh servers per arm andsize, two measured requests per server (the prompt and 32 output tokens). Prefill tok/s, the median of the 4 servers:
Main times its drafter's rounds after ready with a 1,280-token request in every boot, so its first measured request is
not the process's first prefill. A server of this PR that read a stored ladder now serves a 1,283-token warm prompt
inside its load. Its first request is 5% faster than main's first request, and its second is level with the other PR
arm. These requests are shorter than the sweep's, so compare them only within this table.
Decode on the same text, at the earlier heads. M5 Ultra, greedy, the standard cell's procedure (below), with this
PR's eight prompt switches at 0. These cells ran at
1905d995anda3a94835, where the switches still existed;b194d93aeremoves them, so the head cannot repeat these cells. The prompt paths act only on prompt rows: a decodestep takes main's path with them on, as the tests in the kernel rules table check. With the switches at 0, both arms
wrote the same text, so the drafter accepted the same tokens in both arms. A = main
0d117e4fd, B = this PR:1905d995, 8-bit, spec off1905d995, 8-bit, DFlash2a3a94835, 8-bit, spec offa3a94835, 8-bit, DFlash2On
a3a94835the pipeline record stayed open through every measured decode, and each plugin launch paid a hash and ashort scan for it.
a3a94835measured -0.37% with DFlash2. The head, which closes the record at ready, measures-0.07%. The spec-off sweeps agree. There, decode is within 1% of main at every size on
both boxes (-0.72% to +0.99%), although the texts differ; at 512K on the M5 Ultra it is 30.48 on main and 30.43 on this PR, greedy.
With spec on, sweep decode moves -10.0% to +21.6% against main. At 512K greedy, the drafter accepts 4.27 tokens a
round on this PR's text and 4.74 on main's, and decode is 106.96 on main and 96.25 on this PR (M5 Ultra), on different text. The two arms write
different text, and the drafter accepts different amounts of it, so these are not speed results.
Every same-text run, 1905d99 (M5 Ultra, greedy)
ae33b5261716ae33b52617164399b81bb6fb4399b81bb6fb5c75fa07c49c5c75fa07c49c475059729f7d475059729f7db98734df21d1b98734df21d142524ece488242524ece4882Decode on the same input. A step benchmark gives each arm the same input, so it does not depend on the text. This
is the decode check for the head: main
c3390fd85against the head48f90fb0as served: one row 10.680 / 10.669 ms (-0.10%), 8 rows 18.878 / 18.909 ms (+0.16%), medians of 4 runs. The table below is thesame benchmark at
1905d995. M5 Ultra, spec off, 23,040 tokens of context, 400 decode forwards per run, 4 runs perarm, median ms per forward (lower is better):
0d117e4fd1905d995as served1905d995, prompt switches at 0At
1905d995the prompt paths cost nothing in decode: every arm is within 0.15% of main at 1 row and at 8 rows.Every step-benchmark run (ms per forward)
1905d995as served1905d995, switches at 01905d995as served1905d995, switches at 0The standard cell, as served. At the head
48f90fb0against mainc3390fd85, greedy: prefill 6,699.8 / 7,567.3 tok/s (+12.9%), TTFT 3.40 / 3.03 s, decode 194.80 / 215.45 on different text (not a speed result), chunk width 8,192 on every server; card prefill +13.5%. Its texts, tokens per round and ms per round equal the merge headb6b5b6a7's within 0.01 ms. The cell below ran at1905d995(built as211b5490). M5 Ultra, 8-bit pack with DFlash2, against main0d117e4fd: promptsp01, p14 and p21 (23,077, 22,366 and 21,816 tokens), 1,024 output tokens, seed 1234, A B B A A B with a fresh server
per run, a pre-warm per arm on each prompt, a 40 C cool gate. A = main, B = this PR. Each cell is the arm's mean over
the three prompts. Every server of this PR read its stored round ladder and pipeline record, as served.
Prefill is 12.85% higher than main greedy and 12.18% higher with card settings. With the prompt paths on, the two arms
write different text on all 3 prompts, so decode here (+10.6% greedy, +2.8% card) is not a speed result. The drafts
differ, and greedy this PR accepts 4.79 tokens a round against main's 4.29. Per round, this PR takes 22.30, 21.99 and
22.27 ms on p01, p14 and p21, and main takes 22.04, 21.89 and 22.08 ms. The step benchmark above gives both builds the
same forward cost, so that difference also comes from the different text and drafts.
Greedy:
Card settings, same order:
Every standard-cell run, greedy (1905d99, then a3a9483 with spec on and off)
475059729f7d32aa21ad93ea3610a8b82f75b98734df21d142524ece4882d31e986eedcd475059729f7d32aa21ad93ea3610a8b82f75b98734df21d142524ece4882d31e986eedcdae33b5261716d31b0f3b56908bfc78e77f904399b81bb6fb5c75fa07c49cf8aad2742c00Every standard-cell run, card (1905d99, then a3a9483 with spec on and off)
82c16c6f1986d1458c623e83f3f4c1bfb4348c904018f33261fdda39b378447b242cc35c82c16c6f1986d1458c623e83f3f4c1bfb4348c904018f33261fdda39b378447b242cc35c6c7f20d868fd793704ad08027325444442b4b0a0fd50345bb2bb2a1681cd23714711548dContext sweep, 1K to 512K. The coding task built to each size, 1,024 output tokens,
--ctx-sizeN + 16,384, 4 freshservers per point (seeds 1234, 1234, 4321, 4321), greedy and card, at
a3a94835and main0d117e4fd. On the M5Ultra, 4 unmeasured requests stored this PR's round ladder and pipeline record before the measured runs; main runs at
its defaults. In these charts and tables, decode follows the text each arm writes, so it is not a decode
comparison with main. The 512K point ran with the 8-bit pack only, for this PR and main: spec on and off on the M5
Ultra, spec on on the M5 Max. The release-pack (bf16 trunk) sweep ends at 256K on both boxes, and so does the M5 Max's
spec-off sweep; those 512K cells read "not run".
M5 Ultra:
M5 Max:
Sweep means, M5 Ultra: decode / prefill tok/s
Sweep means, M5 Max: decode / prefill tok/s
Every sweep run (arm, spec, size, mode, seed, the six columns, tokens per round, output tokens and a text digest) is in
sweep_runs_m5u.md and
sweep_runs_m5max.md.
Memory, spec on. The server's peak footprint (the max of the 8 runs per size, the mlx-serve process, not the whole
box), the engine's planned total, and the
[admission]request bill. The planned total and the bill are main's atevery size. With the 8-bit pack, server peak differs from main's by -0.9 to +1.4 GB (at 512K, main / this PR: 47.5 / 47.1 GB on
the M5 Ultra and 47.4 / 47.4 on the M5 Max). No bf16 sweep ran at 512K.
Code evals. EvalPlus, pass@1, M5 Max,
a3a94835, greedy, DFlash2 as served, thinking on, max_tokens 16,384:Each trunk hit the 16,384-token cap on 1 HumanEval and 5 MBPP problems. Between the trunks, the 8-bit trunk passes 5
HumanEval problems that bf16 fails and fails 7 that bf16 passes. The counts are 4 and 6 on HumanEval+, 8 and 12 on
MBPP, and 12 and 16 on MBPP+.
Known limits:
TRUNK_Q8is lossy against the release's bf16 trunk. It is opt-in, and the PPL row above gives both trunks.MARKOV_Q8is opt-in, and no run above sets it.A user who set one of the eight removed prompt switches now gets the default path. The
engagedanddeclinedloglines name paths (
relnax,gate_mm,stream_row,prep_strided,gather_rowmap,gu_act,prefill_async),not switches.
The rebase onto
0d117e4fddroppedgroup_contract.zig, so the offline check prints 14 fewer PASS lines than beforethe rebase. Its f16, f32 and tree
relsplitcontract coverage is owed.The pipeline record holds only launches that a before-ready request reaches. A launch that none reaches (sampled
rounds, batched slots, a longer context's lanes) builds its pipeline in the first request that needs it, in every
process.
A greedy or seeded prompt whose pinned chunk does not fit waits up to 10 s for room, and then the engine refuses it
with
PrefillDoesNotFit. A chunk sized from live memory would change the prompt's bytes.No M1-M4 Mac has run this PR. The prompt paths (
prep_strided,gate_mm,stream_row,prefill_async, and the tensor-unit paths) run only where NAX is available (M5), so M1-M4 serve main's path for a prompt, byte for byte (inkling2 proof: off NAX a prompt takes main's path, byte for byte, under the forced GPU-family fallback). Before this gate, an M5 Ultra withMLX_SERVE_DIAG=force-gpu-family-fallback=1ran the four portable paths off NAX (MLX's own kernels may still use the tensor units): the inkling2 lane passed 368 / 23 / 0, and the standard cell's prefill was +1.6% (greedy) and +1.5% (card) against main, with ms per spec round level (see the comment of 2026-11-30). With the gate, that diag takes main's prompt path. No run at this head measures the bundled MTP head (a pack withoutdrafter/).No test runs a whole release-pack prompt through the row norm (
stream_row) against main's path. The whole-forward test was dropped as slow; the norm kernel's byte tests at the release's widths (1/8/16/512 rows, D 2304, routed or not, f32 and bf16), the kernel contract's row-norm entry and the pipeline-record test cover the kernel.The release-pack tests share one load per load configuration (
inkling2/test_loads.zig); a test that changes the loaded model or reads load-time counts keeps its own load.Without
MLX_SERVE_GREEDY_SOLO_ROUNDS=1, a greedy request that shares rounds can get other text than it gets alone(docs/known-issues.md).
The host's sidecar line "the drafter ... served without it" means only that the host's own drafter loader steps aside
for the plugin's. The
drafter: dflash2line says what serves.Searched open and closed issues, open PRs and recent commits; linked the existing thread if there is one
Built and ran this tree on a real Apple Silicon Mac in this session
No comments that restate code, carry history, or cite audit/review items
No source-scan tests; every test checks behaviour
One fix or feature; description under ~15 lines (it carries the work above)