Skip to content

Vulkan failed to build glsl kernel with Android NDK #14507

@Jianhua-Cui

Description

@Jianhua-Cui

🐛 Describe the bug

I'm trying to perform inference using the VULKAN C++ runtime, but I've found that the glslc compiler provided by Android NDK r28c cannot compile the glsl kernel properly.

After I set set(EXECUTORCH_BUILD_VULKAN ON CACHE BOOL "") in the CMakeLists.txt, a custom command for the vulkan backend will attempt to call a Python script, which in turn invokes glslc to compile the gl kernels:

subprocess.CalledProcessError: Command '['/home/cuijianhua/tools/android-ndk-r28c/shader-tools/linux-x86_64/glslc', '-fshader-stage=compute', '/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_dq8ca_q4gsw_tiled_buffer_texture2d_half.glsl', '-o', '/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_dq8ca_q4gsw_tiled_buffer_texture2d_half.spv', '--target-env=vulkan1.1', '-Werror', '-I', '/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders', '-O']' returned non-zero exit status 1.

The specific error message of glslc is as follows:

RuntimeError: Failed to compile /home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/executorch/backends/vulkan//home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_dq8ca_q4gsw_tiled_buffer_texture2d_half.glsl:  /home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int8_compute.glslh:21: error: '#extension' : extension not supported: GL_EXT_integer_dot_product
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int8_compute.glslh:56: error: 'dotPacked4x8AccSatEXT' : no matching overloaded function found
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int8_compute.glslh:53: error: 'assign' :  cannot convert from ' const float' to ' temp highp int'
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int4_compute.glslh:13: error: '#extension' : extension not supported: GL_EXT_integer_dot_product
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int4_compute.glslh:45: error: 'dotPacked4x8AccSatEXT' : no matching overloaded function found
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int4_compute.glslh:42: error: 'assign' :  cannot convert from ' const float' to ' temp highp int'
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int4_compute.glslh:49: error: 'dotPacked4x8AccSatEXT' : no matching overloaded function found
/home/cuijianhua/llm_workspace/executorch_workspace/learning_executorch/build-ANDROID-aarch64-Release/vulkan_compute_shaders/linear_fp_output_tile_int8_int4_compute.glslh:46: error: 'assign' :  cannot convert from ' const float' to ' temp highp int'
8 errors generated.

I believe the glslc compiler frontend provided by the Android NDK does not support the GL_EXT_integer_dot_product extension. For example, we can try a test.glsl kernel like this:

#version 450
#extension GL_EXT_integer_dot_product : require
void main() {}

And then compile this test kernel with:

/home/cuijianhua/tools/android-ndk-r28c/shader-tools/linux-x86_64/glslc \
    -fshader-stage=compute \
    --target-env=vulkan1.3 \
    test.glsl -o tmp.spv

It occurs the same error:

test.glsl:2: error: '#extension' : extension not supported: GL_EXT_integer_dot_product
1 error generated.

I find this very strange. I believe the Vulkan backend has been tested through CI, but this is exactly what I observed.

I would greatly appreciate it if anyone could provide any information.

Versions

Collecting environment information...
PyTorch version: 2.9.0.dev20250906+cpu
Is debug build: False
CUDA used to build PyTorch: Could not collect
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.5 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
Clang version: 14.0.0-1ubuntu1.1
CMake version: version 3.31.6
Libc version: glibc-2.35

Python version: 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:24:10) [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-6.8.0-79-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration:
GPU 0: NVIDIA GeForce GTX 1080 Ti
GPU 1: NVIDIA GeForce GTX 1080 Ti
GPU 2: NVIDIA GeForce GTX 1080 Ti
GPU 3: NVIDIA GeForce GTX 1080 Ti
GPU 4: NVIDIA GeForce GTX 1080 Ti
GPU 5: NVIDIA GeForce GTX 1080 Ti
GPU 6: NVIDIA GeForce GTX 1080 Ti
GPU 7: NVIDIA GeForce GTX 1080 Ti

Nvidia driver version: 550.54.14
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 64
On-line CPU(s) list: 0-63
Vendor ID: GenuineIntel
Model name: Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz
CPU family: 6
Model: 85
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 2
Stepping: 4
CPU max MHz: 3700.0000
CPU min MHz: 1000.0000
BogoMIPS: 4200.00
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 pti intel_ppin ssbd mba ibrs ibpb stibp tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb intel_pt avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts vnmi pku ospke md_clear flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 1 MiB (32 instances)
L1i cache: 1 MiB (32 instances)
L2 cache: 32 MiB (32 instances)
L3 cache: 44 MiB (2 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-15,32-47
NUMA node1 CPU(s): 16-31,48-63
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Mitigation; PTE Inversion; VMX conditional cache flushes, SMT vulnerable
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Mitigation; PTI
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Mitigation; IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; IBRS; IBPB conditional; STIBP conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Mitigation; Clear CPU buffers; SMT vulnerable

Versions of relevant libraries:
[pip3] executorch==1.1.0a0+bc18834
[pip3] numpy==2.2.6
[pip3] pytorch_tokenizers==0.1.0
[pip3] torch==2.9.0.dev20250906+cpu
[pip3] torchao==0.14.0+gitb99904b34
[pip3] torchaudio==2.8.0.dev20250906+cpu
[pip3] torchdata==0.11.0
[pip3] torchsr==1.0.4
[pip3] torchtune==0.6.1
[pip3] torchvision==0.24.0.dev20250906+cpu
[pip3] triton==3.4.0
[conda] executorch 1.1.0a0+bc18834 pypi_0 pypi
[conda] numpy 2.2.6 pypi_0 pypi
[conda] pytorch-tokenizers 0.1.0 pypi_0 pypi
[conda] torch 2.9.0.dev20250906+cpu pypi_0 pypi
[conda] torchao 0.14.0+gitb99904b34 pypi_0 pypi
[conda] torchaudio 2.8.0.dev20250906+cpu pypi_0 pypi
[conda] torchdata 0.11.0 pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchtune 0.6.1 pypi_0 pypi
[conda] torchvision 0.24.0.dev20250906+cpu pypi_0 pypi
[conda] triton 3.4.0 pypi_0 pypi

cc @SS-JIA @manuelcandales @cbilgin

Metadata

Metadata

Assignees

Labels

module: vulkanIssues related to the Vulkan delegate and code under backends/vulkan/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions