Repository navigation
Fix tdm iterate oob - #10935
Merged
Merged
Fix tdm iterate oob#10935
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #10935 +/- ##
===========================================
- Coverage 69.35% 69.34% -0.01%
===========================================
Files 2777 2777
Lines 457906 458002 +96
Branches 67515 67536 +21
===========================================
+ Hits 317548 317561 +13
- Misses 117224 117302 +78
- Partials 23134 23139 +5
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
jichangjichang
left a comment
Contributor
There was a problem hiding this comment.
Please add the test cases
jichangjichang
approved these changes
Aug 19, 2026
Contributor
Author
I'll add test in other PR. |
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.
JIRA ID: AIHPBLAS-4308
AIHPBLAS-4308
Motivation
TDM iterate mode (
iterate_enable) repeats one fetch and advances the global addressbetween repeats. The number of repeats was a compile-time constant sized for a full
tile, so a workgroup landing on a partial tile kept walking past the end of the tensor
and issued out-of-bounds reads.
Technical Details
Derive the iteration count at runtime from the rows the wave actually holds
(
size - MacroTile * workgroupId, capped at what one issueLoad covers) instead of acompile-time constant.
_emitTdmIterCountfolds the-1the field encodes into thedivide; the clamp to 1 precedes the subtract so an empty wave still gets its one walk
without the subtract wrapping.
Narrow the descriptor's
dim1to the same row count. The wave-separated path alreadydid this; the non-wave-separated path left the whole tensor extent there.
TDMSplit issues two loads from one descriptor with the base advanced between them, so
the second load gets its own count (
_emitTdmSplitIterCount). In wave-separated modeA and B share an aliased descriptor and both parities read it, so the parity that is
not in iterate mode is explicitly given zero.
_tdmIterDivMagicsupplies an exhaustively validated multiply-shift pair for anon-power-of-two
tile_dim1. The shared helper in rocisa overflowsintfordivisor 3, so it cannot be used here.
Reject
TDMIterateModeon a tensor whoseTLUis true. The walk steps along the tiledimension, which is what
dim1carries only when the tensor is unroll-major in globalmemory;
TransposeLDS: 2setsUnrollMajorLDSwithout that being true.The walk steps a whole
tile_dim1rows at a time, so a wave left with a row count thatis not a whole number of steps still overruns on its last step. Raise
AssertFree{0,1}ElementMultipletolcm(current, tile_dim1)on iterate kernels, whichbecomes a
Free0/1SizeMultiplepredicate at runtime, so those sizes select a differentkernel instead. Reject outright when
MacroTileitself is not a multiple oftile_dim1.Test Plan
tox
Test Result