-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
DeepSpeedZeroOptimizer: refactor bit16 flattening to support more accelerators #4833
Merged
Conversation
This file contains 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
Today DeepSpeedZeroOptimizer flatten the FP16 weight (which are on the device) by moving the param.data to cpu, while maintaining the same param object. This practice cannot work with all device types. This commit introduces a new approach for doing it without data sharing. 1. copy each param.data to a new CPU tensor 2. keep param onject on device, and shrink the storage. 3. flatten the CPU storages to a host flat tensor 4. move to device 5. resize device params back to their original shape 6. point to offset in the flat buffer.
nelyahu
changed the title
DeepSpeedZeroOptimizer: refactor bit16 flatenning to support more accelerators
DeepSpeedZeroOptimizer: refactor bit16 flattening to support more accelerators
Dec 18, 2023
tjruwase
reviewed
Dec 18, 2023
tjruwase
reviewed
Dec 18, 2023
tjruwase
reviewed
Dec 18, 2023
tjruwase
reviewed
Dec 18, 2023
tjruwase
reviewed
Dec 18, 2023
tjruwase
reviewed
Jan 2, 2024
tjruwase
approved these changes
Jan 3, 2024
Hi @tjruwase - i fixed a failing UT issue, can you please re-trigger workflow? |
mauryaavinash95
pushed a commit
to mauryaavinash95/DeepSpeed
that referenced
this pull request
Feb 17, 2024
…elerators (microsoft#4833) The approach till today use the practice where the torch.nn.parameter data is being replaced with a new cpu data storage, to offload device memory. All params are being flatenned on the host and moved to the device. in some accelerators torch.nn.parameter which is a device parameter cannot be assigned with a cpu storage. This PR copy the param data into a new cpu tensor, and shrinks the device storage. Later when the flat buffer is moved to the device param.data will be a view to the flat buffer. --------- Co-authored-by: Olatunji Ruwase <[email protected]> Co-authored-by: Michael Wyatt <[email protected]>
envsp
added a commit
to envsp/DeepSpeed
that referenced
this pull request
Jun 26, 2024
…more accelerators (microsoft#4833)" This reverts commit ade9836.
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.
The approach till today use the practice where the torch.nn.parameter data is being replaced with a new cpu data storage, to offload device memory.
All params are being flatenned on the host and moved to the device.
in some accelerators torch.nn.parameter which is a device parameter cannot be assigned with a cpu storage.
This PR copy the param data into a new cpu tensor, and shrinks the device storage.
Later when the flat buffer is moved to the device param.data will be a view to the flat buffer.