Skip to content

Conversation

albertvillanova
Copy link
Member

@albertvillanova albertvillanova commented Oct 15, 2025

Fix TypeError: find_adapter_config_file() got an unexpected keyword argument '_adapter_model_path'

  • Pass original dict instead of copy to maybe_load_adapters

The adapter_kwargs is passed to maybe_load_adapters as unpacked keyword arguments: Python does not pass the original dictionary, but instead creates a new dictionary inside the function; so the pop inside the function does not have the intended behavior.

_adapter_model_path, pretrained_model_name_or_path = maybe_load_adapters(
pretrained_model_name_or_path,
download_kwargs_with_commit,
**adapter_kwargs,
)

def maybe_load_adapters(
    pretrained_model_name_or_path,
    download_kwargs: DownloadKwargs,
    **adapter_kwargs,
):
    ...
    _adapter_model_path = adapter_kwargs.pop("_adapter_model_path", None)

This issue was introduced by PR:

Related downstream issue:

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

@albertvillanova
Copy link
Member Author

CC: @ArthurZucker (who opened the PR), @Cyrilvallez (who reviewed it).

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

LGTM, we are probably missing a test as the CI was full green on our side!

@BenjaminBossan
Copy link
Member

BenjaminBossan commented Oct 17, 2025

I encountered this error in the PEFT CI, not sure if we need a separate test for this in transformers. Here is a minimal reproducer:

from transformers import AutoModelForCausalLM
model_id = "peft-internal-testing/opt-125m-dummy-lora"
AutoModelForCausalLM.from_pretrained(model_id)

I can confirm that this PR fixes the issue, but relying on the side effect of calling .pop on the original dict is maybe not the best solution IMO.

@albertvillanova
Copy link
Member Author

Let me know if you would prefer that maybe_load_adapters returns a cleaned version of adapter_kwargs, besides current return values.

@BenjaminBossan
Copy link
Member

Let me know if you would prefer that maybe_load_adapters returns a cleaned version of adapter_kwargs, besides current return values.

I think that's the cleaner solution but I'll leave the final decision to you / @ArthurZucker.

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