Flux and LTX pipelines do not forward the generator to stochastic scheduler steps
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
FluxPipeline と LTXPipeline クラスを読み、scheduler.step() が generator なしで呼び出されている場所を見つけます。パイプラインの generator をその呼び出しに渡し、PR #13678 を反映します。issue の再現スクリプトを実行します: stochastic_sampling=True では、最大差は 0.000000 になります。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
With FlowMatchEulerDiscreteScheduler(stochastic_sampling=True), FluxPipeline and LTXPipeline produce different outputs with the same supplied generator seed when unrelated global RNG state changes.
The pipelines use the supplied generator for initial latents but omit it from scheduler.step(). Subsequent noise therefore uses the global RNG.
PR #13678 fixed generator handling inside the scheduler; the pipeline callers still need to forward it.
I’d be happy to submit a PR to fix the issue.
Reproduction
This CPU example uses small real Flux components and precomputed prompt embeddings. Both calls use generator seed 17; only the global RNG state changes.
import torch
from diffusers import (
AutoencoderKL, FlowMatchEulerDiscreteScheduler,
FluxPipeline, FluxTransformer2DModel,
)
torch.set_num_threads(1)
torch.manual_seed(0)
transformer = FluxTransformer2DModel(
patch_size=1, in_channels=4, num_layers=1, num_single_layers=1,
attention_head_dim=16, num_attention_heads=2, joint_attention_dim=32,
pooled_projection_dim=32, axes_dims_rope=[4, 4, 8],
).eval()
vae = AutoencoderKL(
sample_size=32, in_channels=3, out_channels=3, block_out_channels=(4,),
layers_per_block=1, latent_channels=1, norm_num_groups=1,
use_quant_conv=False, use_post_quant_conv=False,
shift_factor=0.0609, scaling_factor=1.5035,
).eval()
pipe = FluxPipeline(
transformer=transformer, vae=vae,
scheduler=FlowMatchEulerDiscreteScheduler(),
text_encoder=None, tokenizer=None,
text_encoder_2=None, tokenizer_2=None,
)
pipe.set_progress_bar_config(disable=True)
prompt_embeds = torch.randn(1, 16, 32)
pooled_prompt_embeds = torch.randn(1, 32)
for stochastic in (False, True):
pipe.scheduler = FlowMatchEulerDiscreteScheduler(
stochastic_sampling=stochastic
)
outputs = []
for global_seed in (13, 99):
torch.manual_seed(global_seed)
outputs.append(pipe(
prompt_embeds=prompt_embeds,
pooled_prompt_embeds=pooled_prompt_embeds,
height=8, width=8, guidance_scale=1.0,
num_inference_steps=4,
generator=torch.Generator().manual_seed(17),
output_type="latent",
).images)
difference = (outputs[0] - outputs[1]).abs().max().item()
print(f"stochastic_sampling={stochastic}: max difference = {difference:.6f}")
The two runs should produce identical outputs with the same supplied generator seed, but in this example, they differ by up to 2.285045 when only the global RNG state changes.
Logs
stochastic_sampling=False: max difference = 0.000000
stochastic_sampling=True: max difference = 2.285045
System Info
- Diffusers:
0.42.1; also reproduced on main revision86ef420b17363c28e36ebad6b58555e9aa8feda2 - Python:
3.12.14 - PyTorch:
2.14.1 - Transformers:
5.20.2 - Platform: macOS arm64, CPU float32
Who can help?
No response
- 主要言語
- Python
- スター
- 34.8k
- フォーク
- 7.4k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 57
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/diffusers のほかの issue
-
Clarify set_adapters() adapter_weights documentation and type hints対応中かも @gorkadabo1 が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
huggingface/diffusers#15146 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
`encode_video` truncates a fractional `fps`, so the video runs longer than its audio対応中かも @guptaishaan が 11 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
huggingface/diffusers#15104 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
VaeImageProcessor.denormalize() raises AttributeError for NumPy inputs対応中かも @tonycoder-hub が 21 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
huggingface/diffusers#15011 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
`ModelMixin.from_pretrained` on a sharded checkpoint fails under `HF_HUB_OFFLINE=1` even when fully cached (`_get_checkpoint_shard_files` still calls `model_info`)対応中かも @Subodh-17 が 27 日前に担当しました。 オープンbug models
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
huggingface/diffusers#14952 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtype対応中かも @deep1blue が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
huggingface/diffusers#14888 ·
メンテナーはふだん 1 日以内に返信
huggingface/diffusers の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Nixtla/mlforecast#823 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
microsoft/ML-For-Beginners#1061 ·
-
bot-found documentation priority: P3
難易度 2/5 1時間未満 初心者へのやさしさ 82/100
madenvel/KalinkaPlayer#503 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
EleutherAI/lm-evaluation-harness#4508 ·
メンテナーはふだん 1 日以内に返信