You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Investigate a fusion opportunity on Layer Normalization #9139
ONNX pattern-matches multiple layer normalization patterns with/without bias and skip data, and uses a single CUDA kernel for it. On the IREE side, we have three dispatches: mean (reduction), variance (reduction), and normalizations (element-wise operations).
ONNX got ~7% perf improvement by pattern matching 23 layer normalization instances from miniLM.
To clarify, this just means we should be fusing those dispatches together such that they are accessing the source data once for all 3 reductions, correct?
("pattern matching ML layers" is precisely what we don't want to do, so just want to make sure the terminology is right here that it's a fusion opportunity at the linalg level, where multiple linalg ops consuming the same data should be fused into a single dispatch)
@okkwon, you mentioned this was dependent on some in-progress work from @MaheshRavishankar. Is that tracked with an issue yet?
@benvanik, yep, we have been looking at ONNX fusions for inspiration and empirical data, but are only considering opportunities that have meaningful impact and are generalizable at the linalg level.
This is implemented at HEAD but is guarded by the flag --iree-flow-enable-aggressive-fusion pass. This is disabled by default now due to backend issue. So the work for this bug itself is done.
Activity
benvanik commentedon May 16, 2022
To clarify, this just means we should be fusing those dispatches together such that they are accessing the source data once for all 3 reductions, correct?
("pattern matching ML layers" is precisely what we don't want to do, so just want to make sure the terminology is right here that it's a fusion opportunity at the linalg level, where multiple linalg ops consuming the same data should be fused into a single dispatch)
okkwon commentedon May 16, 2022
Yes, I carefully chose "investigate a fusion opportunity" instead of "do pattern matching" according to our design principles. ;) Thanks Ben!
benvanik commentedon May 16, 2022
Cool! This will be a really great improvement!
julianwa commentedon May 16, 2022
@okkwon, you mentioned this was dependent on some in-progress work from @MaheshRavishankar. Is that tracked with an issue yet?
@benvanik, yep, we have been looking at ONNX fusions for inspiration and empirical data, but are only considering opportunities that have meaningful impact and are generalizable at the linalg level.
okkwon commentedon May 16, 2022
@MaheshRavishankar is working on #8970. But, we need a vertical fusion of unrelated operations (some calls it horizontal fusion) to fuse reductions.
MaheshRavishankar commentedon May 16, 2022
Thats the PR, it needs some upstream fixes. I sent a patch out for that already. Have to work on one more.
I am not sure we need "horizontal fusion". The
meanis used invariance, so there is a dependence.11 remaining items
okkwon commentedon Jul 7, 2022
A PR for the first part is under review. #9693
okkwon commentedon Jul 28, 2022
There is an ongoing discussion about how to solve the general fusion problems. No ETA yet.
allieculp commentedon Jul 28, 2022
From today's meeting: assigning to @MaheshRavishankar
allieculp commentedon Aug 11, 2022
Adding @okkwon to this issue in case there have been any updates while Mahesh is out.
MaheshRavishankar commentedon Aug 11, 2022
This is on my plate. The resolution is about 2-3 weeks out.
allieculp commentedon Aug 25, 2022
From meeting 8/25: Draft PR in place, still looking into backend issues
MaheshRavishankar commentedon Sep 29, 2022
This is implemented at HEAD but is guarded by the flag
--iree-flow-enable-aggressive-fusionpass. This is disabled by default now due to backend issue. So the work for this bug itself is done.