Skip to content

Commit 1f30ac0

Browse files
authored
vulkan: Programmatically add RoundingModeRTE to all shaders when the device supports it (ggml-org#21572)
* vulkan: Programmatically add RoundingModeRTE to all shaders when the device supports it * use FetchContent to get SPIRV-Headers * Fetch spirv-headers unconditionally * remove fetchcontent, rely on installed headers * fix ubuntu job * Update docs/build.md
1 parent f4b5bf2 commit 1f30ac0

19 files changed

Lines changed: 146 additions & 177 deletions

.devops/vulkan.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apt update && apt install -y git build-essential cmake wget xz-utils
77

88
# Install SSL and Vulkan SDK dependencies
99
RUN apt install -y libssl-dev curl \
10-
libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc
10+
libxcb-xinput0 libxcb-xinerama0 libxcb-cursor-dev libvulkan-dev glslc spirv-headers
1111

1212
# Build it
1313
WORKDIR /app

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ jobs:
318318
id: depends
319319
run: |
320320
sudo apt-get update
321-
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev libssl-dev ninja-build
321+
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
322322
echo "CC=gcc-14" >> "$GITHUB_ENV"
323323
echo "CXX=g++-14" >> "$GITHUB_ENV"
324324

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libssl-dev
203203
else
204204
sudo apt-get update -y
205-
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev libssl-dev ninja-build
205+
sudo apt-get install -y gcc-14 g++-14 build-essential glslc libvulkan-dev spirv-headers libssl-dev ninja-build
206206
echo "CC=gcc-14" >> "$GITHUB_ENV"
207207
echo "CXX=g++-14" >> "$GITHUB_ENV"
208208
fi

docs/build.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ pacman -S git \
456456
mingw-w64-ucrt-x86_64-gcc \
457457
mingw-w64-ucrt-x86_64-cmake \
458458
mingw-w64-ucrt-x86_64-vulkan-devel \
459-
mingw-w64-ucrt-x86_64-shaderc
459+
mingw-w64-ucrt-x86_64-shaderc \
460+
mingw-w64-ucrt-x86_64-spirv-headers
460461
```
461462

462463
Switch into the `llama.cpp` directory and build using CMake.
@@ -490,9 +491,11 @@ First, follow the official LunarG instructions for the installation and setup of
490491

491492
On Debian / Ubuntu, you can install the required dependencies using:
492493
```sh
493-
sudo apt-get install libvulkan-dev glslc
494+
sudo apt-get install libvulkan-dev glslc spirv-headers
494495
```
495496

497+
SPIRV-Headers (`spirv/unified1/spirv.hpp`) are required for the Vulkan backend and are **not** always pulled in by the Vulkan loader dev package alone. Other distros use names such as `spirv-headers` (Ubuntu / Debian / Arch), or `spirv-headers-devel` (Fedora / openSUSE). On Windows, the LunarG Vulkan SDK’s `Include` directory already contains these headers.
498+
496499
#### Common steps
497500

498501
Second, after verifying that you have followed all of the SDK installation/setup steps, use this command to make sure before proceeding:

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 107 additions & 94 deletions
Large diffs are not rendered by default.

ggml/src/ggml-vulkan/vulkan-shaders/copy_to_quant.comp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#version 450
22

3-
#include "rte.glsl"
43
#include "types.glsl"
54

65
#if defined(SET_ROWS) && QUANT_K == 1

ggml/src/ggml-vulkan/vulkan-shaders/diag.comp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#version 450
22

3-
#include "rte.glsl"
43
#include "types.glsl"
54
#include "generic_unary_head.glsl"
65

ggml/src/ggml-vulkan/vulkan-shaders/exp.comp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#version 450
22

3-
#include "rte.glsl"
43
#include "generic_head.glsl"
54
#include "types.glsl"
65

ggml/src/ggml-vulkan/vulkan-shaders/generic_binary_head.glsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#extension GL_EXT_shader_16bit_storage : require
22
#extension GL_EXT_control_flow_attributes : require
33

4-
#include "rte.glsl"
54
#include "utils.glsl"
65
#if RMS_NORM_ROPE_FUSION
76
#include "rope_params.glsl"

ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#extension GL_EXT_shader_16bit_storage : require
22

3-
#include "rte.glsl"
43

54
layout(local_size_x = 512, local_size_y = 1, local_size_z = 1) in;
65

0 commit comments

Comments
 (0)