Skip to content

Commit 3707b8e

Browse files
committed
Revert "fix: avoid generating black images when running T5 on the GPU (leejet#882)"
This reverts commit 1c32fa0.
1 parent f0c6d71 commit 3707b8e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

stable-diffusion.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,17 @@ class StableDiffusionGGML {
339339
bool clip_on_cpu = sd_ctx_params->keep_clip_on_cpu;
340340

341341
{
342-
clip_backend = backend;
342+
clip_backend = backend;
343+
bool use_t5xxl = false;
344+
if (sd_version_is_dit(version) && !sd_version_is_qwen_image(version)) {
345+
use_t5xxl = true;
346+
}
347+
if (!clip_on_cpu && !ggml_backend_is_cpu(backend) && use_t5xxl) {
348+
LOG_WARN(
349+
"!!!It appears that you are using the T5 model. Some backends may encounter issues with it."
350+
"If you notice that the generated images are completely black,"
351+
"try running the T5 model on the CPU using the --clip-on-cpu parameter.");
352+
}
343353
if (clip_on_cpu && !ggml_backend_is_cpu(backend)) {
344354
LOG_INFO("CLIP: Using CPU backend");
345355
clip_backend = ggml_backend_cpu_init();

t5.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,7 @@ struct T5DenseGatedActDense : public UnaryBlock {
504504
T5DenseGatedActDense(int64_t model_dim, int64_t ff_dim) {
505505
blocks["wi_0"] = std::shared_ptr<GGMLBlock>(new Linear(model_dim, ff_dim, false));
506506
blocks["wi_1"] = std::shared_ptr<GGMLBlock>(new Linear(model_dim, ff_dim, false));
507-
float scale = 1.f / 32.f;
508-
// The purpose of the scale here is to prevent NaN issues on some backends(CUDA, ...).
509-
blocks["wo"] = std::shared_ptr<GGMLBlock>(new Linear(ff_dim, model_dim, false, false, false, scale));
507+
blocks["wo"] = std::shared_ptr<GGMLBlock>(new Linear(ff_dim, model_dim, false));
510508
}
511509

512510
struct ggml_tensor* forward(struct ggml_context* ctx, struct ggml_tensor* x) {

0 commit comments

Comments
 (0)