fix: correct dict comprehension syntax in save_pretrained to prevent ValueError - #47346
Closed
ajayraj30002 wants to merge 1 commit into
Closed
fix: correct dict comprehension syntax in save_pretrained to prevent ValueError#47346ajayraj30002 wants to merge 1 commit into
ajayraj30002 wants to merge 1 commit into
Conversation
This PR corrects a syntax typo in weight_map.update that causes a ValueError when offloaded modules are saved. Fixes #47333
Contributor
|
Thank you for your contribution 🤗! CI Security Gate — automatic approval blockedThis PR was not automatically approved for CI because the security gate failed. Possible reasons:
See the workflow run for the exact violations. A maintainer can review and manually approve CI if a finding is a false positive. |
Member
|
#47336 was open already with this fix + the actual fix! |
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?
Fixes #47333
There is a small syntax error in
modeling_utils.pythat crashes thesave_pretrainedprocess for models with offloaded modules.Currently,
weight_map.update()is being passed a generator yielding single-key dictionaries, which throws aValueErrorbecauseupdate()expects a sequence of 2-item tuples.Before:
weight_map.update({k: os.path.basename(shard_file)} for k in shard_state_dict.keys())After (moved the closing brace to make it a standard dict comprehension):
weight_map.update({k: os.path.basename(shard_file) for k in shard_state_dict.keys()})Code Agent Policy
Before submitting
Who can review?
@Cyrilvallez @SunMarc (Tagging you as you were mentioned in the original issue!)