Repository navigation
[Common] row-scaled nvfp4 path: add single-launch group fused amax - #3467
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
|
…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>
group_fused_amax_supported was never called (the C API calls the launcher directly and alignment checks already live there), and it carried the NVTE_NVFP4_FUSED_AMAX switch. Remove the dead function and its now-unused <cstdlib>. Signed-off-by: Cael Ling <caell@nvidia.com>
|
/te-ci core |
|
/te-ci core |
|
/te-ci core |
| void nvte_group_nvfp4_compute_amax(const NVTETensor input, NVTETensor *outputs, | ||
| const size_t *split_sections, size_t num_tensors, | ||
| cudaStream_t stream); |
There was a problem hiding this comment.
This function name does not mention row-scaled NVFP4 and the API is natural for both
tensor-scaled NVFP4 and row-scaled NVFP4. We only support row-scaled NVFP4 currently, so we should add an internal check to error out if tensor-scaled NVFP4 tensors are provided. The docs mention that this is specific to row-scaled NVFP4, but that's very flimsy.
There was a problem hiding this comment.
Also, this API is redundant with nvte_group_amax:
There was a problem hiding this comment.
#3649 deprecates this function in favor of nvte_group_amax.
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: