deepspeedai / deepspeedai/DeepSpeed
[BUG] DeepSpeed-inference 2GPU performance is lower than 1GPU
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
DeepSpeed-inference 2GPU performance is lower than 1GPU on Bloomz 7.1B
To Reproduce
run the flowing code using two V100 or A100 GPUs.
with this command:
deepspeed --num_gpus 2 --master_port 60000 test.py
`from transformers import AutoModelForCausalLM, AutoTokenizer
import deepspeed
os.environ['CUDA_VISIBLE_DEVICES'] = "0,1"
checkpoint = "bigscience/bloomz-7b1"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint, torch_dtype="auto", device_map="auto")
model = deepspeed.init_inference(
model=model,
mp_size=2,
dtype=torch.float16,
replace_method="auto",
replace_with_kernel_inject=True,
)
inputs = tokenizer.encode("Translate to English: Je t’aime.", return_tensors="pt").to("cuda")
outputs = model.generate(inputs)
print(tokenizer.decode(outputs[0]))`
The performance of two gpu is lower than one gpu.
The main reason is all_reduce time is too long. The reason of all_reduce too long is because there are many space during the kernel execution, as the picture shows:
the all_reduce time of GPU0 is much longer than GPU1 all_reduce time, because there is long spaces during GPU1 op execution.

Expected behavior
2 GPU inference show be faster than 1 GPU.
- OS:
- Ubuntu 18.04
-2 A100 or V100 GPU - Python 3.8
Launcher context
deepspeed --num_gpus 2 --master_port 60000 test.py
Docker context
nvcr.io/nvidia/pytorch:22.09-py3
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 with the test.py reproduction described in the issue and run it with the stated DeepSpeed launcher on two V100 or A100 GPUs. Profile the all_reduce and kernel execution timing to compare one- and two-GPU runs. Done means the two-GPU inference performance improves over one GPU and the reported all_reduce delay is resolved or explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100