Skip to content

[Dispatch Creation] Rework dispatch formation logic#21854

Merged
IanWood1 merged 4 commits into
iree-org:mainfrom
IanWood1:rework_dispatch_creation_logic
Sep 16, 2025
Merged

[Dispatch Creation] Rework dispatch formation logic#21854
IanWood1 merged 4 commits into
iree-org:mainfrom
IanWood1:rework_dispatch_creation_logic

Conversation

@IanWood1
Copy link
Copy Markdown
Member

@IanWood1 IanWood1 commented Sep 5, 2025

Rework FormDispatchRegions to ensure that all outer parallel loops in a dispatch are compatible. The previous implementation did this by ensuring that the producer/consumer's maps were identity along the root op's parallel dimension. However, this breaks down for a generalized DAG dispatch (and requires interchanging indexing maps during the analysis).

This change uses input/result indexing maps to track how the root ops outer parallel loops map to each fused operation. Importantly, when a new op is added to the dispatch, all uses/definitions already in the dispatch are used to ensure a single mapping from root to the new op.

Closes #20019

@IanWood1 IanWood1 force-pushed the rework_dispatch_creation_logic branch 5 times, most recently from 705ee20 to 716fadf Compare September 8, 2025 22:48
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
@IanWood1 IanWood1 force-pushed the rework_dispatch_creation_logic branch from 716fadf to 4bb53e9 Compare September 9, 2025 18:38
@IanWood1 IanWood1 marked this pull request as ready for review September 9, 2025 19:53
Copy link
Copy Markdown
Collaborator

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading through, did the easy part first, but I still have to understand the FusionTracker object. leaving some comments before I do that.

Comment thread compiler/src/iree/compiler/DispatchCreation/FormDispatchRegions.cpp
Comment thread compiler/src/iree/compiler/DispatchCreation/FormDispatchRegions.cpp
Copy link
Copy Markdown
Collaborator

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok did a first pass of the review. Looks really good so far. Have a few question though.

Comment thread compiler/src/iree/compiler/DispatchCreation/FormDispatchRegions.cpp Outdated
Comment thread compiler/src/iree/compiler/DispatchCreation/FormDispatchRegions.cpp
!consumerOperandMap.isProjectedPermutation()) {
return failure();
}
AffineMap inverseMap =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding some comments here of this form

  1. producerMap is a map from (producerIterationSpace) -> (operand data space)
  2. consumerMap is a map from (consumerIterationSpace) -> (operand data space)
  3. inverseMap is a map from (operand data space) -> (producerIterationSpace)
  4. composedMap is a map from (producerIterationSpace) -> (consumerIterationSpace)

So now I am not sure I follow what the composedMap.compose(producerMap) is doing

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Copy link
Copy Markdown
Collaborator

@MaheshRavishankar MaheshRavishankar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some more comments that I dont think have been addressed yet. So not reviewing again. please signal when its ready for review again. (No hurry)

@IanWood1
Copy link
Copy Markdown
Member Author

I had some more comments that I dont think have been addressed yet. So not reviewing again. please signal when its ready for review again. (No hurry)

I thought that I had addressed all comments (but forgot to mark them as resolved). If I missed some could you point me to them?

@MaheshRavishankar
Copy link
Copy Markdown
Collaborator

I had some more comments that I dont think have been addressed yet. So not reviewing again. please signal when its ready for review again. (No hurry)

I thought that I had addressed all comments (but forgot to mark them as resolved). If I missed some could you point me to them?

I unresolved them, but specifically #21854 (comment) and #21854 (comment)

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
@IanWood1 IanWood1 enabled auto-merge (squash) September 16, 2025 19:00
@IanWood1 IanWood1 merged commit 7dbbb6f into iree-org:main Sep 16, 2025
38 of 44 checks passed
@MaheshRavishankar
Copy link
Copy Markdown
Collaborator

Nice cleanup! Lets see if it breaks anything :)

@amd-vivekag
Copy link
Copy Markdown
Contributor

amd-vivekag commented Sep 22, 2025

Hi @IanWood1 ,

This change has introduced a regression and is currently blocking IREE pin version bump : nod-ai/amd-shark-ai#2205.

Created an issue for the same: #22055

Is it possible to get the fix for this ? If not, can you please revert the change?

cc: @IanNod , @MaheshRavishankar

IanWood1 added a commit that referenced this pull request Sep 22, 2025
IanWood1 added a commit to IanWood1/iree that referenced this pull request Sep 22, 2025
IanWood1 added a commit to IanWood1/iree that referenced this pull request Sep 22, 2025
…#21854)"

This reverts commit 7dbbb6f.

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
IanWood1 added a commit that referenced this pull request Sep 22, 2025
…#22058)

This reverts commit 7dbbb6f.

Causing codegen issues in #22053
#22055

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
bangtianliu pushed a commit to bangtianliu/iree that referenced this pull request Sep 22, 2025
Rework FormDispatchRegions to ensure that all outer parallel loops in a
dispatch are compatible. The previous implementation did this by
ensuring that the producer/consumer's maps were identity along the root
op's parallel dimension. However, this breaks down for a generalized DAG
dispatch (and requires interchanging indexing maps during the analysis).

This change uses input/result indexing maps to track how the root ops
outer parallel loops map to each fused operation. Importantly, when a
new op is added to the dispatch, all uses/definitions already in the
dispatch are used to ensure a single mapping from root to the new op.


Closes iree-org#20019

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
IanWood1 added a commit to IanWood1/iree that referenced this pull request Sep 23, 2025
…g#21854)" (iree-org#22058)

This reverts commit 087d5b9.

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
IanWood1 added a commit to IanWood1/iree that referenced this pull request Oct 6, 2025
…g#21854)" (iree-org#22058)

This reverts commit 087d5b9.

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
IanWood1 added a commit that referenced this pull request Oct 10, 2025
#22065)

Re-land dispatch creation changes with an additional check to make sure
that the number of parallel/reduction iterators match (only when fusing
reductions together) and that they are not permuted. This fixes the
issues in #22053 and #22055 that caused the revert.

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
weidel-p pushed a commit to weidel-p/iree that referenced this pull request Oct 21, 2025
…g#21854)" (iree-org#22065)

Re-land dispatch creation changes with an additional check to make sure
that the number of parallel/reduction iterators match (only when fusing
reductions together) and that they are not permuted. This fixes the
issues in iree-org#22053 and iree-org#22055 that caused the revert.

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Signed-off-by: Philipp <philipp.weidel@intel.com>
pstarkcdpr pushed a commit to pstarkcdpr/iree that referenced this pull request Nov 28, 2025
…g#21854)" (iree-org#22065)

Re-land dispatch creation changes with an additional check to make sure
that the number of parallel/reduction iterators match (only when fusing
reductions together) and that they are not permuted. This fixes the
issues in iree-org#22053 and iree-org#22055 that caused the revert.

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DispatchGeneration] Can we fuse two linalg.generic into one dispatch?

3 participants