AndyShih12/paradigms

Inconsistency with DDIM

Opened this issue · 0 comments

Ideally running paradigms with a window size of 1 should be identical to running sequential DDIM given that there is no added noise in DDIM. But I am not observing this. Here is the code I used for testing. Please let me know if I am missing something.

import torch
from diffusers import DDIMParallelScheduler, DDIMScheduler
from diffusers import StableDiffusionParadigmsPipeline, StableDiffusionPipeline
import numpy as np


torch.manual_seed(1)
scheduler = DDIMParallelScheduler.from_pretrained("runwayml/stable-diffusion-v1-5", subfolder="scheduler", timestep_spacing="trailing")
pipe = StableDiffusionParadigmsPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", scheduler=scheduler, torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
prompt = "a photo of an astronaut riding a horse on mars"

image1 = pipe(prompt, parallel=1, num_inference_steps=50).images[0]

torch.manual_seed(1)
scheduler = DDIMScheduler.from_pretrained("runwayml/stable-diffusion-v1-5", subfolder="scheduler", timestep_spacing="trailing")
pipe = StableDiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", scheduler=scheduler, torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
prompt = "a photo of an astronaut riding a horse on mars"

image2 = pipe(prompt, num_inference_steps=50).images[0]

img1 = np.asarray(image1)
img2 = np.asarray(image2)

print((img1-img2).mean())

The output should be ideally 0 but that is not what I am observing. Please help.