Skip to content

cuda: grouped NVFP4 experts behind experts.Grouped (decode rows); prompt rows refused until a staged kernel takes them - #629

Merged
ashhart merged 2 commits into
ashhart:mainfrom
jschmied:cuda-nvfp4-experts-grouped
Oct 10, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
jschmied:cuda-nvfp4-experts-grouped

Conversation

@jschmied

@jschmied jschmied commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Grouped NVFP4 experts behind experts.Grouped, as agreed with @Bizuayeu in #548. Decode rows run on nvfp4/experts.cu, and Grouped.prompt refuses NVFP4 until their staged prompt kernel takes those rows. Stacked on #605; this PR's own commit is the last one. Rebased on main 9041e20a with #605; the receipts below hold after the rebase.

  • cuda/experts.zig:
    • Format gains nvfp4. Layer documents its tables: [E][NI/32][D/32][2][144] int32 blocks for gate and up, [E][D/32][NI/32][1][144] for down, and per-expert global scales.
    • Nvfp4Experts (load, run, packOne, packGateUp) carries the Python packing (_pack's nibble order and scale bytes) and the three epilogues (SwiGLU gate-up, down to fp32, down to bf16 sums).
    • Grouped.decode dispatches to it. Grouped.prompt returns error.PromptFormNotBuilt for NVFP4.
  • zig/kernels/cuda/nvfp4_experts.cu: the device code of nvfp4/experts.cu, and the nvfp4_experts fatbin.
  • tf-cuda-test nvfp4-experts <dir> with oracle/nvfp4_experts.py: the packing and global scales, the plan, then up and down through Grouped.decode, with a blocking stream and outputs filled before each call. The 300-row case runs the decode form with bf16 sums, as nvfp4/experts.py does for prompt rows today, and also checks that Grouped.prompt refuses.

Receipts on GB10 (DGX Spark, sm_121, CUDA 13.0), this branch built with nvcc for sm_121:

… experts route through it, block-FP8 experts join
…mpt rows refused until a staged kernel takes them
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @jschmied. This is merged into main (a43975e) on top of #605 and #595, your commit as it was, and it ships in 1.0.6. The GB10 gate is the one in #595: Nemotron's paths unchanged with nvfp4_experts added to the kernel set, every served reply and release prompt equal to main's. Our bcc1e43 drops oracle/nvfp4_experts.py for the same reason as the other oracles (it imports the Python engine), and tf-cuda-test nvfp4-experts reads recorded fixtures.

Refusing NVFP4 in Grouped.prompt until @Bizuayeu's staged kernel lands is the right call. Until then we'll run NVFP4 prompt rows through the decode form with bf16 sums, as the Python engine does, when we wire NVIDIA's NVFP4 Nemotron checkpoint.

@Bizuayeu

Bizuayeu commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Thanks, @jschmied. This is the entry point we were waiting for in #548. #641 puts the staged NVFP4 prompt kernel behind Grouped.prompt, stacked on this branch. Its prompt rows are byte-equal to the BIZ 2.x engine's experts_prompt.cu on both of your fixture shapes (staged 64, 300 and 1,000 rows; up, and down in bf16 and fp32). It is 2.0–3.2x faster than the decode form on 2,048-row chunks at GLM's widths. Your decode cases still pass on that build.

@Bizuayeu

Copy link
Copy Markdown
Contributor

Update: #641 is closed. By the time it opened, main already had a staged NVFP4 prompt kernel (a6aa478); I'd missed @ashhart's note in #548. The comparison on GLM's real experts continues there: #548 (comment)

@jschmied
jschmied deleted the cuda-nvfp4-experts-grouped branch October 11, 2026 17:36
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… (decode rows)

Thanks @jschmied.

# Conflicts:
#	zig/tests/cuda/main.zig
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