From 16bf5d49ceaa955a6c52fba5709e102cfd4d8f9b Mon Sep 17 00:00:00 2001 From: bri-prism <288398250+bri-prism@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:27:06 -0700 Subject: [PATCH] vulkan: decline GATED_DELTA_NET raw gates instead of computing them wrong ggml_gated_delta_net_set_raw_gates() delivers beta and g pre-activation, so the op must apply beta = sigmoid(beta) and g = a * softplus(g + dt_bias), with dt_bias in src[7] and a in src[8]. gated_delta_net.comp has neither of those bindings nor that math - it applies exp(g) unconditionally - but supports_op never checked the flag, so Vulkan claimed these ops and returned results uncorrelated with the reference (ERR ~1.0 against a 1e-7 tolerance), silently and with no fallback. Decline raw gates in supports_op so they fall back to the CPU, which implements them. This mirrors what the SYCL backend already does. On Arc B390, test-backend-ops -b Vulkan0 goes from 3 failing GATED_DELTA_NET cases to a clean run: the full unfiltered suite reports FAIL before and OK after. --- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index b6f9965add7b..076ee665ee19 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -18616,6 +18616,15 @@ static bool ggml_backend_vk_device_supports_op(ggml_backend_dev_t dev, const ggm if (op->src[6] != nullptr) { return false; } + // raw gates (ggml_gated_delta_net_set_raw_gates): beta and g arrive + // pre-activation and need beta = sigmoid(beta) and + // g = a * softplus(g + dt_bias), with dt_bias in src[7] and a in src[8]. + // gated_delta_net.comp has neither those bindings nor that math - it + // applies exp(g) unconditionally - so the shader silently returns wrong + // results for this case. Decline it and let it fall back to the CPU. + if (ggml_get_op_params_i32(op, 1) != 0) { + return false; + } const uint32_t S_v = op->src[2]->ne[0]; if (S_v != 16 && S_v != 32 && S_v != 64 && S_v != 128) { return false;