]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commit
vulkan: Add fusion support for RMS_NORM+MUL (llama/14366)
authorJeff Bolz <redacted>
Sun, 29 Jun 2025 07:43:36 +0000 (02:43 -0500)
committerGeorgi Gerganov <redacted>
Tue, 1 Jul 2025 14:54:53 +0000 (17:54 +0300)
commit00b36237ba7b7569995bff1ced92f0f796ed8b5c
tree9966f5ce8aea3588b0a746156d9cb8958e90fc8b
parentb900ee424c67a14fd3f650553e6445b83186e39b
vulkan: Add fusion support for RMS_NORM+MUL (llama/14366)

* vulkan: Add fusion support for RMS_NORM+MUL

- Add a use_count to ggml_tensor, so we can detect if an output is used more than once.
- Change the ggml-vulkan rms_norm shader to optionally multiply by another tensor.
- Add detection logic and basic fusion logic in ggml-vulkan.
- Add some testing support for fusion. Rather than computing one node at a time, allow
for computing the whole graph and just testing one node's results. Add rms_norm_mul tests
and enable a llama test.

* extract some common fusion logic

* fix -Winconsistent-missing-override

* move ggml_can_fuse to a common function

* build fix

* C and C++ versions of can_fuse

* move use count to the graph to avoid data races and double increments when used in multiple threads

* use hash table lookup to find node index

* change use_counts to be indexed by hash table slot

* minimize hash lookups

style fixes

* last node doesn't need single use.
fix type.
handle mul operands being swapped.

* remove redundant parameter

---------

Co-authored-by: slaren <redacted>
ggml/include/ggml-backend.h
ggml/src/ggml-backend.cpp
ggml/src/ggml-impl.h
ggml/src/ggml-vulkan/ggml-vulkan.cpp
ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp
ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp
ggml/src/ggml.c