huggingface / huggingface/diffusers

DPMSolverMultistepScheduler out-of-bounds error when using beta_schedule="squaredcos_cap_v2" + use_karras_sigmas=True

Offen
#12,771 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug stale
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Describe the bug

Hi, I might be misunderstanding something here — I’m not very experienced with submitting issues to Diffusers yet, so please feel free to correct me if I’ve overlooked anything.

When using DPMSolverMultistepScheduler with the combination:

```python
DPMSolverMultistepScheduler(
beta_schedule="squaredcos_cap_v2",
use_karras_sigmas=True,
)
```
calling set_timesteps(20) produces duplicate timesteps, which causes the multistep solver’s internal index tracking to drift, eventually leading to an index out of bounds error during sampling.

### Reproduction
```python
import diffusers
import torch
from diffusers import DPMSolverMultistepScheduler

print("Diffusers version:", diffusers.__version__)
print("Torch version:", torch.__version__)

scheduler = DPMSolverMultistepScheduler(
beta_schedule="squaredcos_cap_v2",
use_karras_sigmas=True,
)

scheduler.set_timesteps(20)

print("Timesteps:", scheduler.timesteps)

latents = torch.randn(1, 4, 64, 64)
noise_pred = torch.randn_like(latents)

for i, t in enumerate(scheduler.timesteps):
print(f"Step {i}: t={t.item()}")
try:
result = scheduler.step(noise_pred, t, latents)
latents = result.prev_sample
except Exception as e:
print(f"ERROR: {e}")
break
```

### Logs

```shell
Diffusers version: 0.35.2
Torch version: 2.9.0+cu128
Timesteps: tensor([998, 998, 998, 998, 998, 998, 998, 998, 998, 997, 996, 994, 989, 978,
949, 867, 623, 221, 33, 0])
Step 0: t=998
Step 1: t=998
Step 2: t=998
Step 3: t=998
Step 4: t=998
Step 5: t=998
Step 6: t=998
Step 7: t=998
Step 8: t=998
Step 9: t=997
Step 10: t=996
Step 11: t=994
Step 12: t=989
Step 13: t=978
Step 14: t=949
Step 15: t=867
Step 16: t=623
Step 17: t=221
Step 18: t=33
Step 19: t=0
ERROR: index 21 is out of bounds for dimension 0 with size 21
```

### System Info

- 🤗 Diffusers version: 0.35.2
- Platform: Linux-6.8.0-88-generic-x86_64-with-glibc2.39
- Running on Google Colab?: No
- Python version: 3.12.3
- PyTorch version (GPU?): 2.9.0+cu128 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.35.3
- Transformers version: 4.57.1
- Accelerate version: 1.10.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.6.2
- xFormers version: not installed
- Accelerator: NVIDIA GeForce RTX 4070 Ti SUPER, 16376 MiB
- Using GPU in script?:
- Using distributed or parallel set-up in script?:

### Who can help?

_No response_

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne bei DPMSolverMultistepScheduler.set_timesteps und step und führe dann die bereitgestellte Python-Reproduktion mit beta_schedule="squaredcos_cap_v2" und use_karras_sigmas=True aus. Als erledigt gilt es, wenn die 20-Schritte-Konfiguration keine doppelten timesteps mehr erzeugt, die die Indexverfolgung unterbrechen, und die Sampling-Schleife ohne einen Out-of-Bounds-Fehler abgeschlossen wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python, pytorch
Bereich
machine-learning
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.