Commit 15f75a5 for stable-diffusion.cpp

commit 15f75a5bdfa214315d5bdc31d267f20f07cdb964
Author: leejet <leejet714@gmail.com>
Date:   Sat Dec 5 00:30:29 2026 +0800

    fix(sycl): prevent white images with batched CFG (#2522)

diff --git a/docs/guides/performance.md b/docs/guides/performance.md
index 1f504a2..ee36980 100644
--- a/docs/guides/performance.md
+++ b/docs/guides/performance.md
@@ -51,7 +51,8 @@ step instead of two separate forwards. This is enabled by default whenever the
 run qualifies for it.

 Use `--batched-cfg off` to force separate conditional and unconditional
-forwards.
+forwards. SYCL automatically uses separate forwards in builds configured with
+`SD_USE_UPSTREAM_GGML=ON`.

 In DGL mode the flag sets `batched_cfg` on the execution context. Compatible
 `cfg(positive, negative, ...)` branches use batching automatically; combinations
diff --git a/ggml b/ggml
index a30080c..5db9ef6 160000
--- a/ggml
+++ b/ggml
@@ -1 +1 @@
-Subproject commit a30080c041b263044264b4dac3d043b3cdf6653b
+Subproject commit 5db9ef67837ac4595b7d1470ef8070bf6c69b0f3
diff --git a/src/dgl/models/dit.cpp b/src/dgl/models/dit.cpp
index 7624674..7624395 100644
--- a/src/dgl/models/dit.cpp
+++ b/src/dgl/models/dit.cpp
@@ -1,5 +1,6 @@
 #include "dgl/models/dit.h"

+#include <algorithm>
 #include <utility>

 #include "conditioning/conditioner.h"
@@ -25,6 +26,18 @@ namespace sd::dgl::models {
         : Model(std::move(manager)),
           runtime_(*this, std::move(backends), ModelComponent::Diffusion, SDBackendModule::DIFFUSION, [this] { return build_runners(); }) {}

+    bool DiT::supports_batched_cfg() {
+#ifdef SD_USE_UPSTREAM_GGML
+        // Upstream SYCL group normalization only writes the first sample (#2510).
+        const auto backends = runtime_.backend_manager.runtime_backends(SDBackendModule::DIFFUSION);
+        return std::none_of(backends.begin(), backends.end(), [](ggml_backend_t backend) {
+            return sd_backend_is(backend, "SYCL");
+        });
+#else
+        return true;
+#endif
+    }
+
     int DiT::get_latent_channel() const {
         return find_model_definition(version())->geometry.latent_channels;
     }
diff --git a/src/dgl/models/dit.h b/src/dgl/models/dit.h
index 5060161..2a63364 100644
--- a/src/dgl/models/dit.h
+++ b/src/dgl/models/dit.h
@@ -42,6 +42,7 @@ namespace sd::dgl::models {

     public:
         SDVersion version() const { return runtime_.version; }
+        bool supports_batched_cfg();
         int get_latent_channel() const;
         bool circular_x = false;
         bool circular_y = false;
diff --git a/src/dgl/ops/predictor.cpp b/src/dgl/ops/predictor.cpp
index 1bedd32..6d8bcc0 100644
--- a/src/dgl/ops/predictor.cpp
+++ b/src/dgl/ops/predictor.cpp
@@ -522,6 +522,9 @@ namespace sd::dgl::ops {
                         return;
                 }
             }
+            if (!pos->dit().supports_batched_cfg())
+                return;
+
             const auto key = std::make_pair(pos, neg);
             auto packed    = resources.batched_conditions.find(key);
             if (packed == resources.batched_conditions.end()) {