Skip to content

Wrong step value in parameters sent to callback function #5233

Description

@TimothyAlexisVass

Describe the bug

At least StableDiffusionXLPipeline and StableDiffusionXLImg2ImgPipeline sends step to callback function, starting at 1 and incrementing by 2 instead of incrementing by 1.

Reproduction

import torch

from diffusers import AutoencoderKL, StableDiffusionXLPipeline, StableDiffusionXLImg2ImgPipeline, KDPM2AncestralDiscreteScheduler

vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix",
    torch_dtype=torch.float16
)

base = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae,
    torch_dtype=torch.float16,
    variant="fp16",
    use_safetensors=True
)

scheduler = KDPM2AncestralDiscreteScheduler.from_config(base.scheduler.config, use_karras_sigmas=True)
base.scheduler = scheduler

base.to("cuda")

def print_step(s, t, latents):
    print(s)

generator=torch.manual_seed(1111)

images = base(
    prompt="LOVE",
    num_inference_steps=10,
    generator=generator,
    callback=print_step
).images

for image in images:
    display(image)

Output from print_step function:

1
3
5
7
9
...

Expected output:

0
1
2
3
4
...

System Info

Diffusers 0.21.4

Who can help?

@PatrickSchrML @sayakpaul @williamberman

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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