Repository navigation
[Codegen] Don't fold workgroup loops during workgroup tiling - #21137
Conversation
|
You maybe can move that canonicalization outside of the main tiling methods, but more than that I think this is kind of hinting at issues with the loose/implicit link between different workgroup distributions. Make the workgroup distribution distribute only along x-dimension, i.e. fold all the logical dimensions into a single physical dimension, then you can use delinearize to get back the different dimensions (AFAIK this should be very easy to change cause this is what happens to map a 4D logical distribution onto a 3D distribution. Then you wont care about the unit dims. The x/y/z dimensions have no basis actually in hardware. its all just a list. |
Yeah, we need to be careful about folding away workgroup loops. Folding away any workgroup loop loses some information about the fact that the contained computation is distributed to a single workgroup. In this case, it is easy to tell that folding the loop will be invalid, but if the order of transformations were reversed (do workgroup tiling and fold the forall loop, and then introduce a separate forall later), then it would be very hard to tell that any of the dispatch is already distributed. I didn't want to interfere with the current default path too much in this PR, but now that we aren't assuming only a single scf.forall when we resolve workgroup distribution, I think we really shouldn't ever be fully folding away workgroup loops.
This seems like the job of ReconcileTranslationInfo, no? I think the point of folding away the unit dims was to open op additional optimizations by having more static information in the IR. Linearizing and delinearizing like this seems unnecessary at this phase of codegen. We just need to be careful about folding away forall loops in general IMO. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Ok, based on offline conversation. I can stamp this PR, but there is a lot of "if checking" to walk a very specific path. I think it would be much better if can prefetch the "linearize all to x" first and then this PR will become redundant. I guess it depends on how badly you need this PR to unblock. If you need it, I can stamp it, but the lot of checking here is very specific and threading a very fine needle to effectively just pass tests we have right now.
4f1a060 to
24a4bd3
Compare
Signed-off-by: Max Dawkins <[email protected]>
Signed-off-by: Max Dawkins <[email protected]>
7b385e4 to
306c104
Compare
Signed-off-by: Max Dawkins <[email protected]>
|
@MaheshRavishankar after rebasing, the new test you added was failing, which I fixed by adjusting the lowering config that had tile sizes larger than the problem size (see latest commit). I assume this was a fine change to make, but I'll wait for your confirmation. |
…ree-org#21137)" This reverts commit 887d75a.
…ree-org#21137)" This reverts commit 887d75a. Signed-off-by: MaheshRavishankar <[email protected]>
…ree-org#21137)" This reverts commit 887d75a.
…ree-org#21137)" This reverts commit 887d75a. Signed-off-by: Max Dawkins <[email protected]>
…21137)" (#21318) This reverts the commit 887d75a which caused a failure compiling LLaMa 8b downstream. Also reverts dependent commit: 7f35ecf --------- Signed-off-by: Max Dawkins <[email protected]>
… tiling (iree-org#21137)" (iree-org#21318)" This reverts commit bb040e7.
… tiling (iree-org#21137)" (iree-org#21318)" This reverts commit bb040e7. Signed-off-by: Max Dawkins <[email protected]>
…iree-org#21137)" (iree-org#21382) Undo the revert of iree-org@887d75a and iree-org@7f35ecf now that the failure is fixed by iree-org#21334 Signed-off-by: Max Dawkins <[email protected]>
There are optimizations in `TileAndDistributeToWorkgroupsUsingForallOpPass` that try to fold away unit trip distribution loops, but this is not valid if there are ever any other workgroup forall loops in the IR, because the other forall may ask for multiple workers. This PR prevents the optimizations from fully folding the distribution loop. --------- Signed-off-by: Max Dawkins <[email protected]>
…21137)" (#21318) This reverts the commit 887d75a which caused a failure compiling LLaMa 8b downstream. Also reverts dependent commit: 7f35ecf --------- Signed-off-by: Max Dawkins <[email protected]>
There are optimizations in
TileAndDistributeToWorkgroupsUsingForallOpPassthat try to fold away unit trip distribution loops, but this is not valid if there are ever any other workgroup forall loops in the IR, because the other forall may ask for multiple workers. This PR prevents the optimizations from fully folding the distribution loop.