Commit aa6dbb713 for llama.cpp

commit aa6dbb71386ccb043565c79d2841552508355a38
Author: Aman Gupta <amangupta052@gmail.com>
Date:   Wed Dec 2 15:15:58 2026 +0800

    CUDA: reject non-contiguous src in XIELU and LEAKY_RELU supports_op (#33383)

    ggml_cuda_op_xielu and ggml_cuda_op_leaky_relu assert a contiguous src0,
    but supports_op accepted strided views and the process aborted instead of
    falling back to another backend.

    Add test-backend-ops cases with a non-contiguous src for both ops.

    Fixes #33200

    Assisted-by: Claude Opus 5.5

diff --git a/ggml/src/ggml-cuda/ggml-cuda.cu b/ggml/src/ggml-cuda/ggml-cuda.cu
index 1749fa046..52dab78ec 100644
--- a/ggml/src/ggml-cuda/ggml-cuda.cu
+++ b/ggml/src/ggml-cuda/ggml-cuda.cu
@@ -4187,7 +4187,8 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g
                 case GGML_UNARY_OP_CEIL:
                 case GGML_UNARY_OP_ROUND:
                 case GGML_UNARY_OP_TRUNC:
-                    if (op->src[0]->type == GGML_TYPE_BF16 && ggml_get_unary_op(op) == GGML_UNARY_OP_XIELU) {
+                    if (ggml_get_unary_op(op) == GGML_UNARY_OP_XIELU &&
+                            (op->src[0]->type == GGML_TYPE_BF16 || !ggml_is_contiguous(op->src[0]))) {
                         return false;
                     }
                     return op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32 || op->src[0]->type == GGML_TYPE_BF16;
@@ -4612,7 +4613,7 @@ static bool ggml_backend_cuda_device_supports_op(ggml_backend_dev_t dev, const g
         case GGML_OP_TIMESTEP_EMBEDDING:
             return true;
         case GGML_OP_LEAKY_RELU:
-            return op->src[0]->type == GGML_TYPE_F32 || op->src[0]->type == GGML_TYPE_F16;
+            return (op->src[0]->type == GGML_TYPE_F32 || op->src[0]->type == GGML_TYPE_F16) && ggml_is_contiguous(op->src[0]);
         case GGML_OP_RWKV_WKV6:
         case GGML_OP_GATED_LINEAR_ATTN:
         case GGML_OP_RWKV_WKV7:
diff --git a/tests/test-backend-ops.cpp b/tests/test-backend-ops.cpp
index 564084e13..cbb3b6846 100644
--- a/tests/test-backend-ops.cpp
+++ b/tests/test-backend-ops.cpp
@@ -10320,21 +10320,31 @@ struct test_leaky_relu : public test_case {
     const ggml_type type;
     const std::array<int64_t, 4> ne_a;
     const float negative_slope;
+    const bool v; // non-contiguous a, not in-place

     std::string vars() override {
-        return VARS_TO_STR3(type, ne_a, negative_slope);
+        return VARS_TO_STR4(type, ne_a, negative_slope, v);
     }

     test_leaky_relu(ggml_type type = GGML_TYPE_F32,
             std::array<int64_t, 4> ne_a = {10, 5, 4, 3},
-            float negative_slope = 0.1f)
-        : type(type), ne_a(ne_a), negative_slope(negative_slope)  {}
+            float negative_slope = 0.1f,
+            bool v = false)
+        : type(type), ne_a(ne_a), negative_slope(negative_slope), v(v)  {}

     ggml_tensor * build_graph(ggml_context * ctx) override {
-        ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne_a.data());
-        ggml_set_name(a, "a");
+        ggml_tensor * a;
+        if (v) {
+            a = ggml_new_tensor_4d(ctx, type, ne_a[0]*2, ne_a[1], ne_a[2], ne_a[3]);
+            ggml_set_name(a, "a");
+            a = ggml_view_4d(ctx, a, ne_a[0], ne_a[1], ne_a[2], ne_a[3], a->nb[1], a->nb[2], a->nb[3], 0);
+            ggml_set_name(a, "view_of_a");
+        } else {
+            a = ggml_new_tensor(ctx, type, 4, ne_a.data());
+            ggml_set_name(a, "a");
+        }

-        ggml_tensor * out = ggml_leaky_relu(ctx, a, negative_slope, true);
+        ggml_tensor * out = ggml_leaky_relu(ctx, a, negative_slope, !v);
         ggml_set_name(out, "out");

         return out;
@@ -10982,17 +10992,23 @@ struct test_cumsum : public test_case {
 struct test_xielu : public test_case {
     const ggml_type              type;
     const std::array<int64_t, 4> ne;
+    const bool v; // non-contiguous a

-    std::string vars() override { return VARS_TO_STR2(type, ne); }
+    std::string vars() override { return VARS_TO_STR3(type, ne, v); }

     test_xielu(ggml_type type = GGML_TYPE_F32,
-            std::array<int64_t, 4> ne = { 10, 5, 4, 3 })
-        : type(type), ne(ne) {}
+            std::array<int64_t, 4> ne = { 10, 5, 4, 3 },
+            bool v = false)
+        : type(type), ne(ne), v(v) {}

     ggml_tensor * build_graph(ggml_context * ctx) override {
-        ggml_tensor * a = ggml_new_tensor_4d(ctx, type, ne[0], ne[1], ne[2], ne[3]);
+        ggml_tensor * a = ggml_new_tensor_4d(ctx, type, v ? ne[0]*2 : ne[0], ne[1], ne[2], ne[3]);
         ggml_set_param(a);
         ggml_set_name(a, "a");
+        if (v) {
+            a = ggml_view_4d(ctx, a, ne[0], ne[1], ne[2], ne[3], a->nb[1], a->nb[2], a->nb[3], 0);
+            ggml_set_name(a, "view_of_a");
+        }

         float alpha_n = 4.0f;
         float alpha_p = 20.0f;
@@ -14448,6 +14464,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
         test_cases.emplace_back(new test_clamp     (type, {1024, 1024, 1, 1}));
         test_cases.emplace_back(new test_leaky_relu(type, {7, 1, 5, 3}));
         test_cases.emplace_back(new test_leaky_relu(type, {1024, 1024, 1, 1}));
+        test_cases.emplace_back(new test_leaky_relu(type, {7, 1, 5, 3}, 0.1f, true));
         if (type == GGML_TYPE_F16) {
             test_cases.emplace_back(new test_leaky_relu(type, {33, 2, 2, 2}));
             test_cases.emplace_back(new test_leaky_relu(type, {65, 2, 2, 2}));
@@ -14976,6 +14993,8 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
     test_cases.emplace_back(new test_xielu(GGML_TYPE_F32, { 512, 16, 1, 1 }));
     test_cases.emplace_back(new test_xielu(GGML_TYPE_F16, { 512, 16, 1, 1 }));
     test_cases.emplace_back(new test_xielu(GGML_TYPE_BF16, { 512, 16, 1, 1 }));
+    test_cases.emplace_back(new test_xielu(GGML_TYPE_F32, { 10, 5, 4, 3 }, true));
+    test_cases.emplace_back(new test_xielu(GGML_TYPE_F16, { 10, 5, 4, 3 }, true));

     for (ggml_type type : {GGML_TYPE_F32, GGML_TYPE_F16, GGML_TYPE_BF16}) {
         test_cases.emplace_back(new test_tri(GGML_TRI_TYPE_LOWER, type));