Skip to content

vulkan: fix PowerVR shader compiler crash with subgroup reduction mode - #20565

Closed
Konoxx wants to merge 1 commit into
ggml-org:masterfrom
Konoxx:fix/powervr-subgroup-reduction-mode
Closed

Konoxx wants to merge 1 commit into
ggml-org:masterfrom
Konoxx:fix/powervr-subgroup-reduction-mode

Conversation

@Konoxx

@Konoxx Konoxx commented Mar 14, 2026

Copy link
Copy Markdown

Summary

  • Adds VK_VENDOR_ID_IMAGINATION (0x1010) vendor ID constant
  • Overrides SHADER_REDUCTION_MODE_SUBGROUP to SHADER_REDUCTION_MODE_HYBRID for Imagination Technologies GPUs
  • Fixes VK_ERROR_UNKNOWN (-13) crash during vkCreateComputePipelines on all quantized matmul shaders

Root Cause

PowerVR's shader compiler crashes on the subgroup_no_shmem SPIR-V variant when the specialization constant NUM_COLS >= 2. With NUM_COLS=1 it works fine. The other two reduction modes (SHMEM and HYBRID) work correctly with all NUM_COLS values.

Isolated through 8 targeted test binaries that systematically narrowed the failure from "all pipelines crash" to "this specific shader variant with this specific specialization constant value."

Fix

Two changes:

  1. Define VK_VENDOR_ID_IMAGINATION 0x1010 alongside existing vendor IDs
  2. After computing reduc/reduc16, override SUBGROUP → HYBRID for Imagination GPUs

The HYBRID mode uses subgroup operations with a shared memory fallback, which the PowerVR compiler handles correctly. Performance impact is minimal — HYBRID is only slightly slower than pure SUBGROUP on other vendors.

Testing

Tested on PowerVR Immortalis G925 (Google Pixel 10 Pro XL, Tensor G5):

  • Vulkan 1.3.288, subgroup size 128, 32KB shared memory
  • All quantized matmul pipelines now compile and execute successfully
  • Benchmarked at 4-5 tok/s GPU inference (vs crash before fix)

Note: GPU compute output has a separate correctness issue (garbled text) on this device that appears to be a deeper driver precision bug unrelated to this shader compilation fix. CPU inference works correctly.

Test plan

  • Verify pipelines compile on PowerVR Immortalis G925
  • Verify no regression on non-Imagination GPUs (override is vendor-gated)
  • Benchmark GPU inference runs without crash
  • Test on other Imagination/PowerVR GPUs if available

🤖 Generated with Claude Code

PowerVR DXT (Imagination Technologies, vendorID 0x1010) shader compiler
crashes on the subgroup_no_shmem SPIR-V variant when NUM_COLS >= 2.
This affects all quantized matmul pipelines during vkCreateComputePipelines.

Root cause: SHADER_REDUCTION_MODE_SUBGROUP generates subgroup-only
reduction code without shared memory. The PowerVR compiler cannot
handle this variant with multiple columns. HYBRID mode (subgroup +
shared memory fallback) and SHMEM mode both work correctly.

Fix: Override SUBGROUP -> HYBRID reduction mode for Imagination GPUs.
Tested on PowerVR Immortalis G925 (Pixel 10 Pro XL, Vulkan 1.3.288).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@Konoxx
Konoxx requested a review from 0cc4m as a code owner March 14, 2026 23:29
@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 Mar 15, 2026
@jeffbolznv

Copy link
Copy Markdown
Contributor

Were there any validation errors with the original code?

@0cc4m

0cc4m commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

@Konoxx Please respond if you want to proceed with this.

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 Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants