Skip to content

Fix error message label and docstring default in load_sharded_checkpoint#44523

Open
jnMetaCode wants to merge 1 commit intohuggingface:mainfrom
jnMetaCode:fix/trainer-utils-error-msg-and-docstring
Open

Fix error message label and docstring default in load_sharded_checkpoint#44523
jnMetaCode wants to merge 1 commit intohuggingface:mainfrom
jnMetaCode:fix/trainer-utils-error-msg-and-docstring

Conversation

@jnMetaCode
Copy link
Contributor

Summary

Fixes two small bugs in load_sharded_checkpoint in trainer_utils.py:

Bug 1 — Copy-paste error in error message (line 1108):
When reporting unexpected keys, the error message incorrectly says "Missing key(s)" instead of "Unexpected key(s)". This is a copy-paste error from the missing keys block above.

# Before (wrong):
error_message += f"\nMissing key(s): {str_unexpected_keys}."
# After (correct):
error_message += f"\nUnexpected key(s): {str_unexpected_keys}."

Bug 2 — Docstring default value mismatch (line 1067):
The docstring says prefer_safe defaults to False, but the function signature has prefer_safe=True.

Test plan

  • Verified the actual function signature is prefer_safe=True
  • Verified error message on line 1108 incorrectly labels unexpected keys as missing
  • Existing tests should continue to pass (no behavioral change in logic)

…d_checkpoint

Fix two bugs in load_sharded_checkpoint:
1. Copy-paste error: error message for unexpected_keys incorrectly said
   "Missing key(s)" instead of "Unexpected key(s)" (line 1108)
2. Docstring for prefer_safe said defaults to False but actual default
   in function signature is True

Signed-off-by: JiangNan <1394485448@qq.com>
@Rocketknight1
Copy link
Member

LGTM but cc @SunMarc

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.

2 participants