Skip to content

feat(volta): Qwen3.6 MoE NVFP4 experts on sm_70 - #375

Closed
gilby wants to merge 7 commits into
ashhart:mainfrom
gilby:volta-qwen36-experts
Closed

gilby wants to merge 7 commits into
ashhart:mainfrom
gilby:volta-qwen36-experts

Conversation

@gilby

@gilby gilby commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Part of #313. Stacked on #264, #374 (VoltaLinear) and #345 (Qwen3.6 ModelOpt NVFP4 on CUDA). The earlier commits on this branch are #374's (#264's three commits replayed onto v0.6.5, see our note on #264, and #374's own) and same-patch copies of #344's and #345's commits. This pull request is the last commit. A ModelOpt NVFP4 Qwen3.6 MoE checkpoint
(nvidia/Qwen3.6-35B-A3B-NVFP4, ornith-ai/Ornith-1.5-35B-A3B-NVFP4) now serves on one Tesla V100 with its own MTP
head: the routed NVFP4 experts run on a new sm_70 grouped kernel (VoltaExperts), and the router, the MTP layer's
draft-only NVFP4 linears and experts, and the NVFP4 draft head take the Volta forms.

  • experts884_kernel: items of up to eight (row, slot) pairs routed to one expert, their rows gathered and staged a
    64-input group at a time in the decode kernel's fragment order, the same mma.m8n8k4 chain and fp32 sums. gate and
    up of a column sit side by side with SwiGLU in the epilogue; down writes fp32 (bf16 in prompts). The K split comes
    from the shape and the last slice adds the slices in order. A pair's bits depend only on its own row and expert, so
    the one-block grouping plan may order an expert's pairs freely.
  • The router rows run as a 16-bit VoltaLinear (fp32 logits); moe.moe dispatches to VoltaExperts.
  • Expert scratch that a CUDA graph capture outgrew is kept, never freed: the earlier graph still writes into it.
  • The MLX-affine Qwen3.6 MoE suite skips on sm_70 (its experts kernel needs sm_80); tests/cuda/test_experts_volta.py
    checks pair independence and the fp32 reference.

Bits: as #374, W4A16 with fp16 activations and fp32 sums, the stored weights exactly; drafted equals this engine's
serial decoding, and the bits differ from the sm_80+ engine's.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: Tesla
    V100-PCIE-32GB (sm_70), one card, in a VM, 200 W cap; PyTorch 2.10.0+cu128, Triton 3.6, CUDA 12.8.
    nvidia/Qwen3.6-35B-A3B-NVFP4 and ornith-ai/Ornith-1.5-35B-A3B-NVFP4, own MTP heads. Our own numbers below were measured on 0.6.2 + Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's
    0.6.2 commits + the local equivalents of feat(volta): Qwen3.8-27B NVFP4 checkpoints on sm_70 (W4A16 / W8A16, fp16 activations) #374, feat(qwen3.6 cuda): read ModelOpt NVFP4 checkpoints #345 and this change. On this branch: the test suites (the v0.6.5 line below) and one served check (the v0.6.5 check).
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: our own A/B
    script: drafted == "draft": false (3 prompts), N=2/N=4 == serial, for both checkpoints. Not yet run with upstream's tool on this PR alone.
  • Decode speed before and after, from tools/bench_openai.py: before is a refusal (no MoE NVFP4 on Volta). Ours
    (512-token greedy replies): nvidia/Qwen3.6-35B-A3B-NVFP4 184.6 tok/s single stream, N=2 134–148, N=4 182–196,
    N=8 372–390 aggregate; Ornith 163–165 single (concurrent rows noisy). Not yet run with upstream's tool on this PR alone.
  • Prompt speed before and after, from tools/prefill_cold.py: ours: 4,017 tok/s (Qwen3.6) and 4,005 (Ornith) on a ~6K
    nonce prompt. Not yet run with upstream's tool.
  • On v0.6.5 (this branch as b4abf80, on Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 replayed onto v0.6.5): Mac host suite (M5 Ultra): 5006 passed, 1 failed, 596 skipped. One Tesla V100: 388 passed, 49 skipped, 23 failed (test_flashnext_nvfp4_loader, which skips on sm_70 from feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks #380); test_experts_volta and test_qmmf_volta pass and test_qwen36_moe skips on sm_70. No serve receipt on this PR alone.
  • Tests run, with pass, fail and skip counts: Mac host suite and V100 CUDA tests on this branch: see the v0.6.5 line above. On a V100 (0.6.2 equivalent):
    test_experts_volta.py passed, 334 passed / 40 skipped over the 27B and new suites. tests/cuda -k qwen36 on an sm_80+ card was not run.
  • Checked on v0.6.5 (2026-10-04): one Tesla V100, nvidia/Qwen3.6-35B-A3B-NVFP4 with its own MTP head, --context 32768 --parallel 1 (startup 25.36 GiB of 27.43): fresh == resumed (2,254 of 2,259 tokens from the prompt cache) == "draft": false, token_sha 3193472defb8; 19 × 23 drafted == "draft": false 006f69232d31. New tests on Tesla V100s, this branch's test files copied into the parent's tree, then here: tests/cuda/test_experts_volta.py + tests/cuda/test_qwen36_moe.py fail to import; here 5 passed, 1 skipped. Prompt speed on a checkpoint v0.6.5 serves, RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead + z-lab/Qwen3.8-27B-DFlash2 on 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), v0.6.5 → the top of this stack (feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks #380's tree): 2,591 → 2,606 / 2,840 → 2,855 / 2,731 → 2,751 (the sm_70 code is gated on build.volta(), so GB10 does not run it).
  • Not run, and why: tools/bench_concurrent.py and tools/bench_openai.py on this PR alone (the concurrent receipts are on feat(volta): Qwen3.8-27B NVFP4 checkpoints on sm_70 (W4A16 / W8A16, fp16 activations) #374 and feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks #380), and an sm_80+ card. Platforms: CUDA sm_70 (Tesla V100-PCIE-32GB) only; the sm_80+
    path is unchanged except make_experts' volta() branch, not re-run here. Metal untouched.

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. (Served alone on one V100: drafted == "draft": false and resumed == fresh (see the v0.6.5 check); concurrent == solo was not run on this PR alone (see feat(volta): Qwen3.8-27B NVFP4 checkpoints on sm_70 (W4A16 / W8A16, fp16 activations) #374 and feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks #380).)
  • 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 sm_70: v0.6.5 refuses NVFP4 there. On a checkpoint v0.6.5 serves, RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead on one DGX Spark (GB10), the top of this stack is within noise of v0.6.5 (+0.5 to +0.7%); 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. (On V100s: import error on the parent's tree, 5 passed and 1 skipped here; test_experts_volta.py skips off sm_70 at module level.)
  • 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.

The three #264 commits carried here are RoscoeTT's as replayed onto v0.6.5; their Co-Authored-By trailers are his.

RoscoeTT and others added 7 commits October 4, 2026 09:23
Triton's tl.dot has no tensor-core path on Volta (0.2 TFLOPS) and the shared FP8 and bf16 extensions need sm_80, so the
Qwen3.8-27B MLX 4-bit weights get their own kernels, with the row-invariance contract kept:

- Decode: mma.m8n8k4 from registers, one weight column a thread, weights repacked once at load (Tiled), rows scaled by
  a power of two so every bf16 value is an exact fp16, fp32 sums; the K split is a function of the weight's shape and
  its slices add in order, so a row never depends on the row count. Rows reach the kernel in its fragment order.
- Prompts: a dense fp16 copy of each weight and one cuBLASLt algorithm pinned per weight shape (split-K off), so a row's
  chain over K is the same at every row count and any chunking.
- Extensions declare Volta with need=VOLTA; the FP8 and sm_80 builds keep their clear refusal.
- The Volta-only tests skip elsewhere; sm_80-only modules skip on Volta with their reasons.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
- Tree attention (attention_volta.cu): attention.py's chunk partials on mma.m8n8k4, one per-warp routine under two
  kernels (chunks wholly below the committed keys with every window row in one block; the rest per row with its path
  keys). A row's partial never depends on its warp mates and a key on a path gives the same bits as the same key
  committed, so drafted rows equal serial ones.
- Prompt attention: PyTorch's memory-efficient (CUTLASS) attention in fp16, one key head at a time with its query heads
  on the batch axis and its keys and values broadcast without a copy; query rows pad back to a 128-aligned position so
  a row's tile never moves with chunking.
- DFlash2's block attention (draft_attention_volta.cu), with its shape and shared-memory limits checked.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Qwen3.8 engine states its own capability floor at admission (the MLX checkpoint runs on sm_70; EXL3 and NVFP4
packs are refused by name there), and both planners count the fp16 key and value staging of the prompt attention.
README, the recipe's V100 section with measurements, the family's kernel map and a changelog entry.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…p16 activations)

An NVFP4 checkpoint's three kinds of projection (NVFP4, FP8, bf16) get an sm_70 linear, VoltaLinear, on the
mma.m8n8k4 skeleton of the 4-bit Volta decode kernel. Weights expand in registers to exact fp16 values (e2m1 code
times e4m3 block scale, e4m3, or bf16 scaled by a power of two a column) and one fp32 factor a column is applied
last; rows are prep884's power-of-two-scaled fp16 rows. One kernel and one K split, chosen from the weight's shape,
serve every row count, and the last K slice adds the slices in slice order, so a row never depends on how many rows
share the launch. Prompt rows take a dense fp16 copy of the same values through the pinned cuBLASLt GEMM (chunk
invariant); the bf16 head prompts on the decode kernel.

The bf16 embedding stays in page-locked host memory and the GPU gathers its rows through the mapped address
(HostRows), so admission counts it as no device bytes. nvfp4_load builds these linears on sm_70; the engine admits
NVFP4 there (EXL3 is still refused) with two staging copies instead of three. test_qwen27_nvfp4's synthetic model runs
on sm_70 with the new linears; tests/cuda/test_qmmf_volta.py checks row-count invariance, the stored values and chunk
invariance.
…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.
VoltaExperts runs a ModelOpt checkpoint's routed NVFP4 experts on the decode kernel's mma.m8n8k4 chain: items of up
to eight (row, slot) pairs of one expert are gathered and staged a 64-input group at a time, gate and up of a column
sit side by side with SwiGLU in the epilogue, and down returns fp32 (bf16 in prompts). The K split comes from the
shape and the last slice adds the slices in order, so a pair's bits depend only on its row and expert, and the
grouping plan (one block) may order an expert's pairs freely.

On sm_70 the router rows run as a 16-bit VoltaLinear (fp32 logits); the MTP layer's draft-only NVFP4 linears and
experts and the NVFP4 draft head take the Volta forms; the MoE engine admits NVFP4 there. Expert scratch that a CUDA
graph capture outgrew is kept rather than freed, since the earlier graph still writes into it. The MLX-affine Qwen3.6
MoE suite skips on sm_70, whose experts kernel needs sm_80; tests/cuda/test_experts_volta.py covers the new kernel.
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @gilby. Making each routed pair's bits depend only on its own row and expert, so the grouping plan can order an expert's pairs freely, is the property that lets an expert kernel batch rows without changing a reply. Keeping the scratch an earlier captured graph still writes into, instead of freeing it, was a good catch too.

The Python engine is frozen (#286), so this won't merge. On the Zig engine it waits for two things: an sm_70 target in Zig CUDA, which builds only for GB10 today, and Qwen3.6 MoE as a Zig family. When both exist, VoltaExperts and its pair-independence test are where the work starts, with your credit.

@ashhart ashhart closed this Oct 6, 2026
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.

3 participants