Repository navigation
[Core] Compute grouped NVFP4 RHT member offsets in 64 bits - #3977
Open
ArchanaChetan07 wants to merge 1 commit into
Open
ArchanaChetan07 wants to merge 1 commit into
ArchanaChetan07 wants to merge 1 commit into
Conversation
The graph-safe grouped row/column RHT cast fusion finds the member of each N tile from the element offset of the tile's first row, `row * M`. The per-tile lookup multiplied two ints, so from 2**31 elements on the offset overflowed, the member search ran past every offset, and rows from element 2**31 to the start of the last member were quantized with the last member's amax (rowwise and columnwise). The initial lookup multiplied in 32-bit unsigned arithmetic and wrapped at 2**32. Form the offset as size_t, the type get_current_tensor_id takes, at all four lookups. Register usage of the kernel is unchanged. Add a grouped quantization test whose middle member spans element 2**31 and is followed by a member with a different scale; every member must match quantizing it alone, bit for bit. Fixes NVIDIA#3971. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: ArchanaChetan07 <apatil@sandiego.edu>
ArchanaChetan07
marked this pull request as ready for review
December 1, 2026 20:55
Contributor
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryComputes grouped NVFP4 member offsets in 64 bits at all four RHT quantization lookups.
ArchanaChetan07 explicitly deferred the separate limit above Reviews (1) · Last reviewed commit: "[Core] Compute grouped NVFP4 RHT member ..." · Reviewed by Greptile |
This branch has not been deployed
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
The graph-safe grouped row/column RHT cast fusion (
graph_safe_group_row_cast_col_hadamard_transform_cast_fusion.cu) finds the member tensor of each N tile from the element offset of the tile's first row,row * M. That product was computed in 32 bits:int * int, overflowing from 2^31 elements on.get_current_tensor_idthen searched past every member offset and returned the last member, so rows from element 2^31 up to the start of the last member were quantized with the last member's amax;uint32_tarithmetic, wrapping at 2^32 (overwritten by the per-tile lookup today, but wrong for the same reason).This PR applies the fix proposed by @HuiyingLi in the issue (verified there on GB300 up to just below 2^32 elements): it forms the offset as
size_t(the typeget_current_tensor_idalready takes) at the two per-tile sites, extends it to the two initial lookups for consistency, and adds a regression test.Out of scope: the separate limit above 2^32 elements reported in the issue, which also affects the non-grouped path and
te.Linearand so lies outside this kernel.Fixes #3971
Type of change
Changes
static_cast<size_t>(row) * Mat the fourget_current_tensor_idcall sites.test_grouped_tensor_nvfp4_above_int32_elementstotests/pytorch/nvfp4/test_nvfp4_group_quantize_graph_safe.py: a 270,336 × 8,192 BF16 input split [131072, 139136, 128] with member scales [4, 0.25, 1], so the middle member spans element 2^31 and is followed by a member with a different amax. Every member must match quantizing it alone, bit for bit (amax, data and scales, rowwise and columnwise). Skips with less than 16 GiB free.Validation
sm_100awith CUDA 13.0 (nvcc -O3 --expt-relaxed-constexpr), no warnings.__launch_bounds__(512, 1)). SASS grows by ~26 instructions per instantiation (73,696 → 74,312 total), from the wide multiply and 64-bit compare in the once-per-tile member lookup, outside the quantization inner loop.tests/pytorch/nvfp4suite on a Blackwell GPU (TODO before marking ready).Checklist:
🤖 Generated with Claude Code