UNet2DModel dtype property fails under nn.DataParallel with UnboundLocalError in get_parameter_dtype
Maintainer thường phản hồi trong vòng 1 ngày
@Om-singhaI đang làm issue này rồi.
Từ ngày 24/8/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu trong diffusers/models/modeling_utils.py tại get_parameter_dtype và annotation find_tensor_attributes của nó, sau đó lần theo việc truy cập self.dtype từ diffusers/models/unets/unet_2d.py. Tái hiện lỗi bằng ví dụ UNet2DModel và torch.nn.DataParallel được cung cấp, đồng thời thêm hoặc chạy một kiểm tra hồi quy cho thấy forward pass hoàn tất mà không có UnboundLocalError.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 34.7k
- Fork
- 7.4k
- Merge trung bình
- 2 ngày 18 giờ
- Pull request đã merge (30 ngày)
- 60
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của huggingface/diffusers
-
VaeImageProcessor.denormalize() raises AttributeError for NumPy inputsCó thể đã có người làm @tonycoder-hub đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
huggingface/diffusers#15011 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`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`)Có thể đã có người làm @Subodh-17 đã nhận 11 ngày trước. Đang mởbug models
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
huggingface/diffusers#14952 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtypeCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
huggingface/diffusers#14888 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)Có thể đã có người làm @li-lizhe đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
huggingface/diffusers#14881 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
IndexError when preprocessing an empty image or video listCó thể đã có người làm @MohammadHijjawi97 đã nhận 25 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
huggingface/diffusers#14864 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của huggingface/diffusers
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
infrastructure qa
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
khuisman/mcp-gee-sweet#1068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
The book has a Nix install section that chelis.ch lacks, and it names two of the three systemsĐang mởarea:ecosystem documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Chelis-Lang/chelis#3866 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`lvm_compact` has no self-hosted twin, and `docs/158` §5 says every language-face component mustĐang mởbug sev-3 vm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
issue: Picking a prompt from the / menu in a channel inserts a command chip instead of the promptĐang mởbug confirmed issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 78/100
open-webui/open-webui#32712 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày