fix: preserve positional __init__ args through from_config round trips - #14708
Open
gauravch-code wants to merge 1 commit into
Open
fix: preserve positional __init__ args through from_config round trips#14708gauravch-code wants to merge 1 commit into
gauravch-code wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The
@register_to_configdecorator computed_use_default_valuesby diffingnew_kwargsagainstinit_kwargs, butinit_kwargsonly captured keyword arguments. Positional args mapped intonew_kwargsviazipwere never tracked as explicitly provided, sofrom_configsilently reverted them to class defaults.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
register_to_configmislabels positional__init__args as_use_default_values, sofrom_configround trips silently revert them to defaults聽#14460Who can review?
@sayakpaul @yiyixuxu (general functionalities)