Skip to main content
Mini-SGLang supports distributed serving using Tensor Parallelism (TP) to split large models across multiple GPUs. This enables serving models that exceed single-GPU memory capacity and improves throughput for demanding workloads.

Overview

Tensor Parallelism splits model layers across multiple GPUs, allowing:
  • Large Model Serving: Deploy models like Llama-3.1-70B that don’t fit on a single GPU
  • Increased Throughput: Distribute computation across GPUs for better performance
  • Efficient Memory Usage: Utilize memory from multiple GPUs simultaneously

Requirements

  • Multiple GPUs: 2, 4, or 8 GPUs (must be a power of 2)
  • NVLink: GPUs should be connected via NVLink for optimal performance
  • VRAM: Combined memory must accommodate the model and KV cache
  • CUDA Toolkit: Version matching your driver (check with nvidia-smi)
  • NCCL: Automatically included with PyTorch
  • Linux: Required for CUDA kernel support
Tensor Parallelism requires GPUs to be connected via high-bandwidth interconnects like NVLink. Performance will be significantly degraded over PCIe connections.

Launching with Tensor Parallelism

1

Verify GPU availability

Check that all GPUs are visible:
Expected output:
2

Launch with --tp flag

Specify the number of GPUs to use with --tp:
This will distribute the model across 4 GPUs.
3

Verify distributed initialization

You should see logs indicating TP initialization:

Configuration Examples

2-GPU Setup (Llama-3.1-8B)

4-GPU Setup (Qwen-3-32B)

8-GPU Setup (Llama-3.1-405B)

Advanced Configuration

Custom Port

With Custom Cache Strategy

Attention Backend Selection

This uses FlashAttention for prefill and FlashInfer for decode.

Performance Tuning

Chunked Prefill

Adjust the max prefill length for better memory efficiency:

CUDA Graph Optimization

Set the maximum batch size for CUDA graph capture:

Page Size Configuration

Benchmark Example

From the Mini-SGLang benchmarks, deploying Qwen3-32B on 4×H200 GPUs:
Test Configuration:
  • Hardware: 4×H200 GPU connected by NVLink
  • Model: Qwen3-32B
  • Dataset: Qwen trace (1000 requests)
This configuration achieves state-of-the-art throughput for online serving workloads.

Troubleshooting

Increase NCCL timeout:
  • Reduce --max-prefill-length
  • Reduce --cuda-graph-max-bs
  • Increase number of GPUs with --tp
  • Use a smaller model variant
  • Verify GPUs are connected via NVLink: nvidia-smi topo -m
  • Check GPU utilization: nvidia-smi dmon
  • Ensure no other processes are using the GPUs
Verify the TP degree matches your available GPUs:

Using with ModelScope

For users with HuggingFace access issues:
For single-GPU deployments, see the Online Serving guide.