CPU backend operator fusion #22315
Replies: 5 comments 4 replies
-
|
Sure, there are plenty of people running CPU only, any significant optimization (but do ensure that you do not negatively impact a CPU target) to that backend is welcome. |
Beta Was this translation helpful? Give feedback.
-
|
I think CPU supports the graph plan API, fusion is better done at that point rather than checking for nodes at each compute, it might be slower otherwise. |
Beta Was this translation helpful? Give feedback.
-
|
I've implemented the changes. Looking forward to your review. #22423 |
Beta Was this translation helpful? Give feedback.
-
|
My next focus will be the Gated FFN fusion, which should yield more gains than simple RMS_NORM+MUL fusion |
Beta Was this translation helpful? Give feedback.
-
|
Opened a PR for benchmarking operator groups: #22934 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The CUDA backend already fuses several common op patterns (e.g.
RMS_NORM + MUL,RMS_NORM + MUL + ADD),But on the CPU backend these ops are still executed one by one.I tried to port the same idea to the CPU backend, starting with the simplest and most frequent pattern:
RMS_NORM + MUL(the RMSNorm + weight multiplication that appears in basically every LLaMA-style block).And the benchmark result of the ops-group like:
Note:
RMS_NORM_MUL_ADDis a new test case I added totest-backend-opslocally so that the fused pattern can be measured directlyMy env:
Before:
After:
My main question before turning this into a PR: Is there any appetite for operator fusion optimizations on the CPU backend?
Happy to iterate on this based on feedback. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions