[DeepSpeed] add weight_mapping to _load_state_dict_into_zero3_model#43303
Merged
ArthurZucker merged 31 commits intohuggingface:mainfrom Jan 24, 2026
Merged
[DeepSpeed] add weight_mapping to _load_state_dict_into_zero3_model#43303ArthurZucker merged 31 commits intohuggingface:mainfrom
ArthurZucker merged 31 commits intohuggingface:mainfrom
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. |
kashif
commented
Jan 15, 2026
Contributor
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43303&sha=8b03dd |
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
This is great thanks for the initiative!
- will have device issues probably no?
- for experts, if deepspeed places some on device x,y,z merging or etc could break this
- memory consumption issue!
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
Just merged #43261 which changes stuff a but I'll check this PR out to see if we can simplify a bit calls to re-use some stuff on it today
Contributor
Author
|
i'll use the new |
ArthurZucker
approved these changes
Jan 24, 2026
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
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?
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.