Skip to content

feat(qwen3.6 cuda): read ModelOpt NVFP4 checkpoints - #345

Closed
gilby wants to merge 2 commits into
ashhart:mainfrom
gilby:qwen36-cuda-nvfp4
Closed

gilby wants to merge 2 commits into
ashhart:mainfrom
gilby:qwen36-cuda-nvfp4

Conversation

@gilby

@gilby gilby commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Stacked on #344: the earlier commits here are that stack's; this pull request is the last commit. A ModelOpt export such as nvidia/Qwen3.6-35B-A3B-NVFP4 now serves on the Qwen3.6 MoE
CUDA engine, which refused it by quantization:

  • FP8 attention and DeltaNet projections load through the 27B's NVFP4 loader, which gains an MLP hook;
  • routed and shared experts (weight-only NVFP4) run on the existing grouped NVFP4 expert kernel, the shared expert last
    as in the MLX table;
  • layers ModelOpt declares W4A16 keep bf16 activations under checkpoint math;
  • the bf16 MTP layer (ModelOpt leaves mtp* unquantized) drafts in W4A16 NVFP4, its draft head the lm_head's rows
    of the draft ids as stored.

Admission counts the checkpoint's own tensor sizes and sizes the prompt staging from the widest MoE projection.
Nothing changes for MLX checkpoints.

Receipt

Measured on this change applied to 0.6.3 (the branch before its rebase onto 0.6.4; the rebase was clean and changed
no file this PR touches).

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: this
    change on 0.6.3 + fix(qwen3.6): a Mac checks the row decoder's quantization rule, not the CUDA engine's 4-bit/64 rule #344 (branch now on 0.6.5 (609ca41) as 526cced, rebased cleanly;
    Mac tests pass there; the CUDA receipt is from 0.6.3); PyTorch 2.13.0a0 (NGC 26.07 container, CUDA 13.3), Triton 3.7.1; one DGX Spark (GB10,
    sm_121); nvidia/Qwen3.6-35B-A3B-NVFP4 @ 6c7f09d, drafting with its own MTP layer. Server:
    tensorfold serve <checkpoint> --backend cuda --name m --port 8095 --parallel 4 (default --precision checkpoint;
    startup estimate 74.63 GiB, 262,144-token window, 4 streams).
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false:
    --levels 2,4 --alone --serial (256 tokens, 3 reps, code and chat, temperature 1.0 and 0): every concurrent reply
    equals its alone run (6/6 at N=2, 12/12 at N=4 in all 8 cells), and every alone run equals "draft": false (0
    unequal). One chat request twice, the second with "draft": false: token_sha 006f69232d31 both. Resumed == fresh, on v0.6.5 (one DGX Spark): the same 2,640-token prompt three times on one server at temperature 0: fresh, resumed (2,635 tokens from the prompt cache) and resumed with "draft": false, all token_sha 3e1a19f350f5.
  • Decode speed before and after, from tools/bench_openai.py: before is a refusal at startup ("Qwen3.6 MoE on NVIDIA
    GPUs (CUDA) does not read this checkpoint's weights (modelopt MIXED_PRECISION) ..."). After (--tokens 256 --reps 5,
    median tok/s): fibonacci-raw greedy 177.2, sampled 162.8; gpu-chat-no-think greedy 136.4, sampled 125.1. The same
    server with --mtp-drafts 0: 73.9 / 73.0 / 73.6 / 73.2. MTP drafts accepted 17,641 of 26,233. Concurrent aggregate
    (bench_concurrent, greedy): code N=2 261.3, N=4 377.2; chat N=2 207.0, N=4 306.3 tok/s.
  • Prompt speed before and after, from tools/prefill_cold.py: after, 3 reps, median: 2k 6,031 tok/s, 8k 5,709,
    16k 5,420, 32k 4,865, 64k 4,078 (TTFT 0.34 / 1.44 / 3.02 / 6.74 / 16.07 s). No before (refused).
  • On v0.6.5: this branch rebased onto v0.6.5 (609ca41) as 526cced. Mac host suite (M5 Ultra): 5006 passed, 1 failed, 596 skipped; the one failure, test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on v0.6.5 too. CUDA on v0.6.5 (one DGX Spark, GB10): pytest tests/cuda tests/test_cuda_build.py -k "qwen27 or qwen36 or nvfp4 or b16 or qmm or moe or build or distributed or dflash or dspark or exl3 or graph": 679 passed, 0 failed, 81 skipped.
  • Tests run, with pass, fail and skip counts: Mac host suite on this branch (0.6.4): 4698 passed, 1 failed, 595 skipped (the one failure, test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on 0.6.4 too). On the DGX Spark,
    pytest tests/test_qwen36_moe_check.py tests/test_qwen36_family.py tests/cuda -k "qwen36 or nvfp4 or moe or experts":
    291 passed, 0 failed, 58 skipped (base: 290 passed, 58 skipped). The new test_cuda_reads_a_modelopt_checkpoint
    fails on the base tree (the CUDA rule refuses modelopt) and passes here.
  • Checked on v0.6.5 (2026-10-04): one DGX Spark (GB10), tools/prefill_cold.py (2k / 8k / 16k, 3 reps, median tok/s; runs v0.6.5, this, this, v0.6.5, each side the mean of its two) on Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP at --parallel 4, a checkpoint v0.6.5 serves: v0.6.5 → this 6,485 → 6,460 / 7,277 → 7,258 / 6,810 → 6,831.
  • Not run, and why: no before speed (the base refuses the format). Other CUDA generations (sm_80/86/89/120, sm_70) not
    run; Metal: only the check() change touches the Mac path, covered by the host suite.

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.
  • Prompt processing is no slower than the last release. (No before on the ModelOpt checkpoint: v0.6.5 refuses it. On Vontra/Qwen3.6-35B-A3B-MLX-4bit-MTP, which v0.6.5 serves, one DGX Spark: −0.4 to +0.3%; see the v0.6.5 check.)
  • 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.
  • 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.

gilby added 2 commits October 3, 2026 22:03
…he CUDA engine's 4-bit/64 rule

check() refused every checkpoint but MLX 4-bit in groups of 64 on every host. On a Mac the family decodes
through the dense family's row decoder, which reads per-module affine widths and groups, so oQ-style mixed
checkpoints were refused although they load and decode exactly. On a Mac the check is now the row decoder's
own refusal; CUDA keeps its 4-bit/64 rule.
A ModelOpt export such as nvidia/Qwen3.6-35B-A3B-NVFP4 now serves on the CUDA engine:
- FP8 attention and DeltaNet projections load through the 27B's NVFP4 loader, which gains an MLP hook;
- routed and shared experts (weight-only NVFP4) run on the grouped NVFP4 kernel, the shared expert last;
- layers ModelOpt declares W4A16 keep bf16 activations under checkpoint math;
- the bf16 MTP layer (ModelOpt leaves mtp* unquantized) drafts in W4A16 NVFP4, its draft head the lm_head's
  rows of the draft ids as stored.
Admission sizes the prompt staging from the widest MoE projection.
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @gilby. Serving NVIDIA's ModelOpt export, with its W4A16 layers in checkpoint math and the bf16 MTP layer drafting, is solid work, and the receipt covers v0.6.5 too.

The Python engine is frozen (#286) and new work goes into the Zig engine, so this won't merge. The Zig engine has no Qwen3.6 MoE family or NVFP4 reader yet, and Zig CUDA runs only Nemotron so far. When Qwen3.6 MoE comes to the Zig engine on Zig CUDA, the reader's rules carry over with your credit: which layers keep bf16 activations, the shared expert last in the table, admission from the checkpoint's own tensor sizes, and the MTP layer drafting through the head's rows as stored.

@ashhart ashhart closed this Oct 6, 2026
laudney added a commit to laudney/TensorFold that referenced this pull request Oct 30, 2026
The recipe, the README's support table and the changelog now name
NVIDIA's NVFP4 checkpoint on the native CUDA engine: how to serve
it with its own MTP drafter, what runs in which precision, the
drafter-only exception, credit to ashhart#345, and the GB10 receipts for
decode, concurrency, exactness and cold prefill.
ashhart pushed a commit to laudney/TensorFold that referenced this pull request Oct 31, 2026
nvidia/Qwen3.6-35B-A3B-NVFP4 was refused because the routed experts
read only MLX tables. Admission now checks every expert projection's
effective ModelOpt recipe and keeps the router bf16; the loader packs
each projection of all 257 experts on the GPU into Nvfp4Experts'
tables with the shared expert last; decode rows run the decode
kernel and prompt tiles its decode-sum form, so a pair has the same
bits in any window. Rules ported from ashhart#345 by gilby.
ashhart pushed a commit to laudney/TensorFold that referenced this pull request Oct 31, 2026
The recipe, the README's support table and the changelog now name
NVIDIA's NVFP4 checkpoint on the native CUDA engine: how to serve
it with its own MTP drafter, what runs in which precision, the
drafter-only exception, credit to ashhart#345, and the GB10 receipts for
decode, concurrency, exactness and cold prefill.
ashhart pushed a commit that referenced this pull request Oct 31, 2026
nvidia/Qwen3.6-35B-A3B-NVFP4 was refused because the routed experts
read only MLX tables. Admission now checks every expert projection's
effective ModelOpt recipe and keeps the router bf16; the loader packs
each projection of all 257 experts on the GPU into Nvfp4Experts'
tables with the shared expert last; decode rows run the decode
kernel and prompt tiles its decode-sum form, so a pair has the same
bits in any window. Rules ported from #345 by gilby.
ashhart pushed a commit that referenced this pull request Oct 31, 2026
The recipe, the README's support table and the changelog now name
NVIDIA's NVFP4 checkpoint on the native CUDA engine: how to serve
it with its own MTP drafter, what runs in which precision, the
drafter-only exception, credit to #345, and the GB10 receipts for
decode, concurrency, exactness and cold prefill.
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.

2 participants