UNet2DModel dtype property fails under nn.DataParallel with UnboundLocalError in get_parameter_dtype
メンテナーはふだん 1 日以内に返信
@Om-singhaI がすでに取り組んでいます。
2026年8月24日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 74/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 静か
調査の方向性
diffusers/models/modeling_utils.py の get_parameter_dtype とその find_tensor_attributes アノテーションから始め、次に diffusers/models/unets/unet_2d.py からの self.dtype へのアクセスを追ってください。提供されている UNet2DModel と torch.nn.DataParallel の例で失敗を再現し、UnboundLocalError を発生させずに forward pass が完了することを示す回帰チェックを追加するか実行してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
Description
UNet2DModel fails under torch.nn.DataParallel during the forward pass when it accesses self.dtype inside UNet2DModel.forward.
The error appears to come from diffusers.models.modeling_utils.get_parameter_dtype, where the nested function annotation uses tuple:
def find_tensor_attributes(module: nn.Module) -> list[tuple[str, Tensor]]:
### Reproduction
import torch
from diffusers import UNet2DModel
print("torch:", torch.__version__)
import diffusers
print("diffusers:", diffusers.__version__)
model = UNet2DModel(
sample_size=128,
in_channels=10,
out_channels=5,
layers_per_block=2,
block_out_channels=(64, 128, 256, 256),
down_block_types=(
"DownBlock2D",
"DownBlock2D",
"AttnDownBlock2D",
"DownBlock2D",
),
up_block_types=(
"UpBlock2D",
"AttnUpBlock2D",
"UpBlock2D",
"UpBlock2D",
),
norm_num_groups=8,
)
model = model.cuda()
model = torch.nn.DataParallel(model, device_ids=[0, 1])
model.eval()
x = torch.randn(8, 10, 128, 128, device="cuda")
t = torch.rand(8, device="cuda") * 1000
with torch.no_grad():
y = model(x, t, return_dict=False)[0]
print(y.shape)
### Logs
```shell
File ".../diffusers/models/unets/unet_2d.py", line ..., in forward
t_emb = t_emb.to(dtype=self.dtype)
File ".../diffusers/models/modeling_utils.py", line ..., in dtype
return get_parameter_dtype(self)
File ".../diffusers/models/modeling_utils.py", line ..., in get_parameter_dtype
def find_tensor_attributes(module: nn.Module) -> list[tuple[str, Tensor]]:
UnboundLocalError: cannot access local variable 'tuple' where it is not associated with a value
System Info
Python 3.11.13, torch 2.9.1+cu128, diffusers 0.38.0, CUDA Version: 12.9
Who can help?
No response
- 主要言語
- Python
- スター
- 34.7k
- フォーク
- 7.4k
- 平均マージ
- 3日 14時間
- マージ済み PR(30日)
- 51
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/diffusers のほかの issue
-
`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 が 5 日前に担当しました。 オープン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再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
huggingface/diffusers#14888 ·
メンテナーはふだん 1 日以内に返信
-
WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)対応中かも @li-lizhe が 14 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
huggingface/diffusers#14881 ·
メンテナーはふだん 1 日以内に返信
-
IndexError when preprocessing an empty image or video list対応中かも @MohammadHijjawi97 が 19 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
huggingface/diffusers#14864 ·
メンテナーはふだん 1 日以内に返信
-
Windows: check_ai.py fails decoding UTF-8 guides with the default locale対応中かも @tanvir-ux が 19 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/diffusers#14837 ·
メンテナーはふだん 1 日以内に返信
huggingface/diffusers の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
esphome/esphome.io#7657 ·
メンテナーはふだん 1 日以内に返信
-
comp/gateway comp/plugins duplicate P3 type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NousResearch/hermes-agent#137019 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Kumo-Tabular weights unreachable behind restrictive egress proxies (Xet + plain HTTP both fail)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
NVIDIA/structured-data-models#1091 ·
メンテナーはふだん 1 日以内に返信
-
[work-item] adam-adae-worsening-emergence: conform spec.yaml to the specification style contract (REQ-1280)対応中かも @muse-yamaa-bot が今日担当しました。 オープンwork-item
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信