]> git.djapps.eu Git - pkg/ggml/sources/ggml/commit
vulkan: Add bfloat16 support (llama/12554)
authorJeff Bolz <redacted>
Thu, 1 May 2025 18:49:39 +0000 (13:49 -0500)
committerGeorgi Gerganov <redacted>
Fri, 2 May 2025 18:18:08 +0000 (21:18 +0300)
commit1f8595d7007df531775dc8817e737c6f6312357c
treeeba533eb8eeeb763b5350e63ba2e8f06addf92d9
parent9d3094ff4438e27268707c9de7b57e3ed88dcd21
vulkan: Add bfloat16 support (llama/12554)

* vulkan: Add bfloat16 support

This adds bfloat16 matrix multiply support based on VK_KHR_shader_bfloat16.
The extension is required for coopmat multiply support, but matrix-vector
multiply trivially promotes bf16 to fp32 and doesn't require the extension.
The copy/get_rows shaders also don't require the extension.

It's probably possible to fall back to non-coopmat and promote to fp32 when
the extension isn't supported, but this change doesn't do that.

The coopmat support also requires a glslc that supports the extension, which
currently requires a custom build.

* vulkan: Support bf16 tensors without the bf16 extension or coopmat support

Compile a variant of the scalar mul_mm shader that will promote the bf16
values to float, and use that when either the bf16 extension or the coopmat
extensions aren't available.

* vulkan: bfloat16 fixes (really works without bfloat16 support now)

* vulkan: fix spirv-val failure and reenable -O
13 files changed:
src/ggml-vulkan/CMakeLists.txt
src/ggml-vulkan/ggml-vulkan.cpp
src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
src/ggml-vulkan/vulkan-shaders/contig_copy.comp
src/ggml-vulkan/vulkan-shaders/copy.comp
src/ggml-vulkan/vulkan-shaders/dequant_funcs.comp
src/ggml-vulkan/vulkan-shaders/get_rows.comp
src/ggml-vulkan/vulkan-shaders/mul_mat_vec.comp
src/ggml-vulkan/vulkan-shaders/mul_mm.comp
src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp
src/ggml-vulkan/vulkan-shaders/test_bfloat16_support.comp [new file with mode: 0644]
src/ggml-vulkan/vulkan-shaders/types.comp
src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp