]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
vulkan: Optimize soft_max (llama/10301)
authorJeff Bolz <redacted>
Tue, 19 Nov 2024 07:25:17 +0000 (01:25 -0600)
committerGeorgi Gerganov <redacted>
Wed, 20 Nov 2024 19:00:08 +0000 (21:00 +0200)
commit45f1f9144f062db5777f962fb5014a2c8aa31080
tree5ce32e9d0e94df0e4a9449c52d33534100638829
parent53589c8f12c937d82c2d5889f01b427850e09d88
vulkan: Optimize soft_max (llama/10301)

* vulkan: Optimize soft_max

Large soft_max could already saturate memory, but small/medium sizes were
pretty slow. The bulk of the gains for them comes from using a smaller
workgroup size, and making the workgroup size match the subgroup size also
makes the barriers much cheaper.

Cache some values in locals to avoid refetching/recomputing. And stamp
out a few "template instantiations" so smaller cases will fully unroll.

Add a missing early return for OOB rows. This happens when there are more
than 512 rows and the dispatch is 512 x H.

* vulkan: Further soft_max optimizations

Restore the workgroup size of 512 case, use it for >1024.

Use unrollable loops for more iteration counts.
ggml/src/ggml-vulkan/ggml-vulkan.cpp
ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp