deepspeedai / deepspeedai/DeepSpeed
[BUG] Multi-gpu stuck when the computation graph is not complete for wach process.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
Describe the bug
We train a Transformers with several different classifier readout modules, where each input sample will include a tag to determine which classifier readout modules should be used. We use a ModuleDict to implement it. But we find when we use multi-gpu and deepspeed zero-3 (merged in the transformers package with the accelerate) to train out model, the training will be randomly stuck.
Finally, we find the bug could be caused by the incomplete computation graph. In our model, for a batch, some classifier readout could be not used so that this module is not in the computation graph and this module has no gradient. However, another gpu has a different training batch in the same step could activate this modules. Finally, when the gradient will be gathered, it cause an error.
We finally manually add a zero loss for each modules to keep them in the graph and the bug has been solved. But we believe there could be a more genenral way to solve the problem. For example, the pytorch has a detection whether there are some modules are not in the computation graph.
System info (please complete the following information):
- OS: Ubuntu 18.04
- GPU count and types: one machines with x2 (x4 or x8) A800s each
- Python version: 3.11
- deepspeed: 0.14.0
- transformers: 4.40.0
- accelerate: 0.29.3
- Any other relevant info about your setup
Launcher context
We use accelerate launch and provide it the distributed method as deepspeed zero-3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported hang with accelerate launch, DeepSpeed ZeRO-3, and a ModuleDict whose classifier modules are activated by different samples on each GPU. Compare batches where a module is absent from one computation graph and present on another, using the reported zero-loss workaround as a reference. Done means the multi-GPU training step no longer hangs or fails during gradient gathering without requiring that workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100