GPU
The network is part of the computer
RDMA, RoCEv2 and GPUDirect between two GPUs
The public story of AI infrastructure is told through accelerators. It is accurate and incomplete. The moment a job spans more than one server, the network starts deciding how much of that accelerator capacity turns into work. GPUs in a training job exchange gradients, activations and parameters in synchronized phases, and a slow participant delays the whole group. This lesson follows one such exchange from the memory of GPU 0 in one server to the memory of GPU 1 in another. First the ordinary way, through both hosts. Then the way AI clusters do it, where the network card reaches into GPU memory and the hosts stand aside.
- The Job
- move a 64 MiB tensor from GPU 0 to GPU 1
- Ordinary path
- GPU, host memory, kernel, wire, kernel, host memory, GPU
- RDMA WITH GPUDirect
- GPU, network card, wire, network card, GPU
- Why it matters
- every GPU in the job waits for the slowest link
Read the whole lesson as text
1. Everyone waits for everyone
Two GPUs in two servers train one model. Each has worked through its share of the data and now holds numbers the other needs before either can take the next step. Frameworks don't ask the network to move arbitrary buffers for this. They use collective operations. AllReduce, heavily used in training, combines values from every GPU and gives the result back to all of them. NVIDIA's library for this, NCCL, discovers how the GPUs are connected and turns the collective into a concrete schedule of transfers. Until those transfers finish, the GPUs do nothing.
- GPU 0 finishes its part of the step and holds a tensor that GPU 1 must have before training can go on.
2. The ordinary way: sockets
A socket connection is built for generality. The tensor starts in GPU memory, so first it is copied into host memory. The application hands it to the operating system. The kernel copies it into socket buffers, runs the transport protocol and feeds the network card. On the other side the card interrupts the CPU, the kernel copies the data up to the application, and the application copies it into its GPU. Modern kernels do all this well. The CPU still takes part in every flow, and each host's memory carries every byte twice.
- The tensor is first copied out of GPU memory into the host's memory.
- The kernel copies it into socket buffers, splits it into packets and hands them to the network card.
- On the far side the card interrupts the CPU and the kernel copies the data up to the application.
- Only now is the tensor copied into GPU 1's memory, where it was needed all along.
3. Register memory, build queues
RDMA changes the steady state. Before any transfer the application registers the memory it will use. Ordinary memory moves around and gets paged out, and a device that reads it directly needs addresses that stay put, so registration pins the pages and gives the card the translation it needs. It also produces keys, and a remote side may only touch the memory it holds the right key for. Then the application creates a queue pair, which carries work requests, and a completion queue, which reports finished work. People describe the result as kernel bypass, zero copy and CPU offload. Each phrase needs care. The kernel still allocates, pins and enforces permissions. It just isn't in the path of every packet.
- Once, at the start, the host registers the GPU's buffer with the network card and sets up the queues.
4. Post the work
To send, the application writes a work request into the send queue: write this registered memory to that remote address, using that remote key. Then it tells the card there is work, and goes back to what it was doing. The card consumes the request, does the transfer and later writes a completion entry. The application and the device coordinate through shared structures. The CPU does not treat every packet as a software event of its own. If you have seen how a CPU asks a GPU for a copy, this is the same pattern with a transport engine where the GPU has a copy engine.
- The application queues one work request to the card and rings its doorbell.
5. Straight out of GPU memory
Plain RDMA removes most of the host's network stack from the path. Accelerator work adds one more boundary, because the data starts in GPU memory. Without a direct path it would still be staged through host memory first. GPUDirect RDMA lets the network card reach GPU memory over PCIe as a peer. The card reads the tensor straight from GPU 0's memory and puts it on the wire. The host set the transfer up and controls it. It no longer carries the payload, so its memory bandwidth and its CPU are left alone.
- The network card reads the tensor directly from GPU 0's memory over PCIe, with no stop in host memory.
6. On the wire: RoCEv2
RDMA needs a transport under it. InfiniBand is a fabric built for the purpose. RoCEv2 carries the same InfiniBand transport over ordinary routed Ethernet: an IP packet, a UDP header with destination port 4791, and then the transport header that names the destination queue pair and the packet's sequence number. Because it is IP, operators can build the leaf and spine fabrics they already know and spread traffic over equal paths. The first packet of a write also says where the data should go on the far side and which key allows it.
- The card sends the first packet of the write. It carries the remote address and key along with the first slice of data.
- The switch forwards it by its IP header, in the traffic class set aside for RDMA.
7. Placed, acknowledged, completed
The receiving card checks the key against the memory it was registered for and writes each packet's data straight into GPU 1's memory at the address the header named. No receive call ran on host B. The card acknowledges what it has received, and when the last packet is acknowledged the sending card writes one entry into the completion queue. The application on host A polls that queue in its own memory and learns the transfer is done.
- The receiving card writes the data straight into GPU 1's memory, where the header said it belongs.
- The receiving card acknowledges the last packet.
- The sending card writes a completion entry, and the application finds it by polling its own memory.
8. When everyone sends at once
AI collectives make brutal traffic. Many endpoints start sending at nearly the same instant and many flows aim at the same switch port. Its queue fills. If the switch drops packets, tail latency spikes. If the network overreacts, links sit idle. So the switch marks packets instead: when a queue grows past a configured threshold it starts setting the two-bit ECN field in the IP header to 11, congestion experienced, on more packets the deeper the queue gets. Nothing is dropped. The receiver sees the mark and sends a congestion notification back, and the sender cuts its rate. A widely used control loop for this on RoCEv2 fabrics is called DCQCN. There is also a blunter tool, priority flow control, which pauses one traffic class hop by hop. It prevents loss and, scoped badly, pushes congestion backwards through the fabric.
- The switch's queue passes its threshold, so it marks a packet on its way through and still delivers it.
- The receiving card tells the sender that its packets are meeting a full queue.
- The sending card cuts this flow's rate, then raises it again step by step while no more notifications arrive.
9. Locality, from process to port
Network diagrams start at the server's edge. The real path starts inside the box. A GPU may share a PCIe switch with the network card, one hop away with full peer bandwidth. Or it may sit under one CPU socket while the card sits under the other, so every transfer crosses between sockets. These are not the same, and nothing fails when you get the slow one. A network problem can then look exactly like a training problem: collective phases get longer, GPUs wait at their synchronization points, utilization drops, and every individual program is fast. So measure in layers: PCIe peer access, host to device bandwidth, RDMA bandwidth, GPUDirect bandwidth, the collective, the application.
- How GPU and network card are wired inside the server decides how fast the direct path really is.
Summary
Distributed AI is a communication system as much as a compute system. The ordinary socket path sends every byte through both hosts, with four copies and CPU work per packet. RDMA has the application register memory and post work to queues, and the network card does the transport in hardware. GPUDirect RDMA lets that card read and write GPU memory directly, so the path matches where the valuable state lives. RoCEv2 carries it over routed Ethernet in UDP port 4791. From there on the fabric's behavior under bursts is compute performance: marks, notifications and rate cuts decide how much of a link is usable, and the wiring inside each server decides how fast the first and last hop are. The layers can be designed apart. They can't be measured apart.
Next lesson: Keeping GPUs busy and healthy