Commit c0b97be0b for llama.cpp

commit c0b97be0b297177a88df08e96c01420976bb18d0
Author: Amadeus dyw <74057036+SG-Amadeus@users.noreply.github.com>
Date:   Fri Nov 20 15:38:43 2026 +0800

    vulkan: optimize RMS_NORM_MUL_ROPE loop control (#31149)

diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp b/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp
index b9f0a1841..b73fdeca4 100644
--- a/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp
+++ b/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp
@@ -87,6 +87,12 @@ void rms_norm(uint num_iters) {
 #endif
             FLOAT_TYPE sum = FLOAT_TYPE(0.0f); // partial sum for thread in warp

+#if RMS_NORM_ROPE_FUSION
+            for (uint col = tid; col < ncols; col += BLOCK_SIZE) {
+                const FLOAT_TYPE xi = FLOAT_TYPE(data_a[a_offset + col]);
+                sum += xi * xi;
+            }
+#else
             [[unroll]] for (uint col = tid, idx = 0; idx < num_iters; col += BLOCK_SIZE, ++idx) {
                 FLOAT_TYPE xi = FLOAT_TYPE(0);
                 if (col < ncols) {
@@ -94,6 +100,7 @@ void rms_norm(uint num_iters) {
                 }
                 sum += xi * xi;
             }
+#endif

             #if USE_SUBGROUP_ADD
                 sum = subgroupAdd(sum);
@@ -131,6 +138,15 @@ void rms_norm(uint num_iters) {
             const FLOAT_TYPE mean = sum / FLOAT_TYPE(ncols);
             const FLOAT_TYPE scale = inversesqrt(mean + FLOAT_TYPE(p.param1));

+#if RMS_NORM_ROPE_FUSION
+            for (uint col = tid; col < ncols; col += BLOCK_SIZE) {
+                FLOAT_TYPE value = scale * FLOAT_TYPE(data_a[a_offset + col]);
+                if (do_multiply) {
+                    value *= FLOAT_TYPE(data_b[b_offset + fastmod(col, p.ne10)]);
+                }
+                data_d[d_offset + col] = D_TYPE(value);
+            }
+#else
             if (do_multiply) {
                 if (ncols > p.ne10) {
                     [[unroll]] for (uint col = tid, idx = 0; idx < num_iters; col += BLOCK_SIZE, ++idx) {
@@ -169,6 +185,7 @@ void rms_norm(uint num_iters) {
                     data_d[d_offset + col] = FLOAT_TO_D(scale * FLOAT_TYPE(A_TO_FLOAT(data_a[a_offset + col])));
                 }
             }
+#endif
 #if RMS_NORM_ROPE_FUSION
             barrier();
             rope_params rp = p.rope;
@@ -185,6 +202,10 @@ void rms_norm(uint num_iters) {
 }

 void main() {
+#if RMS_NORM_ROPE_FUSION
+    const uint num_blocks = (p.ne00 + BLOCK_SIZE - 1) / BLOCK_SIZE;
+    rms_norm(num_blocks);
+#else
     // instantiate the rms_norm function for several different
     // dimensions, to allow loop unrolling
     uint num_blocks = (p.ne00 + BLOCK_SIZE - 1) / BLOCK_SIZE;
@@ -209,4 +230,5 @@ void main() {
     } else if (num_blocks == 1) {
         rms_norm(1);
     }
+#endif
 }