Repository navigation
Add pass to expand all vectors in vecmat/matvec operations into matrices to enable tiling - #15273
Conversation
…ces to enable tiling
bjacob
left a comment
There was a problem hiding this comment.
Looking great, just a couple of nits!
| if (op.isRowMajorMatmul() || op.isColumnMajorMatmul() || | ||
| op.isRowMajorBatchMatmul()) { | ||
| return rewriter.notifyMatchFailure(linalgOp, "op is already a matmul"); | ||
| } |
There was a problem hiding this comment.
Is checking this needed? Below at line 46 we are returning failure when not one of the matrix-vector ops that this pattern would rewrite. That line 46 return is necessary and ... sufficient?
There was a problem hiding this comment.
Good point, thanks!
| .addPass(IREE::Flow::createFoldUnitExtentDimsPass) | ||
| .addPass(IREE::Flow::createFuseDequantizationMatmulPass) | ||
| // Expand all vectors in vecmat/matvec ops into matrices for tiling. | ||
| .addPass(createExpandVectorsPass) |
There was a problem hiding this comment.
Should we only add this pass when transformOptions.options.dataTiling == true? It seems like the current main purpose of this pass is for data-tiling.
There was a problem hiding this comment.
Good point. This should be done using .addPredicatedPass similarly to SetEncoding, right? (Couldn't find any explicit documentation that that's what it does so just want to make sure)
There was a problem hiding this comment.
I think so. But let me know if there is a better approach : )
There was a problem hiding this comment.
Yes, we should only add it when data-tiling is enabled for now. If we want to make it on by default, we should collect some data point.
hanhanW
left a comment
There was a problem hiding this comment.
LGTM, just few nits. Thanks!
|
Since this is nearly ready, I'm rebasing my own work #15158 to depend on this (I am adding that missing |
hanhanW
left a comment
There was a problem hiding this comment.
LGTM if the comments are addressd.
|
Impressive improvements on GPT2 benchmarks 🎉 |
|
@MaheshRavishankar FYI there is a boost for GPT2 models from matvec data-tiling |
|
Any reason for concern on the regressions? Otherwise I'll merge it. Thanks everyone for the help :) |
|
That's fantastic. I was hoping that was the case with the gpt numbers . Cc @mariecwhite |
|
The regressions look big on dispatch count/size/etc - do we know why? |
|
If i have to guess its because we have some pack operations that may not be getting fused. There are reshapes introduced that are probably blocking the fusion. That would be good to look into, but for me it is not a blocker. It'd be great if we can file an issue with some snippets of what exactly is happening with this model. |
|
Yeah not a blocker but would be good to capture here when we see it as it's probably easy to spot with an IR diff and will be good to fix - will be trickier to find in the future :) |
|
Wowee! Nice work! |
|
@NatashaKnk would be really useful to do some triage of the increase in dispatch count if you have all the pieces |
Yes, that's likely the case. The regression only happens on data-tiling path. |
|
Awesome! Probably similar issue: #15242 |
…ces to enable tiling (iree-org#15273) As discussed in [issue#15053](iree-org#15053) and [PR#15257](iree-org#15257), expanding the vectors in vecmat/matvec operations and avoiding them in the encoding step entirely seems like the best approach.
This PR fails until the newest llvm integration as it depends on 68945.
As discussed in issue#15053 and PR#15257, expanding the vectors in vecmat/matvec operations and avoiding them in the encoding step entirely seems like the best approach.