huggingface / huggingface/diffusers

DDIMScheduler (or DDPM) of StableDiffusion with 1000 num_inference_steps bugs out

Open
#10,003 10 comments 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
Python
Stars
34.5k
Forks
7.3k
Avg merge
3d 3h
Merged PRs (30d)
91

Description

### Describe the bug

There's something going on with the set_timesteps offset parameters on Stable Diffusion (1v4). The timesteps are set from 1->1000 instead from 0, and so it tries to index out of bounds

### Reproduction

```
model_id = "CompVis/stable-diffusion-v1-4"
scheduler = DDIMScheduler.from_pretrained(model_id, subfolder="scheduler")
pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler).to(device)
pipe("an image of a cat", num_inference_steps=1000)
```

gives
`IndexError: index 1000 is out of bounds for dimension 0 with size 1000`
because `scheduler.timesteps` gives: `tensor([1000, 999, 998, 997, ..., 3, 2, 1], device='cuda:0')`
instead of `tensor([999, 998, 997, ..., 3, 2, 1, 0], device='cuda:0')`

### Logs

_No response_

### System Info

ste the text below in your GitHub issue and FILL OUT the two last points.

- 🤗 Diffusers version: 0.31.0
- Platform: Linux-5.15.0-119-generic-x86_64-with-glibc2.31
- Running on Google Colab?: No
- Python version: 3.12.7
- PyTorch version (GPU?): 2.5.1+cu124 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.26.2
- Transformers version: 4.46.3
- Accelerate version: 1.1.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.5
- xFormers version: 0.0.28.post3
- Accelerator: NVIDIA RTX A6000, 49140 MiB

### Who can help?

@yiyixuxu @asomoza @sayakpaul @DN6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.