Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Distributed gather crashes on PyTorch < 2.6

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

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

@akshatvishu がすでに取り組んでいます。

2026年2月3日 から。

  • #13075 @akshatvishu による — オープン
  • #13093 @Mr-Neutr0n による — マージされずにクローズ
  • #13514 @Ricardo-M-L による — マージされずにクローズ
  • #13993 @Whning0513 による — マージされずにクローズ
  • #14515 @Ricardo-M-L による — マージされずにクローズ

評価

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

調査の方向性

src/diffusers/models/_modeling_parallel.py の gather_size_by_comm から始め、issue にある PyTorch 2.4 を使った最小限の分散再現を実行します。通信バックエンドが gather_device を決定する方法を追跡します。完了条件は、より新しいバージョンでの動作を維持しながら、サポート対象の PyTorch 2.1–2.5 で distributed gather が AttributeError を発生させなくなることです。

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

説明

bug
Describe the bug

AttributeError: module 'torch' has no attribute 'accelerator' when running distributed gather on PyTorch versions < 2.6.

This error happens because gather_size_by_comm in src/diffusers/models/_modeling_parallel.py uses torch.accelerator.current_accelerator(), which only exists in PyTorch 2.6+. Diffusers officially supports PyTorch 2.1+, so this causes a crash on versions 2.1–2.5 with AttributeError: module 'torch' has no attribute 'accelerator'.

Reproduction

Since this is a utility function; it can be triggered directly with a minimal distributed setup:

import torch.distributed as dist
from diffusers.models._modeling_parallel import gather_size_by_comm

dist.init_process_group(
    backend="gloo",
    init_method="file:///tmp/pg",
    rank=0,
    world_size=1,
)

gather_size_by_comm(1, dist.group.WORLD)

Logs
[rank0]: Traceback (most recent call last):
[rank0]:   File "/home/aja/diffusers/test.py", line 11, in <module>
[rank0]:     gather_size_by_comm(1, dist.group.WORLD)
[rank0]:   File "/home/aja/diffusers/src/diffusers/models/_modeling_parallel.py", line 293, in gather_size_by_comm
[rank0]:     gather_device = "cpu" if "cpu" in comm_backends else torch.accelerator.current_accelerator()
[rank0]:                                                          ^^^^^^^^^^^^^^^^^
[rank0]:   File "/home/aja/diffusers/.venv/lib/python3.11/site-packages/torch/__init__.py", line 2216, in __getattr__
[rank0]:     raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
[rank0]: AttributeError: module 'torch' has no attribute 'accelerator'
System Info

diffuser : 0.37.0.dev0
torch : 2.4.0
python : 3.11
system: Linux

Who can help?

@sayakpaul @DN6

主要言語
Python
スター
34.6k
フォーク
7.4k
平均マージ
4日 15時間
マージ済み PR(30日)
49

環境構築

はじめの一歩

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

huggingface/diffusers のほかの issue

huggingface/diffusers の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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