LLM inference in C/C++
C++ ggml
ggml-webgpu: Update to a recent version of Dawn (#28683)
Mendy Bergerd3146f2b56c2
diff --git a/.github/workflows/build-self-hosted.yml b/.github/workflows/build-self-hosted.ymlindex 02a38466fa..c7f992540b 100644--- a/.github/workflows/build-self-hosted.yml+++ b/.github/workflows/build-self-hosted.yml@@ -160,10 +160,10 @@ jobs:- name: Dawn Dependencyid: dawn-dependsrun: |- DAWN_VERSION="v20260317.182325"+ DAWN_VERSION="v20260908.214631"DAWN_OWNER="google"DAWN_REPO="dawn"- DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-ubuntu-latest-Release"+ DAWN_ASSET_NAME="Dawn-94c3c9cc0d5fb2e85aebb370fa8d37b71aa34655-ubuntu-latest-Release"echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"curl -L -o artifact.tar.gz \"https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"@@ -246,10 +246,10 @@ jobs:- name: Dawn Dependencyid: dawn-dependsrun: |- DAWN_VERSION="v20260317.182325"+ DAWN_VERSION="v20260908.214631"DAWN_OWNER="google"DAWN_REPO="dawn"- DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-macos-latest-Release"+ DAWN_ASSET_NAME="Dawn-94c3c9cc0d5fb2e85aebb370fa8d37b71aa34655-macos-latest-Release"echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"curl -L -o artifact.tar.gz \"https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.ymlindex 81b943df7b..5a3166ce68 100644--- a/.github/workflows/build-wasm.yml+++ b/.github/workflows/build-wasm.yml@@ -68,7 +68,7 @@ jobs:- name: Fetch emdawnwebgpurun: |- DAWN_TAG="v20260317.182325"+ DAWN_TAG="v20260908.214631"EMDAWN_PKG="emdawnwebgpu_pkg-${DAWN_TAG}.zip"echo "Downloading ${EMDAWN_PKG}"curl -L -o emdawn.zip \diff --git a/.github/workflows/build-webgpu.yml b/.github/workflows/build-webgpu.ymlindex 8277abcc47..ec582ff274 100644--- a/.github/workflows/build-webgpu.yml+++ b/.github/workflows/build-webgpu.yml@@ -77,10 +77,10 @@ jobs:- name: Dawn Dependencyid: dawn-dependsrun: |- DAWN_VERSION="v20260317.182325"+ DAWN_VERSION="v20260908.214631"DAWN_OWNER="google"DAWN_REPO="dawn"- DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-macos-latest-Release"+ DAWN_ASSET_NAME="Dawn-94c3c9cc0d5fb2e85aebb370fa8d37b71aa34655-macos-latest-Release"echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"curl -L -o artifact.tar.gz \"https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"@@ -147,10 +147,10 @@ jobs:id: dawn-dependsrun: |sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev libxi-dev- DAWN_VERSION="v20260317.182325"+ DAWN_VERSION="v20260908.214631"DAWN_OWNER="google"DAWN_REPO="dawn"- DAWN_ASSET_NAME="Dawn-18eb229ef5f707c1464cc581252e7603c73a3ef0-ubuntu-latest-Release"+ DAWN_ASSET_NAME="Dawn-94c3c9cc0d5fb2e85aebb370fa8d37b71aa34655-ubuntu-latest-Release"echo "Fetching release asset from https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"curl -L -o artifact.tar.gz \"https://github.com/google/dawn/releases/download/${DAWN_VERSION}/${DAWN_ASSET_NAME}.tar.gz"diff --git a/docs/build.md b/docs/build.mdindex 28dcbc2e53..70fc17af24 100644--- a/docs/build.md+++ b/docs/build.md@@ -806,7 +806,7 @@ To read documentation for how to build on Android, [click here](./android.md)## WebGPU-The WebGPU backend relies on [Dawn](https://dawn.googlesource.com/dawn). Follow the instructions [here](https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/quickstart-cmake.md) to install Dawn locally so that llama.cpp can find it using CMake. The current implementation is up-to-date with Dawn commit `18eb229`.+The WebGPU backend relies on [Dawn](https://dawn.googlesource.com/dawn). Follow the instructions [here](https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/quickstart-cmake.md) to install Dawn locally so that llama.cpp can find it using CMake. The current implementation is up-to-date with Dawn commit `94c3c9c`.In the llama.cpp directory, build with CMake:diff --git a/ggml/src/ggml-webgpu/CMakeLists.txt b/ggml/src/ggml-webgpu/CMakeLists.txtindex 1503a1ef8b..2eacca7f2b 100644--- a/ggml/src/ggml-webgpu/CMakeLists.txt+++ b/ggml/src/ggml-webgpu/CMakeLists.txt@@ -39,6 +39,12 @@ ggml_add_backend_library(ggml-webgpuadd_dependencies(ggml-webgpu generate_shaders)+# Dawn needs C++20 (https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/quickstart-cmake.md#prerequisites)+target_compile_features(ggml-webgpu PRIVATE cxx_std_20)++# Disable C++20 module scanning since emscan-deps fails to find webgpu_cpp.h+set_target_properties(ggml-webgpu PROPERTIES CXX_SCAN_FOR_MODULES OFF)+if(EMSCRIPTEN)set(EMDAWNWEBGPU_DIR "" CACHE PATH "Path to emdawnwebgpu_pkg")diff --git a/ggml/src/ggml-webgpu/ggml-webgpu.cpp b/ggml/src/ggml-webgpu/ggml-webgpu.cppindex f06a9c872d..13db0b856f 100644--- a/ggml/src/ggml-webgpu/ggml-webgpu.cpp+++ b/ggml/src/ggml-webgpu/ggml-webgpu.cpp@@ -4006,16 +4006,17 @@ static void ggml_backend_webgpu_request_adapter(wgpu::Instance & instance, wgpu:options.nextInChain = &adapterTogglesDesc;#endif- instance.WaitAny(instance.RequestAdapter(- &options, wgpu::CallbackMode::AllowSpontaneous,- [&adapter](wgpu::RequestAdapterStatus status, wgpu::Adapter _adapter, const char * message) {- if (status != wgpu::RequestAdapterStatus::Success) {- GGML_LOG_ERROR("ggml_webgpu: Failed to get an adapter: %s\n", message);- return;- }- adapter = std::move(_adapter);- }),- UINT64_MAX);+ instance.WaitAny(+ instance.RequestAdapter(+ &options, wgpu::CallbackMode::AllowSpontaneous,+ [&adapter](wgpu::RequestAdapterStatus status, wgpu::Adapter _adapter, wgpu::StringView message) {+ if (status != wgpu::RequestAdapterStatus::Success) {+ GGML_LOG_ERROR("ggml_webgpu: Failed to get an adapter: %s\n", std::string(message).c_str());+ return;+ }+ adapter = std::move(_adapter);+ }),+ UINT64_MAX);}static void create_webgpu_device(ggml_backend_webgpu_reg_context * ctx) {