Skip to content

Conversation

@zucchini-nlp
Copy link
Member

@zucchini-nlp zucchini-nlp commented Nov 20, 2025

What does this PR do?

As per title, fixes #42156 (comment) and adjusts the test case slightly

I didn't not change the setter, we don't call set_encoder unless we're sure there is an encoder right?

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

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this quickly.

@zucchini-nlp zucchini-nlp enabled auto-merge (squash) November 20, 2025 10:21
Copy link
Contributor

@molbap molbap left a comment

Choose a reason for hiding this comment

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

SGTM, thanks!

BenjaminBossan added a commit to BenjaminBossan/peft that referenced this pull request Nov 20, 2025
When using mixed adapter batches (i.e. using different LoRA adapters in
the same batch), users have to pass adapter_names. When simultaneously
using beam search, these adapter names have to be extended by the number
of beams. For encoder-decoder models, even when applying beam search,
the encoder part of the model should, however, not use the extended
adapter_names. This is because the encoder still uses the original,
non-extended samples.

The need for this used to be checked by calling model.get_encoder().
However, with transformers v5, every PretrainedModel will have a
get_encoder method. The new convention is that it will return self if
there is no encoder. This is now what's being checked.

huggingface/transformers#42156

Note that said PR contains a small bug that leads to self not always
being returned. Therefore, for the full fix of the issue on transformers
main, we also need to await this PR:

huggingface/transformers#42295
@zucchini-nlp
Copy link
Member Author

CI is not feeling good today

BenjaminBossan added a commit to huggingface/peft that referenced this pull request Nov 20, 2025
When using mixed adapter batches (i.e. using different LoRA adapters in
the same batch), users have to pass adapter_names. When simultaneously
using beam search, these adapter names have to be extended by the number
of beams. For encoder-decoder models, even when applying beam search,
the encoder part of the model should, however, not use the extended
adapter_names. This is because the encoder still uses the original,
non-extended samples.

The need for this used to be checked by calling model.get_encoder().
However, with transformers v5, every PretrainedModel will have a
get_encoder method. The new convention is that it will return self if
there is no encoder. This is now what's being checked.

huggingface/transformers#42156

Note that said PR contains a small bug that leads to self not always
being returned. Therefore, for the full fix of the issue on transformers
main, we also need to await this PR:

huggingface/transformers#42295
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.

4 participants