Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize reduce(reshape_1D) #5748

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

ThomasRaoux
Copy link
Collaborator

When reducing a 1D tensor the order of elements doesn't matter. This allows us to use a more relaxed version of reshape.

When reducing a 1D tensor the order of elements doesn't matter.
This allows us to use a more relaxed version of reshape.
return failure();
}
rewriter.modifyOpInPlace(reshapeOp,
[&]() { reshapeOp.setAllowReorder(true); });
Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM, but is there any harm in creating two reshape ops if there are non-reduce users? I think with linear layouts an allow-reorder reshape should always be a no-op.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh and this pattern works for HistogramOp as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

SGTM, but is there any harm in creating two reshape ops if there are non-reduce users? I think with linear layouts an allow-reorder reshape should always be a no-op.

The potential harm is extra pressure if this makes the tensor exist with different layouts. We kind of already have this problem when doing ramterialization in layout propagation pass but to be conservative I would prefer avoiding it until it is proven to help.

Oh and this pattern works for HistogramOp as well.

good point.

Copy link
Contributor

Choose a reason for hiding this comment

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

The potential harm is extra pressure if this makes the tensor exist with different layouts.

Hrm okay. It's a bit annoying that we are just papering over a flaw in the layout propagation pass, but hopefully we can resolve that at some point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

well if we create two reshapes with and without allow_reorder then there is likely to have extra pressure whatever we do in layout propagation. What I meant is that layout propagation also does some of it but it is not great

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I might be over cautious but we can re-visit based on findings

@ThomasRaoux ThomasRaoux merged commit c2c193a into triton-lang:main Jan 29, 2025
7 checks passed
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