Guard torch.distributed submodule imports for ROCm builds#1709
Closed
0xDELUXA wants to merge 1 commit into
Closed
Conversation
Owner
|
thx, but I have removed all distributed code in the wan model, please update and let me know if there is some left that crashed on AMD |
Author
|
Great! Closing this as resolved by ce961de |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows ROCm via TheRock, the
torch._C._distributed_c10dC-extension is not shipped.torch.distributeditself is present as a stub, but importing any submodule that touches c10d bindings -torch.distributed.fsdp,torch.distributed._tensor,torch.distributed.tensor.parallel- raises at import time:Wan2GP hits this at startup because
models/wan/any2video.pyunconditionally importsshard_modelfrommodels/wan/distributed/fsdp.py, which pulls intorch.distributed.fsdpat module top. Full traceback ends at:This blocks Wan2GP from starting at all on AMD + TheRock, even for single-GPU inference where distributed is never used.
Fix
Wrap the affected top-level imports in
try/except (ImportError, ModuleNotFoundError), falling back toNonewhen the submodule cannot be loaded. Behavior on CUDA and on ROCm builds that ship c10d is unchanged - the imports succeed and the bound names are identical.Changed files:
models/wan/any2video.py- guardimport torch.distributed as distandfrom .distributed.fsdp import shard_model.models/wan/multitalk/multitalk.py- guardimport torch.distributed as dist. Imported lazily fromany2video.py, so this path only triggers when multitalk features are used, but fails for the same reason.models/kandinsky5/kandinsky/models/parallelize.py- guardtorch.distributed._tensorandtorch.distributed.tensor.parallelimports.Plain
import torch.distributed as diststatements elsewhere in the repo (hyvideo, nanovllm, mmaudio, TTS, magi_human, longcat, radial_attention) were not changed - the bare namespace imports succeed on TheRock; only submodule imports that touch c10d fail.Verification
Reproduced on
torch 2.12.0a0+rocm7.13.0a(TheRock), Windows 11, Python 3.12:python wgp.pycrashes at import with the traceback above.shard_model,dist, and the kandinsky tensor-parallel symbols resolve toNone; no code path in single-GPU inference references them.Resolves
cc @deepbeepmeep @Tophness