# How do several GPUs in one box work together?

> Layer split gives you more memory at about the same speed. Tensor parallel gives more speed but needs fast links between cards and a runtime built for it.

Two GPUs in one box can split a model in two ways. Layer split adds memory and keeps the speed of one card. Tensor parallel adds speed too, but only with the right runtime 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?](https://localagi.co/three-ways-to-cluster).

## Layer split

A model is a stack of layers, and each token 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 weights, 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](https://localagi.co/ollama) and [llama.cpp](https://localagi.co/llama-cpp) do by default when they see several GPUs. You plug in the second card and a bigger model loads.

```bash
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 cards | Suits tensor parallel |
| --- | --- |
| NVLink on data-centre cards | Yes. Built for it |
| NVLink bridge on older consumer cards such as the RTX 3090 | Yes, for pairs |
| PCIe 4.0 or 5.0 at x16 per card | Works well for two cards, falls off at four or more |
| PCIe at x4, or through a chipset | Slow. 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?](https://localagi.co/benchmarking) 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

| Runtime | Layer split | Tensor parallel |
| --- | --- | --- |
| [Ollama](https://localagi.co/ollama) | Yes, automatic | No |
| [llama.cpp](https://localagi.co/llama-cpp) | Yes, the default | A row split mode that spreads work across cards, slower than true tensor parallel on most builds |
| [LM Studio](https://localagi.co/lm-studio) | Yes, with a per-GPU allocation setting | No |
| [vLLM](https://localagi.co/vllm-and-sglang) | Yes, as pipeline parallel | Yes, `--tensor-parallel-size` |
| [SGLang](https://localagi.co/vllm-and-sglang) | Yes | Yes, `--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?](https://localagi.co/multi-gpu-rig) covers building the box itself.

```bash
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.

```bash
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 deeper

### 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?](https://localagi.co/interconnects) 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](https://localagi.co/context-window).
