EulerDiscreteScheduler returns incorrect v-prediction targets for discrete timesteps

オープン 初心者向け
#15,461 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

EulerDiscreteScheduler.get_velocityを読み、timestepの検索方法をDDIMScheduler.get_velocityと比較してください。提示された再現手順を実行し、離散timestep 999と500で不一致が生じることを確認してください。同じbetasと入力に対して、両方のschedulerが一致するvelocity targetを返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug

I found this while reading EulerDiscreteScheduler.get_velocity. It looks up each timestep's position in the descending schedule and uses that position to index alphas_cumprod. At timestep 999 the default schedule reads alphas_cumprod[0]. I plan to fix the lookup to use the discrete training timestep value.

Reproduction
import torch
from diffusers import DDIMScheduler, EulerDiscreteScheduler

config = {
    "beta_start": 0.00085,
    "beta_end": 0.012,
    "beta_schedule": "scaled_linear",
    "prediction_type": "v_prediction",
}
sample = torch.tensor([[1.0, -2.0], [0.5, 3.0]])
noise = torch.tensor([[0.25, 0.5], [-0.75, 1.0]])
timesteps = torch.tensor([999.0, 500.0])
actual = EulerDiscreteScheduler(**config).get_velocity(sample, noise, timesteps)
expected = DDIMScheduler(**config).get_velocity(sample, noise, timesteps.long())
print((actual - expected).abs().max().item())

I get 1.4713691473007202. Both schedulers have the same betas, so the velocity targets should agree.

Context

The SDXL T2I-Adapter training script uses this result as its loss target when the scheduler is configured for v_prediction. I reproduced the mismatch at the scheduler call on CPU with synthetic inputs.

System Info

Diffusers 0.44.0.dev0 at 08d5de3, Python 3.14.5, PyTorch 2.15.0+cpu, Linux x86_64. Single process on CPU.

主要言語
Python
スター
35k
フォーク
7.5k
平均マージ
3日 2時間
マージ済み PR(30日)
58

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

huggingface/diffusers のほかの issue

huggingface/diffusers の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。