Repository navigation
engine: a plugin's optional accelerators are billed, and declined by name where they do not fit - #1402
Closed
davidtai wants to merge 63 commits into
Closed
engine: a plugin's optional accelerators are billed, and declined by name where they do not fit#1402davidtai wants to merge 63 commits into
davidtai wants to merge 63 commits into
Conversation
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.
…d M2 compile The offline contract (metal-tt for M1 and M2) failed 27 inkling2 lines, each a record stating 1024 for one of main's own kernels. relsplit's instantiations compile for 576 on both, under its 96-thread launch (the bf16 sliding, sliding own-rows, global and global own-rows cases, 6 shapes each). relslots' compile for 832, under its 256-thread launch (3 shapes). Recorded as compiled, as REGISTERING.md asks. Record-only: no served path changes.
…its dense trunk as shipped TRUNK_Q8 quantizes the release's dense attention and conv projections, embedding and head to 8-bit affine at load: an inexact option, and inexact options stay opt-in. It is now `config.optIn` (env.zig default "off", as MARKOV_Q8 is declared): unset, the release serves the trunk it ships; TRUNK_Q8=1 gives the 8-bit trunk, byte for byte as tests/convert_inkling2.py --bits 8 stores it. An 8-bit pack is unchanged (its trunk is already 8-bit, and nothing is left dense for the option to quantize). The config test now holds unset and =0 to the dense trunk and =1 to the 8-bit one on Metal only. The proofs and the release test that compares against the converter's bytes already set the switch explicitly.
…pool held, and the tensor-unit read to repeat The proofs of the fresh-server invariant's rule B and of its eval points, on the pack (INKLING2_RELEASE): a prompt of three 8192-row chunks and a tail (two chunks past the log-scaling floor) gives the same first-token logprobs, cache rows and conv states when every buffer MLX's allocator hands out starts as NaN or as a finite pattern (T1), and with PREFILL_ASYNC on or off (T2). The allocator fill is a test hook in MLX's Metal allocator (patches/mlx-metal-alloc-fill.patch, off unless a test sets it), reached through mlx.allocFill. The tensor-unit read behind an earlier chunk's keys runs 24 times a case on the same inputs in one process (sliding 1,024 and global; rows and keys ragged and whole against the kernel's tiles) and must write the same bytes each time. It is red at this commit: a sliding read moved 8 rows of one SIMD group between repeats.
…threadgroup's barriers The fresh-server text changes come from relative_attention_nax.metal reading behind an earlier chunk's keys on a sliding visit: the repeat test (24 repeats a case in one process) moved in 3 of 3 processes on an M5 Ultra, never on a global read. Every move was 8 rows in one head, rows 8 to 15 of one SIMD group's 16, at a random place and repeat: the second row of every lane's fragment, the last values each lane writes into the group's bias tile. A sliding read stages that tile for every visible block (a global read only near the diagonal), and its writes and the score reads that follow were ordered by SIMD-group barriers alone. Each group still stages its own tile (Mtg, its own 16 x 49 floats), now between two threadgroup barriers (mem_threadgroup) that every group of the threadgroup passes for each block group 0 stages: its rows are the threadgroup's nearest to the block, so where it does not stage no group does, and a global read's far blocks pass no barrier. The values are unchanged: the same products, staged and read at the same places. kernels/digests.txt records the new bytes. The repeat test is the proof (red at the old kernel).
…machine and the pack A plugin that declares Caps.repeatable_prefill (Inkling 2) has its prompt chunk pinned from R: the machine's static working-set ceiling less the pack's committed weights, the configured hot-cache ask and an explicit --ctx-size's KV (pinFromMachine), never from the memory live at load. Two boots of the same build, pack, flags and machine run a prompt at one width. A greedy or seeded prompt on such a model that does not fit after the eviction pass waits for room at that width, looking every 100 ms for up to 10 s (waitForRoom), then is refused by name (PrefillDoesNotFit) as before. A sampled unseeded prompt is refused at once, as before. Other plugins are unchanged.
engines/mlx/repro.zig owns the fresh-server record. At load it hashes R's boot terms once (inputsDigest: the build, the OS build, the chip and RAM, the pack's folder, index and config, every MLX_ variable) into ModelConfig.repro_inputs. Each prompt logs one line: [repro] inputs=<R> plan=<plan> width=<pinned>[ company=width:<run>] The plan digest covers what the request's numerics read: the pinned width, the KV scheme, whether it repeats and its seed, the spec mode and whether its rounds run alone. Another request narrowing the width is a company event: printed, and left out of the digest. Two runs with equal digests and no company event that give different bytes name a kernel defect, never a decision.
… had before its bias barriers The bias barriers moved the staging out of the read's non-plain branch and kept the two f32 bias tiles live across both barriers, in a scope every key block reaches. Prefill matched to 32K and fell behind past it (-3.2% at 64K, -7.8% at 256K, spec on, 8192-row chunks): every far block of a global visit paid for the wider loop, not just the near ones that stage. The staging block is now barrier, then (in a group whose block is near) the bias products and their stores with the tiles scoped inside, then barrier. The first barrier orders the last staged block's reads before this block's writes, the second those writes before their reads, as before. The plain scale and the score loop are the code they were before the barriers, near and dbase computed inside the non-plain branch again. A block group 0 does not stage passes no barrier and declares no tile. The values are unchanged.
… hook The header says which upstream change removes the patch: an MLX allocator fill or poison hook, which upstream does not have as of v0.33.
…inexact) MLX_SERVE_INKLING2_EXPERTS_I8=1 (default off) runs both expert GEMMs of a prompt chunk on the M5's int8 matrix units, about twice their bf16 rate. - At load, every layer's gate_up and down banks get an int8 copy beside the packed ones: one f32 scale per output row and K-group (128 for gate_up, 64 for down), from MLX's dequantize, 16 experts at a time. - The MLP input's producers write its int8 copy in 128-groups: twins of mid and norm_row, main's kernel text plus a tail (i8_rows.metal). Main's kernel objects keep serving every other launch. - msv_inkling2_i8_gate_up reads that copy through the row map, folds each group's int32 sum into f32 times the two scales, and writes the soft-capped SwiGLU as int8 in 64-groups; msv_inkling2_i8_down reads it and writes the bf16 rows the weighted sum reads, as the bf16 gather did. - NAX only, prompt loads past 64 rows, bf16 or f16 streams. One row, verifies and batched slots keep the packed kernels. With the switch off no copy is made and no new kernel launches. - The copy (25.5 GB on the release) is not in the admission bill: the engine does not read a plugin's load bytes. Tests: the two GEMMs against an f64 reference of their int8 operands; the whole chain over NVFP4 banks against the f64 product, with the bf16 path's distance beside it; the producer twins against main's X and a host quantization; on the release, the off arm's logits bit for bit around an on load.
… is refused A twin's refused threadgroup now latches `experts_i8.twin_refused` and the launch falls back to main's producer at the same width, instead of narrowing `stream_threads` for every stream kernel of the process. The norm twin reads the same latch, so it is probed once. The load evaluates a slice's codes and scales in one eval and frees the copy if owning it fails. The host quantization in the tests rounds ties to even, as `rint` and MLX's `round` do.
…name where they do not fit A plugin already bills what its load holds through WeightHooks.resident_bytes, under the load settings. A plugin that makes an optional copy beside its weights (an int8 accelerator) bills it there too. Where that bill does not fit, the load now re-bills under "accel":false in the load settings and serves without the copy, instead of refusing the load: - the load path, after idle models make room, against what the load can use; - the registry gate, where the bill alone breaks --max-resident-mem. ModelConfig.accel_declined carries the decline into the load settings the plugin's load reads. A plugin whose bill is no smaller without them, or that has no resident_bytes hook, keeps its bill and its refusal exactly as before. The decline logs the plugin's name and the bytes declined. The load settings buffers grow to 256 bytes: every setting at once no longer fits 128. Tests: a declared accelerator is in the bill and leaves it once declined; a plugin that declares none, or has no hook, keeps its bill and declines nothing; the load settings carry the decline only when declined.
The int8 expert GEMM EXPERTS_I8 runs is not Inkling's own: any routed expert bank's prompt chunk can take it. It moves beside w8a8 as its grouped variant, sdk/blocks/dit/w8a8_grouped.zig, with its kernels in kernels/qmm/: - w8a8_gqmm.metal, the GEMM body (sorted pairs, a row map or rows in place, one f32 scale a row and K-group on each side, exact int32 group sums folded in f32); - w8a8_gqmm_store.metal, the epilogue that stores the rows. The module owns the bank's int8 copy (convert, refusal of a GGUF bank), its bill (bankBytes), the shapes the tiles take, the store launch and the host references its tests share. The groups stay per K-group (128 and 64 on Inkling), not w8a8's per-row scales, so the measured copy's numbers hold. Inkling keeps what is its own: the soft-capped SwiGLU epilogue that writes the down's int8 input, the producer twins and the gate; it builds its kernels from the SDK's text, so its launches are byte for byte what they were. Tests (SDK): the GEMM against the f64 sums of its int8 operands, row- mapped at the gate_up's shape and in place at the down's; a bank's copy holds its billed bytes and the dequantized values within half a step; the shapes and the GGUF refusal.
…nd 2, inexact)
MLX_SERVE_INKLING2_PF_INT8 replaces EXPERTS_I8 with one lossy switch in
levels, as DeepSeek-V4.1's is. Default 0; NAX only; read at load.
- Level 1: a prompt chunk's trunk projections past 64 rows (the joined
q | gate | r | sink, the joined k | v or k and v, a global layer's
dynamic-conv kernel projections, o_proj) run on w8a8's int8 GEMM, input
and weight rotated by its block-256 Hadamard, one scale a row. Each
distinct input is quantized once. The int8 weights are made at load from
what the pack holds (fromAffine for an affine trunk, fromDense for the
release's bf16, dequantized values otherwise), their rows padded with
zeros to the GEMM's 64-wide tile. The embedding, head, router and message
gates stay exact.
- Level 2: level 1 and the routed experts' int8 copy on w8a8's grouped
GEMM, as the copy mode measured.
- The packed weights stay: one row, verifies and batched slots read them.
Level 0 builds and launches nothing new.
One plan (pf_int8.Plan.of: the level, NAX, a GPU stream, the host's
decline) feeds the bill and both builders, so the bill can over-bill but
never under-bill; a builder that built past it fails the load. The bill
rides the plugin's resident_bytes beside the pack's shards, so admission,
the registry gate and the preflight count it, and a load that cannot fit
it declines it by name ("accel":false) and serves the exact path. Each
level's builder logs what it built: the tensor count, the GB and the
milliseconds the quantization took.
Tests: the plan bills nothing at level 0, the trunk at 1, the trunk and
experts at 2, and nothing inert or declined; the resident bill adds the
level's bytes, nothing at level 0 or when declined; the expert copies'
bill at the release's shapes; a joined trunk projection from dense and
8-bit affine weights within w8a8's bound (0.02) of the f64 product, a
planted control past it; the level parser; on the release, level 0's
logits bit for bit around level 1 and 2 loads and under a declined load,
each level engaging what it builds.
The kit's block test requires every block file of an exposed area in kit.blocks.
… of the scale NVFP4 values land on exact half-step ties against a group's 127 levels, where the f32 scale and its reciprocal move |c * step - v| a few ulps past half a step.
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.
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.
The shared release loads meet openWith's settings argument: a held load is opened with no settings, as the tests that share it asked before.
Its five loads stay its own: levels 0, 1 and 2, a level 2 the host declined, and level 0 again, the last a fresh load because the test's bar is that nothing an int8 level loads or latches reaches a later level-0 load. releaseLogitsI8 frees the held load before each one, and the test moves after the TRUNK_Q8 bytes test so it no longer splits the dense-trunk tests' shared load. No assertion changes. INKLING2_RELEASE loads per binary go from 15 to 10.
…the key walks env.vars' declarations by name
…/int8-accel # Conflicts: # src/plugins/inkling2/proof_test.zig
…clarations, as env.zig does
…ized Level 1 quantized each int8 projection's input in its own launch (w8a8's rotate + quantize over the bf16 rows the producer had just written). A prompt chunk's producers now write those codes themselves: - q, k and v: `pre` on a first pass (1 or 3 inputs) and a later pass's row `norm` launch twins (main's text, a head staging X in threadgroup memory, the shared rq tail), writing X as before plus XQ/XS for every input. - o: the read comes ungated and one launch (`gated_rq`) gates, rotates and quantizes it, replacing `gated` + the quantize. The rotate/quantize math (`rq_header.metal`) is w8a8_rq.metal's operations in the same order. The test holds each twin to main's bf16 rows bit for bit and to w8a8's `quantize` of them (codes and scales, outlier channel, a planted row shift caught), and the o projection's bytes to the unfused one; a release test holds level 1's logits fused vs unfused bit for bit. Decode, verifies, batched slots and rows at or under packed_rows keep the unfused path; a refused twin threadgroup falls back for the process.
4 of 5 tasks
…their own change ddalcu#1330 no longer patches MLX. The async-against-sync eval point test stays and reads the pool as it is.
…elerator decline PF_INT8 is inexact, so it moves to a CommunityServe plugin, and its int8 GEMM kernels move to TurboNAX. This tree keeps only the engine hook: a plugin's optional accelerators are billed through weights.resident_bytes and declined by name where they do not fit. Every other file returns to inkling2/mini-speed: the Inkling 2 plugin, the w8a8_gqmm kernels and their digests, sdk/blocks/dit/w8a8_grouped.zig, its kit export, the PF_INT8 variable and the test registrations. The full work stays on inkling2/pf-int8-port-src. The decline test now also checks the decline's log line: one line, naming the plugin, and none where nothing was declined.
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).
davidtai
added a commit
to davidtai/mlx-serve
that referenced
this pull request
Dec 1, 2026
…#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.
Contributor
Author
|
Closing in favour of #1401 (#1401), so that one PR gets the review. This PR's #1401's head
With |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed / why
A plugin already bills its load through
weights.resident_bytes. A plugin that builds an optional copy beside its weights (an accelerator) bills it there too. Where that bill does not fit (live memory at load, after idle models make room, or--max-resident-memat the registry gate), the load re-bills under"accel":falsein the load settings, logs the decline with the plugin's name and the bytes declined, and serves without the copy instead of refusing the load.ModelConfig.accel_declinedcarries the decline to the plugin's load. A plugin with no accelerators, or with noresident_byteshook, keeps today's bill and refusal exactly. The load settings buffers grow from 128 to 256 bytes so every setting fits at once.Stacked on #1330; the commits after #1330's head are new. No plugin in this tree uses the hook yet. The Inkling 2 PF_INT8 accelerator that first used it is inexact, so it moves out of core to a CommunityServe plugin, and its int8 GEMM kernels move to TurboNAX.
How I verified it (
zig build test; tests inengines/mlx/runtime/preflight.zigandengines/mlx/plugin/driver.zig, on fake plugin tables, with no model)declineAccel: ... logged by name: a fake plugin that declares a 5-byte accelerator bills pack + 5; once declined it bills the pack alone, the load settings carry the decline, and a second decline does nothing. A plugin that declares none, and one with no hook, keep the pack's bill and decline nothing. The log holds one decline line, naming the plugin.the load settings decline a plugin's accelerators only where the load declined them:"accel":falseappears only when declined, and every setting at once fits the 256-byte buffer.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