shaderc internal error: Invalid capability operand: 5447 with cooperative‑matrix shader
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 445
- Avg merge
- 11h 6m
- Merged PRs (30d)
- 6
Description
# Bug Report
## Environment
- Platform: Android aarch64 (Termux)
- glslc/shaderc installed from Termux official repository
## Problem
When compiling a Vulkan compute‑shader that uses Cooperative Matrix 2 capabilities with optimization flag `-O`, the compilation succeeds, but the SPIR‑V optimizer crashes internally:
shaderc: internal error: compilation succeeded but failed to optimize: Invalid capability operand: 5447
## Reproduction command
```bash
glslc -fshader-stage=compute --target-env=vulkan1.3 flash_attn_cm2.comp -o test.spv -O -DFLOAT16=1
Expected
Shader file compiles and optimizes successfully.
Actual
Optimizer crashes with capability operand error 5447.
log
FAILED: [code=1] ggml/src/ggml-vulkan/flash_attn_cm2.comp.cpp /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/flash_attn_cm2.comp.cpp
cd /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan && /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/Release/vulkan-shaders-gen --glslc /data/data/com.termux/files/usr/bin/glslc --source /data/data/com.termux/files/home/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp --output-dir /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/vulkan-shaders.spv --target-hpp /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/ggml-vulkan-shaders.hpp --target-cpp /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/flash_attn_cm2.comp.cpp && /data/data/com.termux/files/usr/bin/cmake -E cmake_transform_depfile Ninja gccdepfile /data/data/com.termux/files/home/llama.cpp /data/data/com.termux/files/home/llama.cpp/ggml/src/ggml-vulkan /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/flash_attn_cm2.comp.cpp.d /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/CMakeFiles/d/30a9d6f3b1b015303a03ec3dbf8eddc26d6be08bdddef1e96be34374efff9e92.d
cannot compile flash_attn_f32_f16_cm2 (exit code 1)
/data/data/com.termux/files/usr/bin/glslc -fshader-stage=compute --target-env=vulkan1.3 /data/data/com.termux/files/home/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp -o /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/vulkan-shaders.spv/flash_attn_f32_f16_cm2.spv -O -MD -MF /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/flash_attn_cm2.comp.cpp.d -DACC_TYPE=float -DACC_TYPEV2=vec2 -DACC_TYPEV4=vec4 -DDATA_A_IQ4_NL=1 -DD_TYPE=float -DD_TYPEV4=vec4 -DFLOAT16=1 -DFLOAT_TYPE=float16_t -DFLOAT_TYPEV2=f16vec2 -DFLOAT_TYPEV4=f16vec4 -DFLOAT_TYPE_MAX=float16_t(65504.0) -DQ_TYPE=float
shaderc: internal error: compilation succeeded but failed to optimize: Invalid capability operand: 5447
cannot compile flash_attn_f32_f16_f16acc_cm2 (exit code 1)
/data/data/com.termux/files/usr/bin/glslc -fshader-stage=compute --target-env=vulkan1.3 /data/data/com.termux/files/home/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp -o /data/data/com.termux/files/home/llama.cpp/build-vulkan-gpu/ggml/src/ggml-vulkan/vulkan-shaders.spv/flash_attn_f32_f16_f16acc_cm2.spv -O -DACC_TYPE=float16_t -DACC_TYPEV2=f16vec2 -DACC_TYPEV4=f16vec4 -DACC_TYPE_MAX=float16_t(65504.0) -DDATA_A_IQ4_NL=1 -DD_TYPE=float -DD_TYPEV4=vec4 -DFLOAT16=1 -DFLOAT_TYPE=float16_t -DFLOAT_TYPEV2=f16vec2 -DFLOAT_TYPEV4=f16vec4 -DFLOAT_TYPE_MAX=float16_t(65504.0) -DQ_TYPE=float
shaderc: internal error: compilation succeeded but failed to optimize: Invalid capability operand: 5447
vulkan-shaders-gen: one or more shaders failed to compile
Contributor guide
Research direction
Start by reproducing the reported glslc command with ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp and the Vulkan 1.3 target on Android aarch64. Trace the shaderc optimization path that reports capability operand 5447, then compare behavior with optimization disabled. Done means the cooperative-matrix shader compiles and optimizes successfully with -O without the internal error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100