Repository navigation
Fix per-group norm constant indexing in block-scale-factor epilogue stores (grouped/ptr-array GEMM) - #3392
Merged
Conversation
…tores For ptr-array/grouped GEMM the batch coordinate l is zeroed after selecting the per-group SFD pointer, but the norm constant lookup reuses l afterwards, so every group encodes with group 0's norm constant. Capture the group index before the zeroing and use it for the norm constant lookup. Signed-off-by: David Kogan <[email protected]>
Collaborator
|
the fix makes sense to me. + @hwu36 |
hwu36
approved these changes
Jul 18, 2026
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.
Summary
In the block-scale-factor epilogue store visitors, the per-group norm constant is
never read on the grouped (ptr-array) path: every group's SFD tensor is encoded
with group 0's norm constant, regardless of the
dNormConstbatch stride.This PR fixes the SM120 visitor (validated on hardware, reproducer below). The
same pattern exists in the SM100 visitor; a pattern-identical companion hunk is
included, compile-verified only.
Affected files:
include/cutlass/epilogue/fusion/sm120_visitor_store_tma_warpspecialized.hpp(
Sm120BlockScaleFactorRowStore::get_consumer_store_callbacksandSm120BlockScaleFactorColStore::get_consumer_store_callbacks)include/cutlass/epilogue/fusion/sm100_visitor_store_tma_warpspecialized.hpp(the two analogous overloads; companion, compile-verified)
Mechanism
For ptr-array / grouped GEMM with a
BlockScaleFactorper group, the visitorselects the group's SFD pointer and then zeroes the batch coordinate, because
each group's SFD tensor has no batch mode:
The norm-constant lookup executes about 20 lines later and reuses the zeroed
l:With
dNormConst = {_0, _0, 1}every group readsnorm_constant_ptr[0]; theper-group stride has no effect. Group
g's dequantized output is then mis-scaledby exactly
c_0 / c_g.The fix captures the group index before it is zeroed and uses it for the
norm-constant lookup only. The SFD indexing keeps the zeroed
l, which iscorrect:
Per-group norm constants are used in MoE-style grouped GEMMs with FP4 output.
Each expert carries its own scaling constant.
No in-tree example exercises per-group norm constants: the SFD-generating
examples use a single shared constant (size-1 allocation, e.g.
examples/92_blackwell_moe_gemm), where the zeroed index is coincidentallycorrect.
Reproducer
Attached standalone program (
blockscaled_grouped_norm_const_repro.cu): a4-group NVFP4 grouped GEMM (
Sm120,KernelPtrArrayTmaWarpSpecializedPingpong,LinCombBlockScaleFactorepilogue, FP4 D + ue4m3 SFD). All groups get identicalA/B inputs and unit SFA/SFB, but distinct norm constants c = {1.0, 1.2, 1.4, 1.6}.
Dequantizing each group's FP4+SFD output with its own constant is compared
against a host fp32 reference.
Before this change (main @ d01487d):
After this change (same machine, same tree plus patch):
cos of about 0.9955 is the expected e2m1 plus e4m3 block-scale quantization
floor either way; the bug shows up in the norm-ratio column.
Testing done
Hardware: GB10 (DGX Spark), sm_121a. CUDA 13.1. Driver 580.95.05. Tree: main @ d01487d.
share this epilogue path. The single-constant case (group 0) is unchanged.
examples/75_blackwell_grouped_gemm/75_blackwell_grouped_gemm_block_scaled.cuwith the "Enable for SF Output" lines enabled for
sm_100a, before and afterthe change. I do not have SM100 hardware. If you would rather take the SM100
change through a separate PR, I can remove those hunks from this one.
l_norm_const == lthere byconstruction.
test/unit/gemm/device/sm120 case during review if wanted.cc @yzhaiustc
blockscaled_grouped_norm_const_repro.cu (standalone reproducer)