TCDScheduler advances the generator on the final step of a strength-truncated custom schedule
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
TCDScheduler の step メソッドから始めてください。ここでは最終ステップの判定が現在のインデックスを num_inference_steps と比較し、eta > 0 のときにノイズをサンプリングします。issue の再現スクリプトを実行してください。このスクリプトは set_timesteps(timesteps=[999, 499, 19], strength=0.5) を使っています。そのうえで、ジェネレーターの状態が変化することを確認してください。判定が self.timesteps の長さを使い、実際の最終ステップでジェネレーターの状態が変わらず、既存の TCD スケジューラーのテストがすべて通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When TCDScheduler uses a non-empty custom timestep schedule truncated by
strength < 1, its actual final step advances the supplied random generator
when eta > 0.
For example, timesteps=[999, 499, 19] with strength=0.5 leaves only [19],
but num_inference_steps remains 3. The final-step check uses the original
step count and enters the noise-sampling branch.
In the tested case, the terminal output stays the same because the noise
coefficient is zero, but the generator state changes. Subsequent draws using
the same generator therefore differ.
I expected the actual final step to leave the generator state unchanged,
consistent with the scheduler's comment that noise is not used on the final
timestep.
A possible fix is to decide whether another step exists using the length of
self.timesteps. I have tested a candidate fix and can provide it for review.
Reproduction
import diffusers
import torch
from diffusers import TCDScheduler
print(f"torch={torch.__version__} diffusers={diffusers.__version__}")
print(f"source={diffusers.__file__}")
scheduler = TCDScheduler(prediction_type="sample")
scheduler.set_timesteps(timesteps=[999, 499, 19], strength=0.5, device="cpu")
generator = torch.Generator(device="cpu").manual_seed(0)
control = torch.Generator(device="cpu").manual_seed(0)
sample = torch.ones((1, 1), device="cpu")
before = generator.get_state().clone()
result = scheduler.step(
torch.zeros_like(sample),
scheduler.timesteps[0],
sample,
eta=0.3,
generator=generator,
)
after = generator.get_state()
next_draw = torch.randn(4, generator=generator, device="cpu")
control_draw = torch.randn(4, generator=control, device="cpu")
print(f"actual timesteps={scheduler.timesteps.tolist()}")
print(f"num_inference_steps={scheduler.num_inference_steps}")
print(f"prev_sample={result.prev_sample.item()}")
print(f"pred_noised_sample={result.pred_noised_sample.item()}")
print(f"RNG state preserved: {torch.equal(before, after)}")
print(f"next draw: {next_draw.tolist()}")
print(f"control: {control_draw.tolist()}")
assert torch.equal(before, after), "The terminal step advanced the generator"
Context
No response
Logs
Baseline: unmodified Diffusers source at commit
43e30028af5120d8b0868cb6975b9fad39cc4fab
torch=2.9.0+cu126
diffusers=0.44.0.dev0
actual timesteps=[19]
num_inference_steps=3
prev_sample=0.21879726648330688
pred_noised_sample=0.21879726648330688
RNG state preserved: False
next draw: [-0.293428897857666, -2.1787893772125244, 0.5684312582015991, -1.0845223665237427]
control: [1.5409960746765137, -0.293428897857666, -2.1787893772125244, 0.5684312582015991]
AssertionError: The terminal step advanced the generator
System Info
Platform: Windows 11
Python: 3.12.8
PyTorch: 2.9.0+cu126
Diffusers: 0.44.0.dev0, source checkout at commit 43e30028af5120d8b0868cb6975b9fad39cc4fab
Device used for reproduction: CPU
Who can help?
No response
- 主要言語
- Python
- スター
- 34.9k
- フォーク
- 7.5k
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 65
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/diffusers のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/diffusers#15363 ·
メンテナーはふだん 1 日以内に返信
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeError対応中かも @chessing234 が 1 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
huggingface/diffusers#15337 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)対応中かも @sunhouy が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
huggingface/diffusers#15313 ·
メンテナーはふだん 1 日以内に返信
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded again対応中かも @sohailshk が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
huggingface/diffusers#15211 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
set_ip_adapter_scale(float) raises "Cannot assign 1 scale_configs to 2 IP-Adapter" when several IP-Adapters are loaded対応中かも @sohailshk が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
huggingface/diffusers#15210 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
huggingface/diffusers の issue をすべて見る
似ている issue
-
[dbt] exported dataset keys reference physical columns対応中かも @WilliamKelley が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/ossie-converters#251 ·
メンテナーはふだん 2 日以内に返信
-
cli difficulty: easy enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
desec-io/desec-stack#1312 ·
メンテナーはふだん 14 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws/aws-durable-execution-sdk-python#977 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
flashinfer-ai/flashinfer#9803 ·
メンテナーはふだん 1 日以内に返信