RDMA Concepts
Queue pairs, memory registration, InfiniBand vs RoCE v2 β understanding RDMA networking without writing verbs code.
RDMA (Remote Direct Memory Access) is the networking technology behind GPU cluster communication. You donβt need to program RDMA directly β NCCL handles it. But understanding the concepts helps you debug network issues and make informed hardware decisions.
1. What RDMA Does Differently
Traditional networking (TCP/IP):
App β Kernel β Socket buffer β TCP stack β NIC β Network
RDMA:
App β NIC β Network (bypass kernel entirely)
Three key properties:
- Zero-copy: Data moves directly between app memory and NIC β no kernel buffers
- Kernel bypass: No system calls for data transfer β userspace talks to NIC directly
- CPU offload: The NIC handles the protocol β CPU is free for other work
2. RDMA Programming Model
Queue Pairs (QP)
Communication happens through queue pairs β a send queue + receive queue:
Node A Node B
βββββββββββ βββββββββββ
β Send Q β ββββ RDMA send βββββ β Recv Q β
β Recv Q β βββ RDMA send ββββββ β Send Q β
βββββββββββ βββββββββββ
The application posts work requests to the send queue. The NIC processes them asynchronously. Completions appear in a completion queue (CQ).
Memory Registration
Before RDMA can access memory, it must be registered with the NIC:
// Conceptual (not actual API β NCCL handles this)
struct ibv_mr *mr = ibv_reg_mr(pd, buffer, size, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);
Registration pins the memory (prevents OS from swapping it) and gives the NIC a translation table for virtual β physical addresses. This is why RDMA requires pinned memory.
RDMA Operations
| Operation | Description | Used by |
|---|---|---|
| Send/Recv | Traditional message passing | Control messages |
| RDMA Write | Write to remote memory without remote CPU involvement | NCCL data transfer |
| RDMA Read | Read from remote memory without remote CPU involvement | Less common |
| Atomic | Remote atomic operations (CAS, Add) | Synchronization |
NCCL primarily uses RDMA Write β the sender writes data directly into the receiverβs GPU memory. The receiverβs CPU never knows it happened until it checks a completion flag.
3. InfiniBand vs RoCE v2
Two RDMA transports, each with tradeoffs:
| InfiniBand | RoCE v2 (RDMA over Converged Ethernet) | |
|---|---|---|
| Network | Dedicated InfiniBand fabric | Standard Ethernet switches |
| Bandwidth | NDR: 400 Gb/s, XDR: 800 Gb/s | 100-400 GbE |
| Latency | ~1 ΞΌs | ~2-5 ΞΌs |
| Congestion control | Credit-based (lossless) | ECN/DCQCN (lossy network + SW control) |
| Cost | Higher (dedicated switches) | Lower (reuse existing Ethernet) |
| Reliability | Excellent (hardware flow control) | Good (requires careful tuning) |
| Used by | Top AI clusters (Meta, NVIDIA DGX) | Cloud providers (Azure, some AWS) |
When to Use Which
- InfiniBand: Dedicated AI training clusters where performance is critical. The standard for top-tier training (Metaβs 24K GPU cluster, NVIDIA DGX SuperPOD).
- RoCE v2: Cloud environments where Ethernet infrastructure exists. Azure uses RoCE for its AI clusters. Requires Priority Flow Control (PFC) and DCQCN tuning.
The Practical Difference
For NCCL AllReduce of 1 GB across 2 nodes:
| InfiniBand NDR | RoCE v2 (100 GbE) | |
|---|---|---|
| Bandwidth | 50 GB/s | 12.5 GB/s |
| Time | 20 ms | 80 ms |
| Latency overhead | ~2 ΞΌs | ~5 ΞΌs |
InfiniBand is 4Γ faster for this example β and the gap widens with more nodes (InfiniBandβs credit-based flow control handles congestion better at scale).
Congestion Control
The biggest practical difference between IB and RoCE:
InfiniBand: Uses credit-based flow control β the receiver tells the sender how much buffer space is available. No packet loss, no congestion collapse. βLosslessβ by design.
RoCE v2: Runs on standard Ethernet which can drop packets. Requires:
- PFC (Priority Flow Control): Ethernet-level pause frames to prevent buffer overflow
- DCQCN (Data Center QCN): End-to-end congestion control that reduces send rate when ECN marks are detected
Why this matters: RoCE without proper PFC/DCQCN tuning can suffer from PFC storms β cascading pauses that stall the entire network. This is why RoCE deployments require careful switch configuration, while InfiniBand βjust works.β
4. NCCL Network Configuration
Selecting Network Interface
# Use InfiniBand
export NCCL_IB_DISABLE=0 # enable IB (default)
export NCCL_IB_HCA=mlx5_0,mlx5_1 # specific IB devices
# Use TCP/Ethernet (fallback, slow)
export NCCL_IB_DISABLE=1
export NCCL_SOCKET_IFNAME=eth0
# Multiple NICs (multi-rail)
export NCCL_IB_HCA=mlx5_0,mlx5_1,mlx5_2,mlx5_3 # 4 NICs
Multi-Rail: Using All NICs
DGX H100 has 8 ConnectX-7 NICs (one per GPU pair). NCCL uses all 8 simultaneously:
GPU 0,1 β NIC 0 (400 Gb/s)
GPU 2,3 β NIC 1 (400 Gb/s)
GPU 4,5 β NIC 2 (400 Gb/s)
GPU 6,7 β NIC 3 (400 Gb/s)
...
Total: 8 Γ 50 GB/s = 400 GB/s aggregate inter-node bandwidth
This rail-optimized topology ensures each GPU has dedicated NIC bandwidth.
5. Verifying RDMA Setup
# Check IB devices
ibv_devinfo
# Test RDMA bandwidth
ib_write_bw --size=1048576 # on server
ib_write_bw --size=1048576 <server_ip> # on client
# NCCL performance test
cd /path/to/nccl-tests
./build/all_reduce_perf -b 1M -e 1G -f 2 -g 8
# Shows bandwidth for AllReduce at various message sizes
Self-Check
- Explain the 3 key RDMA properties (zero-copy, kernel bypass, CPU offload)
- Explain queue pairs and why memory registration (pinning) is required
- Explain the difference between InfiniBand and RoCE v2
- Configure NCCL to use specific InfiniBand devices
- Run nccl-tests to measure AllReduce bandwidth