Skip to content

vulkan: use shared-memory reduction for dequant mul_mat_vec on Imagination PowerVR - #28341

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
JulianPscheid:vulkan-powervr-dmmv-shmem
Sep 10, 2026
Merged

ggerganov merged 1 commit into
ggml-org:masterfrom
JulianPscheid:vulkan-powervr-dmmv-shmem

Conversation

@JulianPscheid

@JulianPscheid JulianPscheid commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Imagination's proprietary Vulkan compiler cannot compile the subgroup-only reduction variants of the dequant mul_mat_vec shaders. vkCreateComputePipelines returns VK_ERROR_UNKNOWN, ggml_vk_create_pipeline_func rethrows, and the process dies with an uncaught vk::SystemError on the first generated token. Prompt processing runs first and succeeds, so the failure looks like a hang partway into generation.

This affects every type that goes through reduc16: Q2_K through Q6_K, TQ2_0, the IQ types, MXFP4 and NVFP4. The legacy quants use the plain subgroup reduction and compile fine, so the subgroup path itself is not the problem.

Falling back to the shared-memory reduction for those shaders fixes it.

Additional information

Device

Pixel 11 Pro, PowerVR C-Series CXTP-48-1536 MC1, VK_DRIVER_ID_IMAGINATION_PROPRIETARY, driver 1.662.3024, Vulkan 1.4.317. Subgroup size 128, min 32, max 128. 32 KB shared memory, no cooperative matrix, no integer dot product.

The failing pipeline is created with require_full_subgroups=1, requiredSubgroupSize=128, wg_denoms=[2,1,1], specialization constants [128,2,1], 17320 bytes of SPIR-V.

What I ruled out

None of these help; the compile still fails:

  • dropping VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT
  • dropping the VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT pNext
  • dropping both
  • forcing the subgroup size to 64
  • forcing it to 32

So it is the shader body, not the pipeline flags or the subgroup width.

Why not the hybrid variant

#20565 proposed hybrid reduction for the same vendor on a Pixel 10. Hybrid does compile here and is correct, but it costs 27% of token throughput on this device:

reduction pp128 tg32
shared memory 21.41 t/s 5.20 t/s
hybrid 21.41 t/s 3.78 t/s

Qwen3.5-2B-Q4_K_M, -ngl 99 -p 128 -n 32 -r 3.

Testing

test-backend-ops against the CPU reference, on device:

type before after
Q2_K pipeline compile fails 11/11
Q3_K pipeline compile fails 11/11
Q4_K pipeline compile fails 26/26
Q5_K pipeline compile fails 11/11
Q6_K pipeline compile fails 11/11

Q4_K and Q6_K repeated four times each, same result every run. llama-bench on Qwen3.5-2B-Q4_K_M runs end to end after the change; before it aborts at the first generated token.

Gated on driver_id rather than vendor_id because the evidence is for the proprietary Android driver only. I have not tested Mesa's PowerVR driver.

Related: #28214 (other problems on the same device, not addressed here), #20565.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. AI was used to help create this PR, including the on-device investigation.

@JulianPscheid
JulianPscheid requested a review from a team as a code owner September 3, 2026 18:44
@github-actions github-actions Bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Sep 3, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Hi @JulianPscheid, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@ggml-gh-bot ggml-gh-bot Bot added the draft PR will be changed to draft by github-actions bot label Sep 3, 2026
@github-actions
github-actions Bot marked this pull request as draft September 3, 2026 18:50
@github-actions github-actions Bot removed the draft PR will be changed to draft by github-actions bot label Sep 3, 2026
@JulianPscheid

Copy link
Copy Markdown
Contributor Author

Hi @JulianPscheid, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

THanks for the feedback. I reworked it to follow the template.

@JulianPscheid
JulianPscheid marked this pull request as ready for review September 3, 2026 20:01
Comment thread ggml/src/ggml-vulkan/ggml-vulkan.cpp Resolved
The Imagination proprietary Vulkan compiler returns VK_ERROR_UNKNOWN from
vkCreateComputePipelines for every dequant mul_mat_vec shader built with the
subgroup-only reduction that requires a subgroup size >= 16. That covers the
k-quants, the i-quants, TQ2_0, MXFP4 and NVFP4. ggml rethrows, so the first
generated token of any such model kills the process.

Reproduced on a Pixel 11 Pro (PowerVR C-Series CXTP-48-1536 MC1, driver
1.662.3024, subgroup size 128, min 32, max 128). The failure is independent of
subgroup size: 32, 64 and 128 all fail, as does dropping the full-subgroups
flag and the required-subgroup-size pNext. The legacy quants, which use the
plain subgroup reduction, compile and run fine.

The shared-memory reduction variant compiles and matches the CPU reference for
q2_K, q3_K, q4_K, q5_K and q6_K. The hybrid variant also compiles but costs
27% of token throughput (3.78 vs 5.20 t/s on Qwen3.5-2B-Q4_K_M).
@JulianPscheid
JulianPscheid force-pushed the vulkan-powervr-dmmv-shmem branch from b5299b1 to 032670a Compare September 4, 2026 14:09
@0cc4m 0cc4m added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Sep 10, 2026
@ggerganov
ggerganov merged commit 3ff67eb into ggml-org:master Sep 10, 2026
28 of 30 checks passed
@BrewTestBot BrewTestBot mentioned this pull request Sep 14, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants