Skip to content

[Codegen] Skinny mm/bmm/mv : use to vector distribute#21679

Closed
newling wants to merge 1 commit into
iree-org:mainfrom
newling:vector_distribute_for_matvec
Closed

[Codegen] Skinny mm/bmm/mv : use to vector distribute#21679
newling wants to merge 1 commit into
iree-org:mainfrom
newling:vector_distribute_for_matvec

Conversation

@newling

@newling newling commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

Before this PR, use of vector distribute was gated on this ad hoc constraint:

isa<linalg::ReduceOp, linalg::GenericOp>(op) && llvm::any_of(op.getIteratorTypesArray(), linalg::isReductionIterator);

For this PR I wanted to relax that gate to just

llvm::any_of(op.getIteratorTypesArray(), linalg::isReductionIterator)

But that failed because there is a test pooling_dynamic in nvvm_pipeline.mlir
that, when it goes down vector distribution, hits an assertion failure in
configure-tensor-layouts about one of the operands not having a projection
permutation.

I assume that's because layout inference scheme doesn't work well unless the maps
are just permutations/projections?

This PR works around this by gating on not having any non-projecting maps.

@kuhar kuhar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems like many tests are failing?

Comment on lines +303 to +305
const auto loopRanges = op.getStaticLoopRanges();
const auto loopTypes = op.getIteratorTypesArray();
const auto indexingMaps = op.getIndexingMapsArray();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, we probably don't need const on most of the local variables in this file, especially Types/Values/etc.

//
// false is returned. These maps appear in convolution/pooling ops, which are
// not currently supported by the vector distribute pipeline.
for (const auto m : indexingMaps) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also here

}

// Check for non-unit reduction dim.
for (const auto [type, range] : llvm::zip(loopTypes, loopRanges)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use zip_equal if these have the same length

@newling

newling commented Aug 14, 2025

Copy link
Copy Markdown
Contributor Author

Seems like many tests are failing?

Yeah I thought I'd found a good solution but some e2e tests didn't compile. Pipeline selection is quite a slippery path! Curious, what is your approach for testing before pushing a PR @kuhar and others? I generally just do

ctest -R odegen -j60

And if that passes then I'll make a PR to check if there are other tests which fail in CI. Obvs if I am checking numerics I then compile an e2e test and run that locally on a GPU. But in general I assume that if lit tests pass, and numerics are fine.

Ideally an e2e numerical test will never be the first place we see a compilation failure, ideally it should be caught in a lit test. Wondering if there's a way to get all numerical e2e tests just compile locally.

@Groverkss

Copy link
Copy Markdown
Contributor

Seems like many tests are failing?

Yeah I thought I'd found a good solution but some e2e tests didn't compile. Pipeline selection is quite a slippery path! Curious, what is your approach for testing before pushing a PR @kuhar and others? I generally just do

ctest -R odegen -j60

And if that passes then I'll make a PR to check if there are other tests which fail in CI. Obvs if I am checking numerics I then compile an e2e test and run that locally on a GPU. But in general I assume that if lit tests pass, and numerics are fine.

Ideally an e2e numerical test will never be the first place we see a compilation failure, ideally it should be caught in a lit test. Wondering if there's a way to get all numerical e2e tests just compile locally.

I think you want to run e2e lit tests: https://iree.dev/developers/general/testing-guide/#code-coverage

@kuhar

kuhar commented Aug 14, 2025

Copy link
Copy Markdown
Member

Curious, what is your approach for testing before pushing a PR @kuhar and others? I generally just do

My go-to test command is: ninja all iree-test-deps && ctest all -j32 --output-on-failure -E 'cuda|metal'

@newling

newling commented Aug 18, 2025

Copy link
Copy Markdown
Contributor Author

This isn't needed, the way to go is #21720

@newling newling closed this Aug 18, 2025
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.

3 participants