Repository navigation
Turn on aggressive fusion heuristics by default. - #11980
MaheshRavishankar wants to merge 3 commits into
Conversation
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in Also fixes iree-org#11505.
|
Current blocker is #12019 |
1ad697d to
322bd70
Compare
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR #11980. The bufferization issue is tracked in #12019 Also fixes #11505.
322bd70 to
58c78a6
Compare
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019 Also fixes iree-org#11505.
58c78a6 to
460a7d7
Compare
|
All Vulkan and CPU tests pass for me locally now. Running CI. |
|
I thought you didn’t want to turn it on? This will break once we remove rematerialization pass. |
Didnt you plan to move all of that into the softmax decomposition pass? |
|
Going to look into the failures, but as it stands these are the dispatches on the benchmarks Before
After
|
Right, the idea is to make the softmax decomposition do the rematerialization when decomposing and then remove the general pass. That means if a code sequence like softmax (but not using the softmax op) is fused we will have large allocations again. It sounds like that’s what could happen with aggressive fusion. |
yup, understood... today rematerialization works, cause really the only case that get fused that way is softmax. Once the decomposition does rematerialzation, I can remove the use of that pass in the backends and make sure we dont fuse in a way that creates allocations. I think those could be decoupled. In any case, large stacks are a hard-error today... so we will know if there are issues. |
Got it, so you are going to remove the cases that would create large allocs from the fusion? That would work. This is not done yet right? |
Trying to guage the order of things. Ill probably defer that to later stage. So keep the rematerialization for now (its used on all backends), and then evaluate after softmax doesnt need it. |
Sounds good to me. I was going to remove it because you were concerned about it but I can’t really think about case where doing the rematerialization is worse and where backend cse wouldn’t revert it in case it is worth. |
I dont think it is a waste. Rematerialization and CSE are not the inverse of each other (they only become inverse of each other if you remove all the loops and thats a very special case....). The softmax matcher is needed anyway for flash attention... I am just trying to land it without rocking the boat too much... |
Right, what I’m saying is that when there are loops we will always end up with stack allocations which is In general not what we want. But let’s if we find counter examples in the future. |
Yeah, but we can also not do such fusions. We can say we use rematerialization to avoid stack allocation but that is coming dangerously close to needing a cost model to decide fusion efficacy. That's not the intent right now, and I would like to not rely on it in a way that we cannot turn off materialization if we need based on other examples. Definitely need to look at examples, and today we don't have any. So I am OK with keeping it for now if it isn't used in a load bearing way like it is for softmax. |
| } | ||
|
|
||
| // Finally only fuse if the `ins` operand can be properly bufferized. | ||
| // TODO(#10498): Handle the multi-result case. |
There was a problem hiding this comment.
What's the status of #10498?
I think we're able to handle the case for a while. Can you verify it and close the issue?
I wonder what those numbers look like after the merge of softmax patterns. |
Dont know. Will rebase and rerun scripts. |
| // CHECK: flow.dispatch.workgroups | ||
|
|
||
| // ----- | ||
|
|
There was a problem hiding this comment.
Do we have tests to cover cases that are now fused and were not before?
…ons. Rework the logic that prevents fusions that result in stack allocation. This is mostly a WAR since these dispatches should be lowered without any stack allocation. The root cause is that these dispatches are not vectorized. When vectorized there wont be a stack allocation.
3fd3438 to
201d47d
Compare
|
Moved the first commit out into its own PR. (#12277 ) |
|
The compilation errors in CI are related to CUDA backend and ARM CPU backend with data-tiling enabled. Here is the list of issues:
|
|
This has landed in main already. Closing |
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019 Also fixes iree-org#11505.
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR #11980. The bufferization issue is tracked in #12019 Also fixes #11505.
The tile and fuse transformation upstream has been split into its individual steps allowing caller more control in terms of which producers to fuse and which values to yield from within the tiled loop nest. This moves IREEs tile+fuse to use these components, allowing for handling of multi-result dispatches. Currently multi-result dispatches do seem to cause bufferization issues. IREE currently doesnt form such dispatches by default, but will do so with PR iree-org#11980. The bufferization issue is tracked in iree-org#12019 Also fixes iree-org#11505.
No description provided.