Skip to content

Conversation

@tyb0807
Copy link
Contributor

@tyb0807 tyb0807 commented Dec 15, 2025

This showcases end to end execution using water transformations. However it's not straightforward to put this as a pytest, since it messes up with all the package setup... I guess a lit_test with assertions to check computed results is good for now.

Fixes #584

@tyb0807 tyb0807 requested a review from ftynse December 15, 2025 12:43
@tyb0807 tyb0807 force-pushed the e2e_test branch 9 times, most recently from abeeefe to 8a0d767 Compare December 15, 2025 22:20
Copy link
Contributor

@ftynse ftynse left a comment

Choose a reason for hiding this comment

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

Overall nit: please be systematic about using or not using the full stop at the end of sentences in comments. I'm fine either way as long as it is locally consistent in a file.

Comment on lines 249 to 252
# CHECK-NOT: wave.read
# CHECK-NOT: wave.write
# CHECK-NOT: wave.mma
# CHECK-NOT: wave.iterate
Copy link
Contributor

Choose a reason for hiding this comment

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

These appear misplaced (or I don't understand something). Don't we want to have an mfma inside the scf.for? It is currently matched before. Also if we check for there not being a wave.read after an scf.for, there may well be one before it and this structure won't complain.

let arguments = (ins
Arg<WaveSymbolAttr, "Iterator symbol">:$iterator,
Arg<Variadic<WaveTensorType>, "Carried values">:$iter_args,
Arg<Variadic<AnyTypeOf<[WaveTensorType, AnyVectorOfAnyRank]>>, "Carried values">:$iter_args,
Copy link
Contributor

Choose a reason for hiding this comment

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

WaveTensorInRegister? Do we want to support non-register tensors here actually?


let results = (outs
Res<Variadic<WaveTensorType>, "Yielded values">:$results
Res<Variadic<AnyTypeOf<[WaveTensorType, AnyVectorOfAnyRank]>>, "Yielded values">:$results
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto


let arguments = (ins
Arg<Variadic<WaveTensorType>, "Yielded values">:$values
Arg<Variadic<AnyTypeOf<[WaveTensorType, AnyVectorOfAnyRank]>>, "Yielded values">:$values
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as iterate

if (!elementsPerThread)
return mlir::ChangeResult::NoChange;

// Only propagate to operands[0] (register), not operands[1] (memory)
Copy link
Contributor

Choose a reason for hiding this comment

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

Trick to avoid hardcoding operand positions: getRegisterMutable().getOperandNumber().

Comment on lines 140 to 142
// TODO: Implement proper iteration variable handling
baseSymVals.emplace_back(
arith::ConstantIndexOp::create(rewriter, loc, 0));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please implement. There is also no guarantee that iterate is the direct parent and that the iterator symbol belongs to the immediately enclosing loop rather than some of the other nested loops.


// Not from wave.allocate, use original type shape
ArrayRef<Attribute> symbols(originalType.getShape().begin(), originalType.getShape().end());
return {symbols, AffineMap{}}; // Empty map means identity
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be simpler / more consistent to create an actual identity map?

Comment on lines 441 to 453
if (effectiveShapeInfo.has_value()) {
ArrayRef<Attribute> symbols = effectiveShapeInfo->first;
SmallVector<wave::WaveSymbolAttr> convertedSyms;
convertedSyms.reserve(symbols.size());
for (Attribute attr : symbols) {
auto symbolAttr = dyn_cast<wave::WaveSymbolAttr>(attr);
if (!symbolAttr) {
return rewriter.notifyMatchFailure(
op, "expected WaveSymbolAttr in distributed shape");
}
convertedSyms.push_back(symbolAttr);
}
orderedSyms = convertedSyms;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unlike shapes in the type, distrbuted shapes may be arbitrarily complex expressions AFAIK, which may need to be handled before beyond just the list of symbols.

Comment on lines 147 to 158
// Phase 2: Convert control flow operations
{
RewritePatternSet phase2Patterns(ctx);

// Add only control flow patterns
wave::populateWaveControlFlowLoweringPatterns(typeConverter, phase2Patterns);

if (failed(applyPartialConversion(op, target, std::move(phase2Patterns),
config))) {
op->emitError() << "failed to convert in phase 2";
return WalkResult::interrupt();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather make a separate pass then, and potentially a named pipeline to manage that complexity

@tyb0807 tyb0807 changed the title [wave2water] E2e execution test using water pipeline [wave2water] E2e execution matrix add test using water middle-end Dec 19, 2025
@tyb0807 tyb0807 force-pushed the e2e_test branch 2 times, most recently from e1694bb to 0e44243 Compare December 19, 2025 12:38
This showcases end to end execution using water transformations. However it's not straightforward to put this as a pytest, since it messes up with all the package setup... I guess a lit_test with assertions to check computed results is good for now.

Fixes iree-org#584

Signed-off-by: tyb0807 <[email protected]>
@tyb0807
Copy link
Contributor Author

tyb0807 commented Dec 19, 2025

Ok, I simplified this PR to only lowering matrix add test, to make review easier. Working on breaking down the changes to smaller PR. Will address your comments along the way.

@tyb0807 tyb0807 requested review from ftynse and tgymnich December 19, 2025 20:21
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.

Make matrix add kernel lowered through water and run by IREE

2 participants