Lab: tensor parallel versus data parallel on two GPUs
Serve one model on two GPUs two ways (one tensor-parallel copy across both, or two independent replicas), predict the result from the communication cost model, then measure latency and goodput under load and explain the crossover. Includes a topology check, the exact sweep, a results table and how to read it.
By Sandip Maity, Applied AI Engineer
Goal: decide, with measurements, how to use two GPUs for one model that fits on one: as one tensor-parallel copy (TP=2) or as two data-parallel replicas (DP=2). You will predict first, then measure, then explain the gap.
You need: a machine (or rented instance) with two identical NVIDIA GPUs, vLLM or SGLang, a 7 to 8B model in BF16, Python 3.10+, and the loadgen.py open-loop load generator from the baseline-to-3x lab. About 90 minutes.
Honest limits. Engine flag names change between versions; check your engine's documentation. Results depend on your GPUs, interconnect and workload: the point of the lab is the method and the explanation, not a specific number.
#Step 0: check the topology
nvidia-smi topo -m
nvidia-smi nvlink --status # if the GPUs have NVLinkWrite down the link between GPU 0 and GPU 1: NV# (NVLink), PIX/PXB (PCIe switch), PHB (host bridge) or SYS (across CPU sockets). Everything else in this lab depends on it (interconnects).
Pro content
Keep reading with Inference Academy Pro
Unlock this full lab, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.
Still to come in this lab
- Step 1: predict
- Step 2: run the TP=2 layout
- Step 3: run the DP=2 layout
- Step 4: fill the table
- Step 5: explain
- Self-check
- Stretch goals
You will be able to answer
- Before measuring, what does the course predict for an 8B model on two NVLink-connected GPUs?
- Your two GPUs show SYS in nvidia-smi topo -m. What changes?
- Why compare goodput rather than peak tokens per second?
Articles that build on this lesson
Preparing for an interview?
- Multi-GPU LLM serving interview questions (5 questions with model answers)