这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@BenjaminBossan
Copy link
Member

Resolves #2772

Fixes several edge cases with unusual layer names or target modules.

  1. As "UserWarning: Found missing adapter keys while loading the checkpoint" when module name contains "weight" #2772 stated, if "weight" is part of a layer name, it would be treated incorrectly when creating the PEFT state_dict.
  2. Similarly, when the adapter name itself is part of a layer name.

Some of these errors would pass silently, which is especially bad (e.g. a weight not being loaded but no error raised).

I also added some tests that were not failing before, but to cover some yet uncovered cases or to lay out some basic functionality.

While working on this, I also noticed that it was possible to target a BaseTunerLayer with modules_to_save and trainable_token_indices (e.g. the lora_A and lora_B nn.Linear would be wrapped with ModulesToSaveWrapper). I don't think this is ever desired, so we now raise an error if this is detected.

Note to reviewers: Please be super diligent in reviewing this and don't hesitate to suggest more tests if you have ideas. It is easy to add a (silent) breaking change here if not careful.

Resolves huggingface#2772

Fixes several edge cases with unusual layer names or target modules.

1. As huggingface#2772 stated, if "weight" is part of a layer name, it would be
treated incorrectly when creating the PEFT state_dict.
2. Similarly, when the adapter name itself is part of a layer name.

Some of these errors would pass silently, which is especially bad (e.g.
a weight not being loaded but no error raised).

I also added some tests that were not failing before, but to cover some
yet uncovered cases or to lay out some basic functionality.

While working on this, I also noticed that it was possible to target a
BaseTunerLayer with modules_to_save and trainable_token_indices (e.g.
the lora_A and lora_B nn.Linear would be replaced with
ModulesToSaveWrapper). I don't think this is ever desired, so we now
raise an error if this is detected.

Note to reviewers: Please be super diligent in reviewing this and don't
hesitate to suggest more tests if you have ideas. It is easy to add
a (silent) breaking change here if not careful.
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

- better wording in comment
- better error message
Copy link
Collaborator

@githubnemo githubnemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

@BenjaminBossan BenjaminBossan merged commit e596112 into huggingface:main Sep 30, 2025
25 of 27 checks passed
@BenjaminBossan BenjaminBossan deleted the fix-module-target-edge-cases branch September 30, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"UserWarning: Found missing adapter keys while loading the checkpoint" when module name contains "weight"

3 participants