deepspeedai / deepspeedai/DeepSpeed

How to manipulate model weights within a ZeRO 3 training process?

Open
#3,959 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug training
Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

What I want to do is pretty straightforward - average the current model weights after a specified training steps with previous saved checkpoints (or torch model, whichever it works better with deepspeed). One problem I've found so far is directly accessing the model state_dict can lead to tensors of size 0, which is also mentioned in deepspeed official doc caused by model sharding.
I wonder how can I achieve this in an elegant way? I was told that even if I managed to gather all the tensors and do the average operation, I also need to cope with the fp32 model parameters maintained in the optimizer in additional to replacing the model parameters in fp16?
Any insights on this issue would be greatly appreciated. One important note is that I do need to realize this in the ZeRO 3 setting.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ZeRO 3 documentation on model sharding and the behavior of model state_dict tensors. Trace how saved checkpoints, gathered parameters, and the optimizer's fp32 parameters are handled during training. Done means identifying and documenting an elegant supported way to average weights at specified steps while keeping model and optimizer parameters consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.