Skip to content

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

Description

@vladmandic

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

importtorchimportdiffusersrepo_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.bfloat16device=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

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