-
Notifications
You must be signed in to change notification settings - Fork 31.8k
[DeepSpeed] add weight_mapping to _load_state_dict_into_zero3_model #43303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
| new_state_dict[target_name] = param | ||
| except Exception as e: | ||
| # If conversion fails, log and skip (better than failing completely) | ||
| logger.warning(f"Failed to convert {first_param_name}: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the warning ok or should we have an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert for sure. how will it work if it's invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks changing
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43303&sha=f45026 |
What does this PR do?
This pull request introduces enhancements to the DeepSpeed integration for model loading, specifically improving how weight conversions (such as renaming and merging/splitting of weights) are handled when loading state dictionaries into models using DeepSpeed ZeRO-3. The changes add a new utility for applying weight conversion logic before loading, and update the model loading pipeline to use this utility when needed.
Key changes:
Weight Conversion Utilities
_apply_weight_conversions_to_state_dictindeepspeed.pyto handle weight renaming and merging/splitting operations on state dicts before loading them into a model. This function supports both simple renaming and more complex conversions usingWeightConverterandWeightRenamingobjects.DeepSpeed Model Loading Logic
_load_state_dict_into_zero3_modelto accept an optionalweight_mappingargument. If provided, it uses the new_apply_weight_conversions_to_state_dictfunction to preprocess the state dict before loading. It also stores the applied weight conversions on the model for later reference._load_state_dict_into_zero3_modelin_load_pretrained_model(inmodeling_utils.py) to pass theweight_mappingargument, ensuring that weight conversions are applied during DeepSpeed ZeRO-3 model loading.Fixes #43257
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.