RDMA and AI High-Speed Networking¶
In single-node training, GPUs primarily communicate via PCIe, NVLink, or NVSwitch; once scaled to multiple nodes, the network can determine the upper bound of the entire workload. The value of RDMA is enabling data to travel between nodes with less CPU involvement, fewer memory copies, and lower software stack overhead.
This page progresses from network fundamentals to Kubernetes deployment. The focus is not on any specific vendor's commands, but on establishing a complete communication path that can be verified and troubleshot.
1. What RDMA Actually Is¶
RDMA stands for Remote Direct Memory Access. It allows one machine to directly access memory regions registered by another machine, with the data path bypassing the remote CPU and traditional kernel network protocol stack as much as possible.
The traditional Socket path can be simplified as:
English rendering — the original text is retained below.
The RDMA path is closer to:
English rendering — the original text is retained below.
It delivers three main categories of benefits:
- Kernel Bypass: Reduces kernel protocol stack involvement in the data plane;
- Zero/Low Copy: Reduces copies between user-space and kernel buffers;
- CPU Offload: RDMA-capable NICs (RNIC/HCA) handle transport, freeing CPU for data preprocessing or training coordination.
RDMA does not mean "no CPU at all" or "the network never drops packets." Connection establishment, memory registration, control paths, congestion control, and error recovery still require software involvement.
2. InfiniBand, RoCE, and iWARP¶
| Technology | Underlying Network | Routability | Common Location | Key Characteristics |
|---|---|---|---|---|
| InfiniBand | Native IB Fabric | Managed by IB Subnet Manager | HPC, dedicated AI training networks | Unified protocol stack and switching fabric, low latency, high bandwidth, independent operations system |
| RoCE v1 | Ethernet Layer 2 | Does not route across Layer 3 | Small same-Layer-2 networks | Based on Ethernet, deployment scope limited to Layer 2 |
| RoCE v2 | UDP/IP | Routable at Layer 3 | The most common Ethernet RDMA in data center AI clusters | Reuses Ethernet, but QoS, congestion, and lossless/semi-lossless policies must be carefully designed |
| iWARP | TCP/IP | Routable | Some storage and legacy RDMA scenarios | Leverages TCP reliability, relatively uncommon in AI GPU clusters |
InfiniBand¶
InfiniBand uses dedicated HCAs, switches, and a Subnet Manager. Its service levels, routing, partitioning, and congestion management differ from ordinary Ethernet. The advantage is that the entire fabric is designed around high-performance communication; the cost is the need for a separate networking skill set and equipment ecosystem.
RoCE¶
RoCE carries RDMA over Ethernet. RoCE v2 uses UDP/IP, making it better suited for large routable data center networks. It is not "naturally faster just by installing an RDMA-capable NIC": endpoints, switches, queues, MTU, PFC, ECN, DSCP/PCP, and congestion control must all remain consistent.
3. Why AI Depends on RDMA¶
Data Parallelism: All-Reduce¶
Each worker computes a portion of the batch, then exchanges and aggregates gradients. The larger the model and the more GPUs, the more easily All-Reduce time can eat into the computational gains.
English rendering — the original text is retained below.
If gradient communication grows faster than the parallel compute gains after adding nodes, Scale-out Efficiency will decline.
Model Parallelism: All-Gather / Reduce-Scatter / All-to-All¶
- Tensor Parallel frequently synchronizes tensor shards;
- FSDP/ZeRO requires All-Gather and Reduce-Scatter;
- Mixture-of-Experts Token Dispatch often relies on All-to-All;
- Pipeline Parallel requires transferring Activations between stages.
These communication patterns are typically more sensitive than pure data parallelism, especially MoE All-to-All, which simultaneously stresses bandwidth, congestion, and tail latency.
Distributed Inference¶
- Multi-node Tensor/Pipeline Parallel;
- KV Cache transfer between Prefill and Decode Pools;
- Distributed KV Cache, Remote Memory, and model weight loading;
- Cache or Adapter coordination across replicas.
RDMA is therefore no longer exclusive to training clusters; it is increasingly entering large-scale LLM inference platforms.
4. What GPUDirect RDMA Solves¶
Without GPUDirect RDMA, GPU network data typically must pass through Host Memory:
GPUDirect RDMA allows compatible NICs to DMA GPU Memory directly:
This reduces Host Memory bounce and CPU overhead. Whether GPUDirect is actually exercised depends on:
- GPU, NIC, Driver, CUDA, rdma-core, and Kernel support;
- PCIe/NUMA topology between GPU and NIC;
- Kernel mechanisms such as DMA-BUF or
nvidia-peermem; - IOMMU, ACS, and virtualization configuration;
- Whether NCCL/UCX selected the correct Transport.
"A Pod can see both the GPU and /dev/infiniband" is only a necessary condition; it does not mean GPUDirect is in effect. It must be confirmed through topology, logs, and performance A/B testing.
Reference: GPU Operator GPUDirect RDMA
5. A Complete Data Path in Kubernetes¶
English rendering — the original text is retained below.
Common component responsibilities are as follows:
| Component | Responsibility |
|---|---|
| Default CNI (Cilium/Calico/Flannel, etc.) | Pod general networking, Service, NetworkPolicy, and control traffic |
| Multus | Invokes multiple CNIs for a Pod, attaching a second or additional NICs |
| NetworkAttachmentDefinition | Declares attached networks and IPAM configuration |
| SR-IOV Network Device Plugin | Discovers PF/VF/SF and publishes them as extended resources to kubelet |
| SR-IOV CNI / Host-Device CNI | Places the allocated NIC/VF into the Pod Network Namespace |
| RDMA CNI / RDMA Device Plugin | Configures RDMA Namespace or exposes shared HCA resources |
| NVIDIA Network Operator | Manages Network Driver, Device Plugin, CNI, IPAM, and RDMA/GPUDirect-related components |
| GPU Operator | Manages GPU Driver, Toolkit, Device Plugin, and GPUDirect GPU-side capabilities |
References: Multus CNI, SR-IOV Network Device Plugin, NVIDIA Network Operator
6. Why a Second Pod NIC Is Often Used¶
The default CNI primarily optimizes general Kubernetes connectivity, Services, and security policies; the training data plane may require:
- Avoiding Overlay encapsulation;
- Using SR-IOV VFs or Host NICs directly;
- Independent MTU, VLAN, PKey, routing, and QoS;
- Isolation from management/storage/public traffic;
- Keeping RDMA NetDevice, GID, and Network Namespace consistent.
Multus is a Meta CNI: it retains eth0 as the default network, then invokes SR-IOV, Macvlan, IPVLAN, and other plugins to add net1. Applications must explicitly select the high-speed interface; if NCCL automatically picks an unreachable management interface, it may stall during initialization.
7. Three Pod Access Methods¶
1. Host Network¶
The advantage is simplicity and a short performance path, suitable for controlled dedicated clusters or rapid validation. The disadvantages are port conflicts, weak tenant isolation, and limited NetworkPolicy capabilities; not recommended as a general multi-tenant solution.
2. Shared HCA¶
Multiple Pods share the same physical HCA, each obtaining RDMA access resources. Resource utilization is high, suitable for training within a trusted domain; isolation, QoS, and failure blast radius require careful validation.
3. SR-IOV VF¶
Allocates an independent Virtual Function to each Pod, with clearer device and queue isolation, suitable for multi-tenant and high-performance scenarios. The cost is greater complexity in VF count, IPAM, switch policy, scheduling resources, and node lifecycle.
| Requirement | Preferred Method |
|---|---|
| Fast single-tenant validation | Host Network or Shared HCA |
| Multi-tenant, metered resources | SR-IOV VF |
| Pod count far exceeds VF count | Shared HCA, with quotas and security boundaries |
| Strict network isolation and fixed performance | SR-IOV VF / dedicated node pool |
8. A Conceptual Pod Example¶
The following example expresses the combination of "default network + Multus high-speed network + GPU + RDMA resources." Resource names and NetworkAttachmentDefinition must be adjusted according to the actual Operator/Device Plugin configuration.
apiVersion: v1
kind: Pod
metadata:
name: nccl-worker
annotations:
k8s.v1.cni.cncf.io/networks: ai-system/roce-net
spec:
containers:
- name: worker
image: registry.example.com/nccl-tests@sha256:...
resources:
limits:
nvidia.com/gpu: 8
rdma/rdma_shared_device_a: 1
env:
- name: NCCL_SOCKET_IFNAME
value: net1
Do not copy directly into production. Different RDMA Plugins may use different resource names; SR-IOV scenarios typically also request the corresponding VF Resource.
9. Why RoCE Networks Are Difficult¶
Ethernet allows congestion and packet loss, while RDMA is sensitive to packet loss, reordering, and tail latency. RoCE Fabrics typically combine the following mechanisms:
PFC: Priority Flow Control¶
PFC can pause only a specific priority's traffic, building an approximately lossless queue. It reduces packet loss, but misconfiguration can cause Pause Storms, Head-of-Line Blocking, and even spread congestion to a wider area.
ECN: Explicit Congestion Notification¶
Switches mark packets when queues begin to congest, and endpoints reduce send rates based on CNP/congestion feedback. ECN thresholds, switch buffers, and endpoint algorithms must be tuned together.
QoS and Priority¶
RoCE Traffic Class, DSCP/PCP, switch Priority, PFC Queue, and CNP Queue must be consistent end to end. If an intermediate hop rewrites or drops priority, the network may behave normally under light load and suddenly collapse under heavy load.
MTU¶
Training networks often use Jumbo Frames, but all endpoints, VFs, PFs, and switching paths must be consistent. MTU mismatch may manifest as small packets working fine, large messages timing out, or abnormal throughput.
Reference: NVIDIA RoCE Configuration
10. Topology Awareness Matters More Than NIC Speed¶
Even with the same 400 Gb/s NIC, actual performance also depends on the path from GPU to NIC:
English rendering — the original text is retained below.
The platform needs to record and leverage:
- GPU/NIC/NUMA relationships of
nvidia-smi topo -m; - HCA name, port, Link Layer, and Rail;
- Node's Rack, Block, and Leaf Switch location;
- Whether each Pod Group requires single Rail, dual Rail, or cross-Rail;
- CPU Pinning, HugePages, and IRQ affinity.
Kueue Topology-Aware Scheduling or a dedicated scheduler can control workers to stay within the same Rack/Block as much as possible; in-node GPU/NIC affinity also requires coordination between Runtime, NCCL, and device allocation policies.
11. How NCCL Selects the Network¶
NCCL probes Socket, InfiniBand/RoCE, and topology, then selects Collective algorithms and Transports. Common environment variables are suitable for diagnostics and explicit interface selection, but a large set of "tuning parameters" should not be permanently copied without benchmarking.
Common diagnostic variables:
A/B test to determine whether the issue is on the RDMA path:
If the workload becomes slower but stable after disabling RDMA, the problem is likely in the HCA, GID, RoCE Fabric, GPUDirect, or RDMA Namespace; if it still fails, continue checking application startup, DNS, ports, and general networking.
12. Layer-by-Layer Benchmarking¶
Do not test the network directly with a full training workload. It is recommended to build a test ladder from the bottom up:
Layer 1: Physical and Driver¶
lspci | grep -Ei 'Mellanox|NVIDIA|Ethernet|InfiniBand'
rdma link
ibstat
ibdev2netdev
ethtool <interface>
Confirm Link is Active, rate and width match expectations, Link Layer is correct, and there is no unexpected speed downgrade.
Layer 2: IP and MTU¶
Confirm attached network addresses, routes, and large packets are consistent across all nodes.
Layer 3: RDMA Perftest¶
# 服务端
ib_write_bw -d <device>
# 客户端
ib_write_bw -d <device> <server-address>
# 延迟
ib_write_lat -d <device> <server-address>
Test different message sizes, bidirectional traffic, concurrent connections, and cross-rack combinations. Normal bandwidth does not mean normal tail latency.
Layer 4: NCCL Tests¶
Run all_reduce_perf, all_gather_perf, and alltoall_perf, covering respectively:
- Single-node multi-GPU;
- Two nodes;
- Multiple nodes in the same rack;
- Cross-rack;
- Single Rail and multi-Rail;
- GPUDirect on/off A/B.
Layer 5: Real Frameworks¶
Finally, run PyTorch FSDP, DeepSpeed, Megatron, JAX, or inference KV Transfer benchmarks. If performance is abnormal at this point, compare against the results from the first four layers rather than blindly modifying NCCL parameters.
Reference: NCCL Networking Troubleshooting
13. Common Failure Modes¶
| Symptom | Common Cause | Priority Checks |
|---|---|---|
| NCCL initialization hangs | Wrong interface selected, port unreachable, Rank address error | NCCL_DEBUG, interface connectivity, DNS, Firewall |
| Small traffic works, large messages time out | MTU, PFC/ECN, Buffer, packet loss | Jumbo Frame, switch counters, RDMA Counter |
| Only cross-rack is slow | Oversubscription, ECMP, congestion, topology placement | Fabric Telemetry, Kueue TAS, path consistency |
| RDMA and TCP performance are similar | Not using IB Transport or GPUDirect | NCCL Log, NCCL_IB_DISABLE A/B, GPU/NIC topology |
| Individual nodes consistently slow | Link downshift, PCIe Width, NUMA, bad cable | mlxlink, ethtool, nvidia-smi topo -m |
| Pod has RDMA Device but cannot communicate | Corresponding NetDevice/GID not in Pod Namespace | Multus/RDMA CNI, ip addr, GID Table |
| Whole network stalls under high load | PFC Pause Storm or incorrect congestion configuration | PFC, ECN/CNP, Buffer and Queue Counter |
| Device unavailable after Pod recreation | CNI cleanup, VF Reset, Device Plugin registration anomaly | kubelet, CNI, Device Plugin logs and resource health |
In rdma statistic, continuously growing rnr_nak_retry_err, packet_seq_err, implied_nak_seq_err, or local_ack_timeout_err often indicate packet loss, retries, or timeouts, and should be observed together with switch and HCA counters.
14. Observability¶
Node/HCA¶
- Port State, Link Rate, Link Width;
- Symbol/CRC Error, Packet Discard;
- RDMA Retry, RNR, Timeout;
- PCIe Replay, ACS, NUMA and IRQ;
- PFC Pause Duration, ECN Mark, CNP.
Kubernetes¶
- SR-IOV/RDMA Resource allocatable and allocated;
- Device Plugin, CNI, Network Operator DaemonSet health;
- Pod additional network creation time and failures;
- VF/HCA reclamation after node drain;
- Pending reasons for Topology-Aware Scheduling.
Application¶
- NCCL Collective time and Algorithm/BUS Bandwidth;
- Communication ratio in Training Step;
- All-to-All P95/P99;
- Inference KV Cache Transfer throughput and latency.
Network metrics must be correlatable to Node, NIC, Port, Pod, Job, and Rank. Keeping only switch-level aggregate bandwidth makes it difficult to locate the slow node of a training job.
15. Security Boundary¶
High-performance additional networks may bypass the default CNI's NetworkPolicy. SR-IOV VF, Host Device, and RDMA access mean workloads are closer to hardware, so additional controls are required:
- Use dedicated Namespace, ServiceAccount, node pool, and RuntimeClass;
- Only allow trusted images to request RDMA/SR-IOV resources;
- Use VLAN, PKey, VRF, switch ACL, or physical Fabric for data-plane isolation;
- Prohibit ordinary users from modifying NetworkAttachmentDefinition;
- Restrict privileged, Host Network, HostPath, and device passthrough;
- Audit the allocation relationship among VF, HCA, GPU, and tenants;
- Verify container escape, DMA/IOMMU, and firmware security policies.
Do not assume the default Kubernetes NetworkPolicy automatically covers all Multus additional interfaces; whether it takes effect depends on the corresponding CNI and data path.
16. Go-Live Checklist¶
- The reason for choosing InfiniBand or RoCE and the operational responsibility are clear.
- GPU, NIC, PCIe, NUMA, Rack, and Rail topology have asset records.
- Default network and training data network are isolated from each other, with clear routing boundaries.
- Multus, SR-IOV/RDMA Plugin, and Operator versions are pinned and compatible.
- RoCE MTU, PFC, ECN, QoS, and Buffer are consistent end-to-end.
- Confirmed that NCCL actually uses the expected HCA, interface, and GPUDirect path.
-
ib_write_bw/latand NCCL Tests have single-node, same-rack, and cross-rack baselines. - Network and training metrics can be correlated to Job, Pod, Rank, NIC, and switch ports.
- Node drain, VF reclamation, Operator upgrade, and HCA failure have been rehearsed.
- Additional network security and tenant isolation do not rely on default NetworkPolicy assumptions.