Skip to content

[VectorDistribution]reduction support along LLVMGPUVectorDistribute pipeline - #18519

Closed
bangtianliu wants to merge 7 commits into
iree-org:mainfrom
bangtianliu:reduction_vectordistribute
Closed

bangtianliu wants to merge 7 commits into
iree-org:mainfrom
bangtianliu:reduction_vectordistribute

Conversation

@bangtianliu

@bangtianliu bangtianliu commented Sep 13, 2024 •

Copy link
Copy Markdown
Contributor

Adding support for Linalg operations with reduction dimensions using the LLVMGPUVectorDistribute pipeline. Currently, there are unknown issues (debugging) when compiling sdxl, so this is marked as a draft until the bugs are resolved

@bangtianliu

Copy link
Copy Markdown
Contributor Author

Still need to solve long compilation time issue

@Groverkss Groverkss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is great work. Thanks! The approach is reasonable. To get started, can we split this into 3 patches:

  1. Distribution fixes for splat values
  2. Layout analysis fixes
  3. KernelConfig additions

The first 2 patches are easy to stamp, the 3rd patch needs some thinking through.

replaceOpWithDistributedValues(rewriter, constantOp,
distirbutedOp->getResult(0));

//@Bangtian: will revisit this part later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove this comment

Comment on lines +112 to +113
bool isScalar = cast<ShapedType>(vectorType).getRank() == 0;
if (!isScalar) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: invert condition to be if (isScalar) and move the else branch

//@Bangtian: will revisit this part later
bool isScalar = cast<ShapedType>(vectorType).getRank() == 0;
if (!isScalar) {
Operation *distirbutedOp = rewriter.create<arith::ConstantOp>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: distirbuted -> distributed

//@Bangtian: will revisit this part later
bool isScalar = cast<ShapedType>(vectorType).getRank() == 0;
if (!isScalar) {
Operation *distirbutedOp = rewriter.create<arith::ConstantOp>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Operation * -> auto

replaceOpWithDistributedValues(rewriter, constantOp,
distirbutedOp->getResult(0));
} else {
Operation *distirbutedOp = rewriter.create<arith::ConstantOp>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Operation * -> auto

// rank check is added to ensure that the type is indeed a vector
// value.
bool isSrcVector =
(srcVector != nullptr) && (srcVector.getType().getRank() != 0);

@Groverkss Groverkss Oct 15, 2024 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: you can just check srcVector && ...

// rank check is added to ensure that the type is indeed a vector
// value.
bool isSrcVector =
(srcVector != nullptr) && (srcVector.getType().getRank() != 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would create a helper function "isScalar" and use that instead of checking rank everywhere.

Comment on lines +139 to +141
void visitRegionBranchTerminatorOpInterface(RegionBranchOpInterface branch,
RegionBranchPoint branchPoint);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we move this fix to a seperate patch?

Comment on lines +641 to +642
if (resultLattices.empty())
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: braces

Comment on lines +708 to +709
if (!isa<VectorType>(inputType))
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: braces

Groverkss pushed a commit that referenced this pull request Oct 28, 2024
…ion with scalars (#18800)

Splitting #18519 into four patches.

Depends #18784 

This is the second one, adding the corresponding layout analysis and
especially supporting the case where reduction is performed inside
scf.for operation.

Also, the relevant tests are added. 

Since patch 2 includes changes from patch #18784, the necessary updates
from the first patch have also been included here.

---------

Signed-off-by: Bangtian Liu <[email protected]>
Eliasj42 pushed a commit that referenced this pull request Oct 31, 2024
…ion with scalars (#18800)

Splitting #18519 into four patches.

Depends #18784

This is the second one, adding the corresponding layout analysis and
especially supporting the case where reduction is performed inside
scf.for operation.

Also, the relevant tests are added.

Since patch 2 includes changes from patch #18784, the necessary updates
from the first patch have also been included here.

---------

Signed-off-by: Bangtian Liu <[email protected]>
Signed-off-by: Elias Joseph <[email protected]>
giacs-epic pushed a commit to giacs-epic/iree that referenced this pull request Dec 4, 2024
…ion with scalars (iree-org#18800)

Splitting iree-org#18519 into four patches.

Depends iree-org#18784

This is the second one, adding the corresponding layout analysis and
especially supporting the case where reduction is performed inside
scf.for operation.

Also, the relevant tests are added.

Since patch 2 includes changes from patch iree-org#18784, the necessary updates
from the first patch have also been included here.

---------

Signed-off-by: Bangtian Liu <[email protected]>
Signed-off-by: Giacomo Serafini <[email protected]>
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.

2 participants