Multi-GPU Inference
Overview
Multi-GPU Inference is a method of performing LLM inference across multiple GPUs simultaneously. It is used when a model does not fit into the VRAM of a single device or when increased throughput is required. Distribution can be done by layers (pipeline parallelism) or by tensors (tensor parallelism).
Strategy Comparison
| Strategy | Principle | Advantages | Limitations |
|---|---|---|---|
| Pipeline Parallelism | Layers distributed across GPUs | Low communication volume | Simple, but can lead to load imbalance |
| Tensor Parallelism | Tensors split across GPUs | High speed per request | High interconnect requirements |
| Data Parallelism | Model copies on GPUs | High throughput | Requires weight synchronization |
Implementation
Popular frameworks: vLLM, TensorRT-LLM, DeepSpeed. Example of running vLLM with tensor parallelism:
vllm serve meta-llama/Llama-3-70B --tensor-parallel-size 4
Key parameters: --tensor-parallel-size, --pipeline-parallel-size. GPU interconnect (NVLink, InfiniBand) is critical for tensor parallelism.