deepspeedai / deepspeedai/DeepSpeed
How to inference with data parallelism and model parallelism[BUG]
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
I try to use inference with model parallelism and data parallelism, but it seems something wrong
logger.info("DeepSpeed Inference Initialization")
model = LlamaForCausalLM.from_pretrained(ckpt_path, device_map='cpu', torch_dtype=model_dtype)
if is_pipeline:
model = pipeline("text-generation",
model=model,
tokenizer=tokenizer,
torch_dtype=model_dtype)
model.model = deepspeed.init_inference(
model.model,
mp_size = model_parallel_size,
dtype=model_dtype,
replace_with_kernel_inject=False
)
model.device = torch.device(f"cuda:{int(os.environ.get('LOCAL_RANK', 0))}")
command line: deepspeed --include localhost:4,5,6,7 --master_addr=127.0.0.1 --master_port=29501 run_inference_model_parallelism.py
The text above is main code. model_parallel_size is 2, and num_gpus is 4.
Got the warning below:
/anaconda3/lib/python3.9/site-packages/torch/distributed/distributed_c10d.py:278: UserWarning: Running all_reduce on global rank 3 which does not belong to the given group.
/anaconda3/lib/python3.9/site-packages/torch/distributed/distributed_c10d.py:278: UserWarning: Running all_reduce on global rank 2 which does not belong to the given group.
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 shown inference setup with model_parallel_size=2 on GPUs 4–7 using the provided DeepSpeed command. Inspect how ranks are assigned to the model-parallel group around the reported all_reduce warnings; done means the configuration runs without warnings and performs inference as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100