[Common] row-scaled nvfp4 path: add single-launch group fused amax - #3467
Open
cael-ling wants to merge 3 commits into
Open
[Common] row-scaled nvfp4 path: add single-launch group fused amax #3467cael-ling wants to merge 3 commits into
cael-ling wants to merge 3 commits into
Conversation
Compute per-expert rowwise/columnwise amax over a packed (sum_M, K) grouped input in one kernel launch instead of one launch per expert, exposed via nvte_group_nvfp4_compute_amax and gated by NVTE_NVFP4_FUSED_AMAX. Adds a gtest that checks the result against a CPU reference and across launches. Signed-off-by: Cael Ling <caell@nvidia.com>
for more information, see https://pre-commit.ci
Contributor
Greptile SummaryThe PR adds a public grouped NVFP4 amax operation that computes per-expert rowwise and columnwise maxima from a packed BF16 input using one CUDA launch.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the trailing-column truncation is prevented by explicit alignment validation, and nullable per-expert amax buffers are guarded before every zeroing or atomic-write access. Important Files Changed
Reviews (2): Last reviewed commit: "[Common] Enforce K alignment and per-exp..." | Re-trigger Greptile |
…VFP4 amax The public entry point calls the launcher directly, bypassing the eligibility check, so misaligned K silently dropped trailing columns and heterogeneous per-expert amax buffers could dereference null. Add a column/split alignment check in the launcher, take do_row/do_col as the union over experts with a per-expert null guard in the kernel, and cover it with HeterogeneousColumnwise. Signed-off-by: Cael Ling <caell@nvidia.com>
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.
Description
Adds a single-kernel row/col amax pass for grouped (MoE) row-scaled NVFP4. It replaces the per-expert loop of
compute_rowwise_amax+compute_columnwise_amaxwith one launch over a packed(sum_M, K)input, exposed asnvte_group_nvfp4_compute_amax. The kernel is the grouped generalization of #3454 - the single-tensorcompute_fused_amax_kernel(same tiling / SMEM pipeline / acquire-barrier reduction). A single input TMA map covers all experts; per-expert amax vectors are selected via a prefix sum of row counts, so a 128-row chunk always lands in one expert.Type of change
Changes
New gtest
tests/cpp/operator/test_row_scaled_nvfp4_grouped_amax.cu:NVFP4GroupedRowScaledAmaxTestSuite.MatchesPerExpertOracle— grouped amax vs a CPU per-row/per-colmax(|x|)reference over the same BF16 bytes, plus cross-launch determinism, across 6 expert/shape configs.DISABLED_LoopVsGrouped— microbench comparing the same kernel called per-expert (loop)vs once (grouped).
Performance
Same kernel called per-expert (loop) vs a single grouped launch, GB200, K=4096. Speedup is loop / grouped.
Checklist: