huggingface / huggingface/diffusers
DDIMScheduler.step() logic mismatches set_timesteps() list when using timestep_spacing='linspace'
- Lingua principale
- Python
- Stelle
- 34.5k
- Fork
- 7.3k
- Merge medio
- 3g 3h
- PR unite (30g)
- 91
Descrizione
### Describe the bug
The step() function calculates prev_timestep using a hard-coded formula:
`prev_timestep = timestep - self.config.num_train_timesteps // self.num_inference_steps.`
https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim.py#L402
However, if the scheduler is initialized with timestep_spacing="linspace", the preve_timestep is not match the set_timesteps.
Suggested Method to Fix:
This inconsistency could be resolved by modifying the step() function to look up the correct prev_timestep from the self.timesteps list directly, just as in DDPMScheduler.
https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddpm.py#L549
### Reproduction
```
scheduler = DDIMScheduler.from_pretrained(model_id, subfolder='scheduler', timestep_spacing="linspace")
scheduler.set_timesteps(10)
prev_timesteps = []
for t in scheduler.timesteps:
prev_t = t- 1000 // num_inference_steps
prev_timesteps.append(prev_t.item())
```
### Logs
```shell
```
### System Info
Diffusers version: 0.35.2
### Who can help?
_No response_
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in src/diffusers/schedulers/scheduling_ddim.py, in DDIMScheduler.step(), e confronta il calcolo del timestep precedente con la ricerca utilizzata in src/diffusers/schedulers/scheduling_ddpm.py. Esegui la riproduzione di linspace con set_timesteps(10) e verifica che step() segua la voce corrispondente di self.timesteps per ogni timestep.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- machine-learning
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100