Skip to content

feat(volta): Qwen3.8-Flash-Next NVFP4 checkpoints on sm_70, one GPU or four ranks - #380

Closed
gilby wants to merge 18 commits into
ashhart:mainfrom
gilby:volta-flashnext
Closed

gilby wants to merge 18 commits into
ashhart:mainfrom
gilby:volta-flashnext

Conversation

@gilby

@gilby gilby commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Part of #313. Stacked on #379 and #375. The earlier commits on this branch are #379's (see #376 for what they carry) and copies of #344's, #345's and #375's commits. The copies are the same patches except #345's (9a32430, now 8437a39), which is merged with #356's layer= hook in load_nvfp4 / load. Rebased onto #379's review fix (40a79ab); this pull request's two commits are now b70876b and d8fc799 (were e7645c5 and ff185d8), their content unchanged. This pull request is the last two commits: the Volta Flash Next commit and a fix on top that splits the expert width evenly over four ranks (below). qwen4_exp
(Qwen3.8-Flash-Next) NVFP4 checkpoints run on Tesla V100s, on one GPU or four ranks:

  • bf16 linears (DeltaNet, attention, hyper-connections, PLE projections, MTP fc, the head) as 16-bit VoltaLinear;
    a row-parallel shard keeps the whole matrix's column factors.
  • Routed NVFP4 experts as VoltaExperts; the bf16 shared expert and the router as 16-bit linears. The MTP layer's
    bf16 experts and the draft head quantize to NVFP4 by ModelOpt's recipe (draft-only, so outputs stay exact).
  • The embedding in page-locked host memory; the FP8 n-gram tables stay memory-mapped on the host, gathered per
    lookup.
  • attn_volta.cu: the chunked attention partials (o, m, l), one block a (row, key head, chunk), fp32, a fixed
    order inside the block (Triton has no Volta tensor-core path).
  • gdn / gdn_io build for sm_70; the expert planner skips picks past the expert table (the shared slot runs on
    its own).
  • The engine takes --tp 4 (and 2) for NVFP4 checkpoints on sm_70 (the four-rank sharding and rank sums come from
    perf(cuda): rank sums over an engine's communicator; prompt-sized partials by copies through shared host memory #378 and feat(qwen4_exp cuda): Flash Next on four ranks (--tp 4), each rank's sums over the shared rank-sum transports #379); admission counts the host embedding and two staging copies; loading on 32 GB cards
    uses growable segments, one layer read ahead, each expert sliced as it is read and the MTP stacks sliced on the
    host.
  • Four ranks split Flash Next's 640-wide experts 160/160/160/160 instead of 192/192/128/128. The Volta expert kernel
    takes a K that ends in a 32-input half group (packed after the whole groups, nothing stored past K) and the 16-bit
    linears take the same tail, so a share is whole 32-input halves (ranks.UNIT 32; an NVFP4 checkpoint off sm_70
    keeps 64-input groups, ranks.GROUP). Before, ranks 0 and 1 carried 6.5 GiB more than ranks 2 and 3, and the
    startup window was sized off them. The startup estimate uses the same shares. A width whose 64-input groups
    already split evenly (two ranks, 512, 768) gets the same shares and the same kernels, bit for bit. At four ranks
    Flash Next's bits change: each rank's down projections (routed and shared) now sum 160 inputs, so the four
    row-parallel partials and their rank-ordered sum round differently. Drafted, concurrent and serial outputs stay
    equal to each other.

Receipt

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: four
    Tesla V100-PCIE-32GB (sm_70, no P2P) in a VM, power capped at 200 W, host-memory sums; an earlier local branch (0.6.3 +
    the Volta stack + this change). RadixArk/Qwen3.8-Flash-Next-NVFP4 with its own MTP head, 512-token greedy
    replies, 84,559-token window, n-gram tables locked in host memory.

  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: ours (own A/B
    script: 437 check, drafted vs "draft": false, N=2/4/8 vs serial): exact; serial shas identical over host-memory
    sums and NCCL. Upstream's tools: see the v0.6.5 line below.

  • Decode speed before and after, from tools/bench_openai.py: before is a refusal (NVFP4 refused on sm_70). Ours:
    serial 87.6 tok/s (65-107 across prompts); NCCL-only sums 82.1. For scale on the same four cards: llama.cpp with
    the UD-Q4_K_XL GGUF 31.7. One verify window replays as a graph in 28.5 ms (1 row) against 95 ms of eager host
    time. Upstream's tools: see the v0.6.5 line below.

  • Prompt speed before and after, from tools/prefill_cold.py: ours 1,204 / 1,234 tok/s at 6K / 25K (NCCL only
    1,097 / 1,165). Not yet run with upstream's tool on sm_70; GB10 in the v0.6.5 check.

  • On v0.6.5 (this branch as e7645c5, on Qwen3.8-27B on Tesla V100 (sm_70): Volta kernels #264 replayed onto v0.6.5): Mac host suite (M5 Ultra): 5013 passed, 1 failed, 596 skipped. Four Tesla V100s, the Volta CUDA selection: 460 passed, 0 failed, 76 skipped. test_packed_passes_keep_each_prompt_one_token_early fails on pristine v0.6.1 on Jetson AGX Thor (sm_110) #261: qwen4_exp._volta_nvfp4 lets an NVFP4 checkpoint on sm_70 past refuse_small_gpu() (MLX and EXL3 stay refused; host test added); fix(flash next cuda): build the CUDA extensions before the weights load #202's build_kernels loads the sm_70 extensions on Volta. Upstream tools, RadixArk/Qwen3.8-Flash-Next-NVFP4 (its own MTP head) on four V100s, --tp 4 --parallel 1 --context 32768, rank sums through host memory (startup estimate 25.60 GiB within 27.31 GiB): v0.6.5 refuses; here token_sha drafted == "draft": false on three prompts (8fed409c72c9, e45267d01fb8, fc6e2c14272e); --levels 2,4 --alone --serial 0 failed and 0 unequal in all 8 cells (requests queue at --parallel 1); tools/bench_openai.py, sampled / greedy: fibonacci-raw 82.5 / 100.3, gpu-chat 64.5 / 67.0 tok/s.

  • Tests run, with pass, fail and skip counts: Mac host suite on the earlier 0.6.3 version of this branch: 4470 passed, 1 failed, 566 skipped (the one failure, test_glm5_prompt_kernels::test_fused_index_scores_are_the_three_ops, fails on the release too). Ours on sm_70:
    test_flashnext_nvfp4_volta (four ranks as threads: shards == checkpoint slices, drafted == serial greedy and
    sampled, windows == serial steps, repeated runs bit-identical, logits == one GPU to rounding; attention rows alone
    == among others and == the Triton partials to rounding; host rows and the real FP8 n-gram rows exact); four-process
    host sum and DMA gather == NCCL gather + rank-ordered sum.

  • Checked on v0.6.5 (2026-10-04): four Tesla V100s, RadixArk/Qwen3.8-Flash-Next-NVFP4 with its own MTP head, --tp 4 --parallel 1 --context 65536 (startup 26.68 GiB of 27.31), rank sums through host memory: fresh == resumed (2,300 of 2,301 tokens from the prompt cache) == "draft": false, token_sha 13636f359e75; 19 × 23 drafted == "draft": false fc6e2c14272e. New tests on Tesla V100s, this branch's test files copied into the parent's tree, then here: tests/cuda/test_flashnext_nvfp4_loader.py, test_flashnext_nvfp4_volta.py and tests/test_flashnext_cuda_floor_host.py: 7 failed; here 27 passed, 23 skipped. The floor host test without CUDA: 1 failed on the parent's tree, 9 passed here. 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 (this branch): 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).

  • Even expert shares (the second commit; before = e7645c5): four Tesla V100-PCIE-32GB (no P2P), PyTorch 2.10.0+cu128,
    Triton 3.6, CUDA 12.8, RadixArk/Qwen3.8-Flash-Next-NVFP4 with its own MTP head, --tp 4, rank sums through host
    memory, n-gram tables locked in host memory, default context.

    before after
    startup estimate a rank, --context 32768 (GiB) 25.60 / 25.60 / 19.10 / 19.10 22.36 × 4
    startup estimate a rank, default context (GiB, cap 27.31) 27.31 / 27.31 / 20.80 / 20.80 27.31 × 4
    admitted prompt/reply window (native 262,144) 84,559 183,184
    nvidia-smi after the run (MiB) 27,142 / 27,148 / 20,416 / 20,410 25,520 / 25,524 / 25,518 / 25,514

    tools/bench_concurrent.py --levels 4 --alone --serial (code and chat, T=1 and greedy): 0 failed and 0 unequal in
    all 4 cells on both builds (alone 12/12 a cell, serial 4/4 sampled and 1/1 greedy). Requests queue (one at a time
    on four ranks), aggregate tok/s before / after: code T=1 81.4 / 78.3, chat T=1 60.6 / 61.2, code greedy 93.7 /
    91.5, chat greedy 63.7 / 67.2 (one run each, not alternated, so within run-to-run noise). Drafted == "draft": false on three greedy prompts on both builds (after: ac456ed0247c, 71edd1a1ac16, 4785e888d213). The token_sha
    values in the v0.6.5 bullets above were taken at e7645c5, before this commit.

    Same bits where the split did not change: the old and new kernels on the same random weights, experts 512 / 768 /
    192 / 128 wide (1-300 rows) and 16-bit linears 2560×640 to 62080×2560 (decode and prompt paths, 1-2048 rows)
    plus 64-aligned row-parallel shards: 47 of 47 identical.

    Tests on the four V100s, before → after: test_experts_volta + test_qmmf_volta + test_qmm_volta 48 failed,
    127 passed → 175 passed (the 48 are the new ones: widths 160 / 96, K = 160 / 96 / 2592, half-group 16-bit
    shards); test_flashnext_nvfp4_volta + test_flashnext_nvfp4_loader 29 passed, 24 skipped on both (the tiny
    checkpoint's four ranks now 96/96/64/64, with tails); test_qwen27_nvfp4_tp_volta, test_attention_volta,
    test_qwen27_distributed, test_qwen27_nvfp4, test_qwen36_moe 72 passed, 21 skipped on both. All of
    tests/cuda on the V100s: the only difference between the two builds is those 48 tests (the sm_80+ suites fail or
    error the same way on both). Host tests (no GPU): test_flashnext_volta_shares_host 1 failed, 1 passed → 2
    passed; test_flashnext_ranks_host fails to import before (ranks.GROUP), 3 passed after; the rest of the host
    suite on this Linux machine has the same failures on both builds and nothing new.

  • After the rebase onto feat(qwen4_exp cuda): Flash Next on four ranks (--tp 4), each rank's sums over the shared rank-sum transports #379's fix (2026-10-05), four Tesla V100s: test_flashnext_ranks_host (5 passed),
    test_flashnext_volta_shares_host, test_flashnext_nvfp4_volta and test_flashnext_nvfp4_loader: 37 passed,
    23 skipped. Shas quoted above are from before the rebase.

  • Not run, and why: tools/prefill_cold.py on V100s; GB10 and sm_80+ four-GPU machines (the code is gated on sm_70); V100 SXM2 / NVLink not available. The even split (second commit) on GB10 or sm_80+ (four-rank NVFP4 runs only on sm_70), and a Mac host suite run of it (its host changes are ranks.py and the sm_70 branch of the estimate).

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: 7 failed on the parent's tree, 27 passed and 23 skipped here; the floor host test also without CUDA (1 failed before, 9 passed here); test_flashnext_nvfp4_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.

gilby and others added 15 commits October 2, 2026 15:05
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.
…r four ranks

qwen4_exp on Volta (cuda/volta.py):
- bf16 linears (DeltaNet, attention, hyper-connections, PLE projections, MTP fc, the head) as 16-bit VoltaLinear;
  a row-parallel shard keeps the whole matrix's column factors (VoltaLinear.groups).
- Routed NVFP4 experts as VoltaExperts; the bf16 shared expert and the router as 16-bit linears; the planner skips
  picks past the expert table (the shared slot runs on its own). The MTP layer's bf16 experts and the draft head
  quantize to NVFP4 (draft-only), the head in row chunks with the whole weight's global scale.
- The embedding in page-locked host memory (HostRows); the FP8 n-gram tables stay memory-mapped on the host.
- attn_volta.cu: the chunked attention partials (o, m, l) a block a (row, key head, chunk), fp32; Triton has no
  Volta tensor-core path.
- gdn / gdn_io build for sm_70.

The engine takes --tp 4 (and 2) for NVFP4 checkpoints on sm_70; other GPUs keep NVFP4 on one GPU. Admission counts
the host embedding and two staging copies. Loading on 32 GB cards: expandable segments, one layer read ahead, each
expert sliced as it is read, the MTP stacks sliced on the host (reader.host).
Flash Next's sm_120 startup floor lets an NVFP4 checkpoint through on sm_70, which these kernels serve; MLX and
EXL3 checkpoints stay refused there. The extensions built before the weights load are the sm_70 ones.

Tests (sm_70): test_flashnext_nvfp4_volta (four ranks as threads: shards equal checkpoint slices, drafted equals
serial greedy and sampled, windows equal serial steps, repeated runs bit-identical, logits equal one GPU's to
rounding; attention rows alone equal rows among others and the Triton partials to rounding; host rows and the real
FP8 n-gram rows exact). The sm_80+ loader tests skip on sm_70, which builds the Volta faces.
test_flashnext_cuda_floor_host: a Volta passes the floor with an NVFP4 checkpoint and is refused with an MLX one.
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.
--device N (TF_CUDA_DEVICE) makes device N the current CUDA device before an engine loads, in every CUDA engine,
and the unified-memory check reads the current device. Two ranks on one machine can then both see both GPUs and
each run on its own, so their transfers can map the peer GPU. Without the flag nothing changes: device 0.
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.
…ms over a peer mapping

load_nvfp4 takes a per-layer hook, and two ranks split each layer to their shard as it loads, so a rank holds one
full layer at most; admission counts layer tensors halved and no startup copy, where before a rank needed twice
the full checkpoint at startup.

tensorfold.cuda.p2p: when both ranks' GPUs can map each other, a row-parallel sum is one kernel. Each rank stages
its fp32 partial in a cudaIpc buffer the peer has mapped, blocks meet their peer blocks on flags that only grow,
and both ranks add rank 0 + rank 1 in fp32 and round once to bf16: the bits of the gathered rank-ordered sum.
Sums larger than the staging buffer (prompt chunks) keep NCCL; TF_TP_P2P=0 turns the kernel off. Two ranks on
one machine reach it with --device 0 and --device 1.
…e the GPUs cannot map each other

GPUs without a peer mapping (PCIe cards in a VM, where cudaIpcOpenMemHandle fails with
cudaErrorPeerAccessUnsupported) never installed the P2P sum, so every row-parallel sum went through NCCL.
HostSum puts both ranks' staging and flags in one /dev/shm buffer, page-locked and mapped by each GPU
(cudaHostRegister + cudaHostGetDevicePointer); the same kernel writes and reads the partials over PCIe, rank 0 +
rank 1 in fp32, rounded once, so the bits equal the NCCL gather. Waiting blocks poll the host flags with a short
__nanosleep (TF_TP_HOST_SPIN_NS).

install() picks P2P, else host memory when both ranks run on one machine (hostname and boot id), else NCCL;
TF_TP_HOST_SUM=0 keeps NCCL. Startup names the transport.
…m_70

VoltaLinear shards like the sm_80+ linears, every stored word kept:
- outputs(rows): any output columns (a rank's GDN gate rows too), re-tiled from only the 32-output tiles they
  touch, a chunk at a time; equal to the projection built from the checkpoint's rows (codes, e4m3 block scales,
  column factors).
- inputs(rank): whole 64-input groups, an NVFP4 group's block scales with it; 16-bit rows keep their powers of two.
- partial(x): the fp32 product, unrounded, row-count invariant (its bf16 output is it rounded once).
- copy(): the two-rank DFlash2 drafter owns its head rows instead of views of the unsplit head.

The rank-sum extension builds on sm_70, so two V100s without P2P sum through shared page-locked host memory.

Tests: tests/cuda/test_qwen27_nvfp4_tp_volta.py (shards equal the sliced checkpoint, synthetic and real; partials;
the two-rank forward in two threads: windows equal serial steps, runs repeat, prompts ignore chunking);
test_qwen27_nvfp4's two-rank start covers sm_70 too.
… ranks

--tp {1,2,4} and --rank 0..3; ranks past 0 follow rank 0. The 27B engine, its shards (distributed.split_layer and
split_weights, every inputs() shard: NVFP4/FP8 lane, bf16 Plain, VoltaLinear, MLX affine), decode_tp (candidates
merged in rank order), the --parallel decoder and admission (layers split by the rank count) take two or four
ranks. The DFlash2 drafter splits over two ranks only; at four, rank 0 drafts alone with the whole drafter.

p2p: PeerSum and HostSum add every rank's partial in rank order (fp32, one rounding), two to eight ranks; each
block keeps its round in device memory, so a captured sum replays with the next round.

Tests: four-process host-memory sum equals the gathered rank-ordered sum; four-rank shards equal checkpoint slices
(synthetic and the real checkpoint); four-rank windows equal serial steps, repeated runs and chunked prompts are
bit-identical; the CLI takes --tp 4 and --rank 0..3.
…tials by copies through shared host memory

- p2p: the sums install over torch.distributed's group or an engine's own communicator (all_gather, barrier,
  world), with a stage size the caller picks; the sum kernel stages into two buffers by round parity and meets its
  peers once. Partials too large for one launch (prompt chunks) go by DMA copies through the shared page-locked
  buffer (HostSum.gather) and are added in rank order in fp32, the bits of the NCCL gather and rank-ordered sum.
- The 27B engine sizes the stage for a 4,096-row prompt chunk, so prompt sums take the copies instead of NCCL.
- comm: the library found in the pip nvidia-nccl wheel torch depends on.

Tests: the multi-process host-memory test gathers prompt-sized partials by copies and checks them, and every
round's sum, against the NCCL gather plus the rank-ordered add.
…sums over the shared rank-sum transports

- weights: heads split by the rank count (refused by name where they do not divide); key/value heads past the
  rank count are shared, each rank keeping the one its query heads read; expert and shared-expert widths split on
  whole quantization groups (ranks.share: the lower ranks one block more where they do not divide); the MTP
  layer's bf16 experts keep each rank's gate rows and its up rows.
- engine: --tp 1, 2 or 4; rank 0 posts each request to every following rank, settings are gathered from every
  rank, and the rank sums install over the engine's communicator. NVFP4 checkpoints still run on one GPU here;
  --parallel stays on one GPU or two ranks.
- forward: row-parallel branches sum through the installed transport (one launch, or copies for prompt-sized
  partials), NVFP4 bf16 faces return fp32 partials, and prompt partials of an NVFP4 checkpoint are bf16.
- gdn / gdn_io: a rank's share of four (4 key and 12 value heads).
- geometry: admission counts a rank's expert share, shared key/value heads, and bf16 MTP experts as NVFP4.
- n-gram tables are locked only as far as the host's available memory allows on a discrete GPU; read-ahead pins
  host pages on the caller's device.

tests/test_flashnext_ranks_host.py: the shares are whole groups, lower ranks first, and a width that leaves a rank
no group is refused.
gilby added 3 commits October 5, 2026 08:39
… 32-input halves

Flash Next's routed and shared experts are 640 wide. On sm_70 a rank's share was whole 64-input groups, so four
ranks took 192/192/128/128: ranks 0 and 1 held the larger expert stacks, every request had to fit on them, and the
startup window was sized off them.

The Volta expert kernel now takes a K that ends in a 32-input half group (the down projection's K is the share),
packed after the column tile's whole groups with no padding, and the 16-bit linears take the same tail (zero words
past K, the decode kernel stops at K; VoltaLinear.from_bf16 builds a half-group shard with the whole rows' column
factors). ranks.UNIT is 32, so four ranks take 160 each; a width whose 64-input groups already split evenly gets
the same shares and the same kernels, bit for bit. An NVFP4 checkpoint off sm_70 keeps 64-input shares
(ranks.GROUP). The startup estimate gives every rank the same share and counts sm_70's 16-bit shared down shard in
whole 64-input groups, as it loads.

Exactness is unchanged: the K split and the tail depend on the weight's shape only.

Tests: test_experts_volta (widths 160 and 96: pairs match the fp32 reference and never depend on the other pairs;
160-wide experts store no padding), test_qmmf_volta (K = 160, 96, 2592 in NVFP4 / FP8 / 16-bit: row-count
invariant, stored values exact, decode and prompt rows match fp32; half-group 16-bit shards are the rows' slices
with the whole rows' column factors), test_flashnext_nvfp4_volta (the tiny checkpoint's four ranks now 96/96/64/64,
with tails), test_flashnext_ranks_host (shares in halves, 64-input shares as before) and
test_flashnext_volta_shares_host (the estimate gives four ranks equal shares).
…read

With 2 key/value heads over 4 ranks, the MLX loader's attention sliced kv_heads // world = 0 heads a rank, so
every rank's k and v projections were empty. It now takes the same shared head as the NVFP4 loader: one head a
rank where the heads do not divide, head rank * kv_heads // world.

tests/test_flashnext_ranks_host.py: load() of a one-layer checkpoint as each rank of 2 and of 4 keeps whole k/v
rows of the right head.
…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.
@ashhart

ashhart commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @gilby. Getting Flash Next onto V100s at one GPU or four, then evening the expert split to 160 a rank with a 32-input half group at the tail instead of leaving two ranks 6.5 GiB heavier, is careful engineering. Keeping the NVFP4 quantization to draft-only weights, so replies stay exact, was the right line to draw.

The Python engine is frozen (#286), so this won't merge. Flash Next runs on the Zig engine on Metal, and Zig CUDA builds only for GB10 today, so this waits for Zig CUDA to take Flash Next, ranks and an sm_70 target. When it does, this stack is where Volta 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