Skip to content

DPMSolverMultistepScheduler has wrong number of timesteps given num_inference_steps with StableDiffusionXL pipelines #4122

Closed
@AmericanPresidentJimmyCarter

Description

Describe the bug

For example when 100 steps are given for num_inference_steps, only 95 are performed.

Reproduction

from diffusers import StableDiffusionXLPipeline
from diffusers.schedulers import DPMSolverMultistepScheduler
import torch

scheduler = DPMSolverMultistepScheduler(
    beta_start=0.00085,
    beta_end=0.012,
    beta_schedule="scaled_linear",
    prediction_type="epsilon",
    num_train_timesteps=1000,
    trained_betas=None,
    thresholding=False,
    algorithm_type="dpmsolver++",
    solver_type="midpoint",
    lower_order_final=True,
    use_karras_sigmas=True,
)

hf_cache_dir = '/path/to/hf'

pipe = StableDiffusionXLPipeline.from_pretrained(
    f"{hf_cache_dir}/stable-diffusion-xl-base-0.9", variant="fp16", use_safetensors=True,
    torch_dtype=torch.bfloat16,
)
pipe.enable_model_cpu_offload(0)
pipe.enable_vae_slicing()
pipe.enable_vae_tiling()
pipe.register_modules(scheduler=scheduler)

with torch.no_grad(), torch.amp.autocast('cuda', dtype=torch.bfloat16):
    random_generator = torch.Generator()
    random_generator.manual_seed(12345)
    prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
    image = pipe(prompt=prompt, output_type="pil",
        num_inference_steps=100, generator=random_generator).images[0]

Logs

python test_sdxl2.py 
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████| 7/7 [00:02<00:00,  2.81it/s]
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████| 5/5 [00:03<00:00,  1.65it/s]
 95%|███████████████████████████████████████████████████████████████████████████████████████████▏    | 95/100 [00:32<00:01,  2.91it/s]

System Info

Commit b024ebb (main)

Who can help?

@patrickvonplaten @wil

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions