Repository navigation
Conversation
Under an affine model, bias-less uint8-scale banks always resolved as mxfp8 with a group size from mxfp8's ratio: an nvfp4 g16 bank loaded as mxfp8 g8, an mxfp4 g32 bank as mxfp8 g16. The fp format now comes from the packed ratio (the non-affine arm's rule); other ratios keep the old fallback. Inkling 2 Mini's 4-bit pack carries such banks.
A new plugin for mlx-lm-layout Inkling 2 Mini packs: config parse with by-name refusals, the 48-visit schedule (prelude, 3-pass looped core, tail), short convs, relative-logit attention with sinks, depth attention residuals, message gates, NVFP4/MXFP8 routed experts with the per-expert scale. Text only; images, Inkling 2 Small and the ModelOpt release are refused. Kernel wrappers are stubs that decline. Tests against mlx-lm's Inkling 2 (tests/dump_inkling2_fixtures.py): tiny CPU f32 and quantized GPU fixtures, chunked prefill, verify rollback, the served driver, a real pack teacher-forced; tests/test_inkling2.sh live.
Ports of mlx-lm's relative_attention (prefill) and depth_attention kernels, bodies unchanged, launched through mlx-c. Registered with the kernel contract (gates 1-5, drift guard, planted controls), digests and NOTICE. The composed path stays the fallback and the reference; MLX_SERVE_INKLING2_KERNELS=0 turns both off. On an M5 Max 4-bit pack: prefill 8192 1688 vs 226 tok/s, decode 40.0 vs 35.1 tok/s (on vs =0).
Author
|
Superseded by #1261 (same commits, opened from the author's account). |
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.
Closes #1253. Reference: the mlx-lm Inkling 2 PR (ml-explore/mlx-lm#2086).
A new plugin,
src/plugins/inkling2/, servesinkling2_loop(Inkling 2 Mini) text generation from mlx-lm-layoutpacks:
mlx-community/Inkling-2-Mini-4bit(affine 4-bit trunk) and mlx-lm-converted 8-bit / bf16 trunks, all with therelease's NVFP4 / MXFP8 experts. The v1
inklingplugin is unchanged. Images are refused by name,inkling2(Small, no loop) and the ModelOpt release (
model.llm.*) are not claimed, decode is serial, and spec decode is notwired.
Three commits:
computeQuantParamsfix (shared SDK). Under an affine model, a bias-less uint8-scale bank was always read asmxfp8 with a group size derived from mxfp8's ratio, so an NVFP4 g16 bank loaded as mxfp8 g8 and an MXFP4 g32 bank as
mxfp8 g16. The fp format is now solved from the packed ratio (the rule the non-affine arm already used), and the
old rule remains the fallback for any other ratio. The test was red on the unpatched tree (
expected .nvfp4, found .mxfp8). EverycomputeQuantParams/ quant caller filter gives the same per-test results before and after.3-pass looped core, tail), short convs, relative-logit attention with sinks, depth (block) attention residuals,
message gates, and routed experts with the NVFP4 per-expert scale. Also the tiny fixtures and their mlx-lm dump
script, the proof tests, the live script
tests/test_inkling2.sh, and the docs rows.relative_attention(prefill) anddepth_attentionMetal kernels, with their bodiesunchanged. Each is registered with the kernel contract and listed in digests and NOTICE. The composed path stays
the fallback and the reference, and
MLX_SERVE_INKLING2_KERNELS=0turns both kernels off.Parity
The fixtures and references come from
tests/dump_inkling2_fixtures.pyrun on the mlx-lm PR. Every bf16 referenceuses transformers' declared rounding (static convs and weighted norms in f32), which the script patches into mlx-lm.
Spread against stock mlx-lm, 3 chat prompts x 33 rows (prefill's last row + 32 teacher-forced steps), kernels on:
Each top-1 miss falls on a row where mlx-lm's two roundings also disagree, with margins of 0.04-0.10 logits.
Speed
The kernels against their own kill switch, from one binary:
MLX_SERVE_INKLING2_KERNELS=0(tok/s)Method: M5 Max 128 GB, macOS 27.0, ReleaseFast.
--warmup-full --prefix-cache-entries 0 --no-pld, boots A B B A(one arm per boot, because the switch is read per process). Raw
/v1/completionsprompts of exactly 512 / 2048 / 8192tokens with
max_tokens 1, then 256 greedy chat tokens withignore_eos. Each cell is the median of 6 samples(2 boots x 3 reps) of the server's own rate line. Both
[inkling2] ... engagedlines appear in every on-arm boot andnone in the off-arm boots.
Against mlx-lm (the PR branch,
stream_generatein process) on the same packs, mlx-serve is slower:Method: same machine and session, one model at a time, boots S L L S per pack, and the same prompt texts (equal token
counts on both sides). mlx-serve runs over HTTP with the flags above. mlx-lm runs
stream_generateafter one untimedwarm-up, with its default
prefill_step_size2048 and the rates mlx-lm reports. Each cell is the median of 6 samples.The MLX allocator peak for a one-shot 300-token CLI run is 15.66 GB for mlx-serve and 17.47 GB for mlx-lm (4-bit).
The cost: decode is 4% behind mlx-lm and prefill is 3-17% behind. Most of the remaining decode time is kernel encode:
about 9,200 small kernels per 48-visit forward. mlx-lm compiles its clip and softcapped SwiGLU chains, and this PR
runs them eagerly. Compiling those chains and fusing the decode-attention prep are follow-up PRs, each to be measured
against this head.
Known limits
--ctx-size 32768, prefix restore works and matches a cold server, as the live script checks.=0, or a non-bf16 pack), the composed prefill holds[H, L, S]f32 logits per global visit,and the chunk auto-cap does not account for them.
Verified
On an M5 Max with 128 GB, macOS 27.0.1, ReleaseFast:
inkling2(76 pass, 1 skip: the real-pack test without its env),computeQuantParams,mlx-lm configs,plugin registry,inkling plugin,inkling config(v1 unchanged), andkernel contract(
636/636 kernels pass gates 1-4, 64 known findings, 10/10 controls red).python3 scripts/lint.py --strictexits 0, andzig build unit-closurepasses.zig build units-check -Dunits=truefails with the same 19 duplicated globals on
main(none from this plugin).tests/test_inkling2.shpasses 10/10 on the 4-bit pack: model listing, greedyBerlin, prefix reuse and restorematching a cold server, image 400,
reasoning_effort, and both kernels engaged. It also passes 10/10 on the 8-bitpack. The script fails at step 1 on a
mainbinary.cd app && swift build && bash test.sh: 4406 tests, 0 failures.zig build test -Dslow-tests -Doptimize=ReleaseFast): 5518/5925 passed, 402 skipped, 5failed. One failure was this branch's: the new 4-bit fixture config was missing from the quant-block claimant table.
It is fixed in commit 2, and
-Dtest-filter="quant block"now passes. The other 4 areverify_projection_test, which runs out of GPU memory. They fail the same way when run alone on this branch and onmain(c60de41).🤖 Generated with Claude Code