Distributed gather crashes on PyTorch < 2.6
Maintainers usually reply within 1 day
@akshatvishu is already working on this.
Since Feb 3, 2026.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Domain
- distributed-systems
Research direction
Start in src/diffusers/models/_modeling_parallel.py at gather_size_by_comm and run the minimal distributed reproduction from the issue with PyTorch 2.4. Trace how the communication backends determine gather_device. Done means distributed gather no longer raises AttributeError on supported PyTorch 2.1–2.5 while retaining behavior on newer versions.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 34.6k
- Forks
- 7.4k
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 44
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from huggingface/diffusers
-
UniPCMultistepScheduler fails in torch.linalg.solve under a float64 default dtype: the unit entry of rks takes the default dtypePossibly taken @DawnofGenX claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
huggingface/diffusers#14888 ·
Maintainers usually reply within 1 day
-
WanAnimatePipeline.get_i2v_mask() defaults device to "cuda", which raises on non-CUDA accelerators (NPU/XPU/MPS)Possibly taken @li-lizhe claimed this 7 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
huggingface/diffusers#14881 ·
Maintainers usually reply within 1 day
-
IndexError when preprocessing an empty image or video listPossibly taken @MohammadHijjawi97 claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
huggingface/diffusers#14864 ·
Maintainers usually reply within 1 day
-
Windows: check_ai.py fails decoding UTF-8 guides with the default localePossibly taken @tanvir-ux claimed this 12 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
huggingface/diffusers#14837 ·
Maintainers usually reply within 1 day
-
TangentialClassifierFreeGuidance.is_conditional reads an attribute that does not existPossibly taken @dafahaha claimed this 18 days ago. Openbug needs-env-info pipelines
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
huggingface/diffusers#14794 ·
Maintainers usually reply within 1 day
All issues in huggingface/diffusers
Similar issues
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Possibly taken @mayureshsonawane17 claimed this today. OpenWaiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
bojieli/ai-agent-book#1169 ·
Maintainers usually reply within 1 day
-
priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenHands/extensions#738 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
micronaut-projects/micronaut-core#13677 ·
Maintainers usually reply within 1 day