GPU Cluster: RoCE Architecture
Lessons (6, study in order)
GPU Cluster: RoCE
Beginner · about 6 min
Goal: What the cluster network is made of
RoCE builds the GPU compute fabric from Ethernet switches
RoCE carries RDMA packets in UDP/IP and forwards them with Ethernet switches. The cluster has the same shape as with InfiniBand: leaf-spine, with uplinks as wide as downlinks. Rail wiring is common here too: the 8 ports of each server go to 8 different leaves, so losing a leaf costs each server only 1 port.
The switches and protocols differ: every link is a routed port, switches usually run BGP with each other, and ECMP spreads traffic over the uplinks.
Ethernet drops packets by default; RoCE needs lossless configuration
An Ethernet switch drops packets when a queue is full. RDMA resends a long run of packets after one loss, so throughput collapses. A RoCE network therefore configures two things:
· PFC: when a queue is nearly full, tell the upstream to pause, so nothing is dropped
· ECN: when a queue starts to grow, mark packets so the receiver tells the sender to slow down
InfiniBand needs neither: its link layer has built-in credit flow control, so the sender transmits only when the receiver has room and a queue never fills.
GPU traffic is a few very large flows, which ECMP spreads badly
ECMP hashes each flow's five-tuple and pins the flow to one uplink. An ordinary data center has thousands of small flows, so every link ends up with a similar share.
GPU training has only a few flows, each near the adapter's full rate. When several hash to the same link it congests while the link next to it sits idle.
Meta's published training network
Meta's training clusters use two independent networks: the frontend network for data ingestion, checkpoints and logging, and the backend network for RoCE training traffic only.
The backend unit is an AI Zone, a two-tier design: one RTSW (leaf) per rack connects the rack's GPUs over copper cables, and CTSW switches form the spine. An AI Zone is non-blocking inside. This is per-rack wiring, unlike rail wiring: when an RTSW fails, every GPU in its rack is cut off.
Several AI Zones are joined by ATSW switches. That layer is oversubscribed. When a job spans AI Zones, the scheduler places its nodes so that as little traffic as possible crosses zones.
InfiniBand versus RoCE architecture
· Switches; InfiniBand: Dedicated InfiniBand switches; RoCE: Ethernet switches
· Addresses; InfiniBand: LIDs, assigned by the subnet manager; RoCE: IP addresses
· Routing; InfiniBand: Computed centrally by the subnet manager; RoCE: A routing protocol on every switch, usually BGP
· How loss is avoided; InfiniBand: Link-layer credit flow control, built in; RoCE: PFC + ECN, must be configured
· Spreading over uplinks; InfiniBand: Forwarding tables from the subnet manager; RoCE: ECMP hashing
· Public example; InfiniBand: NVIDIA DGX SuperPOD; RoCE: Meta's training clusters
Problems Meta met and what they did (published)
· Topic: ECMP; Detail: Training traffic has few, large flows, so five-tuple hashing performs poorly
· Topic: Path pinning, tried first; Detail: Uneven when racks were partly allocated; training performance fell by more than 30% at worst
· Topic: What they moved to; Detail: Switches hash on the destination QP and the training library opens several QPs per GPU pair; up to 40% better AllReduce
· Topic: Congestion control; Detail: DCQCN is off on 400G and only PFC is used; the training library controls sending, and a sender waits for the receiver's permission
Sources
· Meta Engineering: RoCE networks for distributed AI training at scale (2024-08-05) https://engineering.fb.com/2024/08/05/data-center-engineering/roce-network-distributed-ai-training-at-scale/
· SIGCOMM 2024 paper: RDMA over Ethernet for Distributed AI Training at Meta Scale https://dl.acm.org/doi/10.1145/3651890.3672233
· SIGCOMM 2016 paper (Microsoft): RDMA over Commodity Ethernet at Scale https://conferences.sigcomm.org/sigcomm/2016/program.php
· NVIDIA Cumulus Linux documentation: RoCE https://docs.nvidia.com/networking-ethernet-software/cumulus-linux-510/Layer-1-and-Switch-Ports/Quality-of-Service/RDMA-over-Converged-Ethernet-RoCE/
· Cisco white paper: RoCE Storage Implementation over NX-OS VXLAN Fabrics https://www.cisco.com/c/en/us/td/docs/dcn/whitepapers/roce-storage-implementation-over-nxos-vxlan-fabrics.html
① ECMP spreads traffic over the uplinks
Beginner · about 5 min
Goal: How traffic is spread over the 4 uplinks
How traffic is spread over the 4 uplinks: 1 connection per GPU pair
4 flows hashed: some links crowded, some idle: Port 1 of each of the 4 servers sends 400G to port 5 of another server: 1600G in total. Every port 1 is on L1 and every port 5 on L5, and traffic between two rails crosses a spine. L1 has four 400G uplinks, also 1600G.
One connection per GPU pair makes 4 flows. L1 hashes each flow's five-tuple, and the hash picks the uplink. Result: SP1 2, SP2 1, SP3 0, SP4 1.
The link to SP1 is asked to carry 800G and has 400G, so it congests; the link to SP3 is idle. Total capacity is enough, yet only 1200G gets through.
· Throughput: 1200G / 1600G(75%)
· Busiest link: L1 to SP1: 800G / 400G
· Chance that 4 flows land exactly 1 per link: 9.4%
· Traffic inside one rail: Crosses one leaf and no spine, so it has no such problem
How traffic is spread over the 4 uplinks: 8 connections per GPU pair
32 small flows: much more even: Port 1 of each of the 4 servers sends 400G to port 5 of another server: 1600G in total. Every port 1 is on L1 and every port 5 on L5, and traffic between two rails crosses a spine. L1 has four 400G uplinks, also 1600G.
The training library opens 8 connections (QPs) per GPU pair, so one 400G flow becomes eight 50G flows. Each QP has a different UDP source port and therefore a different hash. The 32 small flows land as: SP1 8, SP2 8, SP3 6, SP4 10.
The busiest link, to SP4, carries 500G. 1500G gets through.
This is what Meta does: switches hash on the destination QP and the training library opens several QPs per GPU pair. Their published result is up to 40% better AllReduce performance.
· Throughput: 1500G / 1600G(94%)
· Busiest link: L1 to SP4: 500G / 400G
· Cost: More QPs per GPU pair; the spread is still probabilistic, not guaranteed even
How traffic is spread over the 4 uplinks: Per packet
Each packet picks its own path: all four links full: Port 1 of each of the 4 servers sends 400G to port 5 of another server: 1600G in total. Every port 1 is on L1 and every port 5 on L5, and traffic between two rails crosses a spine. L1 has four 400G uplinks, also 1600G.
The switch no longer pins a flow to one link; every packet picks the least-loaded uplink at that moment. All four links carry 400G, exactly full.
Packets of one flow take different paths and arrive out of order, so the receiving adapter must handle reordering. Newer AI Ethernet designs (NVIDIA Spectrum-X, Ultra Ethernet) support this.
· Throughput: 1600G / 1600G(100%)
· Cost: Needs support in both switches and adapters
BGP on a leaf (NVIDIA Cumulus Linux)
One eBGP session per uplink. All 4 spines advertise the same prefix, which gives the leaf 4 equal-cost paths.
nv set router bgp autonomous-system 65101 nv set router bgp router-id 10.0.0.11 nv set vrf default router bgp neighbor swp49 remote-as external nv set vrf default router bgp neighbor swp50 remote-as external nv set vrf default router bgp neighbor swp51 remote-as external nv set vrf default router bgp neighbor swp52 remote-as external nv set vrf default router bgp address-family ipv4-unicast redistribute connected nv config apply
See how many equal-cost paths lead to another rail
4 next hops are the 4 uplinks. Output is trimmed.
$ ip route show 10.2.1.0/24 10.2.1.0/24 proto bgp metric 20 nexthop via inet6 fe80::4638:39ff:fe00:1 dev swp49 weight 1 nexthop via inet6 fe80::4638:39ff:fe00:2 dev swp50 weight 1 nexthop via inet6 fe80::4638:39ff:fe00:3 dev swp51 weight 1 nexthop via inet6 fe80::4638:39ff:fe00:4 dev swp52 weight 1
Make the training library open more QPs per GPU pair
NCCL opens 1 QP per GPU pair by default. This environment variable makes it open 8, giving ECMP more flows to spread.
export NCCL_IB_QPS_PER_CONNECTION=8
② Staying lossless under congestion
Beginner · about 5 min
Goal: What is enabled on the switches
What is enabled on the switches: Nothing
1. 800G heads for a 400G port: Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. Port 1 is on L1 and port 5 on L5; the two flows go through SP1 and SP2 and meet at one egress port on L5, whose queue starts to grow.
A third flow goes from port 1 of S3 to port 5 of S1; its destination port is not congested.
2. The queue fills and packets are dropped: Once the queue is full, arriving packets are dropped. 800G comes in and only 400G can leave, so about half the packets are lost.
3. Retransmission collapses throughput: The RoCE receiver sees a gap in sequence numbers and asks the sender to resend from the lost packet; everything already sent after it is discarded. With constant loss and resending, far less than 400G of useful data arrives.
· Packet loss: Yes
· The two congested flows: Useful throughput far below 400G
· The third flow: Unaffected
What is enabled on the switches: PFC only
1. 800G heads for a 400G port: Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. Port 1 is on L1 and port 5 on L5; the two flows go through SP1 and SP2 and meet at one egress port on L5, whose queue starts to grow.
A third flow goes from port 1 of S3 to port 5 of S1; its destination port is not congested.
2. L5 pauses its upstream: The queue reaches its threshold. L5 sends PAUSE frames to the upstream switches feeding it (SP1, SP2), telling them to stop sending this priority. Nothing is dropped.
3. The pause spreads back hop by hop: With SP1 and SP2 paused, their own queues fill and they send PAUSE to L1; L1 then pauses port 1 of S1 and S2. The senders are held back and nothing is lost anywhere.
4. An unrelated flow is blocked too: Port 1 of S3 sends to port 5 of S1, which is not congested. But it shares a priority queue with the other two flows and uses the paused link from L1 to SP1, so it stops as well.
This is head-of-line blocking, the cost of relying on PFC alone.
· Packet loss: None
· The two congested flows: About 200G each
· The third flow: Slowed down
What is enabled on the switches: PFC + ECN
1. 800G heads for a 400G port: Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. Port 1 is on L1 and port 5 on L5; the two flows go through SP1 and SP2 and meet at one egress port on L5, whose queue starts to grow.
A third flow goes from port 1 of S3 to port 5 of S1; its destination port is not congested.
2. The queue grows and L5 marks packets with ECN: The queue passes the ECN threshold, which is lower than the PFC threshold. L5 sets a congestion mark on packets passing through and still delivers them to S4.
3. The receiver tells the senders to slow down: The adapter on S4 sees the mark and returns a CNP packet to the sender. S1 and S2 each slow down and settle at about 200G, which together match the 400G egress port.
4. The queue drains and PFC never fires: The queue falls back below the threshold without reaching the PFC level, so nothing upstream is paused. The flow from S3 is never affected.
This mark, CNP, slow-down loop is DCQCN. PFC stays enabled as the last line of defence.
· Packet loss: None
· The two congested flows: About 200G each
· The third flow: Unaffected (400G)
· What Meta does: On 400G they turned DCQCN off and use PFC only; the training library controls when to send, and a sender waits for the receiver's permission
Switch: enable lossless RoCE (NVIDIA Cumulus Linux)
One command does all of this: trust the DSCP in packets; put RoCE traffic (DSCP 26) in priority 3 and enable PFC on priority 3; put CNP (DSCP 48) in priority 6 with strict priority; enable ECN on the priority 3 queue.
nv set qos roce nv config apply
Verify
Check that the mode is lossless, PFC is on priority 3, and the ECN thresholds. Output is trimmed.
$ nv show qos roce enable on mode lossless congestion-control congestion-mode ECN enabled-tc 0,3 min-threshold 146.48 KB max-threshold 1.43 MB pfc pfc-priority 3 rx-enabled enabled tx-enabled enabled trust trust-mode pcp,dscp
Switch: the Cisco NX-OS equivalent
The same four things, written separately: classify by DSCP, enable PFC on priority 3, enable ECN on queue 3, turn PFC on at the port. The DSCP value is a network-wide agreement; 26 is used here.
class-map type qos match-any ROCEv2
match dscp 26
class-map type qos match-any CNP
match dscp 48
policy-map type qos QOS_MARKING
class ROCEv2
set qos-group 3
class CNP
set qos-group 7
policy-map type network-qos qos_network
class type network-qos c-8q-nq3
pause pfc-cos 3
mtu 9216
policy-map type queuing QOS_EGRESS_PORT
class type queuing c-out-8q-q3
bandwidth remaining percent 80
random-detect minimum-threshold 150 kbytes maximum-threshold 3000 kbytes drop-probability 7 weight 0 ecn
system qos
service-policy type queuing output QOS_EGRESS_PORT
service-policy type network-qos qos_network
interface Ethernet1/1
service-policy type qos input QOS_MARKING
priority-flow-control mode on
Host (Linux, NVIDIA adapters)
Three things: trust DSCP; enable PFC on priority 3 only; set the RoCE ToS to 106, which is DSCP 26 plus the bits that allow ECN marking.
mlnx_qos -i ens1f0np0 --trust dscp mlnx_qos -i ens1f0np0 --pfc 0,0,0,1,0,0,0,0 cma_roce_tos -d mlx5_0 -t 106
Advanced ① Mismatched configuration
Advanced · about 5 min
Goal: What does not match
What does not match: Everything matches
All three flows are fine: The agreement across the network: RoCE packets carry DSCP 26; switches trust DSCP and put DSCP 26 in priority 3; priority 3 has PFC and ECN enabled.
Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. ECN slows the two flows to 200G each, nothing is dropped and the third flow is unaffected.
· Packet loss: None
· What has to match: Every host and every switch
What does not match: SP2 has no PFC
1. SP2 is missing its PFC configuration: SP2 went into service without PFC; every other switch has it. Under light traffic nothing looks wrong.
Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. The flow from S2 goes through SP2.
2. SP2 ignores L5's PAUSE: In a burst, L5's queue hits the PFC threshold and it sends PAUSE to SP1 and SP2. SP1 stops; SP2 has no PFC and keeps sending to L5.
3. L5's buffer overflows and drops packets: The buffer L5 reserved for this queue is overrun by traffic from SP2 and packets are dropped. The flow that goes through SP2 is the one that loses them.
4. Symptoms and how to check: Symptoms: between the same two servers some GPU pairs are fine and others are erratic. The hash decides which spine a flow uses, and only flows hashed to SP2 suffer.
Check: on every switch, see whether PFC is enabled, how many PAUSE frames were sent and received, and how many packets were dropped.
· Affected flows: Only those through SP2
· Sender adapter counter: out_of_sequence keeps rising (loss and retransmission)
· Fix: Enable the lossless RoCE configuration on SP2
What does not match: S1 does not mark DSCP
1. RoCE packets from S1 carry DSCP 0: Switches classify by DSCP, and only DSCP 26 goes to priority 3. The adapters on S1 were never configured with the RoCE DSCP, so their packets carry DSCP 0.
2. The packets land in the default queue: Switches treat these packets as ordinary traffic and put them in the default queue, which has no PFC and drops when full.
3. Loss under congestion: Port 1 of S1 and port 1 of S2 both send 400G to port 5 of S4. That port is only 400G. Packets from S1 are dropped in the default queue, RoCE retransmits and throughput collapses. S2 marks DSCP 26 and its flow is fine.
The priority 3 counters on the switches show none of S1's traffic because it never entered that queue.
4. How to check: Look at the per-priority traffic counters on the switch: RoCE traffic belongs in priority 3, and if it sits in priority 0 the host is not marking. Set the RoCE ToS to 106 (DSCP 26) on the host.
· Where packets drop: The switches' default queue
· Affected flows: Only those sent by S1
· Fix: cma_roce_tos -d mlx5_0 -t 106
Check RoCE configuration and counters on each switch (Cumulus Linux)
The first shows whether RoCE settings are active on the port; the second shows PAUSE frames sent and received, ECN marks and drops.
nv show interface swp1 qos roce status nv show interface swp1 qos roce counters
Cisco NX-OS: PFC per port
Mode and Oper should both be On. RxPPP / TxPPP count PAUSE frames received and sent.
# show interface priority-flow-control Port Mode Oper(VL bmap) RxPPP TxPPP Ethernet1/1 On On (8) 9638881 12024
On the host: look for loss and retransmission
A rising out_of_sequence means packets are being lost on the path. rx_prio3_pause counts PAUSE frames this adapter received.
$ cat /sys/class/infiniband/mlx5_0/ports/1/hw_counters/out_of_sequence
18204
$ ethtool -S ens1f0np0 | grep prio3_pause
rx_prio3_pause: 51234
tx_prio3_pause: 0
Host (Linux, NVIDIA adapters)
Three things: trust DSCP; enable PFC on priority 3 only; set the RoCE ToS to 106, which is DSCP 26 plus the bits that allow ECN marking.
mlnx_qos -i ens1f0np0 --trust dscp mlnx_qos -i ens1f0np0 --pfc 0,0,0,1,0,0,0,0 cma_roce_tos -d mlx5_0 -t 106
Advanced ② PFC storm
Advanced · about 5 min
Goal: PFC watchdog
PFC watchdog: Off
1. One adapter keeps sending PAUSE: The adapter on port 5 of S4 malfunctions and sends PAUSE to L5 continuously. L5 obeys and stops sending priority 3 packets to that port.
2. L5 backs up and pauses its upstream: Packets for port 5 of S4 pile up inside L5 until its buffer is full. L5 starts sending PAUSE to all 4 spines.
3. The spines back up and pause every leaf: Packets bound for L5 pile up on the spines too and fill their buffers. The spines send PAUSE to the leaves feeding them, and the uplinks of all 8 leaves are paused.
4. RoCE traffic stops on every server: With their uplinks paused the leaves back up as well and pause the server ports below them. One bad adapter has stopped RoCE traffic on all 8 rails, including flows that have nothing to do with S4. This is a PFC storm.
Microsoft documented this failure from production in a 2016 paper.
· Affected: All priority 3 traffic on all 8 rails
· Cause: 1 adapter
· Lasts until: The faulty adapter is isolated
PFC watchdog: On
1. One adapter keeps sending PAUSE: The adapter on port 5 of S4 malfunctions and sends PAUSE to L5 continuously. L5 obeys and stops sending priority 3 packets to that port.
2. The watchdog sees the port paused for too long: L5's PFC watchdog checks every 100 ms. The lossless queue on this port is found paused 3 checks in a row and is declared abnormal.
3. L5 stops honouring PAUSE from this port: The watchdog makes L5 temporarily ignore PAUSE received on this port and discard packets bound for it, so the buffer is no longer held. When the PAUSE frames stop, PFC on the port is restored.
4. The fault is confined to one port: Only port 5 of S4 is unreachable. The other 7 ports of S4 and all other servers carry on.
· Affected: Only port 5 of S4
· Check interval: 100 ms, 3 in a row (Cumulus Linux defaults)
· Next: Replace the faulty adapter
Enable the PFC watchdog (NVIDIA Cumulus Linux)
Enabled per port. By default it checks every 100 ms and acts when a lossless queue is found paused 3 checks in a row.
nv set interface swp1 qos pfc-watchdog nv config apply
See whether the watchdog has fired
One line per queue: status OK or DEADLOCK, followed by how many times it has fired.
nv show interface swp1 qos pfc-watchdog
On the host: how many PAUSE frames the adapter sent
The adapter whose tx_prio3_pause keeps climbing fast is the source.
$ ethtool -S ens1f0np0 | grep prio3_pause
rx_prio3_pause: 0
tx_prio3_pause: 48219377
Advanced ③ Fail a device
Advanced · about 5 min
Goal: What fails
What fails: All healthy
All healthy: The 8 ports of each server go to 8 different leaves. Each leaf has one BGP session to each of the 4 spines, so traffic leaving the unit has 4 equal-cost paths.
· Ports up: 8 / 8 per server
· Equal-cost paths: 4
What fails: Leaf L3
L3 fails: every server loses one port: L3 is rail 3. When it fails, port 3 of every server connected to it goes down and the other 7 ports keep working.
No server is cut off completely. Training jobs using port 3 fail; until L3 is repaired each server has 7 GPUs available for multi-node training.
· Ports down: 1 per server (port 3)
· Servers cut off completely: 0
· Compared with per-rack wiring: Meta's published design connects every port in a rack to the leaf on top of it. There, losing a leaf cuts off the whole rack.
What fails: Spine SP2
1. SP2 fails: one fewer equal-cost path: SP2 fails and the links from all 8 leaves to it go down. Each leaf loses its BGP session with SP2 and withdraws the routes through it, leaving 3 equal-cost paths out of 4.
Traffic inside one unit and one rail crosses a single leaf and is unaffected.
2. Traffic leaving the unit is rehashed onto the remaining 3 links: Flows that used SP2 are rehashed onto the other 3 spines. Each leaf keeps 75% of its uplink capacity, so heavy traffic leaving the unit congests; ECN and PFC hold the senders back, so nothing is lost but everything is slower.
· Ports down: 0
· Uplink capacity per leaf: 75% left
· Traffic inside a rail: Unaffected
What fails: The cable on port 5 of S2
One cable fails: one port is affected: The cable from port 5 of S2 to L5 fails. Only GPU5 on S2 loses the network; the other ports are fine.
· Ports down: 1
Look at the BGP sessions
After SP2 fails, its session on the leaf is no longer Established. Output is trimmed.
$ sudo vtysh -c "show bgp ipv4 unicast summary" Neighbor V AS MsgRcvd MsgSent Up/Down State/PfxRcd sp1(swp49) 4 65201 8423 8419 06:58:21 3 sp2(swp50) 4 65201 0 0 00:00:42 Active sp3(swp51) 4 65201 8420 8418 06:58:20 3 sp4(swp52) 4 65201 8421 8419 06:58:20 3
See how many equal-cost paths remain
3 next hops instead of 4. Output is trimmed.
$ ip route show 10.2.1.0/24 10.2.1.0/24 proto bgp metric 20 nexthop via inet6 fe80::4638:39ff:fe00:1 dev swp49 weight 1 nexthop via inet6 fe80::4638:39ff:fe00:3 dev swp51 weight 1 nexthop via inet6 fe80::4638:39ff:fe00:4 dev swp52 weight 1