Skip to content

hip flashnext: take the MTP head's root from the index - #1613

Merged
ashhart merged 3 commits into
ashhart:mainfrom
gilby:strix/hip-mtp-root
Nov 2, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
gilby:strix/hip-mtp-root

Conversation

@gilby

@gilby gilby commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What this changes

The HIP Flash Next loader takes the MTP head's root from index.mtpRoot instead of fixed language_model.mtp.* names, so oMLX checkpoints (head at top-level mtp.*) load with MTP drafts. Fixes #1598.

Receipt

  • Environment: TensorFold 7c068895 plus this change, tensorfold-native 1.1.8 built with zig build native-hip -Dhip-arch=gfx1151, Ubuntu archive HIP 7.1 (clang 21), AMD Ryzen AI MAX+ 395 with Radeon 8060S gfx1151 (128 GB unified memory). Checkpoint: an oMLX oQ4e quantization of Qwen3.8-Flash-Next (group 32 base, one width per fused stack), served once with the head under language_model.mtp.* and once with the same tensors renamed to top-level mtp.* (the oMLX spelling). --parallel 1 --context 131072 --prompt-cache-gib 0.
  • Exactness, tools/bench_concurrent.py --tokens 256 --reps 3 --temperatures 0 --levels 1,4 --alone --serial: every cell alone 3/3 (1 stream) and 12/12 (4 streams) equal, serial equal, 0 failed, for stock with language_model.mtp.*, this change with language_model.mtp.*, and this change with mtp.*. The token_sha256 sets of bench_openai, bench_concurrent and bench_cache are identical across the three runs. Stock refuses the mtp.* spelling with checkpoint has no tensor language_model.mtp.pre_fc_norm_embedding.weight; this change loads it with mtp drafts 3 under 0.3.
  • Decode speed, tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0 (median tok/s, code / chat): stock 41.9 / 36.1; this change with language_model.mtp.* 40.3 / 33.8; with mtp.* 41.6 / 35.8. The change cannot reach the decode path; the spread is load from compilation on the same machine during these runs, and I can repeat alternated runs on an idle machine if wanted.
  • Prompt speed: n/a, the change only names tensors at load.
  • Tests run: zig build test -Dhip=true --summary all 466/466 steps, 0 failed (exit 0, same on the base); zig build hip-kernel-test 103/103 kernel tests passed; python3 tools/zig/lean_check.py 425 problems on both the base and this change (inherited, no new findings); git diff --check clean.
  • Not run: Metal and CUDA (the change is in the HIP Flash Next loader only); other AMD chips.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel change.)
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new test: the HIP loader has no GPU-free test and the fixture index uses the language_model.mtp spelling; the served receipt covers both spellings.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

@ashhart

ashhart commented Oct 30, 2026

Copy link
Copy Markdown
Owner

Thanks — this is a tidy change and reuses the existing index helpers well. Could you add a short description, and either a small test or a load log showing a checkpoint with top-level mtp.* names loading and drafting on HIP? A quick run on the existing layout would also confirm nothing moved there. With that, this looks close.

@gilby

gilby commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks. Pushed 219ed81c: the loader now builds the MTP head's six names through mtpNames(root), and a host test feeds two small weight maps (mlx-lm's language_model.mtp.* and oMLX's top-level mtp.*), checks that index.mtpRoot picks language_model.mtp and mtp, and asserts all 12 names exactly, so hard-coding the root again would fail it. zig build test -Dhip=true 466/466 steps, 0 failed.

The description already covers both layouts on a real checkpoint: the same oQ4e quantization served with the head under language_model.mtp.* (stock and this change: identical token_sha256 sets, every bench_concurrent --alone --serial cell equal) and renamed to top-level mtp.* (stock refuses with checkpoint has no tensor language_model.mtp.pre_fc_norm_embedding.weight; this change serves it with identical tokens). A load log from the top-level mtp.* copy on gfx1151, paths and addresses removed:

[tensorfold] HIP rank 0 of 1: policy matrix=auto,attention=auto,kernels=auto,graphs=auto,prefill_step=1024,fill_rows=512; mtp drafts 3 under 0.3, 8 snapshots
[tensorfold] HIP gfx1151 device 0, rank 0 of 1: Flash Next, 78.40 GiB on the device, 1 stream of 8256 positions, 0.79 GiB each; prompts in 1024-row chunks
[tensorfold] serving Qwen3.8-Flash-Next-oQ4e-tf-hip2-omlxnames at http://<host>:28100/v1 (sampling: temperature 1.0, top_k 20, top_p 0.95; drafts: MTP + copies; context: 8192; loaded in 142.0s)
[tensorfold] done chatcmpl-c3fe2cfb12a6cbfcb7cfb16fcf4f2d9f prompt=19 cached=0 thinking=False effort=none tokens=3 sha=ec772f18d0e2 finish=stop rounds=1 accepted=2/2 ttft=0.733 decode=0.131 elapsed=0.864 queued=0.000 tok/s=15.3

The index of that copy lists 76 top-level mtp.* names and no language_model.mtp.* names; accepted=2/2 is the MTP head's drafts being accepted.

gilby and others added 3 commits November 2, 2026 01:23
oMLX writes the Flash Next MTP head at the top level (mtp.*). The HIP
loader named it from fixed language_model.mtp.* constants, so oMLX
checkpoints failed with a missing language_model.mtp tensor. The loader
now takes the root from index.mtpRoot, as the n-gram shard spelling
already does; names for language_model.mtp checkpoints are unchanged.

Fixes ashhart#1598
…ads only those

The loader now builds the MTP head's six names once, through one join,
from index.mtpRoot; the test formats them over both spellings a
checkpoint's weight map can list the head under and checks every string,
so a hard-coded root fails.
@ashhart
ashhart force-pushed the strix/hip-mtp-root branch from e692326 to 1f2ae50 Compare November 2, 2026 01:23
@ashhart
ashhart merged commit b8262de into ashhart:main Nov 2, 2026
0 of 9 checks passed
@ashhart

ashhart commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you @gilby. 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.

@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

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.

HIP Flash Next: the loader requires the MTP head under language_model.mtp, so oMLX checkpoints fail

2 participants