]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commit
cuda: fuse snake activation (mul, sin, sqr, mul, add) (#22667)
authorPascal <redacted>
Fri, 8 May 2026 09:44:09 +0000 (11:44 +0200)
committerGitHub <redacted>
Fri, 8 May 2026 09:44:09 +0000 (17:44 +0800)
commit58e68df0f91dd16ff56423ee5ef44062ed73bdfc
treee02ae1619ebd02292a519456d9e8b37f24afbc4b
parent9b2925e1e01e24976b60538eb201617f86a8dd46
cuda: fuse snake activation (mul, sin, sqr, mul, add) (#22667)

* cuda: fuse snake activation (mul, sin, sqr, mul, add)

Add ggml_cuda_op_snake_fused with F32 / F16 / BF16 templates. The
matcher recognizes the naive 5 op decomposition emitted by audio
decoders (BigVGAN, Vocos) for snake activation
y = x + sin(a*x)^2 * inv_b and rewrites it to a single elementwise
kernel.

Add test_snake_fuse comparing CPU naive vs CUDA fused across
F32 / F16 / BF16.

* cuda: address review feedback from @am17an

Use ggml_cuda_cast for F32/F16/BF16 conversions and rename
kernel_snake to snake_kernel to match upstream conventions.

* cuda: snake fusion fastdiv on T_len, Suggested-by: @am17an

* Update tests/test-backend-ops.cpp

Co-authored-by: Aman Gupta <redacted>
* cuda: snake fusion check add->type matches x->type

Address review feedback from @am17an

* cuda: snake fusion check add->type matches x->type

Moved for readability (equivalent)
Address review feedback from @am17an

---------

Co-authored-by: Aman Gupta <redacted>
ggml/src/ggml-cuda/ggml-cuda.cu
ggml/src/ggml-cuda/snake.cu [new file with mode: 0644]
ggml/src/ggml-cuda/snake.cuh [new file with mode: 0644]
tests/test-backend-ops.cpp