←Contents目錄
Chapter 11第 11 章
Chapter 11 of 13 · Part II · The network
第 11 章(共 13 章)· 第二部 · 網路

Sharing the cluster: isolation, placement and spare capacity共用叢集:隔離、擺放與備用容量

Learn why a training cluster runs many jobs at once, how jobs disturb one another on a shared network, why placement is the strongest network lever, how allocation units fragment a cluster, and how operators keep a shared network healthy.了解為何一個訓練叢集同時跑許多任務、任務如何在共用的網路上互相干擾、為何擺放是最強的網路槓桿、配置單位如何讓叢集碎片化,以及營運者如何讓共用的網路保持健康。

≈ 45 min · 4 panels · 4 animations≈ 45 分鐘 · 4 個面板 · 4 個動畫Jump to the quiz ↓跳到測驗 ↓
Before you start
開始之前

This chapter builds on Chapters 3, 6, 7, 8, 10. These earlier terms appear most often below; each chip links to its definition.

本章建立在第 3、6、7、8、10 章之上。下列較早定義的名詞在本章最常出現;點選即可回到它的定義。

New terms in this chapter (4)本章新名詞(4)

Each term is defined in the text where it first appears; the link jumps there. Terms from earlier chapters are listed under "Before you start".

每個名詞都在它第一次出現的段落中定義,點連結可跳過去。前面各章的名詞列在「開始之前」。

  • Fragmentation碎片化 Free GPUs that exist but not in a shape a job can use without crossing racks or pods. 空閒 GPU 存在,但其形狀無法讓工作不跨機櫃或 pod 就使用。
  • Isolation, contention隔離、爭用 Keeping one job's traffic from slowing another's; contention is two jobs wanting the same link. 避免一個工作的流量拖慢另一個;爭用是兩個工作想用同一條鏈路。
  • Multi-tenancy, tenant多租戶、租戶 Several jobs or customers sharing one cluster and its network. 多個工作或客戶共用一個叢集及其網路。
  • Placement, scheduler放置、排程器 Choosing which GPUs a job gets and which rank runs where; it decides which links the traffic crosses. 決定工作拿到哪些 GPU、各 rank 放在哪裡;它決定流量經過哪些鏈路。

11.1Why clusters are shared, and what sharing breaks叢集為何共用,以及共用會破壞什麼

A cluster is sized for the largest job it will ever run, but it runs that job rarely. HPN's Figure 6 says that 96.3% of Alibaba's LLM training jobs use fewer than 1,000 GPUs, on a pod built for 15,000. So the normal state of a cluster is tens of jobs of different sizes, starting and finishing at different times, and the scheduler must pack them. Two things go wrong when it does. Fragmentation means that free GPUs exist but not in a shape a job can use without crossing racks or segments. Queueing means that a job waits for a shape to become free. Both have a network cost, because a scheduler under pressure accepts a placement that spreads a job out.

叢集依它將跑過的最大任務來定規模,但很少真的跑那個任務。HPN 的 Figure 6 說,阿里 96.3% 的 LLM 訓練任務使用少於 1,000 顆 GPU,而 pod 是為 15,000 顆建的。所以叢集的常態是數十個大小不同、起訖時間不同的任務,排程器必須把它們裝進去。這麼做時會出兩種問題。碎片化指的是有空閒的 GPU,卻不是任務能在不跨機櫃或 segment 的情況下使用的形狀。排隊指的是任務等待某個形狀空出來。兩者都有網路代價,因為壓力下的排程器會接受把任務攤開的配置。

Work one example on an HPN segment: 128 hosts of 8 GPUs, 1,024 GPUs in all. Each host connects to all 8 ToR pairs, one pair per rail, so a job usually takes whole hosts. Job A takes 640 GPUs, 80 hosts. Job B takes 256, 32 hosts. 16 hosts are free. A new job of 256 GPUs cannot fit. It either waits until A or B finishes, or it takes 128 GPUs here and 128 in another segment, and from then on every one of its collectives crosses the aggregation layer. Figure 11.1 draws the example.

在一個 HPN segment 上算一個例子:128 台主機、每台 8 顆 GPU,共 1,024 顆。每台主機都連到全部 8 對 ToR,每個 rail 一對,所以任務通常以整台主機為單位。任務 A 拿 640 顆,80 台主機。任務 B 拿 256 顆,32 台主機。剩下 16 台主機是空的。一個新的 256 顆 GPU 任務放不進去。它要嘛等 A 或 B 結束,要嘛在這裡拿 128 顆、到另一個 segment 拿 128 顆,從此它的每一次集體操作都跨越聚合層。圖 11.1 畫出這個例子。

one HPN segment: 128 hosts × 8 GPUs = 1,024 GPUs一個 HPN segment:128 台主機 × 8 顆 GPU = 1,024 顆 GPUeach block = 16 hosts每格 = 16 台主機AAAAABBfree空job A: 640 GPUs = 80 hosts任務 A:640 顆 GPU = 80 台主機job B: 256 = 32 hosts任務 B:256 顆 = 32 台主機new job: 256 GPUs = 32 hosts; only 16 are free新任務:256 顆 GPU = 32 台主機;空的只有 16 台it waits, or it splits across two segments只能等待,或拆到兩個 segment
Figure 11.1. Fragmentation inside one HPN segment. Every host connects to all eight ToR pairs, so a job takes whole hosts. Two running jobs leave 16 hosts, 128 GPUs, free. A 256-GPU job needs 32 hosts, so it queues or crosses the aggregation layer.圖 11.1。HPN 單一 segment 內的碎片化。每台主機都連到全部八對 ToR,所以任務以整台主機為單位。兩個運行中的任務留下 16 台主機、128 顆 GPU 空著。256 顆 GPU 的任務需要 32 台主機,所以它只能排隊或跨越聚合層。Drawn for this primer from segment sizes in Qian et al., SIGCOMM 2024.

What one job does to another一個任務對另一個任務的影響

Crux measured the network case: a GPT job that shared links with a BERT job took 11% longer per iteration, 1.70 s instead of 1.53 s on average (Figure 11.2).

Crux 量測了網路的情形:與 BERT 任務共用鏈路的 GPT 任務,每次迭代平均多花 11%,從 1.53 秒變成 1.70 秒(圖 11.2)。

CDF of GPT iteration time: alone, almost all runs near 1.53 s; sharing links with a BERT job, runs spread from about 1.55 to 1.9 s
Figure 11.2. Iteration time of a 64-GPU GPT job (8 hosts) alone (red) and next to a 16-GPU BERT job (green, dashed) under the same two ToR switches, measured in the authors' cluster. The GPUs did not change; only the ToR-to-aggregation links were shared. The whole distribution moves right, and its tail reaches about 1.9 s.圖 11.2。64 顆 GPU 的 GPT 任務(8 台主機)單獨執行(紅色),以及在同樣兩台 ToR 交換器下和 16 顆 GPU 的 BERT 任務並存(綠色虛線)時的迭代時間,於作者的叢集實測。GPU 沒有變;只有 ToR 到聚合層的鏈路被共用。整個分布往右移,尾端達到約 1.9 秒。Figure 7, Cao et al., "Crux: GPU-Efficient Communication Scheduling for Deep Learning Training", ACM SIGCOMM 2024.

Once two jobs share switches, three mechanisms couple them. The first is hash collision. A training GPU has few flows, about 4 queue pairs per GPU for an AllReduce in Meta's measurement, so when job A's flow and job B's flow hash onto the same uplink, both run at half speed and every GPU waiting on either flow idles. HPN measured the cost directly: with four AllReduce jobs running at once on 512 GPUs, choosing disjoint paths on the host raised collective performance by up to 34.7%.

一旦兩個任務共用交換器,三種機制把它們耦合在一起。第一是雜湊碰撞。訓練 GPU 的流很少,Meta 量到 AllReduce 每顆 GPU 約 4 個 queue pair,所以當任務 A 的流與任務 B 的流被雜湊到同一條上行,兩者都只剩一半速度,等待任一條流的每顆 GPU 都在閒置。HPN 直接量出代價:512 顆 GPU 上同時跑四個 AllReduce 任務時,在主機端挑選不相交路徑讓集體通訊效能最多提升 34.7%。

The second is priority flow control (PFC). RoCE needs a lossless fabric, and PFC provides it by pausing an upstream port when a buffer fills. PFC pauses ports, not flows, so a pause caused by one job stops every job on that port. The DCQCN paper measured two consequences. In the parking-lot experiment, a sender with its own ingress port reached up to 20 Gb/s while three senders sharing one port split that port's share. In the victim flow experiment, a flow whose path shared no congested link with anyone fell from 20 Gb/s to 10 Gb/s because pause frames from an incast elsewhere cascaded through a switch it traversed, and to 4.5 Gb/s when two more incast senders joined. In a training pod, one job's reduce-scatter incast can pause the ring of a job that shares nothing with it except a switch.

第二是優先權流量控制(PFC)。RoCE 需要無損網路,PFC 在緩衝填滿時暫停上游埠來提供它。PFC 暫停的是埠而不是流,所以一個任務造成的暫停會停止該埠上的每一個任務。DCQCN 論文量到兩個後果。在停車場實驗中,擁有自己入口埠的發送端達到最高 20 Gb/s,共用一埠的三個發送端則分那個埠的份額。在受害者流實驗中,一條路徑與任何人都不共用壅塞鏈路的流,因為別處 incast 的暫停幀串聯穿過它經過的交換器,從 20 Gb/s 掉到 10 Gb/s,再有兩個 incast 發送端加入時掉到 4.5 Gb/s。在訓練 pod 裡,一個任務的 reduce-scatter incast 可以暫停另一個除了交換器之外與它毫無共用的任務的環。

The third is unequal cost. Alibaba's Crux (SIGCOMM 2024) measured that 36.3% of jobs in their cluster were at risk of contention, that is, of competing with another job for the same link, and proposed a rule: give the link to the job whose waiting GPUs are worth the most, because

第三是代價不對等。阿里的 Crux(SIGCOMM 2024)量到他們叢集中 36.3% 的任務有競爭(與另一個任務爭用同一條鏈路)的風險,並提出一條規則:把鏈路給等待中 GPU 價值最高的任務,因為

wasted GPU-seconds=∑jobsGPUsj×delayj \text{wasted GPU-seconds} = \sum_{\text{jobs}} \text{GPUs}_j \times \text{delay}_j
浪費的 GPU-秒=∑任務GPU 數j×延遲j \text{浪費的 GPU-秒} = \sum_{\text{任務}} \text{GPU 數}_j \times \text{延遲}_j

Figure 11.3 is the paper's own example.

圖 11.3 是論文自己的例子。

Two Gantt-style timelines: giving link priority to a 1-GPU job makes 10 GPUs wait; giving priority to the 10-GPU job makes only 1 GPU wait
Figure 11.3. Two jobs contend for one link. If the 1-GPU job goes first, 10 GPUs sit idle. If the 10-GPU job goes first, only 1 GPU waits. Crux schedules the communication so that the fewest GPU-seconds are wasted.圖 11.3。兩個任務爭用同一條鏈路。如果 1-GPU 任務先走,10 顆 GPU 閒著;如果 10-GPU 任務先走,只有 1 顆 GPU 在等。Crux 排程通訊,讓浪費的 GPU-秒最少。Figure 8, Cao et al., "Crux: GPU-Efficient Communication Scheduling for Deep Learning Training", ACM SIGCOMM 2024.

Panel 11.1 lets you apply the rule to two jobs that share one link.

面板 11.1 讓你把這條規則套用到共用一條鏈路的兩個任務。

Panel 11.1面板 11.1

Two jobs, one link: who goes first?兩個任務、一條鏈路:誰先走?

Wasted, job 1 first
浪費,任務 1 先走
Wasted, job 2 first
浪費,任務 2 先走
Wasted, fair share
浪費,平分鏈路
GPU-weighted order
依 GPU 加權的順序

A model of Crux's Figure 8. Each job needs the link for the time shown when it has the link alone, and its GPUs wait until its transfer ends, so wasted GPU-seconds=∑jGPUsj×delayj\text{wasted GPU-seconds} = \sum_j \text{GPUs}_j \times \text{delay}_j The defaults are the paper's example: a 1-GPU job and a 10-GPU job with equal transfers. The 100 ms unit is ours; only the ratios matter. Fair share gives each job half the link while both send. With the defaults, both strict orders give the same mean finish time, but the waste differs tenfold. The waste is smallest when the job with more waiting GPUs per millisecond of transfer goes first, which is the idea behind Crux's GPU intensity.

Crux Figure 8 的模型。每個任務獨占鏈路時需要所示的傳輸時間,它的 GPU 等到傳輸結束才能繼續,所以 浪費的 GPU-秒=∑jGPU 數j×延遲j\text{浪費的 GPU-秒} = \sum_j \text{GPU 數}_j \times \text{延遲}_j。預設值是論文的例子:1 顆 GPU 與 10 顆 GPU 的任務,傳輸時間相同。100 ms 這個單位是我們設的,只有比例重要。平分鏈路讓兩個任務同時傳送時各得一半。用預設值時,兩種嚴格順序的平均完成時間相同,浪費卻差十倍。讓每毫秒傳輸對應較多等待 GPU 的任務先走,浪費最小,這就是 Crux 的 GPU intensity 背後的想法。

Animation 11.1 plays the default case of Panel 11.1 in time, with both jobs' timelines under fair share and under Crux's priority.

動畫 11.1 把面板 11.1 的預設情況按時間播放,畫出兩個任務在平分鏈路與 Crux 優先權下的時間軸。

Animation 11.1動畫 11.1

Two jobs on one link: fair share against Crux's priority一條鏈路上的兩個任務:平分鏈路對上 Crux 的優先權

The default case of Panel 11.1, which models Crux's Figure 8: a 1-GPU job and a 10-GPU job, each with 100 ms of data for the link, and the same waste measure, GPUs times delay, summed over the jobs. The 100 ms unit is ours. All chunks travel at one speed; the share decides how many chunks each job gets. With only two jobs, Crux's GPU-intensity priority reduces to a strict order; the real system sets priorities and paths for many jobs at once.

面板 11.1 的預設情況,它是 Crux Figure 8 的模型:1 顆 GPU 與 10 顆 GPU 的任務,各要在鏈路上傳 100 ms 的資料,浪費的算法也相同:GPU 數乘以延遲,對所有任務加總。100 ms 這個單位是我們設的。所有 chunk 以同一速度前進;分配比例決定每個任務拿到多少 chunk。只有兩個任務時,Crux 以 GPU intensity 定的優先權退化成嚴格的先後順序;實際系統要同時替許多任務設定優先權與路徑。

Isolation mechanisms and what they cost隔離機制與它們的代價

Isolation means that job A's traffic cannot change job B's step time. Four mechanisms exist, each at a different layer and price.

隔離指的是任務 A 的流量無法改變任務 B 的步時間。有四種機制,各在不同的層次、有不同的價格。

Mechanism機制What it separates分開什麼What it does not fix, and its cost沒修好什麼,以及代價Where出處
Lossless priority classes無損優先權類別Buffers and PFC pauses per class: a control or storage class cannot pause a data class每類別的緩衝與 PFC 暫停:控制或儲存類別不能暫停資料類別Links still shared, so collisions remain; each lossless class needs reserved headroom, so operators commonly run one or two鏈路仍共用,碰撞仍在;每個無損類別需要保留的 headroom,營運者通常只跑一到兩個Microsoft RoCE; Meta's high-priority CTS queueMicrosoft RoCE;Meta 的高優先權 CTS 佇列
Per-tenant NICs on one host同一主機上每租戶專屬 NICEach tenant owns some of the 8 NICs and their ToR ports每個租戶擁有 8 張 NIC 中的一部分及其 ToR 埠No relaying through GPUs the tenant does not own, so rail-only's NVLink detour is forbidden; tier 2 must stay any-to-any不能透過不屬於租戶的 GPU 中繼,rail-only 的 NVLink 繞路被禁止;第二層必須維持任意對任意HPN §10, serverless useHPN §10,serverless 用法
Physical slice (air gap)實體切片(air gap)Links and switches: two slices never share any鏈路與交換器:兩個切片永不共用Circuits reserved even when idle; shapes limited to 4i×4j×4k4i \times 4j \times 4k; re-wiring takes milliseconds電路閒置時也被保留;形狀限於 4i×4j×4k4i \times 4j \times 4k;重新接線需要毫秒TPU v4 OCS slicesTPU v4 的 OCS 切片
Rail- or segment-aware allocation依 rail 或 segment 感知的配置Keeps a job under one ToR set, so most traffic crosses one switch把任務留在一組 ToR 下,多數流量只跨一台交換器Holds only while the allocation holds; needs backup hosts; fragments the cluster只在配置成立時有效;需要備援主機;使叢集碎片化HPN segments; MegaScale ToR setsHPN 的 segment;MegaScale 的 ToR 組

Two rows deserve a note. In HPN's serverless use, several tenants, customers renting GPUs, share one host and each owns some of its eight NICs; a tenant cannot relay traffic through a GPU it does not own, so the NVLink detour that rail-only topologies depend on is forbidden. That is one of the two reasons HPN kept an any-to-any aggregation layer instead of a rail-only one that could have held 120,000 GPUs per pod: multi-tenancy changed the topology. TPU v4 is the opposite extreme: every optical circuit belongs to one slice, so two slices never share a link or a switch, and this air gap is the only mechanism in the table that removes hash collisions, PFC coupling and buffer sharing at once. Its price is circuits that sit reserved while idle.

兩行值得補充。在 HPN 的 serverless 用法中,數個租戶(租用 GPU 的客戶)共享一台主機,各擁有八張 NIC 中的一部分;租戶不能透過不屬於自己的 GPU 中繼流量,所以 rail-only 拓樸所依賴的 NVLink 繞路被禁止。這是 HPN 保留任意對任意聚合層、而不採用每個 pod 可容納 120,000 顆 GPU 的 rail-only 的兩個理由之一:多租戶改變了拓樸。TPU v4 是另一個極端:每條光電路屬於一個切片,所以兩個切片永不共用鏈路或交換器,這個 air gap 是表中唯一能一次消除雜湊碰撞、PFC 耦合與緩衝共用的機制。代價是電路閒置時仍被保留。

11.2Placement: the strongest network lever擺放:最強的網路槓桿

A job does not have one traffic matrix. It has one traffic matrix per placement, the assignment of its ranks to particular GPUs. The bytes each dimension moves per step are fixed by the model and the parallelism; where those bytes go is fixed by where the ranks sit. HPN's Table 3 gives the per-step volumes for GPT-3 175B at TP=8\mathrm{TP} = 8, PP=8\mathrm{PP} = 8, DP=512\mathrm{DP} = 512: tensor parallelism moves 560 MB in all-reduce and all-gather, data parallelism 5.5 GB in all-reduce, and pipeline parallelism 6 MB in point-to-point sends. You can check the DP number:

一個任務沒有單一的流量矩陣。它每一種擺放(把它的 rank 分配到哪些 GPU)都有一個流量矩陣。每個維度每步搬動的位元組數由模型與平行化決定;這些位元組往哪裡去,由 rank 坐在哪裡決定。HPN 的 Table 3 給出 GPT-3 175B 在 TP=8\mathrm{TP} = 8、PP=8\mathrm{PP} = 8、DP=512\mathrm{DP} = 512 下每步的量:張量平行在 all-reduce 與 all-gather 中搬 560 MB,資料平行在 all-reduce 中搬 5.5 GB,管線平行在點對點傳送中搬 6 MB。DP 的數字可以驗算:

Question問題Calculation算式Result結果
Gradients of 175 billion parameters at 2 bytes each1,750 億參數、每個 2 位元組的梯度175×109×2175 \times 10^{9} \times 2350350 GB
Shard per GPU, over the TP×PP=64\mathrm{TP} \times \mathrm{PP} = 64 GPUs that hold one copy每顆 GPU 的分片,分給持有一份副本的 TP×PP=64\mathrm{TP} \times \mathrm{PP} = 64 顆 GPU350÷64350 \div 64≈5.47\approx 5.47 GB
Bytes through each GPU's NIC per step, ring all-reduce over DP=512\mathrm{DP} = 512, 2(N−1)/N2(N-1)/N of the shardDP=512\mathrm{DP} = 512 的環狀 all-reduce 每步通過每顆 GPU NIC 的位元組,分片的 2(N−1)/N2(N-1)/N2×511/512×5.5 GB2 \times 511/512 \times 5.5\,\text{GB}≈11\approx 11 GB

So HPN's 5.5 GB is one GPU's gradient shard, and the ring moves about twice that, 11 GB, through each GPU's NIC every step.

所以 HPN 的 5.5 GB 就是一顆 GPU 的梯度分片,而環每步讓約兩倍的量、11 GB 通過每顆 GPU 的 NIC。

Now follow the bytes. In a ring, every GPU sends to one neighbor. If the neighbor is in the same server, the bytes ride NVLink at about 450 GB/s per direction and never touch the fabric. If it is in the same pod, they cross one or two switches at full rate. If it is in another pod, they cross the oversubscribed links: 1:7 at Meta, 15:1 at HPN. For any boundary, bytes crossing=∑dimensions∑groups(ring hops that cross)×bytes per hop.\text{bytes crossing} = \sum_{\text{dimensions}} \sum_{\text{groups}} (\text{ring hops that cross}) \times \text{bytes per hop.} A ring whose ranks are ordered pod by pod crosses each pod boundary once; a ring whose ranks are scattered crosses on almost every hop. Figure 11.4 shows both cases.

現在跟著位元組走。在環中,每顆 GPU 送給一個鄰居。如果鄰居在同一台伺服器,位元組走每方向約 450 GB/s 的 NVLink,完全不碰網路。如果在同一個 pod 內,以全速跨一到兩台交換器。如果在另一個 pod,跨越超額認購的鏈路:Meta 是 1:7,HPN 是 15:1。對任何邊界,跨越的位元組=∑維度∑群組(跨越邊界的環跳數)×每跳位元組。\text{跨越的位元組} = \sum_{\text{維度}} \sum_{\text{群組}} (\text{跨越邊界的環跳數}) \times \text{每跳位元組。}rank 依 pod 排列的環每個 pod 邊界只跨一次;rank 散落的環幾乎每一跳都跨。圖 11.4 畫出兩種情況。

pod Apod Bordered by pod依 pod 排序071625342 of 8 hops cross8 跳中 2 跳跨越scattered散落012345678 of 8 hops cross8 跳全部跨越
Figure 11.4. One ring of eight ranks on two pods. Ordered pod by pod (left), only two hops cross the pod boundary. Scattered (right), all eight cross. The bytes that cross are the crossing hops times the bytes per hop, so the scattered ring sends four times as much over the oversubscribed links.圖 11.4。一個八 rank 的環放在兩個 pod 上。依 pod 排序(左)時,只有兩跳跨越 pod 邊界。散落(右)時,八跳全都跨越。跨越的位元組等於跨越的跳數乘以每跳位元組,所以散落的環在超額認購的鏈路上送出四倍的量。Drawn for this primer.

Animation 11.2 moves the chunks of one ring all-gather on both placements of Figure 11.4.

動畫 11.2 在圖 11.4 的兩種配置上,逐步移動一次環狀 all-gather 的 chunk。

Animation 11.2動畫 11.2

One ring all-gather on two placements兩種配置上的一次環狀 all-gather

Figure 11.4's ring of 8 ranks on two pods, with one chunk per rank and 7 all-gather steps. All hops of a step move at the same time; the drawing staggers them a little so that you can tell them apart. Bandwidth and timing are not modelled: the counters count the chunks that cross the pod boundary, the quantity in this section's formula for bytes crossing.

圖 11.4 中兩個 pod 上 8 個 rank 的環,每個 rank 一個 chunk,all-gather 共 7 步。同一步的所有跳同時移動;圖中把它們稍微錯開,方便分辨。頻寬與時間不在模型內:計數器數的是跨越 pod 邊界的 chunk,也就是本節跨越位元組公式中的那個量。

Three schedulers, one rule三個排程器,一條規則

Meta's scheduler learns where every server sits in the topology and assigns the ranks of a job so that the cut between AI Zones carries as little traffic as possible. In graph terms, the ranks are nodes, the per-step bytes between them are edge weights, and the scheduler looks for the partition into zones with the minimum cut. Inside a zone the fabric is non-blocking, so what remains is path choice, and there Meta deployed centralized traffic engineering (TE), a controller that assigns a path to every flow and held link utilization near 80% where hashing swung between 40% and 90%. Meta did not deploy TE across zones, because a controller reacting to every failure and job change at data-center scale was judged not worth the gain.

Meta 的排程器學習每台伺服器在拓樸中的位置,並指派任務的 rank,使 AI Zone 之間的切割承載最少的流量。用圖論的話說,rank 是節點、它們之間每步的位元組數是邊權重,排程器尋找跨 zone 的最小割分割。zone 內部網路是非阻塞的,剩下的是路徑選擇,Meta 在那裡部署了集中式流量工程(TE):一個為每條流指派路徑的控制器,在雜湊讓使用率於 40% 到 90% 之間擺盪時把它維持在 80% 附近。Meta 沒有跨 zone 部署 TE,因為在資料中心規模下對每次故障與任務變動做反應的控制器被判定不值得那點收益。

Llama 3 shows the rule applied to one run. The parallel dimensions are ordered [TP, CP, PP, DP], innermost first, and the innermost dimension gets the fastest link. Take Table 4, row 2: 16,384 GPUs, TP=8\mathrm{TP} = 8, CP=1\mathrm{CP} = 1, PP=16\mathrm{PP} = 16, DP=128\mathrm{DP} = 128. A TP group is one server on NVLink; a TP×PP\mathrm{TP} \times \mathrm{PP} block is 8×16=1288 \times 16 = 128 GPUs, 8 racks of 16, placed inside one 3,072-GPU pod. A pod holds 24 such blocks, so 128 blocks fill five pods and part of a sixth, each DP group of 128 spans 6 pods, and only FSDP's reduce-scatter and all-gather cross the 1:7 links; the paper allows this because FSDP traffic can be prefetched. Estimate the cost, with 50 GB/s per GPU and a pod-ordered ring in which only the boundary hops cross:

Llama 3 展示這條規則在一次運行上的應用。平行維度依 [TP, CP, PP, DP] 排序、最內層在前,最內層得到最快的鏈路。取 Table 4 第二行:16,384 顆 GPU、TP=8\mathrm{TP} = 8、CP=1\mathrm{CP} = 1、PP=16\mathrm{PP} = 16、DP=128\mathrm{DP} = 128。TP 群組就是一台走 NVLink 的伺服器;一個 TP×PP\mathrm{TP} \times \mathrm{PP} 區塊是 8×16=1288 \times 16 = 128 顆 GPU,即 8 個 16 顆的機櫃,放在一個 3,072 顆 GPU 的 pod 內。一個 pod 容納 24 個這樣的區塊,所以 128 個區塊填滿五個 pod 再加第六個的一部分,每個 128 的 DP 群組橫跨 6 個 pod,只有 FSDP 的 reduce-scatter 與 all-gather 跨越 1:7 鏈路;論文允許這樣是因為 FSDP 流量可以預先抓取。估算代價,以每顆 GPU 50 GB/s、依 pod 排列且只有邊界跳數跨越的環計:

Question問題Calculation算式Result結果
A block's gradient shard per GPU (405B parameters, 2 bytes, 128 GPUs)一個區塊每顆 GPU 的梯度分片(4,050 億參數、2 位元組、128 顆 GPU)405×109×2÷128405 \times 10^{9} \times 2 \div 128≈6.33\approx 6.33 GB
Reduce-scatter plus all-gather, per GPU per stepreduce-scatter 加 all-gather,每顆 GPU 每步2×6.332 \times 6.33≈12.7\approx 12.7 GB
Ring time at 50 GB/s, whether or not it crosses pods50 GB/s 下的環時間,不論是否跨 pod12.7÷5012.7 \div 50≈0.25\approx 0.25 s
Bytes each pod sends over its uplinks per step (128 groups)每個 pod 每步透過上行送出的位元組(128 個群組)2×128×12.7 GB2 \times 128 \times 12.7\,\text{GB}≈3.2\approx 3.2 TB
A pod's uplink at 1:71:7 下一個 pod 的上行3,072×50 GB/s÷73{,}072 \times 50\GBs \div 7≈22\approx 22 TB/s
Time the uplink is busy上行忙碌的時間3.2 TB÷22 TB/s3.2\,\text{TB} \div 22\,\text{TB/s}≈0.15\approx 0.15 s
GPUs per pod that may have a ring neighbor outside before the uplink saturates上行飽和之前,一個 pod 內可有環鄰居在 pod 外的 GPU 數3,072÷73{,}072 \div 7≈440\approx 440
Ring share of a 6 s step (16M-token batch at 400 TFLOP/s per GPU)環占 6 s 一步的比例(16M token 的批次、每顆 GPU 400 TFLOP/s)0.25÷60.25 \div 6≈4%\approx 4\%

Each pod sends about 3.2 TB per step, and its uplinks are busy for about 0.15 s, less than the 0.25 s the ring takes anyway. The oversubscribed links are not the bottleneck; they would become one only if more than about 440 GPUs in a pod had a ring neighbor outside it. Against the whole step the ring is 4%, mostly prefetched. Table 4 agrees: doubling from 8K to 16K GPUs cost 2 MFU points, 43% to 41%.

每個 pod 每步送出約 3.2 TB,上行忙碌約 0.15 s,少於環本來就需要的 0.25 s。超額認購的鏈路不是瓶頸;只有當一個 pod 內超過約 440 顆 GPU 的環鄰居在 pod 外時,它才會成為瓶頸。對比整個步時間,環占 4%,且大多被預先抓取。Table 4 吻合:從 8K 加倍到 16K 顆 GPU 損失 2 個 MFU 百分點,43% 到 41%。

HPN draws the line one dimension lower. Its scheduler keeps TP and DP inside a pod and lets only pipeline traffic cross the core, because 6 MB per step is the smallest volume and point-to-point sends are the least bandwidth-sensitive. That is what makes a 15:1 core acceptable, and 64 backup GPUs per segment keep a job in place when a host fails. MegaScale states the same rule at rack scale: up to 64 servers share one set of eight ToRs, and the scheduler places communication-heavy ranks under the same ToR set so that most traffic crosses one switch. Figure 11.5 puts the Llama 3 and HPN layouts side by side.

HPN 把線畫低一個維度。它的排程器把 TP 與 DP 留在 pod 內,只讓管線流量跨越核心層,因為每步 6 MB 是最小的量,而點對點傳送對頻寬最不敏感。這就是 15:1 的核心層可以接受的原因,而每個 segment 64 顆備用 GPU 讓主機故障時任務留在原位。MegaScale 在機櫃尺度陳述同樣的規則:最多 64 台伺服器共用一組八台 ToR,排程器把通訊密集的 rank 放在同一組 ToR 下,讓多數流量只跨一台交換器。圖 11.5 把 Llama 3 與 HPN 的配置並排。

Llama 3 (Meta)Llama 3(Meta)HPN (Alibaba)HPN(阿里)in a server伺服器內NVLink ≈ 450 GB/sNVLink 約 450 GB/sTP8 GPUs on NVLink8 顆 GPU 走 NVLinkTP560 MBin a podpod 內full rate全速PP16 stages16 個階段DP5.5 GB shard5.5 GB 分片across pods跨 pod1:7 or 15:11:7 或 15:1DP (FSDP)DP(FSDP)≈ 12.7 GB, prefetched≈ 12.7 GB,可預先抓取PP6 MBthe thin boundary carries what tolerates it best最細的邊界承載最能容忍它的流量
Figure 11.5. Where each parallel dimension runs in the two layouts of this section. Both keep TP on NVLink. Llama 3 lets DP cross the 1:7 links, because FSDP traffic can be prefetched. HPN lets only PP cross its 15:1 core, because 6 MB per step is the smallest volume. The Llama 3 DP volume is this section's 405B estimate per GPU per step; the HPN volumes are from HPN Table 3 for GPT-3 175B.圖 11.5。本節兩種配置中各平行維度跑在哪裡。兩者都把 TP 留在 NVLink 上。Llama 3 讓 DP 跨越 1:7 鏈路,因為 FSDP 流量可以預先抓取。HPN 只讓 PP 跨越 15:1 的核心層,因為每步 6 MB 是最小的量。Llama 3 的 DP 量是本節對 405B 每顆 GPU 每步的估計;HPN 的量來自 HPN Table 3 的 GPT-3 175B。Drawn for this primer from Llama 3 §3.3 (Grattafiori et al., 2024) and Qian et al., SIGCOMM 2024.

What a wrong placement costs擺錯的代價

HPN's headline experiment is the clearest measurement of placement in the literature, even though the paper presents it as a topology result. A production job of more than 2,300 GPUs ran on the old network, DCN+, spread over 19 segments. On HPN it fit in 3. Cross-segment traffic fell 37% on average and end-to-end training throughput rose 14.9%. Part of the gain is dual-plane removing hash polarization; the paper's ablation attributes up to 71.6% of the cross-segment gain to it. The rest is that fewer bytes crossed in the first place. The panel below lets you build the Llama 3 layout and then break it.

HPN 的主要實驗是文獻中對配置最清楚的量測,儘管論文把它當作拓樸結果呈現。一個超過 2,300 顆 GPU 的生產任務在舊網路 DCN+ 上橫跨 19 個 segment。在 HPN 上只需 3 個。跨 segment 流量平均減少 37%,端到端訓練吞吐提高 14.9%。部分增益來自 dual-plane 消除 hash polarization;論文的消融把跨 segment 增益中最多 71.6% 歸於它。其餘是一開始就少了跨越的位元組。下面的面板讓你先建出 Llama 3 的配置,再把它弄壞。

Panel 11.2面板 11.2

Place a job on a pod of pods把任務放到 pod 組成的叢集上

DP derived
推得的 DP
Pods one DP group spans
一個 DP 群組橫跨的 pod 數
Bytes crossing pods per step
每步跨 pod 的位元組
Crossing hops in busiest pod
最忙 pod 的跨越跳數
Busiest pod uplink busy
最忙 pod 上行忙碌時間
Extra step time from crossing
跨越造成的額外步時間
Extra time by placement
各配置的額外時間

Defaults reproduce Llama 3's 16,384-GPU run: 8 pods of 3,072 GPUs at 1:7, TP=8\mathrm{TP} = 8, PP=16\mathrm{PP} = 16, DP=128\mathrm{DP} = 128, with TP×PP\mathrm{TP} \times \mathrm{PP} blocks of 128 GPUs placed inside pods and DP groups spanning 6 pods. Per-step volumes come from HPN Table 3 for GPT-3 175B (TP 560 MB, DP 5.5 GB shard, PP 6 MB) scaled by 8/PP8/\mathrm{PP}, so they are smaller than the 405B estimate in the text; the DP ring moves 2(N−1)/N2(N-1)/N of the shard, one direction. Rings follow rank order, so only hops that cross a pod boundary count. A ring is slowed only when the crossing hops in a pod outnumber what the uplink can carry at line rate, GPUs per pod divided by the oversubscription; the extra time is the excess over the in-pod ring time, fully exposed. "Sequential" keeps each DP group contiguous and spreads pipeline stages across pods, which is HPN's rule.

預設值重現 Llama 3 的 16,384 顆 GPU 運行:8 個各 3,072 顆 GPU 的 pod、1:7、TP=8\mathrm{TP} = 8、PP=16\mathrm{PP} = 16、DP=128\mathrm{DP} = 128,128 顆 GPU 的 TP×PP\mathrm{TP} \times \mathrm{PP} 區塊放在 pod 內,DP 群組橫跨 6 個 pod。每步的量來自 HPN Table 3 的 GPT-3 175B(TP 560 MB、DP 5.5 GB 分片、PP 6 MB)再乘以 8/PP8/\mathrm{PP},所以比正文中 405B 的估計小;DP 的環單方向搬動分片的 2(N−1)/N2(N-1)/N。環依 rank 順序排列,所以只有跨越 pod 邊界的跳數計入。只有當一個 pod 的跨越跳數超過上行能以線速承載的數量(每 pod GPU 數除以超額認購)時,環才會變慢;額外時間是超出 pod 內環時間的部分,假設完全暴露。「順序填入」讓每個 DP 群組連續、把管線階段散到各 pod,這是 HPN 的規則。

Stop and think停下來想一想

Keep the Llama 3 defaults and switch the placement to random. Read the crossing hops and the extra step time. Then set oversubscription to 15:1 and placement to sequential: this is HPN's rule, with only PP crossing. Why does the topology-aware layout show no extra time even at 15:1, and what, other than bytes, made Llama 3 put DP rather than PP across pods?

保留 Llama 3 的預設值,把配置切到隨機。讀跨越跳數與額外步時間。然後把超額認購設成 15:1、配置設成順序填入:這是 HPN 的規則,只有 PP 跨越。為什麼拓樸感知的配置即使在 15:1 也沒有額外時間?除了位元組之外,是什麼讓 Llama 3 把 DP 而不是 PP 放到跨 pod?

11.3Job shapes, fragmentation and spare capacity任務形狀、碎片化與備用容量

A scheduler allocates in units, and the unit decides the fragmentation. TPU v4's unit is a cube of 64 chips, and a slice may be any 4i×4j×4k4i \times 4j \times 4k shape: a 192-chip job gets 4×4×124 \times 4 \times 12, so sizes need not be powers of two. More important, the shape can match the parallelism. A pipeline-parallel job with many stages asks for a 512-chip 4×4×324 \times 4 \times 32 cigar, which gives the pipeline a long axis; a job that wants bisection bandwidth asks for 8×8×88 \times 8 \times 8. Table 3 of the paper shows that choosing topology and hyperparameters per job gained 1.2× to 2.3×: 2.3× between a novice's choice and the best for an LLM on 512 chips, 1.2× over an expert's choice for GPT-3 pre-training.

排程器以單位分配,單位決定碎片化。TPU v4 的單位是 64 顆晶片的 cube,切片可以是任何 4i×4j×4k4i \times 4j \times 4k 的形狀:192 顆晶片的任務拿到 4×4×124 \times 4 \times 12,所以大小不必是二的冪。更重要的是,形狀可以符合平行化。階段很多的管線平行任務要一個 512 顆晶片、4×4×324 \times 4 \times 32 的雪茄,給管線一條長軸;想要對分頻寬的任務要 8×8×88 \times 8 \times 8。論文的 Table 3 顯示依任務選擇拓樸與超參數帶來 1.2 到 2.3 倍的增益:512 顆晶片上訓練 LLM,新手的選擇與最佳選擇相差 2.3 倍;GPT-3 預訓練比專家的選擇好 1.2 倍。

Panel 11.3 lets you build a slice and compare the two 512-chip shapes.

面板 11.3 讓你組出一個切片,並比較兩種 512 顆晶片的形狀。

Panel 11.3面板 11.3

Shape a TPU v4 slice塑造一個 TPU v4 切片

Chips in the slice
切片的晶片數
Bisection links
對分鏈路數
Longest shortest path
最遠兩點的最短路徑
Slices per 64-cube machine
一台 64 cube 機器可放的切片

Analysis of a plain 3-D torus. A TPU v4 slice is 4i×4j×4k4i \times 4j \times 4k chips built from cubes of 4×4×44 \times 4 \times 4; one machine has 64 cubes, 4,096 chips. Bisection counts the links cut when the slice is split in half across its longest side; the wrap-around makes each ring cross the cut twice, so bisection=2×\text{bisection} = 2 \times the product of the two other sides. The longest shortest path is the sum of half of each side. The default is the paper's 192-chip slice. The 4×4×324 \times 4 \times 32 cigar gives a pipeline its long axis; the 8×8×88 \times 8 \times 8 cube has four times its bisection and a shorter longest path. TPU v4's twisted torus raises bisection further; this panel ignores it. The OCSes can join any free cubes into a slice (TPU v4 digest), so only the count of free cubes limits how many slices fit.

對一般三維環面的分析。TPU v4 的切片是由 4×4×44 \times 4 \times 4 的 cube 組成的 4i×4j×4k4i \times 4j \times 4k 顆晶片;一台機器有 64 個 cube、4,096 顆晶片。對分鏈路數是沿最長邊把切片切成兩半時被切斷的鏈路數;環繞鏈路讓每個環穿過切面兩次,所以 對分鏈路數=2×\text{對分鏈路數} = 2 \times 另外兩邊的乘積。最遠兩點的最短路徑是各邊一半的總和。預設值是論文中 192 顆晶片的切片。4×4×324 \times 4 \times 32 的雪茄給管線一條長軸;8×8×88 \times 8 \times 8 的立方體有它四倍的對分鏈路,最遠路徑也較短。TPU v4 的扭轉環面會再提高對分頻寬;本面板不計入。OCS 能把任何空閒的 cube 接成切片(TPU v4 導讀),所以能放幾個切片只受空閒 cube 的數量限制。

GPU clusters allocate in racks and ToR sets: a Meta rack holds 16 GPUs under one ToR, an HPN ToR pair serves 128 GPUs, a MegaScale ToR set serves up to 64 servers. The unit is coarse because the fabric is wired for it. Rail-optimized wiring assumes that GPU kk of every host under a ToR set belongs to the same job, and path pinning assumes that every downlink of a rack is in use. Meta's path-pinning stage shows what happens when a rack is half allocated: one of its two hosts used the uplinks and the other did not, so some uplinks idled while others overloaded, and training slowed by more than 30%. Figure 11.6 sketches this case.

GPU 叢集以機櫃與 ToR 組分配:Meta 的一個機櫃在一台 ToR 下有 16 顆 GPU,HPN 的一對 ToR 服務 128 顆 GPU,MegaScale 的一組 ToR 服務最多 64 台伺服器。單位粗是因為網路就是為它接線的。rail-optimized 接線假設一組 ToR 下每台主機的 GPU kk 都屬於同一個任務,路徑固定假設機櫃的每條下行都在使用中。Meta 的路徑固定階段顯示機櫃分配一半時會怎樣:兩台主機中只有一台在用上行、另一台沒有,所以某些上行閒置、另一些過載,訓練慢了超過 30%。圖 11.6 畫出這個情況。

whole rack in the job整個機櫃都在任務中capacity容量even load負載平均RTSW: uplinks 0–15RTSW:上行 0–15host 0主機 0slices 0–7slice 0–7host 1主機 1slices 8–15slice 8–15only host 0 in the job只有主機 0 在任務中capacity容量0–7 overloaded0–7 過載8–15 idle8–15 閒置RTSW: uplinks 0–15RTSW:上行 0–15host 0主機 0slices 0–7slice 0–7host 1主機 1not in job不在任務中pinning: traffic to slice k always uses uplink k路徑固定:送往 slice k 的流量一律走上行 k
Figure 11.6. Path pinning on a Meta rack of 16 GPUs, which holds two hosts of eight. Pinning sends all traffic for downlink slice kk over uplink kk. With the whole rack in one job (left), the 16 uplinks share the load evenly. With only host 0 in the job (right), only slices 0–7 receive traffic, so their uplinks carry all of it and uplinks 8–15 sit idle. Meta measured training more than 30% slower.圖 11.6。Meta 機櫃上的路徑固定,這個機櫃有 16 顆 GPU,分屬兩台各 8 顆的主機。路徑固定讓送往下行 slice kk 的所有流量都走上行 kk。整個機櫃都在一個任務中時(左),16 條上行平均分擔負載。只有主機 0 在任務中時(右),只有 slice 0–7 收到流量,所以它們的上行承載全部流量,上行 8–15 閒置。Meta 量到訓練慢了超過 30%。Drawn for this primer from §4.1 of Gangidi et al., "RDMA over Ethernet for Distributed AI Training at Meta Scale", ACM SIGCOMM 2024.

Every operator keeps spare capacity, and the amount is a policy. HPN reserves 8 of each ToR's 136 host-facing ports as backup, so a segment has 1,024 active GPUs plus 64 spare, 6.25%; a failed host is replaced inside the segment and the job keeps its placement. Meta's final design gives each rack switch 1:1.125 uplink bandwidth, 12.5% more than the downlinks need, chosen so that two failed uplinks do not slow a job; the 1:2 ratio used earlier worked but doubled the cost of the network. The formula behind every row of the table is the same: spare fraction≈expected failures during a job×units lost per failure/units in the job,\text{spare fraction} \approx \text{expected failures during a job} \times \text{units lost per failure} / \allowbreak \text{units in the job,} rounded up to the allocation unit. Figure 11.7 draws the two policies.

每個營運者都保留備用容量,保留多少是政策。HPN 把每台 ToR 136 個面向主機的埠中的 8 個保留為備援,所以一個 segment 有 1,024 顆使用中 GPU 加 64 顆備用,即 6.25%;故障主機在 segment 內被替換,任務保持其配置。Meta 的最終設計給每台機櫃交換器 1:1.125 的上行頻寬,比下行所需多 12.5%,選擇這個值是為了讓兩條上行故障不會拖慢任務;早先用的 1:2 有效,但讓網路成本加倍。表中每一行背後的公式相同:備用比例≈任務期間預期的故障數×每次故障損失的單位數/任務的單位數,\text{備用比例} \approx \text{任務期間預期的故障數} \times \text{每次故障損失的單位數} / \allowbreak \text{任務的單位數,}再向上取到配置單位。圖 11.7 畫出這兩種政策。

HPN: spare hostsHPN:備用主機Meta: spare uplinksMeta:備用上行16 × 8 = 128 active16 × 8 = 128 個使用中8 backup8 個備援16 downlinks16 條下行××18 uplinks = 1.125 × 1618 條上行 = 1.125 × 16one ToR: 136 host ports每台 ToR:136 個主機埠16 ToRs per segment每個 segment 16 台 ToR1,024 active + 64 spare GPUs1,024 顆使用中 + 64 顆備用spare = 6.25%備用 = 6.25%failed host → swap in segment主機故障 → 在 segment 內替換2 fail → 16 left2 條故障 → 剩 16 條full rate kept仍維持全速1:2 worked, at 2× network cost1:2 也有效,但網路成本加倍
Figure 11.7. Two spare policies. Left: each HPN ToR has 136 host-facing ports, drawn in blocks of eight, 128 active and 8 backup, so a segment holds 64 spare GPUs for 1,024 active ones. Right: Meta's rack switch has 1.125 times as much uplink bandwidth as downlink bandwidth. Drawn in units of one downlink's bandwidth, that is 18 uplinks for 16 downlinks, so two uplinks can fail before the rack falls below full rate.圖 11.7。兩種備用政策。左:每台 HPN ToR 有 136 個面向主機的埠(每格 8 個),128 個使用中、8 個備援,所以一個 segment 為 1,024 顆使用中的 GPU 保留 64 顆備用。右:Meta 的機櫃交換器上行頻寬是下行的 1.125 倍。以一條下行的頻寬為單位畫,就是 16 條下行對 18 條上行,所以可以壞兩條上行,機櫃仍維持全速。Drawn for this primer from Qian et al., SIGCOMM 2024 (§5.1) and Gangidi et al., SIGCOMM 2024 (Section 12.2).
Operator營運者Allocation unit配置單位Spare policy備用政策Measured consequence量到的後果
Alibaba HPNSegment: 1,024 GPUs under 16 ToRs; 15 segments per podsegment:16 台 ToR 下 1,024 顆 GPU;每 pod 15 個 segment64 backup GPUs per segment; only PP crosses pods每個 segment 64 顆備用 GPU;只有 PP 跨 pod19 → 3 segments: +14.9% throughput, −37% cross-segment traffic19 → 3 個 segment:吞吐 +14.9%,跨 segment 流量 −37%
Meta / Llama 3Rack of 16 GPUs; AI Zone; pod of 3,072 GPUs16 顆 GPU 的機櫃;AI Zone;3,072 顆 GPU 的 pod1:1.125 rack-switch uplinks; minimum-cut placement機櫃交換器上行 1:1.125;最小割配置Partly allocated racks under path pinning: >30% slower路徑固定下機櫃部分分配:慢 >30%
ByteDance MegaScaleToR set: up to 64 servers on 8 ToRsToR 組:8 台 ToR 上最多 64 台伺服器Standby node pool, automatic swap備用節點池,自動換機>100 restarts in weeks; effective training time >90%數週內重啟 >100 次;有效訓練時間 >90%
Google TPU v4Cube of 64 chips; slice of 4i×4j×4k4i \times 4j \times 4k64 顆晶片的 cube;4i×4j×4k4i \times 4j \times 4k 的切片OCS rewires around failed cubesOCS 繞過故障 cube75% goodput for a quarter-machine slice at 99.0–99.5% availability四分之一機器的切片在 99.0–99.5% 可用性下 75% goodput

Priorities and preemption are the part of this topic with the least published evidence. Crux's rule, serve the job with the most GPU-time at stake, is a priority on the link. Schedulers can also apply priority to the GPUs: a large job may preempt small ones to obtain a contiguous shape, at the cost of the preempted jobs' progress since their last checkpoint, which HPN says comes every two to four hours. How often operators choose preemption over waiting is not reported in these papers, so treat the trade-off as a policy question rather than a settled result.

優先權與搶占是本主題中已發表證據最少的部分。Crux 的規則——服務 GPU 時間損失最大的任務——是鏈路上的優先權。排程器也可以對 GPU 施加優先權:大任務可以搶占小任務以取得連續的形狀,代價是被搶占任務自上次檢查點以來的進度;HPN 說檢查點每二到四小時一次。這些論文沒有報告營運者多常選擇搶占而非等待,所以把這個權衡當作政策問題,而不是已有定論的結果。

Animation 11.3 plays fragmentation in two segments and the three ways out: wait, split, or move a running job.

動畫 11.3 在兩個 segment 中演出碎片化,以及三條出路:等待、拆開,或搬動正在跑的任務。

Animation 11.3動畫 11.3

Fragmentation: free blocks that no job can use碎片化:沒有任務用得上的空格

An invented arrival sequence on two segments, drawn in blocks of 16 hosts as in Figure 11.1. Real clusters run tens of jobs, but the exits are the same three: queue, accept a placement that crosses the aggregation layer, or stop a running job and restart it elsewhere, which costs its progress since the last checkpoint (every two to four hours at HPN). How often operators choose each exit is not reported.

虛構的到達順序,畫在兩個 segment 上,每格 16 台主機,與圖 11.1 相同。真實叢集同時跑數十個任務,但出路一樣是這三條:排隊、接受跨越聚合層的配置,或停下一個正在跑的任務並在別處重啟,代價是它上次 checkpoint 之後的進度(HPN 每兩到四小時一次)。營運者多常選擇哪一條,論文沒有報告。

11.4Operating a shared network營運一個共用的網路

A shared fabric is never finished: jobs come and go, hosts fail, switches are upgraded, and a new GPU generation arrives every two years. The operators converge on three practices: per-job telemetry that attributes a symptom to a tenant, verification of the physical build before any end-to-end test, and change management that assumes upgrades break things.

共享的網路永遠沒有完工的一天:任務來來去去、主機故障、交換器升級,每兩年又有新一代 GPU 到來。營運者在三個做法上趨於一致:把症狀歸到租戶的逐任務遙測、任何端到端測試之前先驗證實體建置、以及假設升級會弄壞東西的變更管理。

Telemetry that names the job能指出是哪個任務的遙測

Signal訊號Threshold or form門檻或形式What it catches抓到什麼Source出處
RDMA traffic counters in the node heartbeat節點心跳中的 RDMA 流量計數器Sudden drop alerts; full stop triggers recovery突然下降發警報;完全停止觸發恢復A hung rank or a flapping NIC, attributed to the job卡住的 rank 或抖動的 NIC,歸到該任務MegaScale §4
PFC watchdogPFC watchdog200 msA port paused too long, which names the paused tenant暫停過久的埠,指出被暫停的租戶Meta RoCE §6; Microsoft used 100 and 200 msMeta RoCE §6;Microsoft 用 100 與 200 ms
Buffer alarm緩衝警報80%A spine buffer about to pause or drop即將暫停或丟包的 spine 緩衝Meta RoCE §6
Out-of-sequence packets, ACK timeouts, link flaps亂序封包、ACK 逾時、鏈路抖動NIC countersNIC 計數器Loss, reordering, marginal links丟包、亂序、邊緣狀態的鏈路Meta RoCE §6
CUDA-event timing per rank逐 rank 的 CUDA 事件計時Heat map of step times步時間的熱圖The 0.5% of machines slow enough to pace the job慢到決定任務節奏的那 0.5% 機器MegaScale §5
INT probesINT 探測封包Switch and port ID at each hop vs. blueprint每跳的交換器與埠 ID 對照藍圖Miswired rails and planes, before any end-to-end testrail 與 plane 接錯,在任何端到端測試之前HPN §10
Reachability pings可達性 pingPeriodic, between all hosts所有主機之間定期執行Routes that silently disappeared悄悄消失的路由Meta RoCE §6

In a shared fabric every counter must be attributed. The scheduler knows which GPUs, and therefore which NICs and ToR ports, belong to each job, so NIC counters map to tenants, a PFC watchdog names the tenant being paused, and a buffer alarm names the switch about to drop or pause. The CUDA-event monitor catches the slow tenant rather than the slow link: removing the 0.5% of slow machines it found made MegaScale's peak MFU consistent from run to run. Monitoring is also what caught Meta's CTSW software upgrade that raised port-to-port latency and silently slowed training.

在共享網路中每個計數器都必須有歸屬。排程器知道哪些 GPU、因而哪些 NIC 與 ToR 埠屬於每個任務,所以 NIC 計數器對應到租戶,PFC watchdog 指出被暫停的租戶,緩衝警報則指出即將丟包或暫停的交換器。CUDA 事件監控器抓的是慢的租戶而不是慢的鏈路:移除它找到的 0.5% 慢機器後,MegaScale 的峰值 MFU 在各次運行間變得一致。也是監控抓到了 Meta 那次提高埠對埠延遲、悄悄拖慢訓練的 CTSW 軟體升級。

Panel 11.4 shows why a small share of slow machines paces almost every large job, and how many spare machines it takes to swap them out.

面板 11.4 說明為什麼一小部分慢機器幾乎決定每個大任務的節奏,以及要多少備用機才能把它們換掉。

Panel 11.4面板 11.4

How often a job holds a slow machine任務裡有慢機器的機率

Machines in the job
任務的機器數
Expected slow machines
預期的慢機器數
Chance of at least one
至少一台的機率
Spares to swap them all
全部換掉所需的備用機

The model assumes that each machine of 8 GPUs is slow with the same probability, independently of the others, and a synchronous job runs at the pace of its slowest rank. The default share, 0.5%, is what MegaScale's CUDA-event monitor found; MegaScale measured those machines about 10% slower and regained about 0.7 MFU points by removing them. The default job, 12,288 GPUs, is MegaScale's largest run. The spare count is the smallest number that covers every slow machine in the job with the chosen probability (binomial distribution). Compare a 1,024-GPU segment with the full job.

這個模型假設每台 8 顆 GPU 的機器以相同機率變慢、彼此獨立,而同步任務以最慢 rank 的節奏運行。預設比例 0.5% 是 MegaScale 的 CUDA 事件監控器找到的;MegaScale 量到那些機器慢約 10%,移除後拿回約 0.7 個 MFU 百分點。預設任務 12,288 顆 GPU 是 MegaScale 最大的運行。備用數是以所選機率涵蓋任務中所有慢機器的最小數量(二項分布)。比較一個 1,024 顆 GPU 的 segment 與整個任務。

Animation 11.4 shows one slow machine pacing a synchronous job, and a spare that replaces it.

動畫 11.4 呈現一台慢機器如何拖慢同步任務,以及備用機如何替換它。

Animation 11.4動畫 11.4

One slow machine paces the job; a spare replaces it一台慢機器拖住整個任務;備用機替換它

A sketch of 8 machines and one spare. The 10% slowdown is what MegaScale measured on the slow machines it removed. The compute and all-reduce lengths are illustrative, and the swap is drawn as instant. The spare sits in the same segment, as HPN's backup hosts do, so the job keeps its placement.

8 台機器加一台備用機的示意。慢 10% 是 MegaScale 在它移除的慢機器上量到的。計算與 all-reduce 的長度只是示意,替換畫成瞬間完成。備用機和 HPN 的備用主機一樣位於同一個 segment,所以任務的配置不變。

Verify the wiring, then stage the change先驗證接線,再分階段改動

HPN's rail-optimized plus dual-plane design means thousands of cables with exact required endpoints, and on-site staff made many mistakes in the early builds. The team now sends in-band network telemetry (INT) probes that record the switch ID and port ID at every hop and compares them against the blueprint before any end-to-end test. A miswired rail does not fail; it silently turns a one-switch path into a three-switch path, a symptom a shared fabric hides among other jobs' noise. Figure 11.8 shows one miswired cable.

HPN 的 rail-optimized 加 dual-plane 設計表示數千條線纜都有精確要求的兩端,早期建置時現場人員犯了很多錯。團隊現在在任何端到端測試之前,先送出帶內網路遙測(INT)探測封包,記錄每一跳的交換器 ID 與埠 ID,並與藍圖比對。接錯的 rail 不會失效;它悄悄把一跳交換器的路徑變成三跳,是共享網路會藏在其他任務雜訊中的症狀。圖 11.8 畫出一條接錯的線。

aggregation聚合層ToR 0G0host 1主機 1G0host 2主機 2ToR 1G1host 1主機 1G1host 2主機 2ToR 2G2host 1主機 1G2host 2主機 2ToR 3G3host 1主機 1G3host 2主機 2miswired接錯blueprint: G3 → ToR 3 → G3 · 1 switch藍圖:G3 → ToR 3 → G3 · 1 台交換器INT probe saw: ToR 3 → agg → ToR 2 · 3 switchesINT 探測記到:ToR 3 → 聚合層 → ToR 2 · 3 台交換器
Figure 11.8. A miswired rail, one plane shown, with each GPU drawn under the ToR of its rail. GPU kk of every host should reach ToR kk, so same-rail traffic crosses one switch. Here host 2's GPU 3 is plugged into ToR 2 instead, and although nothing fails, traffic between the two GPU 3s now crosses three switches (red path). An INT probe records the switch IDs on its path, and a comparison with the blueprint (green link) finds the error before any end-to-end test.圖 11.8。一條接錯的 rail,只畫一個 plane,每顆 GPU 畫在它那條 rail 的 ToR 下方。每台主機的 GPU kk 應該接到 ToR kk,所以同 rail 流量只跨一台交換器。這裡主機 2 的 GPU 3 卻插到 ToR 2,雖然沒有東西失效,兩個 GPU 3 之間的流量現在卻要跨三台交換器(紅色路徑)。INT 探測封包記錄路徑上的交換器 ID,與藍圖(綠色連線)比對,就能在任何端到端測試之前找出錯誤。Drawn for this primer from §10 of Qian et al., SIGCOMM 2024.

Upgrades are the other hazard. HPN found that 70% of its ToR upgrades did not meet the assumption behind in-service software upgrade, that old and new versions differ only slightly; the non-stacked dual-ToR exists partly so that one ToR can be upgraded while the other carries the host at 6.25% lower throughput (Section 6.5). Microsoft's RoCE rollout was staged: lab, test clusters, PFC on ToRs only, then a podset, then the spine; even so, a buffer threshold changed from 1/16 to 1/64 on a new switch model propagated PFC to thousands of servers until it was reverted. The rule is to change one tier at a time, with the monitoring watching, and with a way back.

升級是另一個風險。HPN 發現 70% 的 ToR 升級不符合不中斷服務升級背後的假設——新舊版本只有微小差異;非堆疊式 dual-ToR 存在的部分原因,就是讓一台 ToR 升級時另一台以低 6.25% 的吞吐撐住主機(第 6.5 節)。Microsoft 的 RoCE 部署是分階段的:實驗室、測試叢集、只在 ToR 開 PFC、然後一個 podset、然後 spine;即便如此,新交換器型號上一個從 1/16 改到 1/64 的緩衝門檻仍把 PFC 擴散到數千台伺服器,直到被回退。規則是:一次只改一層,讓監控盯著,並留一條退路。

Capacity planning across generations跨世代的容量規劃

The last operating problem is that the cluster outlives its design point. HPN sized a pod to one building, 18 MW, about 15,000 GPUs, so that every fiber stays under 100 m and can use multi-mode transceivers at 70% lower cost; the next generation is planned around 102.4 Tb/s chips, and new buildings have had their power budgets raised to match. How many GPUs one job may span at full rate is fixed by the switch radix and the building, and revisited only when a chip generation changes. The arithmetic for a two-tier pod is short: GPUs per segment=host-facing ports per ToR×ToRs per segment/NIC ports per GPU,\text{GPUs per segment} = \text{host-facing ports per ToR} \times \text{ToRs per segment} / \allowbreak \text{NIC ports per GPU,} which for HPN is 128×16/2=1,024128 \times 16 / 2 = 1{,}024; GPUs per pod=segments×that\text{GPUs per pod} = \text{segments} \times \text{that}; and the oversubscription toward the core decides how much of the pod one job may really use. When a model class changes the traffic, as mixture-of-experts does with all-to-all between experts on different rails, the placement rule has to be rewritten first.

最後一個營運問題是叢集活得比它的設計點更久。HPN 把一個 pod 定在一棟樓、18 MW、約 15,000 顆 GPU,讓每條光纖都低於 100 m、可以用便宜 70% 的多模光模組;下一代圍繞 102.4 Tb/s 晶片規劃,新建築的電力預算也已相應提高。一個任務可以全速橫跨多少顆 GPU,由交換器埠數與建築決定,只在晶片世代改變時重新檢視。兩層 pod 的算術很短:每個 segment 的 GPU 數=每台 ToR 面向主機的埠數×每個 segment 的 ToR 數/每顆 GPU 的 NIC 埠數,\text{每個 segment 的 GPU 數} = \text{每台 ToR 面向主機的埠數} \times \text{每個 segment 的 ToR 數} / \allowbreak \text{每顆 GPU 的 NIC 埠數,}HPN 是 128×16/2=1,024128 \times 16 / 2 = 1{,}024;每個 pod 的 GPU 數=segment 數×前者;\text{每個 pod 的 GPU 數} = \text{segment 數} \times \text{前者;}而朝核心層的超額認購決定單一任務真正能用多少個 pod。當某類模型改變流量——像混合專家在不同 rail 上的專家之間帶來 all-to-all——配置規則得先重寫。

Chapter summary
本章摘要

A training cluster is sized for its largest job but mostly runs many smaller ones: on HPN's pod, 96.3% of jobs use fewer than 1,000 GPUs. Jobs that share switches disturb one another through hash collisions, PFC pauses that cross job boundaries, and links shared unequally; Crux measured a GPT job 11% slower beside a BERT job. Placement is the strongest lever: the same job moves different bytes over the thin links depending on which GPUs it gets, and the three schedulers of this book all keep the heavy dimensions inside the full-bandwidth part of the network. Allocation units (racks, ToR pairs, TPU cubes) fragment a cluster, and every operator keeps spare hosts or uplinks. A shared network needs telemetry attributed to jobs, verified wiring and staged changes.

訓練叢集是依最大的任務設計的,但大部分時間跑的是許多較小的任務:在 HPN 的 pod 上,96.3% 的任務用不到 1,000 顆 GPU。共用交換器的任務會透過雜湊碰撞、跨越任務邊界的 PFC 暫停,以及不平均地共用鏈路而互相干擾;Crux 量到一個 GPT 任務在 BERT 任務旁慢了 11%。擺放是最強的槓桿:同一個任務拿到不同的 GPU,就會在細鏈路上搬不同的位元組;本書的三個排程器都把吃重的維度留在網路的滿頻寬部分。配置單位(機櫃、ToR 對、TPU cube)讓叢集碎片化,每個營運者都保留備用主機或上行。共用的網路需要歸屬到任務的遙測、經過驗證的接線,以及分階段的改動。

Where these ideas go next
這些概念接下來用在哪裡

Chapter 12 asks how designers predict all of this before the hardware exists: simple models, simulators, and how to check them against measurements.

第 12 章探討設計者如何在硬體存在之前預測這一切:簡單的模型、模擬器,以及如何用量測檢驗它們。

Guided readings for this chapter本章相關的論文導讀

Check your understanding檢驗你的理解