Repository navigation
[Flow] Make dequantization ops clonable into dispatch regions - #15662
Conversation
There was a problem hiding this comment.
Sorry, accidentally added this file. I'll remove it
There was a problem hiding this comment.
Will remove this as well
7811805 to
810decd
Compare
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Thanks! One down. I'll review the next one later tonight
| // Step 2. Check whether it is possible to collapse | ||
| // Step 2. Don't collapse dims if there is a clonable dequantization like | ||
| // producer. Collapsing in this case will prevent fusion later. | ||
| if (llvm::any_of(getCloneableOps(regionOp), [&](Operation *op) { |
There was a problem hiding this comment.
This is kind of OK, but this logic seems better suited to incorporated into the findRootOp method?
There was a problem hiding this comment.
I think we can just leave this here for now, since we plan to remove it by switching the pass order of collapseDims later anyway
There was a problem hiding this comment.
Can we do that first... Just send out a simple PR that does the change in order. If that passes, and then you can drop all this logic, then we dont need to worry about this at all.
| return false; | ||
| } | ||
|
|
||
| // Always fuse dequant to consumer since it's not very useful by itself. |
There was a problem hiding this comment.
Is this logic needed here?
| if (!isa<linalg::LinalgOp, tensor::PadOp, tensor::PackOp, | ||
| IREE::LinalgExt::SetEncodingOp>(op) || | ||
| isa<linalg::FillOp>(op)) { | ||
| isa<linalg::FillOp>(op) || isGroupedDequantizationOp(&op)) { |
There was a problem hiding this comment.
I wonder if it is worth it adding a test in form_dispatch_regions to show that it won't get fused into a dispatch region.
…5671) The CollapseDimensions pass can introduce reshapes that can prevent clonable ops from being cloned into dispatch regions. Specifically, dequantization ops, which are becoming clonable with #15662, will not get fused. Moving CollapseDimensions to after CloneProducersIntoDispatchRegions will prevent anything like this from ever happening.
fce3a47 to
4a4994d
Compare
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Ok, this looks good to me. Maybe adding a test like @raikonenfnu suggested of making sure those dont get pulled into dispatch during FormDispatchRegion is worth it.
We want to avoid dequantization ops ending up in their own dispatch region because the result of these ops are larger than the inputs, often by multiple times. To avoid storing and loading the large results between dispatch regions, this makes dequantization ops clonable into dispatch regions rather than fusing in dispatch region formation.
4a4994d to
c0f6eee
Compare
|
Fantastic. Land it please. Great work @Max191 and @raikonenfnu |
Reintroduces CollapseDimsPass behind a flag after iree-org#15662
Reintroduces CollapseDimsPass behind a flag after #15662
…ee-org#15671) The CollapseDimensions pass can introduce reshapes that can prevent clonable ops from being cloned into dispatch regions. Specifically, dequantization ops, which are becoming clonable with iree-org#15662, will not get fused. Moving CollapseDimensions to after CloneProducersIntoDispatchRegions will prevent anything like this from ever happening.
…rg#15662) This PR eliminates the need for ad hoc custom fusion of dequantization and matmul `linalg.generic` ops. The fusion heuristics are updated and the FuseDequantizationMatmul pattern has been removed from the FuseDequantizationMatmulPass in GlobalOptimization. We want to avoid dequantization ops ending up in their own dispatch region because the result of these ops are larger than the inputs, often by multiple times. To avoid storing and loading the large results between dispatch regions, this makes dequantization ops clonable into dispatch regions rather than fusing in dispatch region formation. --------- Co-authored-by: Stanley Winata <[email protected]>
Reintroduces CollapseDimsPass behind a flag after iree-org#15662
This PR eliminates the need for ad hoc custom fusion of dequantization
and matmul
linalg.genericops. The fusion heuristics are updated andthe FuseDequantizationMatmul pattern has been removed from the
FuseDequantizationMatmulPass in GlobalOptimization.
We want to avoid dequantization ops ending up in their own dispatch
region because the result of these ops are larger than the inputs,
often by multiple times. To avoid storing and loading the large results
between dispatch regions, this makes dequantization ops clonable into
dispatch regions rather than fusing in dispatch region formation.
Fixes #15680