Skip to content

Refactor layer initialization: PR 2960 continued#3047

Open
BenjaminBossan wants to merge 28 commits intohuggingface:mainfrom
BenjaminBossan:refactor-layer-init-pr-2960-continued
Open

Refactor layer initialization: PR 2960 continued#3047
BenjaminBossan wants to merge 28 commits intohuggingface:mainfrom
BenjaminBossan:refactor-layer-init-pr-2960-continued

Conversation

@BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented Feb 17, 2026

Continuation of #2960 which only covered LoRA and AdaLoRA.

This PR targets the __init__ and update_layer methods of the other relevant PEFT methods (i.e. everything except for prompt learning). Again, the goal is to pass the corresponding PEFT config directly and let the layers pick out relevant arguments, instead of having the model classes pick out the arguments and pass them to the layers. The advantage is that this reduces code duplication (this PR reduces LOC by 250). If, say, a new init argument is added, there is no longer the need to update the code in multiple places just to ensure that the argument is passed to the layers correctly.

The handling for trainable tokens is a bit awkward, as the config can have different types. I think ideally it should always be a config instance, but I'm not sure how easy that would be to change.

Bone was not updated, as it will be removed for the 0.19 release.

There was also a bug in the GPTQ AdaLoRA implementation caused by #2960, which is now fixed.

@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.

if "wavelet_family" in optional_kwargs:
wavelet_family = optional_kwargs["wavelet_family"]
if wavelet_family is None:
wavelet_family = waveft_config.wavelet_family
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I ran the unit tests and this handling seemed unnecessary, so I just removed it.

@BenjaminBossan BenjaminBossan marked this pull request as ready for review February 18, 2026 18:44
BenjaminBossan added a commit to BenjaminBossan/peft that referenced this pull request Feb 26, 2026
The layer initialization was refactored in huggingface#2960. This introduced a bug
when initializing AdaLoRA with GPTQ layers because some parameters were
missing. This bug is now fixed.

The same bugfix is contained in huggingface#3047 but is provided here separately to
allow merging it more easily.
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.

2 participants