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

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

Copy link
Copy Markdown
Author

Hi @sayakpaul, could you take a look at this small configuration round-trip fix or point me to the appropriate reviewer? It fixes #14460 by distinguishing positionally supplied arguments from defaulted values and includes a focused regression test; all 12 relevant config tests pass locally. Happy to revise the implementation based on your guidance.

This branch has not been deployed

No deployments
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