Repository navigation
[S-TIR][Schedule] Reject loop_partition on a reduction loop of a block with init - #20858
Open
cchung100m wants to merge 3 commits into
Open
cchung100m wants to merge 3 commits into
cchung100m wants to merge 3 commits into
Conversation
cchung100m
force-pushed
the
issue-20823
branch
from
October 30, 2026 14:52
9a7bbd1 to
013c5b5
Compare
cchung100m
marked this pull request as ready for review
October 30, 2026 17:42
…tring and point to decompose_reduction as the workaround
cchung100m
force-pushed
the
issue-20823
branch
from
October 31, 2026 06:45
f48a890 to
545093b
Compare
Contributor
Author
|
Hi @tlopex @spectrometerHBH @swjng |
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.
Hi Committers,
This PR fixes issue #20823. Any suggestions would be appreciated if you are available.
Root Cause
loop_partitionclones the loop body once per partition.BlockMutatorupdates the iter-var domains and the read/write regions of each clone, but leavesblock->inituntouched. When the partitioned loop binds a reduction iter of a block that has an init statement, every partition keeps its ownwith T.init(): S[v_i] = 0. The second partition therefore resets the accumulator, and only the last partition's contribution survives:expected [45, 145, 245, 345] get [24, 54, 84, 114]
The primitive had no check for this case, so the wrong result was produced silently.
Solution
LoopPartitionnow rejects the unsafe case with aScheduleError.PartitionReductionWithInitErrorinsrc/s_tir/schedule/primitive/loop_transformation.cc. It walks the blocks under the loop and raises when a block with aninithas akCommReduceiter whose binding expression uses the loop var. Composite bindings(for example,ko * 5 + kior a fusedi * 10 + k) are detected as well.initare unaffected.loop_partitiondocstring and point todecompose_reductionas the workaround.I chose rejection over keeping the init only in the first partition because the first partition is guarded by
extent > 0and fused bindings make it hard to tell which partition owns the init.