deepspeedai / deepspeedai/DeepSpeedExamples

Predict latency is more with 4 GPUs than 1 GPU

Open
#135 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.8k
Forks
1.1k
Avg merge
2d 16h
Merged PRs (30d)
1

Description

I am trying deepspeed inference with gtpneo-1.3B model. I am using the example here for reference.

# Filename: example.py
import os
import deepspeed
import datetime
import torch
from transformers import pipeline

local_rank = int(os.getenv('LOCAL_RANK', '0'))
world_size = int(os.getenv('WORLD_SIZE', '1'))
generator = pipeline('text-generation',
                     model='EleutherAI/gpt-neo-1.3B',
                     device=local_rank)

generator.model = deepspeed.init_inference(generator.model,
                                           mp_size=world_size,
                                           dtype=torch.float,
                                           replace_method='auto')

# from parallelformers import parallelize
# parallelize(generator.model, num_gpus=2, fp16=True, verbose='detail')

start = datetime.datetime.now()
string = generator("DeepSpeed is", do_sample=True, min_length=50)
end = datetime.datetime.now()
if not torch.distributed.is_initialized() or torch.distributed.get_rank() == 0:
    print(string)
    print("Time for dp inference", (end - start).total_seconds() * 1000)
deepspeed --num_gpus 4 example.py
Time for dp inference 1457.596

deepspeed --num_gpus 1 example.py
Time for dp inference 666.149

The latency for inference does not makes sense as i see increased latency while using 4 GPUs compared to 1 GPU.

From the docs i see that this model support multi GPU inference with inter GPU communication. https://www.deepspeed.ai/tutorials/inference-tutorial/#end-to-end-gpt-neo-27b-inference

Environment: AWS p3.8xlarge instance.
NVIDIA-SMI 450.142.00   
Driver Version: 450.142.00   
CUDA Version: 11.0
deepspeed                     0.5.3
mpi4py                        3.1.1
ninja                         1.10.2.1
transformers                  4.11.2

4_gpu.log
1_gpu.log

Contributor guide

No contributing guide indexed for this repository

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 example.py and reproduce the deeopspeed --num_gpus 1 and --num_gpus 4 commands using the versions and AWS instance listed. Compare 1_gpu.log and 4_gpu.log, including the inference setup and timing path; done means identifying and documenting why the multi-GPU run has higher latency or what configuration needs correction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.