Skip to content

[BUG] peft 0.19 diffusers LoRA Index Error. #3238

@galaxygliese

Description

@galaxygliese

System Info

I tried SDXL LoRA, but the following error appeared. It didn't appear until upgrade the peft. I trained my model before upgrading the peft.

    r = lora_alpha = list(rank_dict.values())[0]
                     ~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

My env:

diffusers==0.38.0
transformers==5.8.0
peft==0.19.1

For SD3.5, the following warning showed up.

Key                                                                           | Status     | 
------------------------------------------------------------------------------+------------+-
encoder.layers.{0...11}.self_attn.k_proj.lora_B.default_0.weight              | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.k_proj.lora_A.default_0.weight              | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.out_proj.lora_A.default_0.weight            | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.v_proj.lora_A.default_0.weight              | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.out_proj.lora_B.default_0.weight            | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.q_proj.lora_A.default_0.weight              | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.v_proj.lora_B.default_0.weight              | UNEXPECTED | 
encoder.layers.{0...11}.self_attn.q_proj.lora_B.default_0.weight              | UNEXPECTED | 
text_model.encoder.layers.{0...11}.self_attn.q_proj.lora_B.default_0.weight   | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.v_proj.lora_A.default_0.weight   | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.q_proj.lora_A.default_0.weight   | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.out_proj.lora_B.default_0.weight | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.k_proj.lora_A.default_0.weight   | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.k_proj.lora_B.default_0.weight   | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.out_proj.lora_A.default_0.weight | MISSING    | 
text_model.encoder.layers.{0...11}.self_attn.v_proj.lora_B.default_0.weight   | MISSING    | 

Who can help?

No response

Reproduction

The code:

model_id = "stabilityai/stable-diffusion-xl-base-1.0"
pipeline = AutoPipelineForInpainting.from_pretrained(
         model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True
 )
pipeline.enable_model_cpu_offload()
pipeline.enable_xformers_memory_efficient_attention()
pipeline.load_lora_weights(args.lora_checkpoint, weight_name="pytorch_lora_weights.safetensors")

Expected behavior

Maybe the text encoder LoRA parameter keys have changed in the latest update.

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