From f498f864fbc0472004ee1c3616c1188c68eb157f Mon Sep 17 00:00:00 2001 From: Mendy Berger <12537668+MendyBerger@users.noreply.github.com> Date: Wed, 7 Oct 2026 00:29:30 -0400 Subject: [PATCH] ggml-webgpu: no dawn native features on wasi (#27069) --- ggml/src/ggml-webgpu/ggml-webgpu.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ggml/src/ggml-webgpu/ggml-webgpu.cpp b/ggml/src/ggml-webgpu/ggml-webgpu.cpp index a7986b9c7..ebc8a5e78 100644 --- a/ggml/src/ggml-webgpu/ggml-webgpu.cpp +++ b/ggml/src/ggml-webgpu/ggml-webgpu.cpp @@ -4104,7 +4104,7 @@ static void ggml_webgpu_init_memset_pipeline(webgpu_global_context & ctx) { static void ggml_backend_webgpu_request_adapter(wgpu::Instance & instance, wgpu::Adapter & adapter) { wgpu::RequestAdapterOptions options = {}; -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) // TODO: track need for these toggles: https://issues.chromium.org/issues/42251215 const char * const adapterEnabledToggles[] = { "vulkan_enable_f16_on_nvidia", "use_vulkan_memory_model" }; wgpu::DawnTogglesDescriptor adapterTogglesDesc; @@ -4133,7 +4133,7 @@ static void create_webgpu_device(ggml_backend_webgpu_reg_context * ctx) { ctx->webgpu_global_ctx->adapter.GetLimits(&ctx->webgpu_global_ctx->capabilities.limits); wgpu::AdapterInfo info{}; -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) wgpu::AdapterPropertiesSubgroupMatrixConfigs subgroup_matrix_configs{}; if (ctx->webgpu_global_ctx->adapter.HasFeature(wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix)) { info.nextInChain = &subgroup_matrix_configs; @@ -4150,7 +4150,7 @@ static void create_webgpu_device(ggml_backend_webgpu_reg_context * ctx) { wgpu::WGSLLanguageFeatureName::Packed4x8IntegerDotProduct); bool valid_subgroup_matrix_config = false; -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) // Accept f16 subgroup matrix configurations (square or non-square). // NVIDIA GPUs typically report square configs (e.g. 16x16x16), // while Intel Xe2 GPUs report non-square configs (e.g. 8x16x16). @@ -4178,7 +4178,7 @@ static void create_webgpu_device(ggml_backend_webgpu_reg_context * ctx) { // Initialize device std::vector required_features = { wgpu::FeatureName::ShaderF16 }; -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) required_features.push_back(wgpu::FeatureName::ImplicitDeviceSynchronization); if (ctx->webgpu_global_ctx->capabilities.supports_subgroup_matrix) { required_features.push_back(wgpu::FeatureName::ChromiumExperimentalSubgroupMatrix); @@ -4214,7 +4214,7 @@ static void create_webgpu_device(ggml_backend_webgpu_reg_context * ctx) { std::string(message).c_str()); }); -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) // Enable Dawn-specific toggles to increase native performance // TODO: Maybe WebGPU needs a "fast" mode where you can request compilers skip adding checks like these, // only for native performance? @@ -4865,7 +4865,7 @@ ggml_backend_reg_t ggml_backend_webgpu_reg() { instance_descriptor.requiredFeatures = instance_features.data(); instance_descriptor.requiredFeatureCount = instance_features.size(); -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) const char * const instanceEnabledToggles[] = { "allow_unsafe_apis" }; wgpu::DawnTogglesDescriptor instanceTogglesDesc; instanceTogglesDesc.enabledToggles = instanceEnabledToggles; @@ -4885,7 +4885,7 @@ ggml_backend_reg_t ggml_backend_webgpu_reg() { // WebGPU backend requires f16 support and, on native, implicit device synchronization. if (adapter != nullptr && adapter.HasFeature(wgpu::FeatureName::ShaderF16) -#ifndef __EMSCRIPTEN__ +#if !defined(__EMSCRIPTEN__) && !defined(__wasi__) && adapter.HasFeature(wgpu::FeatureName::ImplicitDeviceSynchronization) #endif ) {