vulkan: add SHMEM_STRIDE_PAD/APPLY_SLM_A_RESHAPE for coopmat1 on Intel Xe - #25380
Conversation
|
Would be good to keep ggml_vk_matmul_shmem_support up to date with the new SHMEM_STRIDE_PAD value for Intel. I tested on NVIDIA (coopmat1) and the performance stays the same (as expected) with the change. But also, surprisingly, with the Intel spec constant values set and it was still more or less the same. |
Updated the code in ggml_vk_matmul_shmem_support. APPLY_SLM_A_RESHAPE reduces the number of SLM load messages generated for coopMatLoad in the ISA on Intel GPUs; NVIDIA's coopMatLoad likely doesn't hit the same bottleneck, which would explain why you saw no change there. |
|
Currently I see a slight regression when testing with Arc Pro B50 on Ubuntu 26.04, Mesa 26.1.4 BeforeAfter |
Thanks @rillomas for capturing this on B50 Linux. I found an issue with gpt-oss 20B Q4_K: the shared memory size for kvalues_mxfp4 causes SHMEM_STRIDE_PAD=0 to not work as expected. I submitted a new commit that makes the matrix shared memory address cacheline-aligned to fix this. Could you please double-check? |
|
Thanks, it seems the regression is fixed now. (Environment: Arc Pro B50 on Ubuntu 26.04, Mesa 26.1.4) Before$ master-tree/build_vk/bin/llama-bench -p 8192 -n 0 -r 2 -fa 0,1 --delay 10 -m ~/models/gpt-oss-20b-Q4_K_M.gguf
build: ee445f9 (9892) After$ build_vk/bin/llama-bench -p 8192 -n 0 -r 2 -fa 0,1 --delay 10 -m ~/models/gpt-oss-20b-Q4_K_M.gguf
build: 37c3ead (9895) |
|
@jeffbolznv I have a new commit in the PR: 37c3ead Could you please help review it? I'm not sure how much this impacts other vendors, but it helps with shared memory cacheline alignment for GPT-OSS on Intel GPUs. |
| }; | ||
|
|
||
| shared int8_t kvalues_mxfp4[16]; | ||
| shared int8_t kvalues_mxfp4[64]; |
There was a problem hiding this comment.
This at the very least needs a comment to say it's being padded to a cache line size for performance reasons. But now the loop at line 1796 fetches beyond the end of the source array, so that need to be fixed.
There was a problem hiding this comment.
oh, and the shared memory size calculation logic in ggml-vulkan.cpp also needs to be updated.
There was a problem hiding this comment.
Thanks for catching that. For the OOB read in init_iq_shmem, I've fixed the loop bound to use kvalues_mxfp4_const.length() instead of kvalues_mxfp4.length(), and added a comment explaining the cacheline padding.
For the shmem accounting in ggml_vk_matmul_shmem_support (
llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp
Lines 3633 to 3641 in 37c3ead
There was a problem hiding this comment.
I don't understand this change, shouldn't it already be aligned? Why does increasing the size without using any of the additional space help with alignment? That seems like something the driver should handle internally. I don't want to increased shared memory use without a very good reason.
There was a problem hiding this comment.
The unexpected ISA generated by the Linux driver is causing a perf drop, so we disabled this optimization on Linux for now .
Also agree with your concern about the kvalues_mxfp4 alignment — I've reverted that change, since the SLM-A reshape path is not enabled on Linux right now.
There was a problem hiding this comment.
@0cc4m could you please review this PR again?
a839129 to
4be81ee
Compare
|
@jeffbolznv I rebased and resolved the conflicts with your USE_OCP_FP4 change. Let me know if there's anything else needed to move this PR forward. |
|
The change looks fine to me, just need @0cc4m to review. Are we confident this won't regress any other Intel configurations? |
|
Thanks @jeffbolznv , I have re-verified the perf gains after the rebase on different platforms.
After:
Xe2- B70
After
Xe1 - ARL_H
After:
|
|
We're currently checking on some potential regressions on Linux. |
69271a7 to
a8ff697
Compare
|
We benchmarked two Battlemage GPUs on Linux, and while we see some gains we also saw many losses. Some pipelines like Microbenchmark ResultsFollowing results are from running Arc B570 (Mesa 26.1.4)Best case +25%, worst case -15%. 5.7% of the cases show +5% or more improvement and 24% of the cases show -5% or more regression Arc Pro B50 (Mesa 26.1.4)Best case +25%, worst case -14%. 9.4% of the cases show +5% or more improvement and 10% of the cases show -5% or more regression. Benchmark data
|
|
@0cc4m could you please review this PR again? Let me know if there's anything else needed to move this PR forward. |
|
Sorry, I'm currently on vacation with limited time. Can you rebase this, please? I'll get to it soon. |
…cacheline padding
a8ff697 to
06cf97d
Compare
|
Thanks @0cc4m. Rebase done. |
|
I can't test any of the gains, but I can confirm that I see no regressions. |
…l Xe (ggml-org#25380) * vulkan: add SHMEM_STRIDE_PAD/APPLY_SLM_A_RESHAPE for coopmat mul_mm on Intel Xe * vulkan: fix shmem estimate for Intel SHMEM_STRIDE_PAD=0 in matmul_shmem_support * cacheline aligned for shared kvalues_mxfp4 * vulkan: fix OOB read in kvalues_mxfp4 init after cacheline padding * vulkan: restrict SLM-A reshape to Intel Windows driver, revert mxfp4 cacheline padding
…l Xe (ggml-org#25380) * vulkan: add SHMEM_STRIDE_PAD/APPLY_SLM_A_RESHAPE for coopmat mul_mm on Intel Xe * vulkan: fix shmem estimate for Intel SHMEM_STRIDE_PAD=0 in matmul_shmem_support * cacheline aligned for shared kvalues_mxfp4 * vulkan: fix OOB read in kvalues_mxfp4 init after cacheline padding * vulkan: restrict SLM-A reshape to Intel Windows driver, revert mxfp4 cacheline padding


Overview
Performance (Panther Lake B390 + Windows OS)
BEFORE:
C:\temp\base\Release>llama-bench.exe -p 8192 -n 0 -r 2 -fa 0,1 --delay 10 -ngl 99 -m C:\Users\dungeon\Desktop\models\Qwen3.5-35B-A3B-Q4_K_M\Qwen3.5-35B-A3B-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gpt-oss-20b-Q4_K_M\gpt-oss-20b-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gemma-4-26B-A4B-it-UD-Q4_K_M\gemma-4-26B-A4B-it-UD-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\Qwen3-Coder-30B-A3B-Instruct-Q4_K_M\Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf
ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = Intel(R) Arc(TM) B390 GPU (Intel Corporation) | uma: 1 | fp16: 1 | bf16: 0 | warp size: 32 | shared memory: 49152 | int dot: 1 | matrix cores: KHR_coopmat
build: ee445f9 (9892)
AFTER:
C:\temp\slma_pad\Release>llama-bench.exe -p 8192 -n 0 -r 2 -fa 0,1 --delay 10 -ngl 99 -m C:\Users\dungeon\Desktop\models\Qwen3.5-35B-A3B-Q4_K_M\Qwen3.5-35B-A3B-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gpt-oss-20b-Q4_K_M\gpt-oss-20b-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gemma-4-26B-A4B-it-UD-Q4_K_M\gemma-4-26B-A4B-it-UD-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\Qwen3-Coder-30B-A3B-Instruct-Q4_K_M\Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf
ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = Intel(R) Arc(TM) B390 GPU (Intel Corporation) | uma: 1 | fp16: 1 | bf16: 0 | warp size: 32 | shared memory: 49152 | int dot: 1 | matrix cores: KHR_coopmat
Requirements
I have read and agree with the contributing guidelines
AI usage disclosure: YES, used claude code, then lots of manual review/tweaking.