Skip to content

Comments

FIX Beam search w/ mixed adapter batches & encoder#2921

Merged
BenjaminBossan merged 1 commit intohuggingface:mainfrom
BenjaminBossan:fix-beam-search-mixed-adapter-batch-encoder
Nov 20, 2025
Merged

FIX Beam search w/ mixed adapter batches & encoder#2921
BenjaminBossan merged 1 commit intohuggingface:mainfrom
BenjaminBossan:fix-beam-search-mixed-adapter-batch-encoder

Conversation

@BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented Nov 20, 2025

When using mixed adapter batches (i.e. using different LoRA adapters in the same batch), users have to pass adapter_names (one name per sample). 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.

Note that the transformers 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

I checked the failing tests with that PR applied and they pass.

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

@BenjaminBossan BenjaminBossan merged commit 2d128f1 into huggingface:main Nov 20, 2025
34 of 37 checks passed
@BenjaminBossan BenjaminBossan deleted the fix-beam-search-mixed-adapter-batch-encoder branch November 20, 2025 15:21
Conzel pushed a commit to Conzel/peft that referenced this pull request Nov 25, 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
Arlaz pushed a commit to obvious-research/peft that referenced this pull request Jan 9, 2026
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.

3 participants