Repository navigation
vulkan: add f16 B-type matmul pipelines and warp tile size tuning for Intel coopmat1 - #27471
Conversation
jeffbolznv
left a comment
There was a problem hiding this comment.
Haven't done a full review, just some initial comments.
| @@ -9208,6 +9308,10 @@ static void ggml_vk_mul_mat_q_f16(ggml_backend_vk_context * ctx, vk_context& sub | |||
| const bool x_non_contig = (ctx->device->coopmat2 && src0->type == GGML_TYPE_F32) || | |||
| !ggml_vk_dim01_contiguous(src0); | |||
| const bool y_non_contig = (ctx->device->coopmat2 && src1->type == GGML_TYPE_F32) || | |||
| // Intel coopmat1: force f32->f16 conversion so the f16-B-type pipeline is used. | |||
There was a problem hiding this comment.
Maybe we should do more testing and try to enable this across all devices? Reducing the load bandwidth for the B matrix seems like it should generally be a win. I've also thought about potentially fusing the f32->f16 conversion into the previous node to eliminate any overhead. But even without that, this is a win on NV and at least some Intel, so it seems likely it's a win everywhere.
There was a problem hiding this comment.
Yes, testing on more platforms would be good, but I don't have a non-Intel GPU on hand right now. May try to test later.
Fusing the f32->f16 conversion into the previous node is a great idea — it could reduce the overhead of that conversion.
| @@ -7908,6 +7993,19 @@ static vk_matmul_pipeline ggml_vk_get_mul_mat_mat_id_pipeline(ggml_backend_vk_co | |||
| case GGML_TYPE_MXFP4: | |||
| case GGML_TYPE_NVFP4: | |||
| case GGML_TYPE_TQ2_0: | |||
| if (src1_type == GGML_TYPE_F16 && !ctx->device->coopmat2) { | |||
There was a problem hiding this comment.
Can this be merged into the logic at the end of the function? I think it's just a different selection of mmp.
|
this will also be on windows only for intel arl_h right? since coopmat is not enabled on linux due to driver issue? |
|
I tested it on AMD and Nvidia GPUs: Dense models (pp512 t/s)
tg128 unaffected MoE models (pp512 and tg128 t/s)
For MoE there's probably a missing size threshold where the savings are too small for the overhead, but in general it can help on other vendors too. |
b44211b to
ce1a1b7
Compare
Yes — it just follows from coopmat_support. |
|
@0cc4m, Thanks for testing this on AMD and NVIDIA GPUs! I ran a quick local test on an AMD iGPU (890M) — both dense and MoE show gains. Small sample, so take with a grain of salt (iGPU, more prone to power/thermal noise than a discrete GPU): Before:
After:
BTW, this PR theoretically doesn't touch decode. So the R9700 tg128 -6.6% seems unlikely to come from this change — could it be a power/frequency variance in that run? |
|
@0cc4m Do you have any further guidance or comments to help move the PR forward? |
…oE stays Intel-only)
… to Intel, fix mmp selection
d7a1d16 to
28b7bb8
Compare
…5773) * vulkan: use spec constant for mul mat type_a vulkan: use map for mul_mm shapes cleanup fix indentation fix cm2 and shmem init fix cm2 spec constants fix cm2 bindings consolidate shmem tables and reduce size by type spec constant fix compiler warning fix missing Q2_0 type fix unused warning when integer dot glslc support is missing use minimal shmem size 8 instead of 1 to workaround cm2 compiler bug fix missing Q2_0 type in cm2 matmul fix types * remove LUT quants from unified shader * clean up * restore coopmat2 q4_k/q5_k optimization * split out q4_k/q5_k cm2 shader to fix Ampere regression * revert iq shmem table renames * simplify cm2 code with single uint8_t buffer * fix fp4 extension use switch being overwritten by generic shader * clean up * adapt TQ1_0 changes * adapt #27471 f16 Intel tuning changes
… Intel coopmat1 (ggml-org#27471) * vulkan: add f16 B-type matmul pipelines and warp tile size tuning for Intel coopmat1 * simplify mmp selection in mul_mat_id per review comment * vulkan: enable f16 B-type pipeline for dense matmul on all vendors (MoE stays Intel-only) * vulkan: add missing ocp_fp4 branches, restrict required_subgroup_size to Intel, fix mmp selection * refine mmp selection in mul_mat_id * add f16B pipeline selection just like q8_1 * update f16B pipeline selection in dense function
…ml-org#25773) * vulkan: use spec constant for mul mat type_a vulkan: use map for mul_mm shapes cleanup fix indentation fix cm2 and shmem init fix cm2 spec constants fix cm2 bindings consolidate shmem tables and reduce size by type spec constant fix compiler warning fix missing Q2_0 type fix unused warning when integer dot glslc support is missing use minimal shmem size 8 instead of 1 to workaround cm2 compiler bug fix missing Q2_0 type in cm2 matmul fix types * remove LUT quants from unified shader * clean up * restore coopmat2 q4_k/q5_k optimization * split out q4_k/q5_k cm2 shader to fix Ampere regression * revert iq shmem table renames * simplify cm2 code with single uint8_t buffer * fix fp4 extension use switch being overwritten by generic shader * clean up * adapt TQ1_0 changes * adapt ggml-org#27471 f16 Intel tuning changes
… Intel coopmat1 (ggml-org#27471) * vulkan: add f16 B-type matmul pipelines and warp tile size tuning for Intel coopmat1 * simplify mmp selection in mul_mat_id per review comment * vulkan: enable f16 B-type pipeline for dense matmul on all vendors (MoE stays Intel-only) * vulkan: add missing ocp_fp4 branches, restrict required_subgroup_size to Intel, fix mmp selection * refine mmp selection in mul_mat_id * add f16B pipeline selection just like q8_1 * update f16B pipeline selection in dense function
…ml-org#25773) * vulkan: use spec constant for mul mat type_a vulkan: use map for mul_mm shapes cleanup fix indentation fix cm2 and shmem init fix cm2 spec constants fix cm2 bindings consolidate shmem tables and reduce size by type spec constant fix compiler warning fix missing Q2_0 type fix unused warning when integer dot glslc support is missing use minimal shmem size 8 instead of 1 to workaround cm2 compiler bug fix missing Q2_0 type in cm2 matmul fix types * remove LUT quants from unified shader * clean up * restore coopmat2 q4_k/q5_k optimization * split out q4_k/q5_k cm2 shader to fix Ampere regression * revert iq shmem table renames * simplify cm2 code with single uint8_t buffer * fix fp4 extension use switch being overwritten by generic shader * clean up * adapt TQ1_0 changes * adapt ggml-org#27471 f16 Intel tuning changes
… Intel coopmat1 (ggml-org#27471) * vulkan: add f16 B-type matmul pipelines and warp tile size tuning for Intel coopmat1 * simplify mmp selection in mul_mat_id per review comment * vulkan: enable f16 B-type pipeline for dense matmul on all vendors (MoE stays Intel-only) * vulkan: add missing ocp_fp4 branches, restrict required_subgroup_size to Intel, fix mmp selection * refine mmp selection in mul_mat_id * add f16B pipeline selection just like q8_1 * update f16B pipeline selection in dense function
…ml-org#25773) * vulkan: use spec constant for mul mat type_a vulkan: use map for mul_mm shapes cleanup fix indentation fix cm2 and shmem init fix cm2 spec constants fix cm2 bindings consolidate shmem tables and reduce size by type spec constant fix compiler warning fix missing Q2_0 type fix unused warning when integer dot glslc support is missing use minimal shmem size 8 instead of 1 to workaround cm2 compiler bug fix missing Q2_0 type in cm2 matmul fix types * remove LUT quants from unified shader * clean up * restore coopmat2 q4_k/q5_k optimization * split out q4_k/q5_k cm2 shader to fix Ampere regression * revert iq shmem table renames * simplify cm2 code with single uint8_t buffer * fix fp4 extension use switch being overwritten by generic shader * clean up * adapt TQ1_0 changes * adapt ggml-org#27471 f16 Intel tuning changes
… Intel coopmat1 (ggml-org#27471) * vulkan: add f16 B-type matmul pipelines and warp tile size tuning for Intel coopmat1 * simplify mmp selection in mul_mat_id per review comment * vulkan: enable f16 B-type pipeline for dense matmul on all vendors (MoE stays Intel-only) * vulkan: add missing ocp_fp4 branches, restrict required_subgroup_size to Intel, fix mmp selection * refine mmp selection in mul_mat_id * add f16B pipeline selection just like q8_1 * update f16B pipeline selection in dense function
…ml-org#25773) * vulkan: use spec constant for mul mat type_a vulkan: use map for mul_mm shapes cleanup fix indentation fix cm2 and shmem init fix cm2 spec constants fix cm2 bindings consolidate shmem tables and reduce size by type spec constant fix compiler warning fix missing Q2_0 type fix unused warning when integer dot glslc support is missing use minimal shmem size 8 instead of 1 to workaround cm2 compiler bug fix missing Q2_0 type in cm2 matmul fix types * remove LUT quants from unified shader * clean up * restore coopmat2 q4_k/q5_k optimization * split out q4_k/q5_k cm2 shader to fix Ampere regression * revert iq shmem table renames * simplify cm2 code with single uint8_t buffer * fix fp4 extension use switch being overwritten by generic shader * clean up * adapt TQ1_0 changes * adapt ggml-org#27471 f16 Intel tuning changes
Overview
Performance (Windows OS)
Xe1-ARL_H
Before:
C:\kernel\llama.cpp\build_base\bin\Release>llama-bench.exe -p 512 -n 0 -r 3 -fa 0,1 --delay 10 -ngl 99 -m C:\kernel\model\gemma-4-31B-it-Q4_K_M.gguf,C:\kernel\model\Qwen3-0.6B-Q4_K_M.gguf,C:\kernel\model\qwen3-8b-q4_k_m.gguf,C:\kernel\model\Qwen3.8-27B-Q4_K_M.gguf,C:\kernel\model\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\kernel\model\gpt-oss-20b-Q4_K_M.gguf
After:
C:\kernel\llama.cpp\build\bin\Release>llama-bench.exe -p 512 -n 0 -r 3 -fa 0,1 --delay 10 -ngl 99 -m C:\kernel\model\gemma-4-31B-it-Q4_K_M.gguf,C:\kernel\model\Qwen3-0.6B-Q4_K_M.gguf,C:\kernel\model\qwen3-8b-q4_k_m.gguf,C:\kernel\model\Qwen3.8-27B-Q4_K_M.gguf,C:\kernel\model\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\kernel\model\gpt-oss-20b-Q4_K_M.gguf
Xe3-PTL
Before:
C:\Users\dungeon\Desktop\fish\llama.cpp\build_ d59d\bin\Release>llama-bench.exe -p 512 -n 0 -r 3 -fa 0,1 --delay 10 -ngl 99 -m C:\Users\dungeon\Desktop\models\qwen3-8b-q4_k_m\qwen3-8b-q4_k_m.gguf,C:\Users\dungeon\Desktop\models\qwen2.5-1.5b-instruct-q4_k_m\qwen2.5-1.5b-instruct-q4_k_m.gguf,C:\Users\dungeon\Desktop\models\Llama-3.1-8B-Instruct-Q4_K_M\Llama-3.1-8B-Instruct-Q4_K_M.gguf,C:\Users\dungeon\Downloads\Qwen3.8-27B-Q4_K_M.gguf,C:\Users\dungeon\Downloads\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gpt-oss-20b-Q4_K_M\gpt-oss-20b-Q4_K_M.gguf
After:
C:\Users\dungeon\Desktop\fish\llama.cpp\build\bin\Release>llama-bench.exe -p 512 -n 0 -r 3 -fa 0,1 --delay 10 -ngl 99 -m C:\Users\dungeon\Desktop\models\qwen3-8b-q4_k_m\qwen3-8b-q4_k_m.gguf,C:\Users\dungeon\Desktop\models\qwen2.5-1.5b-instruct-q4_k_m\qwen2.5-1.5b-instruct-q4_k_m.gguf,C:\Users\dungeon\Desktop\models\Llama-3.1-8B-Instruct-Q4_K_M\Llama-3.1-8B-Instruct-Q4_K_M.gguf,C:\Users\dungeon\Downloads\Qwen3.8-27B-Q4_K_M.gguf,C:\Users\dungeon\Downloads\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\Users\dungeon\Desktop\models\gpt-oss-20b-Q4_K_M\gpt-oss-20b-Q4_K_M.gguf
ggml_vulkan: Found 1 Vulkan devices:
ggml_vulkan: 0 = Intel(R) Graphics i gfx-driver-ci-comp_igc-34261 DCH RI (Intel Corporation) | uma: 1 | fp16: 1 | bf16: 0 | fp4: 0 | warp size: 32 | shared memory: 65536 | int dot: 1 | matrix cores: KHR_coopmat
Xe2-B70
Before:
C:\kernel\llama.cpp\build_base\bin\Release>llama-bench.exe -p 512 -n 0 -r 5 -fa 0,1 --delay 10 -ngl 99 -m C:\kernel\model\gemma-4-31B-it-Q4_K_M.gguf,C:\kernel\model\Qwen3-0.6B-Q4_K_M.gguf,C:\kernel\model\qwen3-8b-q4_k_m.gguf,C:\kernel\model\Qwen3.8-27B-Q4_K_M.gguf,C:\kernel\model\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\kernel\model\gpt-oss-20b-Q4_K_M.gguf
After:
C:\kernel\llama.cpp\build\bin\Release>llama-bench.exe -p 512 -n 0 -r 5 -fa 0,1 --delay 10 -ngl 99 -m C:\kernel\model\gemma-4-31B-it-Q4_K_M.gguf,C:\kernel\model\Qwen3-0.6B-Q4_K_M.gguf,C:\kernel\model\qwen3-8b-q4_k_m.gguf,C:\kernel\model\Qwen3.8-27B-Q4_K_M.gguf,C:\kernel\model\Qwen3.6-35B-A3B-UD-Q4_K_M.gguf,C:\kernel\model\gpt-oss-20b-Q4_K_M.gguf
Requirements
I have read and agree with the contributing guidelines
AI usage disclosure: YES, used claude code, then lots of manual review/tweaking.