From 9fc8a9039b805cd31ab9f87d5942ebbc3682ee24 Mon Sep 17 00:00:00 2001
From: Mike Lothian <mike@fireburn.co.uk>
Date: Wed, 21 Oct 2026 12:26:14 +0100
Subject: [PATCH 2/2] vulkan : compute two rows per workgroup in the integer
 mat-vec from two columns on RDNA4

The integer mat-vec used one row per workgroup for 2 to 4 columns and four rows
from five columns. Two rows per workgroup from two columns up reloads the
activations half as often. Speculative decoding verification steps of three to
six tokens are 2 to 5% faster on a Radeon AI PRO R9700. Single tokens and RDNA3
are unchanged.

Assisted-by: Claude Code (Claude Sonnet 5.5)
---
 ggml/src/ggml-vulkan/ggml-vulkan.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp
index 82fd54683..8a728fec4 100644
--- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp
+++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp
@@ -2890,7 +2890,9 @@ void ggml_vk_load_shaders(vk_device& device, vk_pipeline requested) {
     }
     // RDNA3/4: above four columns, static 4 rows for all types bench faster than the default
     const bool is_rdna3_or_4 = device->vendor_id == VK_VENDOR_ID_AMD && (device->architecture == AMD_RDNA3 || device->architecture == AMD_RDNA4);
-    auto const &rm_int_n = [&](uint32_t rows, uint32_t i) { return (is_rdna3_or_4 && i >= 4) ? 4u : rows; };
+    const bool is_rdna4 = device->vendor_id == VK_VENDOR_ID_AMD && device->architecture == AMD_RDNA4;
+    // RDNA4: two rows from two columns up bench faster for the speculative decoding verification batches
+    auto const &rm_int_n = [&](uint32_t rows, uint32_t i) { return is_rdna4 && i >= 1 ? 2u : (is_rdna3_or_4 && i >= 4) ? 4u : rows; };
     // RDNA3-class dGPU: legacy quants are faster with 4 rows from 2 columns
     auto const &rm_int_n_stdq = [&](uint32_t rows, uint32_t i) { return (is_rdna3_or_4 && !device->uma && i >= 1) ? 4u : rows; };
     // RDNA3/4 and NVIDIA except pre-Turing: use 4 rows for MUL_MAT_ID MMVQ.
-- 
2.56.0

