fix(gdn): use block-end decay for SM100 state updates - #4311
Merged
Merged
Conversation
This comment was marked as low quality.
This comment was marked as low quality.
Contributor
📝 WalkthroughWalkthroughThe Blackwell chunked kernel now reads cumulative decay from the final physical chunk slot. A regression test covers prefill sequences that end at and across block boundaries, comparing outputs and final states with the blockwise reference. ChangesChunked decay indexing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
guangyunh-nv
force-pushed
the
fix_sm100_gdn_block_end_decay
branch
from
August 1, 2026 12:04
c55e9ad to
748b43b
Compare
cloudhan
reviewed
Aug 1, 2026
| @@ -171,6 +171,67 @@ def _test_prefill_kernel( | |||
| torch.testing.assert_close(our_state, ref_state, atol=atol_kv, rtol=rtol_kv) | |||
|
|
|||
|
|
|||
| @torch.inference_mode() | |||
| def test_prefill_sm100_block_end_decay(qkv_factory, seed=0): | |||
| _skip_if_not_sm100() | |||
There was a problem hiding this comment.
Other archs should also be checked. Relax it.
guangyunh-nv
force-pushed
the
fix_sm100_gdn_block_end_decay
branch
2 times, most recently
from
August 1, 2026 12:21
d09d18b to
451d3c2
Compare
guangyunh-nv
force-pushed
the
fix_sm100_gdn_block_end_decay
branch
from
August 1, 2026 12:30
451d3c2 to
9fe43e5
Compare
guangyunh-nv
marked this pull request as ready for review
August 1, 2026 13:20
guangyunh-nv
requested review from
bkryu,
jiahanc,
kahyunnam,
yongwww and
yzh119
as code owners
August 1, 2026 13:20
This comment was marked as low quality.
This comment was marked as low quality.
Observer007
approved these changes
Aug 3, 2026
Collaborator
|
/bot run tests/gdn |
Collaborator
6 tasks
19 tasks
2 tasks
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
Root cause
PR #4133 replaced the fixed block-end lookup with an index derived from the last coordinate in each thread's partitioned accumulator fragment:
That max_coord coordinate is thread-dependent. Its second coordinate is:
Representative output:
The fix directly loads the block-end scalar:
This remains correct for a partial block. The gate loader predicates out-of-bounds elements after initializing them to the multiplicative identity
1.0. Their log2 contribution is therefore zero, so the inclusive prefix product remains constant after the final valid token and slotBT - 1contains the product over exactly the valid block.Reproduction
The regression test uses FP16, sequence lengths
[64, 111, 192], one head, normalized K, and alpha/beta sampled from[0.99, 1.0). These lengths cover one full block, a non-multiple tail with recurrent carry, and three aligned blocks.6258e522)5.80e-40 / 469762.28e-40 / 49152f057e15b)1.59e-21660 / 469761.01e-26361 / 491525.80e-40 / 469762.28e-40 / 49152Validation
Result:
1 passedon SM100 with CUDA 13. The test now collects on SM90, SM100, and SM12x so architecture CI covers the shared contract.Summary by CodeRabbit
Bug Fixes
Tests