> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# One Machine or Many

> Describes model sharding choices, tradeoffs between tensor and pipeline parallelism based on interconnect speed, and routing plus cache strategies for multi server deployments

Last time we looked at how to run models that are too large for a single GPU by slicing them across multiple GPUs. There are two common slicing strategies:

* Slice by layer (pipeline parallelism): give each device a contiguous set of layers.
* Slice within a layer (tensor/model parallelism): split the math inside each layer across GPUs.

These two approaches — and how you combine them — are collectively known as model sharding. Which to choose depends mainly on where the GPUs live and, critically, how fast they can communicate.

![A slide titled "Two Ways to Slice" showing two pink rounded rectangles on a dark background: the left illustrates a dashed horizontal cut labeled "By Layer" with a green arrow and note "Quiet — one handoff," and the right shows a dashed vertical cut labeled "Within Each Layer."](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/slice-by-layer-vs-within-layer.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=e9a536867e4fecb30134a706654d3c58)

Where GPUs are placed changes the trade-offs. If GPUs are in different machines, communication goes over the network; if they’re in the same chassis, they can use a high-speed, low-latency interconnect.

![A dark-themed diagram titled "Where the GPUs Live" showing two stylized GPU boxes labeled "GPU 1" (left) and "GPU 2" (right). They are linked by a horizontal line with a red question-mark in the center, indicating an unknown or missing connection.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/where-gpus-live-missing-connection.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=a587dcb2bae2eb2f9c0961d3621a3baa)

Inside a single machine, GPUs are connected by NVLink (NVIDIA) or xGMI (AMD). These interconnects deliver far higher bandwidth and lower latency than Ethernet or even typical InfiniBand networks, which makes the “chatty” approach — splitting a layer’s computation across GPUs — practical.

![An infographic titled "Inside One Machine" showing a stylized machine rack with eight small node panels arranged in two rows and linked by a central green bus. The graphic uses a blue/teal color scheme with rounded module icons.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/inside-one-machine-rack-nodes-bus.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=649548e94fa7fda29422267bbbdc14b2)

On fast intra-node links you can afford frequent exchanges of intermediate tensors (activations, gradients, etc.), so tensor (within-layer) parallelism performs well. Put eight NVLink-connected GPUs in one chassis and they often operate like one logical device — this pattern is how many large models are trained and served today.

![An infographic titled "Eight GPUs, One Box" shows eight small GPU module icons arranged inside a single chassis and linked by a central horizontal interconnect. A caption below reads "How most large models run today" and a green checkmark appears at the side.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/eight-gpus-one-box-infographic.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=6d2296c833348e2b58a56fca880f61c6)

When you span multiple machines, the network is usually slower and higher-latency than NVLink/xGMI. Across-node traffic should therefore be minimized: pipeline parallelism (splitting by layers) sends a single activation from one machine to the next, producing relatively light network load that conventional inter-node links can sustain.

![An infographic titled "The Light Method" with a central pill button labeled "Light – whole stretches." Below it are two rounded boxes labeled "Machine 1" and "Machine 2" containing stacked list items (L1–L3 and L4–L6) connected by a dotted line and a "Little traffic" label.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/light-method-machines-little-traffic.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=455432a5f12068539adfce14a87e207b)

The simple rule of thumb is: keep the chatty (high-bandwidth, low-latency) traffic inside a machine, and keep only light traffic across machines.

Sharding chooses between tensor/model parallelism (within a machine) and pipeline parallelism (across machines) based on interconnect speed. The goal is to minimize slow, high-volume network transfers.

Quick comparison — when to use each sharding method:

| Strategy | Communication pattern | Best when | Typical hardware |
| - | -: | - | - |
| Tensor / Model parallelism (within-layer) | High-frequency, high-bandwidth exchanges of partial tensors | GPUs have ultra-fast interconnects and are in the same chassis | NVLink / xGMI within one server |
| Pipeline parallelism (by-layer) | Low-frequency, single-activation handoffs between stages | Machines are separated by network links | Ethernet / InfiniBand across nodes |
| Hybrid (tensor + pipeline) | Combines both patterns to fit model and latency constraints | Large models span many GPUs and multiple machines | Mixed: NVLink inside chassis, network across chassis |

vLLM provides a practical way to describe and launch these configurations. A single command starts a server that can apply intra-node (chatty) and inter-node (light) splitting according to the parallelism settings:

```bash theme={null}
$ vllm serve
```

You can configure tensor- and pipeline-parallel sizes when you launch. Example:

```bash theme={null}
$ vllm serve deepseek-ai/DeepSeek-V3 --tensor-parallel-size 8 --pipeline-parallel-size 2
```

Check the [vLLM documentation](https://vllm.readthedocs.io/en/latest/) for exact flag names and supported combinations for your version.

![An infographic titled "The Fitting Problem, Solved" with a pink "Giant" banner at the top. It shows two grouped boxes of small server icons illustrating a single machine's worth versus several machines' worth mapped to one logical server.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/fitting-problem-solved-server-mapping.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=647fd9d64e0c5b239ad75fb76f9ed912)

Sharding solves the weight-placement (fitting) problem: by spreading parameters across GPUs you can host models that would not fit on a single device. But sharding does not increase the runtime memory available to a single server session — activation buffers, per-request scratch space, and KV caches still consume each server’s local RAM/VRAM.

For production services you therefore need a fleet of servers: each server hosts the model (sharded across its GPUs) and serves a subset of users. The architecture then raises a classic routing question: where should a user’s next message be sent?

![A stylized diagram titled "A Whole Fleet" showing four servers (Server 1–4), each hosting a pink "Model" box. A KV cache icon is shown above linked to one server, with small user/client icons beneath each server.](https://mintcdn.com/kodekloud-c4ac6d9a/OJzUA92tPKBc1TNu/images/llm-d-A-Deep-Dive/From-One-Server-to-a-Fleet/One-Machine-or-Many/whole-fleet-servers-models-kv-cache.jpg?fit=max\&auto=format\&n=OJzUA92tPKBc1TNu\&q=85\&s=6a9c2413390e3c51ccf9e3ff4cde3c22)

A user’s KV cache — the cached activations and attention keys that make a chat respond quickly — lives in the memory of the server that created it. If the user’s next message is routed to the same server, the reply is fast. If it lands on a different server, that server must reconstruct the conversation state (or fetch it over the network), increasing latency.

In multi-server deployments, incorrect routing or misplaced caches causes recomputation or cache transfers, which degrade latency and throughput. Design routing and cache placement carefully.

Routing and cache management are therefore essential for low-latency, high-throughput serving. Common solutions include sticky routing (send a user to the same server while their KV cache is hot), sharded KV layers, or a shared fast cache layer — each has trade-offs in complexity, memory usage, and network load.

Links and references

* vLLM documentation: [https://vllm.readthedocs.io/en/latest/](https://vllm.readthedocs.io/en/latest/)
* NVIDIA NVLink overview: [https://www.nvidia.com/en-us/data-center/nvlink/](https://www.nvidia.com/en-us/data-center/nvlink/)
* InfiniBand basics: [https://www.infinibandta.org/](https://www.infinibandta.org/)
* Model parallelism and pipeline parallelism concepts: [https://arxiv.org/abs/1905.04097](https://arxiv.org/abs/1905.04097) (Megatron-LM paper)

> **[Watch Video](https://learn.kodekloud.com/user/courses/llm-d-a-deep-dive/module/5ec7ad88-5c69-4985-a776-3f7bca88fbf3/lesson/bedebd12-bc87-4cd7-830f-d265483d48cb)**


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.