Skip to content

peft assumes that torch has distributed support without checking #2958

@vladmandic

Description

@vladmandic

System Info

peft==0.18.0
python==3.12.10
transformers==4.57.3
diffusers==0.36.0.dev
torch==2.9.1+rocm7.11.0a20251215

Who can help?

@BenjaminBossan @sayakpaul

Reproduction

simplest repoduction is to attempt to load lora into diffusers model since diffusers uses peft

from diffusers import ZImagePipeline
pipe = ZImagePipeline.from_pretrained("Tongyi-MAI/Z-Image-Turbo")
pipe.load_lora_weights("path/to/lora_weights.safetensors")
image = pipe("A fantasy landscape with mountains and a river").images[0]
...
│E:\sd\sdnext\venv\Lib\site-packages\peft\tuners\tuners_utils.py:161 in _get_in_out_features                           │
│                                                                                                                      │
│   160 │   │   torch_supports_dtensor = version.parse(torch.__version__) >= version.parse("2.5.0")                    │
│❱  161 │   │   if torch_supports_dtensor and isinstance(module.weight, torch.distributed.tensor.DTensor):             │
│   162 │   │   │   # If Tensor Parallel is used, the weight is sharded, so we need to get the local shape    

AttributeError: module 'torch.distributed' has no attribute 'tensor'

this happens because torch for rocm does not come with distributed support!
this was previously an issue in diffusers as well, but the hard dependencies were since removed.
see huggingface/diffusers#12425 and huggingface/diffusers#12420 for details.

Expected behavior

not fail :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions