Repository navigation
Conversation
An NVFP4 checkpoint (NVFP4 MLP, FP8 attention and DeltaNet, bf16 gates and head) now shards as the MLX checkpoint does, every stored byte unchanged. Fp4Linear and Fp8Linear gain outputs() (whole 64-output tiles of the loaded tiling, a zero tile padding an odd count) and inputs() (whole 64-input groups, four e4m3-scaled 16-input blocks each, the per-tensor scale kept), and partial(), the lane matmul with an unrounded fp32 epilogue for the rank-ordered sum. Plain and Plain8 split their rows or columns as stored. split_weights keeps the checkpoint's precision settings, and the two-rank DFlash2 drafter takes its half of the draft vocabulary from the bf16 head. The engine no longer refuses --tp 2 for NVFP4; EXL3 packs and checkpoint math still run on one GPU.
|
@gilby, one combination to look at: |
…ount With --prefill-fp8, the GDN gates a and b (48 rows) carry an e4m3 copy for prompts. A two-rank shard sliced that copy by whole 64-output tiles, which 24 rows a rank are not, so --tp 2 with --prefill-fp8 refused to load. A shard now makes its copy from its own bf16 rows; the copy's scales are per output row, so the bytes are the full copy's rows at any row count. tests/cuda/test_qwen27_nvfp4_tp.py: a 48x5120 gate (and 128, 384 rows) splits two ways into the copies made from the sliced rows.
|
@BHCC2025, thanks, you were right. Fixed in e453ecc: a column shard of |
|
Thank you, @gilby. Shards that equal the projection loaded from the sliced checkpoint byte for byte, and a partial with an unrounded fp32 epilogue so the rank sum rounds once, make two-rank NVFP4 exact against two-rank serial decoding. The Python engine is frozen (#286), so this won't merge. On the Zig engine it waits for Zig CUDA, which runs one GPU today with no NVFP4 path, and for Qwen3.8-27B as a Zig family. The rounding rule already matches the Zig engine's multi-Mac cluster, which sums fp32 partials in a fixed order and rounds once. When ranks come to Zig CUDA, your |
What this changes
A Qwen3.8-27B NVFP4 checkpoint (NVFP4 MLP, FP8 attention and DeltaNet, bf16 gates and head) now runs at
--tp 2,sharded as the MLX checkpoint is, every stored byte unchanged:
Fp4Linear/Fp8Lineargainoutputs()(whole 64-output tiles of the loaded tiling; a zero tile pads an oddcount) and
inputs()(whole 64-input groups, four e4m3-scaled 16-input blocks each, the per-tensor scale kept). Eachshard equals the projection loaded from the sliced checkpoint tensors, byte for byte.
partial(): the lane matmul with an unrounded fp32 epilogue, for the rank-ordered fp32 sum that rounds once to thebf16 output (row-invariant).
Plain/Plain8(bf16 head and GDN gates, their e4m3 prompt copies) split by rows or columns as stored. Acolumn shard of
Plain8remakes its e4m3 copy from its own bf16 rows (the copy's scales are per output row, so thebytes are the full copy's rows), so the 48-row GDN gates split to 24 a rank under
--prefill-fp8(second commit).split_weightskeeps the checkpoint's precision settings; the two-rank DFlash2 drafter takes its half of the draftvocabulary as views of the bf16 head.
The engine no longer refuses
--tp 2for NVFP4. EXL3 packs and checkpoint math (FP4/FP8 activations) still run on oneGPU and say so.
Receipt
change on 0.6.4 (before its rebase onto v0.6.5, with both porting fixes) against 0.6.4. PyTorch 2.13.0a0 (NGC 26.07 container, CUDA 13.3), Triton 3.7.1; one DGX Spark (GB10, sm_121); real checkpoint
RadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead@ 009632f withz-lab/Qwen3.8-27B-DFlash2@ 50307d4.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: in the tests: atwo-rank verify window equals two-rank serial steps, prompts ignore chunking, logits match one GPU to bf16 rounding,
and every shard equals the sliced checkpoint byte for byte (both ranks on one GPU in two threads). A served
--tp 2run with upstream's tools: not run (see below). Resumed == fresh, on v0.6.5 (one DGX Spark): the same 2,682-token prompt three times on one server at temperature 0: fresh, resumed (2,677 tokens from the prompt cache) and resumed with
"draft": false(one rank), alltoken_sha03c531b17784.tools/bench_openai.py: before is a refusal (--tp 2refused for NVFP4); not run.tools/prefill_cold.py: one rank only, measured later on v0.6.5 (v0.6.5 → this): 2,610 / 2,848 / 2,713 → 2,603 / 2,844 / 2,734 tok/s at 2k / 8k / 16k.--tp 2: not run.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": 692 passed, 0 failed, 81 skipped.test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on 0.6.4 too). On the DGX Spark,pytest tests/cuda tests/test_cuda_build.py -k "qwen27 or nvfp4 or b16 or qmm or build or distributed": 466 passed, 0 failed, 10skipped (0.6.4: 453 passed, 10 skipped). Fail-before: the new
tests/cuda/test_qwen27_nvfp4_tp.pyand the changedtest_qwen27_nvfp4.pycopied into the 0.6.4 tree: 11 failed, 3 errors, 13 passed. Two-process tests need two GPUs inone machine and skip.
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) onRadixArk/Qwen3.8-27B-NVFP4-BF16-LMHead+z-lab/Qwen3.8-27B-DFlash2at--context 131072 --parallel 1, a checkpoint v0.6.5 serves: v0.6.5 → this 2,601 → 2,597 / 2,853 → 2,854 / 2,736 → 2,732. Two NVLinked NVIDIA A40s (48 GB), this branch plus feat(cuda): Ampere (sm_80/86) runs the bf16 kernels; FP8 prompts stay at 8.9 and NVFP4 runs W4A16 below it #363's Ampere commit:--tp 2cannot start the 27B even at--context 8192("0 tokens across the ranks"): startup still holds twice the checkpoint, which perf(cuda): two-rank NVFP4 layers shard as they load; row-parallel sums over a peer mapping #356 fixes.tests/cuda/test_qwen27_nvfp4_tp.pyandtest_qwen27_nvfp4.pyon the two A40s (the two-process tests run there): copied into v0.6.5's tree 11 failed, 6 passed, 7 skipped, 3 errors; here 20 passed, 7 skipped.--tp 2with--prefill-fp8refused to load because the 48-row gates' e4m3copy was cut on 64-output tiles. New
test_bf16_gate_prompt_copies_split_at_any_row_count(48, 128 and 384 rowsof 5120, split two ways): before the fix 48 fails with "a shard's outputs must be whole 64-output tiles", 128 and
384 pass; after, all three pass. Run on a Tesla V100 (the test is tensor slicing only); the rest of
test_qwen27_nvfp4_tp.pyandtest_qwen27_nvfp4.pyneeds sm_80+ and fails the same way on both sides there.A
--prefill-fp8prompt through a 24-row shard was not run: FP8 prompts need sm_89+, and the one-GPU pathalready runs the same copy with 48 rows in a 128-padded tile.
--tp 2receipt. Two DGX Sparks together were not set up, and two 48 GB A40s cannot startthe 27B at this commit (see the v0.6.5 check); the two-rank serves are on perf(cuda): two-rank NVFP4 layers shard as they load; row-parallel sums over a peer mapping #356 and perf(cuda): two-rank sums through shared page-locked host memory where the GPUs cannot map each other #357.
Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Not shown for two ranks on this commit alone: on 48 GB cards it cannot start (startup memory, fixed by perf(cuda): two-rank NVFP4 layers shard as they load; row-parallel sums over a peer mapping #356). Its two-rank code serves exactly on two A40s on perf(cuda): two-rank NVFP4 layers shard as they load; row-parallel sums over a peer mapping #356 and perf(cuda): two-rank sums through shared page-locked host memory where the GPUs cannot map each other #357. One rank is checked above.)(Two ranks change the sum order relative to one GPU — rank-ordered fp32 partial sums — exactly as the existing MLX
--tp 2does. Within--tp 2, the threaded tests show a verify window equal to serial steps; a served--tp 2run needs #356's startup fix; see #356.)