Skip to content

docs: a plan for Inkling 2 Mini on CUDA and Metal in claimable slices - #4274

Merged
ashhart merged 11 commits into
ashhart:mainfrom
akol1:inkling2-mini-plan
Nov 23, 2026
Merged

ashhart merged 11 commits into
ashhart:mainfrom
akol1:inkling2-mini-plan

Conversation

@akol1

@akol1 akol1 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Adds docs/design/inkling-2-mini.md: a plan for serving Inkling 2 Mini (inkling2_loop) on CUDA and Metal, cut into slices that separate contributors can claim. Before: Mini has a proposal for HIP only (#4265) and no plan for the other two backends. After: one document records the maintainer's decisions, the host slices shared with HIP, the CUDA and Metal slices with what each waits on, DSpark on both backends, and the agreed gate.

The maintainer agreed the plan and its gate in this discussion on 2026-11-21. The document now records the seven decisions, the agreed gate with its speed bar, and what the tiny checkpoint can and cannot cover. It claims nothing; I have asked here for H3, with C3 as the fallback, and start neither before confirmation.

Checks on this head

  • Head commit: a4b18d130
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 168 and 168, 0 new (from python3 tools/pr_check.py --base origin/main: 0 errors, 0 warnings).
  • Tests run, with the command and pass, fail and skip counts: git diff --check clean. No test reaches a design document.
  • CI: pending.
  • Not run, and why: zig build test test-golden and zig fmt --check; the change is one Markdown file and touches no source, build file or fixture.

Receipt

n/a: documentation only; nothing here can reach inference.

  • Licence of any new weights or drafter, or "n/a": n/a. No weights are added; the plan names thinkingmachines/Inkling-2-Mini and its mtp.safetensors, both Apache-2.0.

What I have not established

  • The model facts come from the published config.json and model card, not from running the checkpoint. The memory figures are estimates from the config.
  • The loop's arithmetic is not written down here; slice H3 is that work.
  • Whether Small's open CUDA stack (Inkling-2-Small: Add embeddings, router, and other glue kernels #4126 to Inkling-2-Small: Add DSpark drafter kernels #4128) runs the experts as stored, and whether Metal's existing NVFP4 and attention-residual code fits Inkling 2.
  • The tap contract is checked against SGLang's capture code, not against the Transformers pull request, which has no drafter code. SGLang's rounding paths are as reported in review, not checked.
  • I can run one GB10 (sm_121) and one M4 Max. An M5 and other CUDA chips need another tester. I would take one group of slices after the decision and have not chosen which.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (n/a: no tests)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

@akol1
akol1 marked this pull request as ready for review November 21, 2026 00:17
@BlivionIaG

Copy link
Copy Markdown
Contributor

Thanks for laying out the slices. I can test native Metal on an M4 Pro (48 GiB), and would like to coordinate here rather than start a competing proposal.

  • Decision 4: I'd start with the original thinkingmachines/Inkling-2-Mini, including its bundled mtp.safetensors. I ran the original checkpoint at ed40e7da625f594fc9c4990f5f66be24873c22d7 on this M4 Pro with the pinned mlx-lm Mini implementation. Its peak MLX allocator usage was 19.70 GB for short text prompts. That establishes a useful fit baseline, not a native TensorFold or DSpark receipt.
  • Decision 2: SGLang's Mini PR gives us a candidate for the checkpoint-precision expert reference that Transformers and MLX don't exercise. It quantizes expert inputs (FourOverSix NVFP4 and grouped MXFP8) and applies routing weights before quantizing the down-projection input. The raw-accumulator rounding differs between its SM100-series and SM120 paths, so H3/M3 should name the selected path and its rounding points explicitly. MLX is still useful as an independent BF16-activation comparison, not a token-equality oracle for that mode.

I have a local Metal experiment, but no native receipt or ATC claim yet. Once the gate and shared host ownership are agreed, I can contribute the M4 Pro validation and coordinate a Metal slice with you. Which slice would be most useful for me to take?

@BlivionIaG

Copy link
Copy Markdown
Contributor

One correction to the proposed gate: the pinned tiny Mini checkpoint explicitly drops MTP and has a one-block loop core. It can cover plain/resume/concurrency, but not drafted/plain or selection between two previous-pass message sources. Could we make H4 a dependency of C5/M6, cover the two-source message case in H3, and run draft parity on the original bundled pair with actual proposal/acceptance counts?

SGLang's capture code also makes the tap contract explicit: 5/23/41 are inputs to zero-based decoder visits; 48 is the post-final-norm output, not a cache slot.

@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@akol1, thank you for this plan: it is clear, and it is the plan we are now working from. Answers to the seven questions:

  1. Yes: Inkling 2 Mini is wanted on CUDA, Metal and HIP, as one plan with Inkling 2 Mini on HIP (gfx1151): serve the looped 26.4B checkpoint natively #4265, with the host slices shared.
  2. The routed experts follow the checkpoint's declared quantization in hf_quant_config.json, handled the way main already handles ModelOpt NVFP4 and MXFP8 elsewhere, keeping the checkpoint's activation precision as CONTRIBUTING asks. The reference pull request's dequantize-on-load is a fidelity comparison point, not the contract.
  3. sm_12x first, with the stored FP4 and FP8 arithmetic. Older chips can follow as their own pull request.
  4. Metal starts from the original checkpoint (BF16 dense weights, the stored experts, the drafter file), so all three backends run the same weights.
  5. The loop lives in the inkling2 family.
  6. Yes, the gate as proposed. The speed bar: decode no slower than a standard server on the same machine, with and without the drafter.
  7. No separate issues for now. We want Mini in the next release, so we are building the host slices and all three backends in parallel ourselves, from our own code and the published config, tensor headers and model card. Inkling 2 Mini on HIP (gfx1151): serve the looped 26.4B checkpoint natively #4265 and this plan are credited in the pull requests.

If you or @AbrahamCete want a slice, say which here before you start, so nothing is built twice. Device runs on our machines (a GB10, M5 and M3 Ultras, and a gfx1151) come from us.

  • Synthena

@akol1

akol1 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, and coordinating here is what the plan is for. Nothing is claimed yet and the gate is not agreed, so this is a suggestion, not an assignment.

I can run a GB10 and an M4 Max, so my likely share is the CUDA slices on sm_121. Your M4 Pro is the earlier-chip coverage Metal needs: the pre-M5 prompt path of M1 would be the most useful, or M2 if you would rather start on the glue kernels. Neither waits on decision 2. Neither of us has an M5, so the tensor-unit path needs a third tester.

Your 19.70 GB figure is a useful fit baseline for M5's admission by memory class. I've added SGLang's pull request to the plan as a second candidate for decision 2, with your note that H3, C3 and M3 must name the path and its rounding points. I have not checked its rounding myself.

@BlivionIaG

Copy link
Copy Markdown
Contributor

Thanks both. Following @ashhart’s decision, I’ll keep the integrated experiment local and leave the shared host code and full Metal bring-up to your team. I’d like to take M1’s pre-M5 attention prompt path, with M4 Pro validation, if you haven’t started that part. I can work against your attention arithmetic and share the device receipt, without taking the M5 tensor-unit path. If pre-M5 is already underway, I’m happy to validate your branch on the M4 Pro instead. I’ll wait for the ownership confirmation before opening a slice PR.

@AbrahamCete

Copy link
Copy Markdown
Contributor

Thanks @ashhart, and @akol1 for the plan. For HIP I'd like to take the attention slice, the HIP counterpart of M1: sliding and global attention with the sink, the relative bias, log scaling and the L2 clips on gfx1151, following #4125's arithmetic, with the decode and prompt paths under the kernel contract (records and planted controls). It depends only on decision 1, so it can start now, and I can bring gfx1151 receipts from my Strix Halo alongside yours.

If your team has already started HIP attention, I can take the HIP routed experts as stored instead (NVFP4 and MXFP8 decoded to BF16 in registers, with the checkpoint's activation quantization per decision 2, the counterpart of C3 and M3), or validate your branch on gfx1151. I'll wait for your confirmation before opening anything.

@BlivionIaG

Copy link
Copy Markdown
Contributor

Native M4 Pro update for the validation offer: the original Mini checkpoint (ed40e7da625f594fc9c4990f5f66be24873c22d7, no requantization) runs in our local TensorFold integration on a 48 GiB M4 Pro. The loop/device checks passed (36/36), and the integration check compared full logits for batched vs one-row execution, shared streams, rollback and snapshot restore. Bundled DSpark kept the same 16 output token IDs in both greedy and a fixed-seed sampled HTTP case (9/11 proposals accepted; 7 vs 15 target rounds). With drafts off, a warm prompt reused 640 tokens and matched a cache-disabled run. This is smoke evidence, not throughput or release qualification; padded-image operator checks are not yet green. I can run these M4 cases against your native branch as it lands, or share the tests as a standalone slice if useful. No parallel full-port submission.

@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

A correction to answer 2, after reading the checkpoint and the reference more closely.

hf_quant_config.json declares per-token activation quantization, but it does not pin the arithmetic down: the MXFP8 scales are stored one per row per 32 inputs where the file says [32, 32] blocks, and the scale-selection rule and which expert inputs are quantized are not stated. The reference pull request runs bf16 activations on the stored codes and scales decoded exactly (with the per-expert NVFP4 factor rounded to bf16 as it loads).

So the contract for the routed experts is the reference's arithmetic: the stored NVFP4 and MXFP8 weights decoded in registers, bf16 activations, FP32 sums. That keeps every stored weight bit and makes the tiny checkpoint's token-equal fixture usable as the fidelity check. The declared activation quantization can come later as an opt-in with its own quality gate, if anyone wants it.

  • Synthena

@BlivionIaG

Copy link
Copy Markdown
Contributor

The BF16 correction measurably helps on M4 Pro. On hf-internal-testing/tiny-inkling2-mini@ee242a48af34ff0729518f4ac28cfcb847e470ab, I compared the same 27 prompt positions and eight teacher-forced continuation positions to pinned Transformers 6173a2f6 with eager BF16. The local Metal run that decodes the original packed weights in registers and uses BF16 activations/FP32 sums matches the reference top token at 35/35 positions; the earlier activation-quantized run matched 28/35. Prompt/decode logit RMS dropped from 0.176/0.104 to 0.034/0.027. This is one fixture, not a bit-exact logits or speed claim. The comparison used FP32 division of the two BF16-rounded NVFP4 metadata operands as the pinned converter does. I can replay the same fixture on your implementation when the M4 validation slice is available.

@akol1

akol1 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart, that settles all seven. I'll bring the plan document up to date with the decisions, including the corrected answer 2, and with @BlivionIaG's two corrections once I have checked them against the tiny checkpoint and the tap code.

A slice, as you asked, before starting anything: I'd like to take H3, the loop's arithmetic written down for the gates and the cross-pass message, with a float64 model and single-change probes on the host. It needs no GPU and every backend's loop kernels depend on it. If your team has already started it, my fallback is C3, the routed experts as stored on sm_121 with bf16 activations and FP32 sums, which I can run on a GB10. I'll start neither before you confirm.

Meanwhile, and not a slice: I'm measuring standard-server baselines for the speed bar on the two machines I have, a GB10 and an M4 Max with 128 GiB, since I found none published for either. I'll post them here with the pinned revisions and raw results.

@akol1

akol1 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Standard-server baselines for the speed bar, on the two machines I have. Clients: tools/bench_openai.py and tools/bench_concurrent.py --levels 1,4 --alone --serial, --tokens 256 --reps 3 --temperatures 0, one model server at a time.

GB10 (sm_121)

Server, weights Decode, 1 stream 4 streams, total
vLLM, original checkpoint 38.7 tok/s 102.3 tok/s
vLLM, original checkpoint, DSpark 48.6 tok/s 132.4 tok/s
llama.cpp, IQ4_NL 38.8 tok/s 100.2 tok/s
llama.cpp, Q8_0 31.1 tok/s 89.1 tok/s

M4 Max, 128 GiB, macOS 27.2.1

Server, weights Decode, 1 stream 4 streams, total Peak memory
mlx-lm, original checkpoint 33.7 tok/s 85.2 tok/s 18.7 GiB
llama.cpp, IQ4_NL 36.1 tok/s 84.6 tok/s 18.6 GiB
llama.cpp, Q8_0 33.9 tok/s 75.6 tok/s 28.2 GiB

Decode is the raw-completion prompt's median of three; the 4-stream figure is the code prompt.

Pinned:

  • thinkingmachines/Inkling-2-Mini at ed40e7da625f594fc9c4990f5f66be24873c22d7
  • ggml-org/Inkling-2-Mini-GGUF at db61c5b492a6a034d986328d28274af0a439aa6c
  • llama.cpp at 29b52d398b294509746ec0a3f28948a3107c0213
  • mlx-lm at Add Inkling 2 Mini model ml-explore/mlx-lm#2086 head 0c4c99192230f1943dd468d297f0b8a64ae7b7c2
  • vLLM image vllm/vllm-openai@sha256:c2dc759f5984f69c1e2418c6af7c26eb756f5ed2a8934c768ae1253645d1449e, launched as the recipe's DGX Spark command with --max-model-len 262144; the DSpark run adds --reasoning-parser inkling and the recipe's --speculative-config
  • llama.cpp ran with -ngl 99 -c 32768 --parallel 4

Limits:

  • Every generation hit the 256-token cap while the model was still reasoning, so the tokens counted include reasoning.
  • The DSpark row covers the raw-completion prompt only; the chat prompt went unmeasured in that configuration.
  • There is no drafter row on the Mac, because llama.cpp's DSpark support is not merged.
  • I did not capture peak memory on the GB10.
  • The GGUF rows are different weights from the original checkpoint. The vLLM and mlx-lm rows are the like-for-like comparison.

I can attach the raw JSON if useful.

@Mirrdhyn

Copy link
Copy Markdown
Contributor

We can take the XPU column of this plan on an Intel Arc Pro B70 (32 GB, Xe2), following the Metal slices: X1 attention (sliding and global, sink, relative bias, log scaling, L2 clips) on #4125's arithmetic, X2 glue kernels, X3 routed experts as stored (NVFP4/MXFP8 decoded in registers, bf16 activations, FP32 sums per decision 2), then X4 loop kernels once H3 lands and X5 the engine at one card. The baseline would be measured on the same card. We would start nothing before your confirmation, and can also run C-slice checks on a GB10 if useful.

@jschmied

Copy link
Copy Markdown
Contributor

@ashhart, @akol1: we'd like to help where it doesn't duplicate work already asked for. Nothing below is started; I'll wait for your confirmation.

Slice: H4 + C5, the DSpark drafter. H4 is the host side: mtp.safetensors names and shapes against Mini's header, and the four taps mapped to visits and cache slots, with BlivionIaG's tap contract (5/23/41 are visit inputs, 48 is post-final-norm). C5 runs the drafter on #4128's kernels through the shared lane rounds once C4 lands. Drafted output must equal plain decode, and decode with the drafter must be no slower than without. H4 needs only H1, so it can start as soon as H1 is up. If your team has already started the drafter, we'll validate it instead.

Review and test, for any slice:

  • Shared core: we check every Mini PR for code that already exists in core/ or in another family. That covers the lane adapter, prompt-cache snapshots, the 48-slot pool, DSpark rounds, the sliding/global attention from Inkling 2's attention kernels under the kernel contract #4125, and NVFP4/MXFP8 decode from ModelOpt handling elsewhere. The point is that Mini adds the loop and nothing that duplicates them. We say in each review which code is shared and which is backend-only.
  • Device runs on the exact head:
    • GB10 (sm_121): zig build test, the kernel contract with planted controls, and served plain-vs-drafted, resume and concurrency 1/4/8.
    • M3 Pro 36 GB: an earlier-chip Metal run, which fits Mini's ~19.7 GB.
  • Speed bar: A-B-B-A rows against akol1's vLLM baseline on the same GB10 (38.7 tok/s at 1 stream, 48.6 tok/s with DSpark), with the page cache dropped before each server start.

We can begin with reviews of #4127 and #4128 now, since C1, C5 and C6 build on them.

@SashaMIT

Copy link
Copy Markdown
Contributor

Thanks for the plan. We can fill the M5 gap named under Hardware. We run two Mac Studios with M5 Ultra, 512 GB each, and can run each Metal slice's kernel contract (SUMMARY with planted controls) and the served receipt on the exact head, including M1's M5 tensor-unit prompt path, then post the raw output.

For the speed bar on M5 Ultra we already measured a standard-server baseline with the original checkpoint (thinkingmachines/Inkling-2-Mini @ ed40e7da, bundled mtp.safetensors): oMLX 0.8.2, T=0, single stream, 16 real prompts, 512 tokens, three fresh servers, A-B-B-A: 51.1 tok/s decode plain, 65.6 with DSpark (adaptive, about 62% acceptance, 2.25 tokens per verify). We can add the cold 2k/8k/32k/64k rows your receipt asks for, and share the receipts.

We are not claiming a build slice. If you'd like an M5 owner for M1 later, we're happy to take it once you confirm.

@jschmied

Copy link
Copy Markdown
Contributor

Shared-core review of this plan at a4b18d130 and of the Inkling 2 code on main fa13df5dd1 (#3578, #4125, #4126). I read code only: no builds, no GPU. Each point names the existing counterpart, so the slices can reuse it instead of adding a family copy. The yardstick is the reuse list from #3476: core/modelopt.zig, the shared KV pool, core/lanes/, and "never a second scheduler". The plan names none of core/modelopt.zig, core/kv_pool.zig, core/prompt_cache.zig, src/cuda/experts.zig or Dory.

Wrong dependency

  • C1 can't put Mini's experts on Small's kernels. Small's gate/up (kernels/cuda/inkling2/ops.cu:333, tf_ink2_gateup) is hard-wired to EXL3: FWHT plus svh/suh signs. Inkling-2-Small: Add grouped-expert and vision kernels #4127's grouped experts are EXL3-only too (codebook != .mul1 → BadExperts). Mini ships no EXL3 pack.
    • Suggest dropping experts from C1.
    • C3 then extends core src/cuda/experts.zig:19, which already has .nvfp4, rather than writing a family kernel. It adds .mxfp8 and a softcapped-SwiGLU Epi (:42), and checks the per-expert NVFP4 factor rounding against decision 2.
    • From the header: Mini's per-expert global scale is _weight_amax [128] plus a scalar outer_scale_denominator, not ModelOpt's weight_scale_2.

Should

  1. One visit plan in core, not a fourth copy (H1). Dory's families/dory/schedule.zig:11-46 and qwen3_5 cuda: SenseNova-Loop-9B (sensenova_loop) in BF16, text only #3723's families/qwen3_5/loop_schedule.zig are the same host type: layer, pass, a state slot per visit in run order, and enter/leave flags. qwen27 metal: serve SenseNova-Loop-9B natively (BF16 and AWQ g128, 512K YaRN, images) #3859 and Inkling 2 Mini on HIP (gfx1151): serve the looped 26.4B checkpoint natively #4265 would add more copies.
    • A small core/visit_plan.zig would have Step{layer, pass, slot per state kind, enter, leave} and visitOfTap. Dory would be the first caller, with no behaviour change; Mini's H1 would be the second.
    • The gates and cross-pass messages (H3, C2, M4) stay in inkling2, which fits decision 5 if it means the loop arithmetic. @ashhart, is the schedule meant to be in the family too?
  2. The KV pool (C4). Small keeps whole per-stream caches (families/inkling2/kernels.zig:36-46, Layer.global(capacity)), outside core/kv_pool.zig:13.
    • For Mini's 8 global visits that is a full-context reservation per stream: the plan's own 32 GiB at 1M, and no page sharing on prompt-cache hits.
    • Dory is the looped precedent on main: sliding rings in fixed_bytes, full caches paged (families/dory/cuda_pages.zig:59), snapshots through cuda_snap.zig and native/cuda_snaps.zig. C4 could name these.
  3. ModelOpt (H2). families/inkling2/config.zig:325 has its own quantization check and its own Why (same as core/modelopt.zig:61).
    • Mini's quantization_config is plain modelopt/NVFP4, so H2 can call core.modelopt.admit and read each projection through core/modelopt_part.zig.
    • The MXFP8 layers (20-23 in the header) come from tensor dtypes.
  4. M6: Kimi K3 has no DSpark on Metal. native/kimi_metal.zig:79 refuses external draft heads; only MiniMax M3 has one (families/minimax_m3/dspark.zig:174).
    • The DSpark head forward is family-local in MiniMax M3 (Metal and CUDA), DeepSeek V4.1 and Spark2.5, and Inkling would add two more.
    • Worth deciding whether M6 lands as a core Metal DSpark head, with MiniMax as its second caller.
  5. M2/M3 on Metal. Core already routes by sigmoid plus bias (kernels/metal/core/moe_route.metal:72,125); Inkling's route scale and renorm (ops.cu:311-318) can go there if they differ.
    • M3 would be the sixth family-local Metal expert kernel. It could be the first shared grouped NVFP4/MXFP8 kernel in kernels/metal/core, reusing exlr8_dense.metal's MXFP8 decode.
  6. Sampling keys on main. ops.cu:509-529 (mix, race_uniform) copies kernels/cuda/sample.cu:35-52, as does deepseek_v41/glue.cu:289.
    • Drafted output equals sampled output only while these stay bit-equal. A shared common/sample_keys.cuh would keep them so.
    • ops.cu is at 598 lines, so C1's shapes will push it over 600. Splitting the picks out first avoids that.

Small points

The full list, with both sides' file:line, is ready to paste if useful. Per-PR notes follow on #4127, #4128 and #4124.

@BlivionIaG

BlivionIaG commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Opened #4337 with the M4 Pro Metal path. Head 82e7aa0544 on main at dcc29d9d62.

It adds native serving of the original thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7: text, PNG/JPEG, and the bundled DSpark head. Packed NVFP4/MXFP8 weights stay packed. Kernels decode them to BF16 in registers, with BF16 activations and FP32 sums.

On this 48 GiB M4 Pro the expert contract passed 86/86 with the planted controls red, the tiny checkpoint matched 35/35 top tokens against Transformers 6173a2f6 (RMS 0.03390/0.02735), the vision suite passed 83/83, and drafted and plain token IDs matched on the HTTP cases.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Nov 21, 2026
- Preserve the original release NVFP4 and MXFP8 expert weights and execute the looped text backbone on one Metal device.
- Keep the bundled DSpark head and plain prompt-cache reuse in the native lane backend.
- Refs ashhart#4274. Local M4 Pro evaluation, separate from the upstream full port.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Nov 21, 2026
- Keep original NVFP4/MXFP8 checkpoint bytes and decode weights in registers, using BF16 activations and FP32 sums.
- Match pinned Transformers conversion and SwiGLU/route precision, with packed-weight and zero-scale controls.
- Refs ashhart#4274. Local original-weight M4 Pro qualification; not an upstream submission.
@jschmied

Copy link
Copy Markdown
Contributor

The expert scales, read from the original checkpoint's bytes (ed40e7da, publisher-verified). These are for C3, M3, H3 and the HIP expert slice; I did not read any engine's code.

NVFP4, layers 0-19

  • Formula: w = code × E4M3 block_scale × amax_e / outer_scale_denominator. The denominator is 2688.0 (= 6·448) in every tensor checked: L0, L10 and L19, w13 and w2.
  • Fit: rebuilding each expert's max |w| from this formula gives back its stored _weight_amax to within 2e-16 relative, for all 128 experts. Each expert's largest block scale is exactly 448 and holds a code of 6.
  • Cost of bf16 rounding: the factor amax_e/2688 is never exactly representable in bf16 (0 of 128 per tensor). Rounding it to bf16, as the reference does when it loads, scales each expert's weights uniformly by up to 0.37 % (0.14 % mean). So a kernel that keeps it in fp32 won't be bit-equal to the reference fixture.
  • Not settled: nibble order. Both nibbles of a byte sit in the same 16-input block, so the amax fit can't tell the two orders apart. Only a layer-output check can.

MXFP8, layers 20-23

  • Layout: the scales are 1×32, one per row per 32 inputs, as stored. In w13 and w2 on all four layers, no 32-row group shares one scale per column block (0/9216). Single 32×32 tiles are uniform in only 0.1-0.3 % of cases.
  • Config mismatch: this confirms ashhart's reading. The [32,32] in hf_quant_config.json does not describe the data.

Scripts and residual tables are available on request.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Nov 21, 2026
- Preserve the original release NVFP4 and MXFP8 expert weights and execute the looped text backbone on one Metal device.
- Keep the bundled DSpark head and plain prompt-cache reuse in the native lane backend.
- Refs ashhart#4274. Local M4 Pro evaluation, separate from the upstream full port.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Nov 21, 2026
- Keep original NVFP4/MXFP8 checkpoint bytes and decode weights in registers, using BF16 activations and FP32 sums.
- Match pinned Transformers conversion and SwiGLU/route precision, with packed-weight and zero-scale controls.
- Refs ashhart#4274. Local original-weight M4 Pro qualification; not an upstream submission.
@ashhart

ashhart commented Nov 21, 2026

Copy link
Copy Markdown
Owner

The routed-expert correction is now recorded correctly. Two details from the shared review still need fixing. M6 says Kimi K3 has a Metal DSpark drafter to adapt, but its Metal adapter explicitly refuses external draft heads. Please name MiniMax M3 as the existing implementation, or make M6 a shared Metal DSpark slice with a second caller. Also add --loops to the refusal gate, with a test, alongside is_varloop, audio, and pre-vision images.

  • Synthena

@AbrahamCete

Copy link
Copy Markdown
Contributor

gfx1151 figures for the speed bar, since it is the one machine in the plan without them. They use @akol1's method from #4274 (comment), on the same pins: tools/bench_openai.py and tools/bench_concurrent.py --levels 1,4 --alone --serial, --tokens 256 --reps 3 --temperatures 0, one model server at a time.

Strix Halo, Ryzen AI MAX+ 395 (gfx1151), 128 GB, Ubuntu, llama.cpp Vulkan

Server, weights Decode, 1 stream 4 streams, total Peak GPU memory
llama.cpp, IQ4_NL 21.9 tok/s 62.6 tok/s 19.4 GiB
llama.cpp, Q8_0 19.7 tok/s 44.5 tok/s 29.0 GiB

Decode is the raw-completion prompt's median of three. The 4-stream figure is the code prompt.

Pinned:

  • ggml-org/Inkling-2-Mini-GGUF at db61c5b492a6a034d986328d28274af0a439aa6c
  • llama.cpp b12600 (29b52d398b294509746ec0a3f28948a3107c0213), the official ubuntu-vulkan-x64 build
  • the clients from main 50b819756
  • -ngl 99 -c 32768 --parallel 4, plus --cache-ram 0

Limits:

  • As on the GB10 and the M4 Max, every generation hit the 256-token cap. The chat prompt's output came as reasoning despite the thinking-off request, so the counted tokens include reasoning.
  • Peak GPU memory is the peak VRAM plus the peak GTT above idle, sampled every second. The two peaks need not coincide, so it is an upper bound.
  • The --alone and --serial checks are unverified here, because llama.cpp's replies carry no token ids to hash.
  • No server on this machine runs the original checkpoint, so there is no like-for-like row.

@ashhart, one question about HIP: has your team already started HIP attention? If not, I'll start the slice I offered above (#4274 (comment)) on #4125's arithmetic, and bring gfx1151 receipts measured against these figures. If it has, I'd rather validate your branch on this machine.

@ashhart
ashhart merged commit 2045e61 into ashhart:main Nov 23, 2026
7 of 12 checks passed
ashhart added a commit that referenced this pull request Nov 23, 2026
@ashhart

ashhart commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Thank you @akol1. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@Mirrdhyn

Copy link
Copy Markdown
Contributor

Congrats on landing the plan. Picking up my note from the 21st: could the XPU column join it? We'd take it on an Intel Arc Pro B70, built on #4387's host slices and #4124's reply split once they land, and claimed slice by slice as the plan asks.

Where it stands locally, on one B70 (card 0), none of it pushed:

  • Same-engine exactness holds: drafted (DSpark) equals "draft": false, a stream alone equals the same stream among others, and exact windows equal steps bit for bit, under a kernel contract with planted controls.
  • One stream at 128K of context: 55.8 s to the first token and 102.7 tok/s greedy decode with a bf16 cache.
  • Context on one card: 262,144 tokens with the bf16 cache. An opt-in --kv-cache int8 for the 8 global visits (one scale per position and key head) takes it to 520,192 with the same speed at 128K. Its NLL on a 256-token tail of the CMake reference docs stays within noise of bf16 from 4K to 245K of context (mean +0.003 nats).

If that works for you, I'll post the slice list here first and wait for your go before opening anything.

@BlivionIaG

BlivionIaG commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

@ashhart #4337 (Inkling 2 Mini on Metal: text, vision and the bundled DSpark head, M4 Pro) is out of draft. The description now goes through the agreed gate item by item. Short version, with what is not met stated there too:

  • Kernels: 86 pass, 134 controls red, 0 missed, 0 limit problems on the M4 Pro; the M4 Max (@akol1) and M5 Ultra (@SashaMIT) ran the same contract.
  • Exactness on the released checkpoint, greedy and sampled: concurrent equals solo, drafted equals "draft": false, 0 unequal. A resumed prompt now equals a fresh one with the drafter on too (the head's K/V are kept beside the lane snapshot; 56 of 56 multi-turn requests equal plain, 37 of them resumed past the sliding window). Not covered: images with drafts and the cache.
  • Fidelity against MLX: top-1 equal at 1,762 of 1,792 positions, all differences near ties. Not done: a comparison against Add Inkling2 Mini huggingface/transformers#51050 for the language model.
  • Speed bar (decode no slower than a standard server, with and without the drafter): decode is 1.24 to 1.30 times MLX's at every depth from 2,048 to 65,536 tokens, 31.1 against 23 tok/s at one stream and 67 against 23.3 at four. Cold first token is 0.75 to 0.83 of MLX's rate, which the bar does not cover; it is reported as it is.

The decisions that are yours are listed in the description: F1 (NVFP4 outer-factor rounding), fma in the expert multiply-add and the prompt-chunk sum order (both change bits, neither applied), and the two shared-core edits (Governor.hold_from; TF_METAL4 now also covering Mini's prompt chunks). #4744 (the sampler heap, identical tokens, 21 to 29 tok/s sampled at one stream) is also ready. CI has not finished on either head yet because main has been moving; I sync it as it conflicts.

@AbrahamCete

Copy link
Copy Markdown
Contributor

Thank you for landing #4633. With the HIP attention on main, here is a HIP column in the plan's form, for your go before I open anything. It runs the same weights as CUDA and Metal (the original checkpoint) on gfx1151, under the gate agreed on #4265: the kernel contract with planted controls, same-engine exactness, teacher-forced fidelity against huggingface/transformers#51050, and decode no slower than llama.cpp's Vulkan server on the same machine (21.9 tok/s at one stream and 62.6 at four for IQ4_NL, posted above).

Slice What Needs
HIP1 Sliding and global attention with the sink, the relative bias, log scaling and the L2 clips. done: #4633
HIP2 Glue kernels: embedding, the block attention residual, the short convolutions (static and input-dependent), the router, soft-capped SwiGLU and the pick. none
HIP3 The routed experts as stored: NVFP4 and MXFP8 decoded in registers, bf16 activations, FP32 sums. none
HIP4 The loop kernels (the gates and the cross-pass message) under the kernel contract. H3 (#4387's loop model)
HIP5 The engine at one rank, text only: 48 KV and conv slots in HIP's pages and in prompt-cache snapshots, the lane adapter, admission and the family registration. #4387, HIP2 to HIP4
HIP6 DSpark: the drafter's kernels under the kernel contract, then the drafter through the shared lane rounds. Drafted output equals plain decode, and decode with it is no slower than without. HIP5, H4
HIP7 Images: the vision tower and projector. HIP5
HIP8 The served receipt on gfx1151, the recipe page and the ledger cells. HIP5

I would start with HIP2 and HIP3, which need nothing else, then HIP4 once #4387's loop model is on main. If your team has already started any of these on HIP, tell me which, and I will take the others or validate yours on gfx1151.

@BlivionIaG

Copy link
Copy Markdown
Contributor

@ashhart updating my slice claim of 2026-11-21 now that #4387 is on main. #4337 was an integrated draft and will not be the vehicle: I am cutting what main lacks into one pull request per slice, and opening each ready once its checks pass.

From what I measured on main at 5e390519d0 on an M4 Pro (no tensor units, 48 GiB): text answers correctly and a resumed turn serves its cached prefix, images are refused ("serves text only"), decode is about 0.7 tok/s (the routed-expert kernels, which #4448 addresses) and a cold 2,948-token prompt takes 224 s to its first token.

My slices:

Not taking: M2, M3, M4, M6 or the M5 tensor-unit paths, which sethforprivacy, gilby and cwschroeder have open. #4744 (the sampler heap) is separate and ready.

If any of these collides with a slice you or sethforprivacy already have in flight, say so here and I will drop mine.

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

@AbrahamCete, thank you for the HIP column and for #4633. Yes, go ahead with it as you laid it out, one slice per pull request, under the same gate as #4265: the kernel contract with planted controls, same-engine exactness (drafted equals plain, resumed equals fresh, concurrent equals solo), teacher-forced fidelity against the reference, and decode no slower than the Vulkan figures you posted.

A few notes as you start:

  • Inkling 2 Mini on CUDA and Metal #4387 is on main now, so HIP5 can build on main's Inkling 2 Mini host and lane adapter directly, and HIP4 can follow main's loop kernels.

  • HIP2 and HIP3 have no dependencies, so either is a good first pull request.

  • Keep the checkpoint's stored formats (NVFP4 and MXFP8 decoded in registers, FP32 sums) and the same rounding points as the CUDA and Metal paths. Every output bit should match the serial reference; we don't accept tolerances or lower-precision shortcuts, even behind a switch.

  • Synthena

@AbrahamCete

Copy link
Copy Markdown
Contributor

Thank you. I'll start with HIP3, the routed experts, against loop_model.zig as the serial reference: NVFP4 and MXFP8 decoded in registers, f32 sums in ascending order with contraction off, one bf16 round per output, and the combine in ascending expert id. The device's own tanh and exp need not give Zig's bits, so for the activation I'll port the reference's f32 std.math.tanh and @exp to the device and check them bit for bit over every bf16 input.

One question on HIP2 before I fix its arithmetic. loop_model.zig covers the norms, the attention residual and the residual adds, but not the router, the convs or the logit softcap, and there CUDA and Metal round differently:

  • router: CUDA sums the picked weights in selection order and adds 1e-20 last (zig/kernels/cuda/inkling2/ops.cu:314-318); Metal sorts by expert id and sums from 1e-20 (zig/kernels/metal/inkling2/glue.metal:166-176). The sigmoids differ too (ops.cu:263 against glue.metal:9-12).
  • convs: CUDA adds x after the products (ops.cu:406-417), Metal before them (glue.metal:110-113).
  • attention residual scale: CUDA's mix uses rsqrtf(C) (ops.cu:132); Metal and loop_model.zig use binary32(1/48).

Which should HIP match bit for bit? My preference is Metal's order, since it follows the reference's ascending-id convention. If you agree, I'd add serial references for the router, the convs and the softcap to loop_model.zig in that order as part of HIP2, so its contract compares bits instead of a float64 bound.

@BlivionIaG

Copy link
Copy Markdown
Contributor

Slices opened for the claim above, all ready, all against main, each with its own receipt: #4704 (images, M7), #4705 (admission, M5), #4756 (prompt path without tensor units, M1; now cold 2,048 tokens 146 s to 9.7 s with main's bits), #4744 (sampler heap), and now #4919: exact decode without tensor units, main's sums in main's order, 0.7 to about 22 tok/s on an M4 Pro. Everything that changes bits stays in #4337 and is not proposed.

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.