Skip to content

Config kwargs#44953

Merged
ArthurZucker merged 9 commits intohuggingface:mainfrom
zucchini-nlp:accept-kwargs
Mar 24, 2026
Merged

Config kwargs#44953
ArthurZucker merged 9 commits intohuggingface:mainfrom
zucchini-nlp:accept-kwargs

Conversation

@zucchini-nlp
Copy link
Member

@zucchini-nlp zucchini-nlp commented Mar 23, 2026

What does this PR do?

Decouples kwargs manipulation from hub's strict decorator, and ensures that all subclasses of a PreTrainedConfig accept any kwargs which is what we supported prev.

Not all remote code has @strict or has an __init__ defined and therefore can fail to accept arbitrary kwargs. For example, this should be a valid way to define a new config

Note that the init will be wrapped only if the subclass hasn't yet defined its own __init__. In case when subclass has a custom __init__, we assume that the user wants full control and don't wrap it. Otherwise we can cause issues because the wrapper doesn't call original_init, instead it sets attributes for known dataclass fields

from transformers import LlamaConfig

class NewLlamaConfig(LlamaConfig):
    model_type = "new_llama"

config = NewLlamaConfig(foo=1, **any_kwargs) # note the foo attr
model = MyModel(config)

cc @hmellor

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

@zucchini-nlp zucchini-nlp enabled auto-merge March 24, 2026 13:34
@github-actions
Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: afmoe, aimv2, albert, align, altclip, apertus, arcee, aria, audio_spectrogram_transformer, audioflamingo3, autoformer, aya_vision, bamba, bark, bart, beit

@github-actions
Copy link
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44953&sha=c445b9

@ArthurZucker ArthurZucker disabled auto-merge March 24, 2026 14:14
@ArthurZucker ArthurZucker merged commit d4895f0 into huggingface:main Mar 24, 2026
25 of 29 checks passed
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