Skip to content

Conversation

@futz12
Copy link

@futz12 futz12 commented Nov 1, 2025

revert: #16872

fix: #16860

This fix simply disables the optimization for the corresponding shader to address this issue. For glslc versions without this bug, it is unnecessary to turn off the optimization. I added a new macro to check if the data types are the same to avoid casting, rather than disabling optimization, ensuring that performance is not affected.

cannot compile rope_norm_f16

/bin/glslc -fshader-stage=compute --target-env=vulkan1.2 -O /home/cix/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp -o /home/cix/llama.cpp/build/ggml/src/ggml-vulkan/vulkan-shaders.spv/rope_norm_f16.spv -DA_TYPE=float16_t -DD_TYPE=float16_t 

shaderc: internal error: compilation succeeded but failed to optimize: Expected input to have different bit width from Result Type: FConvert
%212 = OpFConvert %half %211

During the process of compiling SPV with glslc, FConvert is used to convert variables of the same type. Shaderc considers this invalid, resulting in a compilation error.

@jeffbolznv

# Conflicts:
#	ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp
#	ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp
#	ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp
@futz12 futz12 requested a review from 0cc4m as a code owner November 1, 2025 19:01
@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 Nov 1, 2025
@jeffbolznv
Copy link
Collaborator

I would rather disable spirv-opt, which I don't think gains any performance at all, than add more complexity to the shaders.

@0cc4m
Copy link
Collaborator

0cc4m commented Nov 1, 2025

Do you see a performance difference from this change?

@futz12
Copy link
Author

futz12 commented Nov 2, 2025

You are right, enabling opt can even result in negative optimization.

@futz12 futz12 closed this Nov 2, 2025
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.

Compile bug: Vulkan backend, glslc shader compilation errors (Ubuntu 24.04.3)

3 participants