Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniPC with FlowMatch fails with index out-of-bounds #10266

Closed
vladmandic opened this issue Dec 17, 2024 · 0 comments · Fixed by #10267
Closed

UniPC with FlowMatch fails with index out-of-bounds #10266

vladmandic opened this issue Dec 17, 2024 · 0 comments · Fixed by #10267
Labels
bug Something isn't working

Comments

@vladmandic
Copy link
Contributor

vladmandic commented Dec 17, 2024

Describe the bug

If using new variant of UniPCMultistepScheduler introduced via #9982 it fails with index out-of-bounds on last step
(DPM is fine, I haven't checked other supported schedulers, but DEIS and SA are likely affected as well)

Reproduction

import torch
import diffusers

repo_id = 'Efficient-Large-Model/Sana_1600M_1024px_BF16_diffusers'
cache_dir = '/mnt/models/Diffusers'
prompt = 'sports cars parked in the city with people watching'
negative = ''
dtype = torch.bfloat16
device = torch.device('cuda')

pipe = diffusers.SanaPipeline.from_pretrained(repo_id, cache_dir=cache_dir, variant='bf16', torch_dtype=dtype)
pipe.scheduler = diffusers.UniPCMultistepScheduler(use_flow_sigmas=True, prediction_type='flow_prediction')
pipe = pipe.to(device=device, dtype=dtype)
result = pipe(
    prompt = prompt,
    negative_prompt = negative,
)
image = result.images[0]
image.save('/tmp/sana.png')

Logs

File "/home/vlado/dev/sdnext/venv/lib/python3.12/site-packages/diffusers/pipelines/sana/pipeline_sana.py", line 819, in __call__
    latents = self.scheduler.step(noise_pred, t, latents, **extra_step_kwargs, return_dict=False)[0]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vlado/dev/sdnext/venv/lib/python3.12/site-packages/diffusers/schedulers/scheduling_unipc_multistep.py", line 999, in step
    prev_sample = self.multistep_uni_p_bh_update(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vlado/dev/sdnext/venv/lib/python3.12/site-packages/diffusers/schedulers/scheduling_unipc_multistep.py", line 688, in multistep_uni_p_bh_update
    sigma_t, sigma_s0 = self.sigmas[self.step_index + 1], self.sigmas[self.step_index]
                        ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
IndexError: index 20 is out of bounds for dimension 0 with size 20

System Info

diffusers==0.32.dev

Who can help?

@hlky @a-r-r-o-w @lawrence-cj

@vladmandic vladmandic added the bug Something isn't working label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant