deepspeedai / deepspeedai/DeepSpeed

torch.cuda.synchronize() takes a lot of time for the 10B model training with Zero 2

Open
#620 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I recently run some experiments for the 10B model training with Zero 2 on 128 A100 GPUs with 400Gb/s bandwidth, and I observed that communication dominates the total training time, which is about 18 times more expensive than the backward computation. I managed to use nsight system to do some profiling, and the following picture shows the profiling result:

image

It can be seen that the torch.cuda.synchronize() in
https://github.com/microsoft/DeepSpeed/blob/a4763f5516c0a9bb8f32d2e8a48c618f0fe88e37/deepspeed/runtime/zero/stage2.py#L1084 is the most expensive one and is called multiple times due to the bucketing. I wonder if there is any potential problem if we remove this line? And if we can adopt multiple CUDA streams as in APEX to parallelize the allreduce calls?

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 by reviewing deepspeed/runtime/zero/stage2.py at the referenced line and the surrounding bucketing and allreduce flow. Use the reported 10B-model, Zero 2, 128-A100 profiling context to investigate whether removing torch.cuda.synchronize() is safe and how multiple CUDA streams could affect the calls. Done means the synchronization and stream behavior are evaluated without regressing distributed training correctness or performance.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.