Skip to content
The Daily Triptych083 / 365
Three strategies for splitting a model across devices

Each strategy trades off device utilisation against interconnect bandwidth requirements. Tensor parallelism keeps all devices busy but demands fast links; layer-wise sharding tolerates slow links but leaves most devices idle.

Try it in the local lab

Observe layer-wise sharding with a split model

If you have a model split across devices using a tool like llama.cpp or Ollama, you can observe which device is active during generation by monitoring GPU utilisation in real time.

$ # In one terminal, start generation with a split model
$ ollama run llama2:70b "Explain tensor parallelism in detail"
$ # In another terminal, watch GPU utilisation every second
$ watch -n 1 nvidia-smi --query-gpu=index,utilization.gpu --format=csv
$ # Or on macOS with Metal:
$ sudo powermetrics --samplers gpu_power -i 1000
$ # You will see utilisation spike on one device, drop to near zero,
$ # then spike on the next device as activations move between layers.
$ # With tensor parallelism, all devices would show high utilisation
$ # simultaneously. With layer-wise sharding, they take turns.

This only works if your model is actually split across devices. If the entire model fits on one GPU, you will see constant utilisation on that device only. The pattern is most visible with large models that must be split and during the prefill phase, where each layer processes the entire prompt. During generation, each device is active for a shorter time per token, but the sequential pattern remains.

II · THE IDEA · ARTIFICIAL INTELLIGENCE

Splitting a Model Across Machines

Hardware and local inference · Model parallelism · Sharding

▶ Listen · narrated

The largest open models exceed half a trillion parameters. No consumer card holds them whole, so running one locally means choosing how to divide work—the wrong choice turns hardware into a waiting room.

At a glance

Tensor parallelism
Split each matrix operation across devices; all communicate every layer
Pipeline parallelism
Assign whole layers to devices; each waits for the previous stage to finish
Layer-wise sharding
Load contiguous layer groups on separate devices; pass activations once per group
Bandwidth requirement
Tensor parallelism needs high-speed interconnect; pipeline and layer-wise tolerate slower links

Imagine you need to move a large pile of bricks from one side of a field to the other, but the pile is too heavy for one person to carry. You have three options. First, you could split each load: several people carry parts of the same load at the same time, meeting in the middle to hand off their portions. This is fast, but only if everyone can walk side by side — if the path is narrow, they will collide and slow down. Second, you could form a relay: the first person carries a load partway, sets it down, and while they walk back for the next load, the second person carries the first load onward. This works on a narrow path, but if you only have one brick to move, most people are standing around waiting. Third, you could have one person carry the entire brick all the way, then the next person carries the next brick. Simple, works on any path, but only one person works at a time. Splitting a model across machines is the same problem: you can split the work inside each layer (tensor parallelism, needs a wide path), split the model into stages and stream batches through (pipeline parallelism, needs multiple bricks in motion), or just pass the work from one device to the next (layer-wise sharding, one device active at a time).

Look closer

  1. Tensor parallelism splits the arithmetic inside a single layer

    A large matrix multiplication — say, transforming a hidden state through a feed-forward layer — can be divided so that each GPU computes part of the output. The input activations must be broadcast to all devices, each performs its fraction of the work, then the partial results are gathered and summed. This happens at every layer, so the devices communicate constantly. Megatron-LM demonstrated this at scale, training models with billions of parameters by splitting attention and feed-forward operations across multiple GPUs connected by NVLink, NVIDIA's high-bandwidth interconnect.

  2. Pipeline parallelism assigns whole layers to different devices and streams the batch

    Instead of splitting operations, you split the model vertically: the first few layers live on GPU zero, the next few on GPU one, and so on. A batch is divided into smaller micro-batches that flow through the pipeline in sequence, so while GPU two is processing micro-batch three, GPU one is working on micro-batch four. GPipe introduced this scheme, showing that careful scheduling of these micro-batches could keep all devices busy most of the time. Communication happens only at layer boundaries, so bandwidth requirements are much lower than tensor parallelism, but devices spend time idle waiting for the previous stage unless the batch is large enough to keep the pipeline full.

  3. Layer-wise sharding is pipeline parallelism with a batch size of one

    You place contiguous layer groups on separate devices and pass activations from one to the next, but you process only a single sequence at a time. There is no pipelining, no micro-batching, and most of the time only one device is working while the others wait. It is the simplest scheme to implement and tolerates slow interconnects — even CPU-to-CPU links over a network — because communication is infrequent. The cost is poor utilisation: if you have four devices, three are idle at any moment. For inference on a single prompt, where you cannot fill a pipeline, this is often the only practical choice when the model does not fit on one machine.

The story

When a model grows beyond the memory of a single accelerator, you must distribute it. Three strategies have emerged, each trading off bandwidth, latency and utilisation differently.

Tensor parallelism divides the work inside each layer. A matrix multiplication that would normally happen on one device is split so that each device computes a portion of the result. The devices must exchange data before and after every operation: inputs are broadcast, outputs are gathered and summed. This means tensor parallelism demands a fast link between devices. Megatron-LM, published by researchers at NVIDIA, used this approach to train models with multiple billions of parameters by splitting both the attention mechanism and the feed-forward layers across GPUs connected by NVLink, which offers substantially higher bandwidth than PCI Express. The method scales well when the interconnect is fast, but performance collapses over slower links because communication becomes the bottleneck. Every forward pass and every backward pass during training requires multiple all-reduce operations, and if the time to move data between devices exceeds the time to compute, the GPUs spend more time waiting than working.

Pipeline parallelism takes a different approach. Instead of splitting operations, you split the model vertically: the first few layers run on one device, the next few on another, and so on. A batch of inputs is divided into smaller micro-batches that flow through the pipeline in sequence. While one device processes micro-batch three, the next device works on micro-batch four. GPipe demonstrated that with careful scheduling, this could keep all devices busy most of the time, training models too large for any single accelerator. Communication happens only at layer boundaries — one device sends its output activations to the next — so bandwidth requirements are much lower than tensor parallelism. The trade-off is utilisation: unless the batch is large enough to fill the pipeline, devices sit idle waiting for the previous stage. Training benefits from large batches, but inference often processes one prompt at a time, which makes pipeline parallelism less attractive there.

Layer-wise sharding is the simplest scheme and the one most commonly used for local inference. You place contiguous groups of layers on separate devices and pass activations from one to the next, processing a single sequence with no attempt at pipelining. At any given moment, only one device is working while the others wait. If you have split a model across four GPUs, three are idle at all times. Utilisation is poor, but the method tolerates slow interconnects — even CPU-to-CPU links over a network — because communication is infrequent. For someone running a large model on consumer hardware, often across mismatched devices, this is the only practical option. The alternative schemes require either high bandwidth or large batches, neither of which a local setup is likely to provide.

The choice of strategy depends on what you are optimising for. Tensor parallelism maximises utilisation when the interconnect is fast, making it the preferred method for training clusters with purpose-built networking. Pipeline parallelism works when you have large batches and can tolerate some idle time, and it needs less bandwidth. Layer-wise sharding sacrifices utilisation entirely in exchange for working on any hardware, which makes it the default for inference on models that do not fit on one device. The interconnect is the deciding factor: a slow link between devices rules out tensor parallelism and limits how well pipeline parallelism can perform, leaving layer-wise sharding as the only viable choice despite its inefficiency.

Why it mattered then

Megatron-LM and GPipe were both published in 2019, at a moment when model size was increasing faster than single-GPU memory. Training a billion-parameter model required either buying more expensive hardware or finding a way to distribute the work across cheaper devices. Tensor parallelism worked well within a single machine where NVLink provided high bandwidth between GPUs, and it became the standard approach for training large models in data centres. Pipeline parallelism offered a way to scale across machines connected by slower network links, though it required large batches to keep the pipeline full. Both methods were designed primarily for training, where batches are large and gradients must flow backward through the entire model. The papers demonstrated that distribution was practical, not just possible, and that careful attention to communication patterns could make multi-device training competitive with single-device speeds.

Why it matters now

The techniques remain relevant because models have continued to grow and because the hardware landscape has diversified. Cloud providers offer multi-GPU instances with fast interconnects, making tensor parallelism practical for training and for high-throughput inference. Meanwhile, the availability of open-weight models has created a new use case: individuals running very large models on consumer hardware, often splitting them across mismatched devices or even across separate machines on a local network. For these users, layer-wise sharding is often the only option, and understanding why it is so inefficient helps explain why local inference on large models is slow. The rise of mixture-of-experts architectures has also created hybrid cases where different experts can be placed on different devices, blending aspects of all three strategies. The fundamental trade-off — between communication cost, utilisation, and the flexibility to run on varied hardware — has not changed, and anyone working with models too large for a single device must still choose which costs to pay.

The surprising detail

Pipeline parallelism introduces a subtle problem called the pipeline bubble. At the start of processing a batch, the first device begins working while all others are idle. As micro-batches flow through, more devices become active, but there is always a ramp-up period where the pipeline is filling and a ramp-down period where it is draining. During these phases, some devices are idle, and the larger the number of pipeline stages, the larger the bubble. GPipe's key contribution was a scheduling scheme that minimised this waste, but it could not eliminate it entirely. The bubble is why pipeline parallelism needs large batches: only when the pipeline is full for most of the time does the utilisation approach that of tensor parallelism. For inference, where you often process one sequence at a time, the bubble is the entire workload, which is why pipeline parallelism is rarely used there despite its lower bandwidth requirements.

Remember this

Tensor parallelism needs fast links because it communicates every layer. Pipeline and layer-wise sharding communicate less often, but layer-wise leaves most devices idle most of the time.

Test yourself

You have two machines, each with one GPU, connected by a one-gigabit Ethernet link. You want to run a 70-billion-parameter model that does not fit on one GPU. Which parallelism strategy is practical, and what specific behaviour will you observe during inference?

Go deeper

Image: Original diagram, The Daily Triptych. Licence: Original work. Source.

← Back to day 83