Skip to content

[Bug] kl_optimal has inconsistent outputs #1130

@daniandtheweb

Description

@daniandtheweb

Git commit

98916e8

Operating System & Version

Arch Linux

GGML backends

Vulkan

Command-line arguments used

./sd-cli -M img_gen -p "1girl, vivid colors, best quality, masterpiece," -n "bad quality, worst quality," --sampling-method euler_a --steps 20 -W 1024 -H 1024 --cfg-scale 5--model /home/daniandtheweb/Workspace/sd.cpp-webui/models/checkpoints/hassakuXLIllustrious_v32.safetensors --vae /home/daniandtheweb/Workspace/sd.cpp-webui/models/vae/sdxl_vae_fp16_fix.safetensors --scheduler kl_optimal --diffusion-fa --vae-conv-direct

Steps to reproduce

Executing this specific model (for now I haven't been able to reproduce it on any other model).

What you expected to happen

A normally denoised image.

What actually happened

Black image.

I've already investigated the issue and the problem is on how the sigmas close to zero interact in the last step.
The current implementation is adapted from AUTOMATIC1111 and ComfyUI's (closer to comfyui's as the last step enforces a jump to sigma=0).

I currently have two different ideas to fix it and I'd like some feedback on them:

  1. Change kl_optimal to stop at sigma_min (just like AUTOMATIC1111), however this apparently may have some downsides.
  2. Add safeguards in the samplers to handle the cases where the sigmas would lead to incorrect calculations and a black image.

Logs / error messages / stack trace

No response

Additional context / environment details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions