]> git.djapps.eu Git - pkg/ggml/sources/ggml/commit
vulkan: Optimize soft_max (llama/10301)
authorJeff Bolz <redacted>
Tue, 19 Nov 2024 07:25:17 +0000 (01:25 -0600)
committerGeorgi Gerganov <redacted>
Tue, 19 Nov 2024 11:46:16 +0000 (13:46 +0200)
commit47991a2e37fcc7c815112685c15958d3f557b831
tree9d12e4b62e8786d506ce3d17b21b42dd0bbc8565
parentc932dd609753e33fca0ec494671832c76cc46ef6
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.
src/ggml-vulkan/ggml-vulkan.cpp
src/ggml-vulkan/vulkan-shaders/soft_max.comp
tests/test-backend-ops.cpp