Skip to content

feat(volta): Qwen3.8-27B NVFP4 checkpoints on sm_70 (W4A16 / W8A16, fp16 activations) - #374

Closed
gilby wants to merge 4 commits into
ashhart:mainfrom
gilby:volta-nvfp4
Closed

gilby wants to merge 4 commits into
ashhart:mainfrom
gilby:volta-nvfp4

Conversation

@gilby

@gilby gilby commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Part of #313. Stacked on #264. The earlier commits on this branch are #264's three commits replayed onto v0.6.5 (see our note on #264). This pull request is the last commit. Qwen3.8-27B NVFP4 checkpoints (NVFP4 MLP, FP8 attention and DeltaNet, bf16 gates and head) now run on
Tesla V100s, which #264 refuses by name today. Each projection kind gets an sm_70 linear (VoltaLinear,
cuda/kernels/qmmf_volta.{cu,py}) on #264's mma.m8n8k4 decode skeleton; EXL3 stays refused on Volta.

How the bits stay put:

  • Weights expand in registers to exact fp16 values, then one fp32 factor a column comes back last. NVFP4: the
    e2m1 code shifted into an fp16 (code × 2^-14) times the e4m3 block scale shifted likewise (× 256), a product of at
    most 5 significant bits, exact in fp16; column factor = global scale × 2^14. FP8: e4m3 shifted into fp16 (value ×
    2^-8, subnormals too); column factor = tensor scale × 2^8. bf16: the column scaled by a power of two into
    [2^14, 2^15), stored as fp16; column factor = that power.
  • Rows are Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's prep884 rows (bf16 × a power of two, exact fp16), the row scale back in the epilogue.
  • Decode: one kernel and one K split, chosen from the weight's shape, for every row count. A block takes 128
    columns and one K slice; each 64-input group's rows are staged in shared memory three groups ahead, every tile keeps
    two accumulator chains (fixed, part of the bits), and the last K slice to finish adds the slices in slice order, so
    no second launch runs and a row never depends on how many rows share the launch.
  • Prompts: a dense fp16 copy of the same values through Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's pinned cuBLASLt GEMM (chunk invariant, not
    decode's chain, as Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's prompt path); the bf16 head (too large to copy) prompts on the decode kernel.
  • Embedding: kept in page-locked host memory and gathered by the GPU through its mapped address (HostRows,
    exact rows), counted as no device bytes. Admission uses two staging copies instead of three on sm_70.

Bits: W4A16 / W8A16 with fp16 activations and fp32 sums, the stored weights exactly. As with #264, drafted replies
equal this engine's own serial decoding; the bits differ from the sm_80+ NVFP4 engine's (bf16 activations there).

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, power capped at 200 W; PyTorch 2.10.0+cu128, Triton 3.6, CUDA 12.8.
    Checkpoint RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead with z-lab/Qwen3.8-27B-DFlash2. Our own numbers below were measured on TensorFold 0.6.2 +
    Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's 0.6.2 commits + this change + the Qwen3.6 Volta experts (feat(volta): Qwen3.6 MoE NVFP4 experts on sm_70 #375); the upstream-tool numbers on this branch are in the v0.6.5 line below.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: our own A/B
    script (3 prompts, temperature 0, drafted vs "draft": false; 4 serial prompts then N=2 and N=4 concurrent, output
    hashes compared): drafted == "draft": false (greedy, and sampled with seeds 1234 and 1237), N=2/N=4 == serial.
    Upstream's tools: see the v0.6.5 line below.
  • Decode speed before and after, from tools/bench_openai.py: before is a refusal (Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 refuses NVFP4 on Volta), so
    the comparison is against Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's MLX 4-bit checkpoint on the same card. Ours (own script, 512-token greedy replies):
    73.5 tok/s single stream (52–100 across prompts), N=2 109, N=4 141, N=8 173–191 aggregate at --parallel 8.
    Upstream's tools on this branch: see the v0.6.5 line below.
  • Prompt speed before and after, from tools/prefill_cold.py: ours: 1,028 tok/s on a ~6K nonce prompt. Not yet run with upstream's tool
    on sm_70; GB10 in the v0.6.5 check.
  • On v0.6.5 (this branch as 956a7dc, on Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 replayed onto v0.6.5): Mac host suite (M5 Ultra): 5000 passed, 1 failed, 596 skipped. One Tesla V100-PCIE-32GB, torch 2.10.0+cu128, Triton 3.6, CUDA 12.8, the Volta CUDA selection: 383 passed, 48 skipped; the 61 failures are Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's on v0.6.5 (test_qwen36_moe 38 and test_flashnext_nvfp4_loader 23 do not skip on sm_70 until feat(volta): Qwen3.6 MoE NVFP4 experts on sm_70 #375 and feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks #380 add the skips). Upstream tools, RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead + z-lab/Qwen3.8-27B-DFlash2 on one V100, --parallel 4 --context 32768 (startup estimate 26.51 GiB within 27.43 GiB): v0.6.5 refuses NVFP4 on sm_70; here token_sha drafted == "draft": false on three prompts (b7ba471133e4, 077d971998da, 8a68c4047935); --levels 2,4 --alone --serial 0 failed and 0 unequal in all 8 cells; tools/bench_openai.py --tokens 256 --reps 3, sampled / greedy: fibonacci-raw 117.9 / 100.5, gpu-chat 57.3 / 62.0 tok/s; N=2 / N=4 greedy aggregate code 147.7 / 182.1, chat 95.3 / 130.8. On the base: perf(cuda): tree attention folds whole key groups in their programs (drafted rounds -5% at 90k, -9..-10% at 242k; drafts equal serial) #268's grouped tree-attention partials do not fit Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264's per-chunk Volta kernel, so sm_70 plans fold no groups (attention._ungrouped); Volta tree-attention bits may differ in the last place from Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 on v0.6.3. test_gate_copy_tracks_the_bf16_product skips on sm_70 (FP8 prompts).
  • Tests run, with pass, fail and skip counts: Mac host suite and V100 CUDA selection on this branch: see the v0.6.5 line above. On a V100 with
    the local equivalent of this stack (0.6.2): 334 passed, 40 skipped (27B suites + test_qmmf_volta.py), the real
    checkpoint included. tests/cuda -k "qwen27 or nvfp4" on an sm_80+ card, to show nothing outside Volta moved, was not run.
  • Checked on v0.6.5 (2026-10-04): one Tesla V100, the same checkpoint and drafter, --context 65536 --parallel 1 (startup 25.05 GiB of 27.43): fresh == resumed (2,296 of 2,301 tokens from the prompt cache) == "draft": false, token_sha 1a85da39c982; 19 × 23 drafted == "draft": false 8a68c4047935. New tests on Tesla V100s, this branch's test files copied into the parent's tree, then here: tests/cuda/test_qmmf_volta.py fails to import and tests/cuda/test_qwen27_nvfp4.py gives 4 failed, 3 errors; here 93 passed, 7 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/prefill_cold.py on sm_70, and the sm_80+ CUDA selection. Platforms: CUDA sm_70
    (Tesla V100-PCIE-32GB) only for the new kernels; no V100 SXM, Titan V or other Volta. The change is gated on
    build.volta(), so GB10, A40, RTX PRO 6000, sm_89/sm_90 paths are unchanged by construction but not re-run here.
    Metal: not touched; the Mac suite ran on an M5 Ultra.

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 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: fails on the parent's tree (import error; 4 failed, 3 errors), 93 passed and 7 skipped here; test_qmmf_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 4 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.
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @gilby. Expanding each NVFP4 code and block scale into an exact fp16 value, a product of at most five significant bits, then applying one fp32 factor a column last, keeps the stored weights exact on a GPU without bf16 MMA. That fits the Zig engine's rule of keeping stored weights exact.

The Python engine is frozen (#286), so this won't merge. On the Zig engine it waits on three things: Zig CUDA builds only for GB10 today, it has no NVFP4 path yet, and Qwen3.8-27B isn't a Zig family yet. When Volta comes to Zig CUDA, VoltaLinear's expansion and its single kernel and K split for every row count are where that 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