AI Network Bottlenecks: Find & Fix Them
In this article
This guide walks you through the systematic process of identifying and reducing network bottlenecks that slow down AI training and inference in a data center. By the end, you'll have a clear methodology for diagnosing where packets are getting stuck and concrete techniques for relieving the pressure points, whether they're in the NIC, the switch fabric, or the application layer.
What You'll Need
- Access to the AI cluster's network monitoring tools (e.g., SNMP, sFlow, netflow, or vendor-specific dashboards).
- SSH access to at least one compute node and the ability to run command-line tools like
iperf3,ss, andethtool. - Knowledge of the AI workload's communication pattern (e.g., all-reduce, all-to-all, parameter server) and its expected data sizes.
- Baseline performance numbers from when the workload ran well (if available).
Step-by-Step
- Define the expected communication pattern. Identify how your AI workload exchanges data. For distributed training, this is usually collective operations like all-reduce (each GPU needs a sum of all gradients) or all-to-all (each node sends unique data to every other node). Inference often uses a client-server request/response pattern. Write down the expected message sizes and frequency. This gives you a target for what the network should be handling.
- Measure achieved throughput per node. Run a simple point-to-point test between two nodes using
iperf3to establish the maximum achievable bandwidth on the physical link. For example, on node A runiperf3 -sand on node B runiperf3 -c <nodeA_IP>. Compare this to the theoretical line rate (e.g., 100 Gbps for a 100GbE link). If you get significantly less (say, 70 Gbps), you have a physical or driver-level bottleneck. - Check NIC and driver health. On each compute node, run
ethtool -S <interface>(e.g.,eth0) to look for error counters likerx_errors,tx_errors,rx_dropped, ortx_dropped. High drop counts often indicate ring buffer overruns or a saturated PCIe bus. Also verify the link speed and duplex withethtool <interface>; it should be auto-negotiated to the maximum (e.g., 100000Mb/s). - Monitor switch port statistics. Log into your top-of-rack (ToR) switch and examine the counters for the ports connected to your compute nodes. Look for CRC errors, runts, giants, or excessive collisions—these point to cabling issues or faulty optics. Also check for output discards on the switch ports that connect to the spine or aggregation layer; discards here mean the switch's buffer is full, indicating congestion.
- Identify congestion points with flow analysis. Use sFlow or netflow data to see which flows are consuming the most bandwidth. Look for flows that are 'elephant flows' (large, long-lived transfers) that might be filling up a specific link. In an AI cluster, this is often the all-reduce traffic. If you see one link at 100% while others are idle, you have an imbalance.
- Test the collective operations. Run a real collective operation benchmark, like
nccl-tests(for NVIDIA GPUs) or a similar tool for your hardware. Runall_reduce_perfwith a message size that matches your workload's gradient size (e.g., 256 MB). Compare the achieved bus bandwidth to the theoretical peak. If it's much lower, the bottleneck is likely in the collective algorithm or the network topology (e.g., a non-blocking fat-tree vs. a oversubscribed tree). - Check for CPU/GPU starvation. Sometimes the bottleneck isn't the network but the host. During a training run, watch CPU utilization with
toporhtop. If a single core is pegged at 100% while the network is idle, your data loading or gradient reduction is CPU-bound. Similarly, if the GPU is waiting for data (low GPU utilization), the network might be too slow, but it could also be a storage bottleneck. - Inspect TCP/UDP settings. For TCP-based workloads, check the socket buffer sizes and congestion control algorithm. On Linux, run
sysctl net.ipv4.tcp_rmemandnet.ipv4.tcp_wmem. Default buffers (e.g., 128KB) are far too small for high-bandwidth, high-latency links. Increase them to at least 1MB. For RDMA (InfiniBand or RoCE), verify that flow control is enabled (e.g.,pauseframes on RoCE) and that the congestion control is set to a high-performance mode like DCQCN. - Examine the topology for oversubscription. Look at your network diagram. If you have 40Gbps of compute nodes connected to a ToR switch that only has 20Gbps of uplinks to the spine, you have 2:1 oversubscription. This will cause congestion when multiple nodes communicate across racks. If possible, reduce oversubscription by adding more uplinks or using a flatter topology.
- Implement flow control and QoS. For storage and management traffic, lower priority can be set. For AI training traffic, assign a higher priority class and enable priority-based flow control (PFC) if using RoCE. On the switches, configure QoS queues to ensure that AI traffic gets preferential treatment over bulk file transfers.
- Optimize the collective algorithm. If you're using NVIDIA GPUs, NCCL has a ring algorithm by default. For large clusters, try the tree algorithm (set
NCCL_ALGO=Tree) which often scales better. Also experiment withNCCL_IB_DISABLE=0to ensure InfiniBand is used, andNCCL_BUFFSIZEto adjust the message chunk size. - Re-test and iterate. After each change, re-run the iperf test and the collective benchmark to see if throughput improved. Keep a log of changes and results. Bottleneck identification is an iterative process; you'll often find that fixing one bottleneck reveals another.
Common Mistakes
- Only looking at average utilization. Average link utilization over a minute can hide bursty traffic that causes micro-bursts and packet drops. Look at peak utilization in 1-second or 100ms intervals.
- Ignoring the PCIe bus. A GPU can't send data to the NIC if the PCIe link is only running at x8 instead of x16. Check with
lspci -vvto verify link width and speed. - Assuming TCP is the problem. For AI workloads, TCP can be a bottleneck due to its congestion control. If you're using TCP, consider using RDMA or at least tune the buffers. But don't immediately blame TCP; measure first.
- Forgetting about the storage network. If your AI workload reads data from a network filesystem (e.g., NFS), the storage network can be the bottleneck, not the compute network. Monitor both separately.
- Not checking for packet drops at the end host. The switch might be fine, but the NIC's ring buffer might be too small. Always check
ethtool -Son the host.
Tips
- Use the right tools. For a quick test,
iperf3is great. For collective ops, usenccl-tests. For deep packet inspection, use Wireshark on a mirror port. - Baseline early. Run benchmarks before you scale up your workload. It's much easier to identify a bottleneck when you know the expected numbers.
- Monitor everything. Use a time-series database like Prometheus with Grafana to visualize network counters over time. This helps correlate network issues with training steps.
- Consider the message size. Small messages (e.g., 1KB) are latency-bound, while large messages (e.g., 1GB) are bandwidth-bound. Tune your collective algorithms accordingly.
- Use a dedicated network for AI. If possible, separate AI training traffic from storage and management traffic using VLANs or physical separation. This prevents interference.
Troubleshooting
- No improvement after tuning. If you've increased buffers and changed algorithms but see no change, revert one change at a time. Perhaps the bottleneck is not in the network but in the GPU's ability to generate data. Run a GPU benchmark (e.g.,
gpu-burn) to check. - Link is up but no traffic. Check the IP configuration and routing. Try pinging the other node. Also check the firewall; it might be blocking the ports used by iperf or NCCL.
- High packet loss on the switch. If you see output discards on a switch port, you have congestion. Reduce the number of nodes sending to that port, or increase the buffer size if the switch allows it. Also check for a faulty cable—replace it and see if the errors go away.
- RDMA is not working. If you're using RoCE, ensure that PFC is enabled on all switches in the path. Also check that the NIC's firmware is up to date. Use
ibv_devinfoto verify the device state. - Performance drops when scaling. This often indicates a topology problem like oversubscription. If you have a tree topology, try to place communicating nodes in the same rack. If using a fat-tree, ensure the routing is optimal.
Frequently Asked Questions
What is the most common bottleneck in AI data center networks?
For distributed training, the most common is oversubscription in the network fabric—where the total bandwidth of the compute ports exceeds the uplink bandwidth. This causes congestion during collective operations like all-reduce.
How do I know if the bottleneck is the network or the GPU?
Run a GPU benchmark (like gpu-burn) to see the GPU's maximum compute performance. Then run a network benchmark (like nccl-tests) with a large message size. If the network test achieves near line rate, the network is fine; if not, it's the network. Also, monitor GPU utilization during training—if it's low while the network is saturated, the network is the bottleneck.
Should I use TCP or RDMA for AI workloads?
RDMA (InfiniBand or RoCE) is generally preferred for AI because it reduces CPU overhead and provides lower latency and higher throughput. However, it requires a lossless network (with PFC) to avoid performance collapse. If your network doesn't support RDMA, TCP with large buffers is a fallback.
How can I reduce the impact of all-reduce on the network?
Use a hierarchical all-reduce algorithm (like the tree algorithm in NCCL) that reduces traffic across racks. Also, consider using gradient compression techniques like quantization or sparsification to reduce message sizes.
What is PFC and why is it important?
Priority-based Flow Control (PFC) is a mechanism that prevents packet loss on RoCE networks by pausing traffic on a specific priority class when a switch buffer is full. Without it, packet drops cause severe performance degradation in RDMA.
Can I use the same network for training and storage?
Technically yes, but it's not recommended. Storage traffic (like reading training data) can create bursts that interfere with the latency-sensitive training traffic. Use separate VLANs or physical networks to isolate them.