Fix IMA caused by OOB lanes in varlen indexer top-k#410
Open
hxbai wants to merge 1 commit into
Open
Conversation
Signed-off-by: Hongxiao Bai <hongxiaob@nvidia.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe varlen top-k kernel now excludes vector-tail padding from histogram construction, index collection, and refinement. A CUDA regression test verifies that negative-infinity padding does not affect returned indices or selected values. ChangesVarlen top-k padding handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
hxbai
marked this pull request as ready for review
July 20, 2026 09:45
Collaborator
|
@cudnn-ci-bot run |
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.
Before submitting
pre-commit runand committed any formatting changes.Affected area
Summary
Fix the varlen indexer top-k kernel so that out-of-bounds lanes from predicated vector loads do not participate in radix histogram construction or candidate collection.
The change applies the existing vector-lane bounds predicate during:
A regression test covers rows where the valid input prefix contains fewer finite values than
top_k, making the top-k threshold-inf.Why
The kernel uses predicated vector loads and fills out-of-bounds register lanes with
-inf. However, those lanes were still counted in the radix histogram and could subsequently be collected as top-k candidates.When the real top-k threshold was also
-inf, the kernel could not distinguish valid in-range-infvalues from the synthetic OOB values. This produced thousands of invalid candidates, overflowed the per-row extra buffer, and resulted in an illegal memory access.Filtering candidates by their logical input index fixes the issue while preserving valid top-k semantics for real in-range
-infvalues.Related issues
None.
API and compatibility impact
None. There are no public API or input-contract changes.
The kernel now excludes internal OOB vector lanes from top-k selection. Valid in-range values, including
-inf, retain their existing top-k semantics.Testing
Tested on an NVIDIA B200 (SM100) with CUDA launch blocking enabled.
python -m pytest -q --tb=short fe_api/dsa/test_DSA_indexer_top_k.py5 passed(633, 768)float32seq_lens=633top_k=512git diff --checkSummary by CodeRabbit
Bug Fixes
Tests