Repository navigation
Fix constant row indices for TMA gather and scatter - #3365
Conversation
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Row-index normalization and compile test tilelang/language/copy_op.py, testing/python/language/test_tilelang_language_tma_gather_scatter.py |
Both APIs convert integer row indices to int32 TIR constants and leave other values unchanged. A CUDA compute capability 10 test compiles gather and scatter with constant rows and checks that the generated source contains gather4 and scatter4 operations. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related PRs
- tile-ai/tilelang#3685: Adds CuTeDSL TMA gather4 and scatter4 operations and tests row ordering and write behavior.
Suggested reviewers: yongqi-zhuo, leiwang1999
Merge Risk: 
Minimal · up to 6aa33
-
No actionable merge-blocking issue is identified in this change.
Security architecture risk: 
Minimal · up to 2e4b4
-
This is a narrow input-compatibility fix. Existing buffer checks and caller synchronization responsibilities remain intact, and no material security risk was identified in the changed behavior.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The identified change affects the representation of caller-supplied row indices for operations on caller-supplied buffers. The inspected test adds fixed literal indices rather than a new externally supplied input channel or privileged execution endpoint.
Trust Boundaries and Controls
- observed — Both operations retain checks for buffer types and memory scopes, rank-two tensors, matching dtypes, four-row shared tiles, unit inner global stride, and exactly four row indices. Integer normalization does not replace these checks.
-
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title "Fix constant row indices for TMA gather and scatter" matches the main change. The PR converts Python integer row indices to int32 TIR constants in the gather4 and scatter4 helpers, and adds a Blackwell-gated compile test for both operations. The title is specific and describes the primary fix. It does not mention the test addition, which is expected for a title.
Full details: Linked Issues check
-
Explanation
Directly linked issue
#2601requires that constant row indices in T.tma_gather4 and T.tma_scatter4 either compile or raise an actionable error. The reported crash occurs in LowerBulkGather4. The issue states that the only difference between a crash and a clean lowering is whether each rows element is a constant or a tensor-loaded value. The diff at head changes both frontend helpers. Each Python int row becomes tirx.const(row, dtype="int32") before the annotation is built. Non-int rows pass through unchanged. The count check for exactly four rows still follows. The change since the previous review only inlines the former normalization helper. Its behavior is the same. The added test, test_gather_scatter_constant_rows_compile, compiles a kernel with literal rows [5, 17, 42, 9] for both operations. It asserts that the generated source contains tma_load_gather4 and tma_store_scatter4. The test is gated to CUDA compute capability 10 and below 11. The PR reports that the test did not run. The crash mechanism is inferred from the issue analysis and was not reproduced here. The code evidence shows that constant rows now reach the lowering path as int32 TIR objects. This addresses the reported trigger. The issue does not require runtime numeric validation, so that is not assessed.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR diff from the merge base changes two files. In tilelang/language/copy_op.py, the row normalization in tma_gather4 and tma_scatter4 changes. In testing/python/language/test_tilelang_language_tma_gather_scatter.py, one program helper and one compile test are added. Both changes directly support issue
#2601. No unrelated behavior, refactoring, or files appear in the diff. The inlining since the previous review does not change behavior and does not add scope.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Autopilot is currently an internal CodeRabbit preview.
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 @coderabbitai help to get the list of available commands.
LeiWang1999
left a comment
There was a problem hiding this comment.
A small simplification to the row normalization.
Summary
Fixes #2601.
Validation
Summary
int32TIR constants intma_gather4andtma_scatter4. Other row expressions remain unchanged.#2601. The new test checks compilation, not runtime numeric correctness.Validation
git diffchecks reportedly pass.fcntl, so the TileLang test did not run.