Files
llama.cpp/ggml/src/ggml-cuda
Oliver SimonsandJohannes Gäßler 661ae31c9c CUDA: Optimize rms_norm_f32 kernel and its fused variants, giving 1-6% perf E2E (#15715)
* Add fastdiv, use it in modulo and use modulo in rms_norm_f32

Fastdiv is much faster way to do integer division, which was identified
as bottleneck in rms_norm_f32

* Support more `block_size` values in `rms_norm_f32`

This makes us more flexible in selecting the optimal threads w.r.t
paralellizing across a col vs. launch-overheads of threads and mio
throttles

* Update ggml/src/ggml-cuda/common.cuh

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>

* Replace modulo with fastmodulo in `rms_norm_f32`

* Use `BinPackArguments=true` for formating function calls

Will file a separate PR to adjust .clang-format file

* Update ggml/src/ggml-cuda/common.cuh

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>

* Use uint3 for both `fastdiv` and `fastmodulo`

The compiler seems to reliably optimize away the unused .z component in
the fastdiv use-case, see https://godbolt.org/z/rx8KPrKr3

* More constrained type declarations

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>

* Rename fastdiv and fastmodulo variables to shared variable name

As suggest by JohannesGaessler, this increases clarity of the intended
use

* Pack fastdiv/fastmodulo constants into uint2/uint3 objects

By packing constants to be used together into a struct, we are less
likely to make errors.

* Rename function parameter of fastmodulo

`modulo_consts` is more fitting/descriptive

---------

Co-authored-by: Johannes Gäßler <johannesg@5d6.de>
2025-09-03 19:59:16 +02:00
..
2025-08-20 10:17:37 +08:00
2025-08-05 22:10:36 +03:00
2024-11-21 18:18:50 +01:00
2025-06-20 09:50:24 +08:00
2025-06-20 09:50:24 +08:00
2025-08-28 20:33:03 +02:00
2025-08-21 11:06:05 +08:00
2025-08-21 11:06:05 +08:00
2025-08-05 22:10:36 +03:00
2025-06-22 12:39:54 +08:00
2025-08-21 11:06:05 +08:00
2025-08-21 11:06:05 +08:00
2025-08-21 11:06:05 +08:00
2025-08-21 11:06:05 +08:00
2025-07-29 14:45:18 +08:00
2025-07-29 14:45:18 +08:00
2025-07-09 18:16:12 +02:00
2025-07-29 14:22:03 +02:00
2025-07-29 14:22:03 +02:00
2025-08-05 22:10:36 +03:00
2025-03-31 18:05:13 +02:00
2025-03-31 18:05:13 +02:00
2025-06-22 12:39:54 +08:00
2025-08-05 22:10:36 +03:00
2025-08-05 22:10:36 +03:00