Repository navigation
Conversation
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.
This was referenced Oct 4, 2026
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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'smma.m8n8k4decode skeleton; EXL3 stays refused on Volta.How the bits stay put:
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.
prep884rows (bf16 × a power of two, exact fp16), the row scale back in the epilogue.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.
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.
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
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-LMHeadwithz-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.
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: our own A/Bscript (3 prompts, temperature 0, drafted vs
"draft": false; 4 serial prompts then N=2 and N=4 concurrent, outputhashes 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.
tools/bench_openai.py: before is a refusal (Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 refuses NVFP4 on Volta), sothe 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.
tools/prefill_cold.py: ours: 1,028 tok/s on a ~6K nonce prompt. Not yet run with upstream's toolon sm_70; GB10 in the v0.6.5 check.
test_qwen36_moe38 andtest_flashnext_nvfp4_loader23 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-DFlash2on one V100,--parallel 4 --context 32768(startup estimate 26.51 GiB within 27.43 GiB): v0.6.5 refuses NVFP4 on sm_70; heretoken_shadrafted =="draft": falseon three prompts (b7ba471133e4, 077d971998da, 8a68c4047935);--levels 2,4 --alone --serial0 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_productskips on sm_70 (FP8 prompts).the local equivalent of this stack (0.6.2): 334 passed, 40 skipped (27B suites +
test_qmmf_volta.py), the realcheckpoint included.
tests/cuda -k "qwen27 or nvfp4"on an sm_80+ card, to show nothing outside Volta moved, was not run.--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_sha1a85da39c982; 19 × 23 drafted =="draft": false8a68c4047935. New tests on Tesla V100s, this branch's test files copied into the parent's tree, then here:tests/cuda/test_qmmf_volta.pyfails to import andtests/cuda/test_qwen27_nvfp4.pygives 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-DFlash2on 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 onbuild.volta(), so GB10 does not run it).tools/prefill_cold.pyon 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
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHeadon 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.)test_qmmf_volta.pyskips off sm_70 at module level.)The three #264 commits carried here are RoscoeTT's as replayed onto v0.6.5; their Co-Authored-By trailers are his.