Skip to content

fix: preserve positional __init__ args through from_config round trips - #14708

Open
gauravch-code wants to merge 1 commit into
huggingface:mainfrom
gauravch-code:fix-register-to-config-positional-args
Open

fix: preserve positional __init__ args through from_config round trips#14708
gauravch-code wants to merge 1 commit into
huggingface:mainfrom
gauravch-code:fix-register-to-config-positional-args

Conversation

@gauravch-code

Copy link
Copy Markdown

What does this PR do?

The @register_to_config decorator computed _use_default_values by diffing new_kwargs against init_kwargs, but init_kwargs only captured keyword arguments. Positional args mapped into new_kwargs via zip were never tracked as explicitly provided, so from_config silently reverted them to class defaults.

s = DDIMScheduler(500)
s.config.num_train_timesteps          # 500
DDIMScheduler.from_config(s.config).config.num_train_timesteps  # 1000 (wrong)

The fix tracks positional arg names separately and includes them in the set of explicitly provided parameters when computing _use_default_values.

Fixes #14460

Before submitting

Who can review?

@sayakpaul @yiyixuxu (general functionalities)

The @register_to_config decorator computed _use_default_values by
diffing new_kwargs against init_kwargs, but init_kwargs only captured
keyword arguments. Positional args mapped to new_kwargs via zip were
never tracked as explicitly provided, so from_config silently reverted
them to class defaults.

Track positional arg names separately and include them in the set of
explicitly provided parameters when computing _use_default_values.

Fixes huggingface#14460
@github-actions github-actions Bot added size/S PR with diff < 50 LOC fixes-issue tests and removed fixes-issue labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR with diff < 50 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

register_to_config mislabels positional __init__ args as _use_default_values, so from_config round trips silently revert them to defaults

1 participant