]> git.djapps.eu Git - pkg/ggml/sources/ggml/commit
vulkan: Optimize argsort (llama/15354)
authorJeff Bolz <redacted>
Sun, 17 Aug 2025 08:41:45 +0000 (03:41 -0500)
committerGeorgi Gerganov <redacted>
Mon, 18 Aug 2025 16:15:25 +0000 (19:15 +0300)
commit51bc2b509b211e37849528a1626e7fbbdccc053c
tree7eeb0c0560f44da376b393df0a8c18106f2e8702
parent8c021e3dd32d8c648cf66dc84be9bf546f572fe8
vulkan: Optimize argsort (llama/15354)

- Launch an appropriate number of invocations (next larger power of two).
32 invocations is common and the barrier is much cheaper there.
- Specialize for "needs bounds checking" vs not.
- Make the code less branchy and [[unroll]] the loops. In the final code,
I see no branches inside the main loop (only predicated stores) when
needs_bounds_check is false.
- Always sort ascending, then apply the ascending vs descending option when
doing the final stores to memory.
- Copy the values into shared memory, makes them slightly cheaper to access.
src/ggml-vulkan/ggml-vulkan.cpp
src/ggml-vulkan/vulkan-shaders/argsort.comp
tests/test-backend-ops.cpp