Commit fb1fff5
ssjia
Update on "[ET-VK] Implement SDPA with fused ops"
## Context
As title; optimize the SDPA operator by introducing shaders to perform the operation in 3 steps:
1. Compute attention weights, multiplying QT x K_cache, and applying scale and mask
2. Compute softmax normalization of computed attention weights
3. Compute final output by multiplying attention weights with V cache
This new implementation is much more efficient than the existing one, which performed slicing, repeat_interleave, and transposition of projected and cache tensors as separate steps. The fusion of scale and mask with the computation of attention weights also allows for the computation of elements within the mask region to be skipped.
## Impact
Decode latency for LLMs is much improved. For llama 3.2 3B generating ~250 tokens, decode latency increases from ~15 tok/s to ~21.5 tok/s
Differential Revision: [D82053493](https://our.internmc.facebook.com/intern/diff/D82053493/)
[ghstack-poisoned]1 parent 89abb6f commit fb1fff5
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
973 | 973 | | |
974 | 974 | | |
975 | 975 | | |
976 | | - | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
977 | 980 | | |
978 | 981 | | |
979 | 982 | | |
| |||
0 commit comments