TCDScheduler ignores set_alpha_to_one in the terminal update

Ouverte
#15,370 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

  • #15292 par @twojian — fermée sans fusion

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
18/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
python, pytorch
Domaine
ai, machine-learning

Piste de recherche

The terminal-step alpha is read from alphas_cumprod[0] in the TCDScheduler step logic, not from final_alpha_cumprod, so set_alpha_to_one has no effect there. Run the reproduction snippet on CPU to confirm both flags return about 0.0292. Done means the True case returns 0 while the False case is unchanged, and this needs a maintainer decision on the intended semantics. Linked PR #15292 already proposes a fix, so check it before starting.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

bug
Describe the bug

TCDScheduler documents that set_alpha_to_one=True sets the final alpha cumulative product to 1. However, the terminal update currently uses alphas_cumprod[0], regardless of that setting.

As a result, set_alpha_to_one=True and False produce the same terminal output in the following CPU reproduction.
The terminal update uses alphas_cumprod[0] instead of final_alpha_cumprod, bypassing the set_alpha_to_one configuration.

The TCD reference implementation also uses index 0 at the endpoint, so this may be an intentional compatibility choice rather than an implementation oversight. However, it differs from the documented behavior.

I have submitted PR #15292 with a proposed fix and CPU regression tests. Maintainer guidance on the intended terminal-alpha semantics would be appreciated.

Reproduction

import torch
from diffusers import TCDScheduler

for flag in (True, False):
scheduler = TCDScheduler(
prediction_type="sample",
set_alpha_to_one=flag,
)
scheduler.set_timesteps(1, device="cpu")

sample = torch.ones(1, 1)
result = scheduler.step(
    torch.zeros_like(sample),
    scheduler.timesteps[0],
    sample,
)
print(flag, result.prev_sample.item())

Observed behavior: both settings return approximately 0.0292233.

Expected behavior under the documented terminal-alpha semantics: the True case returns 0, while the False case retains the existing output.

Context

While investigating TCDScheduler's terminal-step behavior and validating scheduler correctness on CPU, I found that changing set_alpha_to_one had no effect on the terminal output.

This matters for users relying on the documented scheduler configuration and for reproducibility when comparing different terminal-alpha settings.

Logs

System Info
  • OS: Windows
  • Diffusers: 0.44.0.dev0 (development version)
  • Device: CPU
  • PyTorch: 2.9.0+cu126
  • Python: 3.12.8

The minimal reproduction uses CPU only and does not require CUDA.

Who can help?

No response

Langage dominant
Python
Étoiles
35k
Forks
7.5k
Merge moyen
2 j 22 h
PR mergées (30 j)
58

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de huggingface/diffusers

Toutes les issues de huggingface/diffusers

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.