How do several GPUs in one box work together?

4 min readMarkdown

Two GPUs in one box can split a model in two ways. Layer splitPipeline parallelThe model is cut into consecutive slices across devices. Adds memory, not speed.Read more adds memory and keeps the speed of one card. Tensor parallelTensor parallelEvery device works on every token. Needs a very fast link.Read more adds speed too, but only with the right runtimeRuntimeThe software that loads a model file and runs it.Read more and enough bandwidth between the cards.

This page is about cards in one machine. The same two ideas apply across machines, with a much slower link in the middle, in What are the ways to split work across machines?.

Layer split

A model is a stack of layers, and each tokenTokenA chunk of text, usually part of a word. Models read and write in tokens.Read more passes through them in order. Layer split puts the first half of the stack on card one and the second half on card two. The token's working state hops across once, in the middle.

That hop is small. It is one vector per token, a few kilobytes, so ordinary PCIe moves it in no time. Two 24 GB cards behave like one 48 GB card for fitting a model.

Speed stays about where one card would be. While card one works on its layers, card two waits, then they swap. Each card reads only its own half of the weightsWeightsThe full set of a model's parameters, stored in a file.Read more, but they take turns, so the total read per token is the same as one big card with the same bandwidth.

Rule of thumb

Layer split buys memory, not speed. Two cards on layer split run a model about as fast as one card with double the memory would.

This is what Ollama and llama.cpp do by default when they see several GPUs. You plug in the second card and a bigger model loads.

shell
llama-server -m model.gguf -ngl 99 --split-mode layer --tensor-split 3,1

-ngl 99 puts every layer on a GPU. --tensor-split 3,1 gives the first card three quarters of the layers, which you want when the cards differ in size, such as a 24 GB card next to an 8 GB one. Despite the name, this flag sets the layer proportions in layer mode.

The catch

The slowest card sets the pace for its share. A fast card paired with an old one waits for the old one on every token. Give the slower card fewer layers, or leave it out.

Tensor parallel

Tensor parallel cuts every layer in half instead of cutting the stack. Both cards work on every token at the same time, each holding half of each weight matrix. Each reads half the weights per token, so in principle you get close to double the speed.

The price is traffic. After each layer the cards swap partial results and combine them, which means two exchanges per layer, dozens of times per token. Every exchange waits on the link between the cards.

Link between cardsSuits tensor parallel
NVLink on data-centre cardsYes. Built for it
NVLink bridge on older consumer cards such as the RTX 3090Yes, for pairs
PCIe 4.0 or 5.0 at x16 per cardWorks well for two cards, falls off at four or more
PCIe at x4, or through a chipsetSlow. Layer split is often faster

Real speedups are below double. Two cards on a fast link run a model noticeably faster than one, and four cards faster again, with each extra card adding less. How do I benchmark my own setup? shows how to measure it on your own build.

Tensor parallel also needs a model that divides evenly. The runtime splits attention heads between cards, so the count of heads must divide by the number of GPUs. That is why you see two, four and eight cards, and rarely three.

Which runtimes do which

RuntimeLayer splitTensor parallel
OllamaYes, automaticNo
llama.cppYes, the defaultA row split mode that spreads work across cards, slower than true tensor parallel on most builds
LM StudioYes, with a per-GPU allocation settingNo
vLLMYes, as pipeline parallelYes, --tensor-parallel-size
SGLangYesYes, --tp

For one person on a mixed pair of cards, llama.cpp or Ollama with layer split is the simple answer. For a team on matched cards, vLLM with tensor parallel is faster and batches better. How do I build a multi-GPU rig? covers building the box itself.

shell
vllm serve Qwen/Qwen3-32B --tensor-parallel-size 2
Try it

On a two-GPU NVIDIA box, check how the cards connect before choosing a mode.

shell
nvidia-smi topo -m

NV entries mean NVLink. PHB, PXB or SYS mean the traffic goes over PCIe or across CPUs, which is slower.

Go deeperThat's enough

Why consumer cards struggle past two

Modern GeForce cards have no NVLink. All tensor-parallel traffic goes over PCIe, and on most desktop boards only one or two slots get the full 16 lanes. A third card often runs at x4 through the chipset, which drags every exchange.

NVIDIA also limits direct card-to-card transfers on GeForce cards, so traffic often goes through system memory. Workstation boards with many full-speed slots and pro cards avoid both problems.

Pipeline parallel and batching

Layer split leaves one card idle while the other works, but only for a single user. With many users, a serving runtime keeps both halves busy by feeding a new batch into card one while card two finishes the previous one. That is pipeline parallel, and it raises aggregate throughput without speeding up any single stream.

Mixing tensor and pipeline parallel

On eight cards you can run tensor parallel within groups of four and pipeline parallel between the groups. vLLM takes both flags at once. This matters most across machines, where tensor parallel over a slow network would stall, as Which cable do I need between machines? explains.

KV cache splits too

Under tensor parallel each card holds the cache for its share of attention heads. Under layer split each card holds the cache for its own layers. Either way the cache spreads across cards, so two cards also give you room for longer contexts.