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

Failures and stragglers: the arithmetic of staying up故障與落後者:保持運轉的算術

Learn how often the parts of a large cluster fail, why one failure stops the whole job, how often to checkpoint, how recovery is automated, how network design makes failures cheaper, and why the slowest rank sets the pace even when nothing fails.了解大型叢集的零件多常故障、為何一次故障會讓整個任務停下、多久做一次檢查點、恢復如何自動化、網路設計如何讓故障的代價變小,以及為何即使沒有故障,最慢的 rank 仍決定節奏。

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

This chapter builds on Chapters 1, 4, 6, 9. These earlier terms appear most often below; each chip links to its definition.

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

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

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".

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

10.1What fails, and how often什麼會壞,多常壞

Mechanism. In the language of reliability engineering, every part of a synchronous training job is in series. The job works only if every GPU, every NIC, every link, every switch and every process works. A series system fails at the sum of its parts' failure rates. That is why the question is never "how reliable is one GPU" but "how many parts are there, and what is the sum". The Llama 3 paper gives the only public table of what actually stopped a 16K-GPU run (Llama 3 §3.3.4, Table 5). It is reproduced here with the paper's own counts and percentages.

機制。用可靠度工程的語言來說,同步訓練任務的每個零件都是串聯的。只有當每顆 GPU、每張 NIC、每條鏈路、每台交換器與每個行程都正常,任務才能運作。串聯系統的故障率是各零件故障率的總和。所以問題從來不是「一顆 GPU 多可靠」,而是「有多少零件,總和是多少」。Llama 3 論文給出了唯一公開的、關於什麼真的讓一次 16K GPU 運行停下來的表格(Llama 3 §3.3.4,Table 5)。這裡用論文自己的次數與百分比重現。

Component元件Category類別Count次數Published %論文百分比What it means for design對設計的意義
Faulty GPUGPU 故障GPU14830.1%The largest single row; about a third of all unexpected stops最大的單一項;約占所有非預期停機的三分之一
GPU HBM3 memoryGPU HBM3 記憶體GPU7217.2%The second largest row; about half the size of the first第二大項;約為第一項的一半
Software bug軟體錯誤Dependency依賴5412.9%One per day; the largest cause outside the GPU每天一次;GPU 以外最大的原因
Network switch / cable網路交換器 / 線纜Network網路358.4%The row that topology (dual-ToR, headroom) can shrink拓樸(dual-ToR、餘裕)能縮小的那一項
Host maintenance (unplanned)主機維護(非預期)Maintenance維護327.6%An operational cause, not a broken part營運上的原因,不是壞掉的零件
GPU SRAM memoryGPU SRAM 記憶體GPU194.5%On-chip memory; about a quarter of the HBM3 row晶片內記憶體;約為 HBM3 項的四分之一
GPU system processorGPU 系統處理器GPU174.1%The GPU's management controller, not its compute coresGPU 的管理控制器,不是計算核心
NICHost主機71.7%Rare; with HPN's dual-port NIC a NIC failure still removes a GPU少見;即使用 HPN 的雙埠 NIC,NIC 故障仍會拿掉一顆 GPU
NCCL watchdog timeoutsNCCL watchdog 逾時Unknown不明71.7%A hang that the watchdog ended; nobody learned why被 watchdog 結束的卡死;沒有人知道原因
Silent data corruption靜默資料損毀GPU61.4%Wrong numbers with no error; the hardest to detect (below)算錯卻沒有錯誤訊號;最難偵測(見下文)
GPU thermal interface + sensorGPU 熱介面 + 感測器GPU61.4%Heat as a hard stop; Section 10.6 has its soft form, the 1–2% diurnal swing熱造成的硬停機;第 10.6 節 有它的軟形式,每日 1–2% 的擺動
SSD / power supply / chassis / IO board / CPU / system memory / otherSSD / 電源 / 機箱 / IO 板 / CPU / 系統記憶體 / 其他Host主機163.9%Everything else in a server, together under 4%伺服器裡其他一切,合計不到 4%

How to read it. Three things to notice. First, the counts sum to 419, but the published percentages sum to about 95%. The paper's percentages are approximate; we quote them as printed. Second, GPU hardware dominates: the six GPU rows (faulty GPU, HBM3, SRAM, system processor, thermal, silent data corruption) are 58.7% as printed, and 64.0% by the counts (268 of 419). The first row shows the gap most clearly: 148 of 419 is 35.3%, not the printed 30.1%. Software bugs are 12.9%. Switches and cables are 8.4% and NICs 1.7%, so the network is about 10%. Third, 78% of the unexpected interruptions were confirmed or suspected hardware. The network is a minority cause of stops. But it is the cause that network design can change, and it is also the system that carries the checkpoint and the recovery traffic. Panel 10.1 lets you remove one group of rows and see how much the mean time between failures (MTBF, defined below) grows.

怎麼讀。注意三件事。第一,次數加起來是 419,但論文的百分比加起來約 95%。論文的百分比是近似值;我們照印刷原樣引用。第二,GPU 硬體占主導:六個 GPU 項目(GPU 故障、HBM3、SRAM、系統處理器、熱、靜默資料損毀)照印刷值合計 58.7%,依次數計算則是 64.0%(419 次中的 268 次)。第一項最能看出差距:419 次中的 148 次是 35.3%,而不是印出的 30.1%。軟體錯誤 12.9%。交換器與線纜 8.4%、NIC 1.7%,所以網路約 10%。第三,78% 的非預期中斷是確認或疑似的硬體問題。網路是停機的少數原因。但它是網路設計能改變的原因,也是承載檢查點與恢復流量的系統。面板 10.1 讓你拿掉一組項目,看平均故障間隔(MTBF,後面會定義)會增加多少。

Panel 10.1面板 10.1

Remove one cause from Table 5從 Table 5 拿掉一個原因

Interruptions per day
每天中斷數
Cluster MTBF MM
叢集 MTBF MM
MTBF gain
MTBF 增加
Share of stops removed
拿掉的停機比例

Model: a series system, so M=54×24 h÷(interruptions in 54 days)M = 54 \times 24\,\text{h} \div \text{(interruptions in 54 days)} The four groups are Table 5's counts: GPU rows 268, software bugs 54, network 42 (switches and cables 35, NICs 7), host, maintenance and unknown 55; they sum to 419. Every count scales in proportion to the GPU count, which assumes a fixed rate per GPU. Defaults: 16,384 GPUs and the network rows removed completely. The MTBF moves from 3.1 h to 3.4 h, about 11%, because the network is about 10% of the stops. Try: remove the GPU rows instead, then double the GPUs.

模型:串聯系統,所以 M=54×24 小時÷(54 天的中斷數)M = 54 \times 24\,\text{小時} \div \text{(54 天的中斷數)}。四組是 Table 5 的次數:GPU 項目 268、軟體錯誤 54、網路 42(交換器與線纜 35、NIC 7)、主機、維護與不明 55;合計 419。每個次數都與 GPU 數成正比,這假設每顆 GPU 的故障率固定。預設:16,384 顆 GPU,網路項目全部拿掉。MTBF 從 3.1 小時變成 3.4 小時,約 11%,因為網路約占停機的 10%。試試:改成拿掉 GPU 項目,然後把 GPU 加倍。

The network's own rates. HPN measured its fleet (HPN §2.2): 0.057% of NIC–ToR links and about 0.051% of ToR switches fail per month, and 5,000 to 60,000 link flaps happen every day across the fleet. A flap is a link that goes down and comes back within seconds. The rates look small until you multiply. Take a 16,384-GPU cluster in the Llama 3 style: 2,048 hosts of 8 GPUs, one 400G NIC per GPU, 16 GPUs under each rack switch. That is 16,384 NIC–ToR links and 1,024 ToRs. The expected failures per month, with Llama 3's observed count beside them:

網路自己的故障率。HPN 量測了自家機群(HPN §2.2):每月有 0.057% 的 NIC–ToR 鏈路與約 0.051% 的 ToR 交換器故障,整個機群每天發生 5,000 到 60,000 次鏈路抖動(flap)。抖動是鏈路斷掉、在數秒內又恢復。這些比率看起來很小,直到你乘起來。取一個 Llama 3 風格的 16,384 顆 GPU 叢集:2,048 台 8 GPU 主機、每顆 GPU 一張 400G NIC、每台機櫃交換器下 16 顆 GPU。那就是 16,384 條 NIC–ToR 鏈路與 1,024 台 ToR。每月的期望故障數如下,旁邊附上 Llama 3 觀察到的次數:

Question問題Calculation算式Result結果
Expected link failures per month (HPN rate, 16,384 links)每月期望鏈路故障數(HPN 比率、16,384 條鏈路)16,384×0.0005716{,}384 \times 0.00057≈9.3\approx 9.3
Expected ToR failures per month (HPN rate, 1,024 ToRs)每月期望 ToR 故障數(HPN 比率、1,024 台 ToR)1,024×0.000511{,}024 \times 0.00051≈0.52\approx 0.52
Llama 3's switch-and-cable interruptions per 30-day month (35 in 54 days)Llama 3 每 30 天的交換器與線纜中斷(54 天 35 次)35×30÷5435 \times 30 \div 54≈19\approx 19

Llama 3's 19 per month came from a different fleet with different parts, yet it agrees with HPN's 9.3 link failures within a factor of two. For failure statistics from two operators, that is close agreement.

Llama 3 的每月 19 次來自另一個機群、不同的零件,卻與 HPN 的每月 9.3 次鏈路故障在兩倍之內吻合。對兩家營運者的故障統計而言,這算是很接近。

Google's TPU v4 fleet gives per-part rates of the same kind, measured over about two years in production: on average 0.08% of machines, 0.005% of ICI cables and 0.04% of OCSes fail per day (TPU v4 resiliency, NSDI 2024; Figure 10.1).

Google 的 TPU v4 機群給出同類的逐零件故障率,在正式環境量測了約兩年:平均每天有 0.08% 的機器、0.005% 的 ICI 線纜與 0.04% 的 OCS 故障(TPU v4 韌性,NSDI 2024;圖 10.1)。

Three line charts over 100 weeks of the average daily failure rate in percent of TPU machines, ICI links and OCSes
Figure 10.1. From Figure 12 of the TPU v4 resiliency paper: weekly averages of the daily failure rate of TPU machines, ICI links and OCSes in one production supercomputer over about two years (measured). Machines fail most often per unit, and the rates swing by a factor of three or more from week to week.圖 10.1。取自 TPU v4 韌性論文的圖 12:一座正式環境超級電腦約兩年間 TPU 機器、ICI 鏈路與 OCS 每日故障率的每週平均(實測)。以單一元件而言,機器最常故障;每週之間的故障率可以相差三倍以上。Zu et al., NSDI 2024, Figure 12.

Cluster MTBF. For a system that stops when any part fails, failure rates add. If part type ii has rate λi\lambda_i per unit time and there are nin_i of them, the cluster's rate Λ\Lambda and its mean time between failures (MTBF) MM are

叢集 MTBF。對一個任何零件故障就會停的系統,故障率相加。若第 ii 種零件每單位時間的故障率是 λi\lambda_i、數量是 nin_i,叢集的故障率 Λ\Lambda 與平均故障間隔(MTBF)MM 是

Λ=∑iλini,M=1Λ \Lambda = \sum_i \lambda_i n_i, \qquad M = \frac{1}{\Lambda}

This treats failures as independent and memoryless. It is a first-order model, and the data is not better than first order. A worked example with the numbers above, per month of 30 days, one term per row:

這把故障視為獨立且無記憶。這是一階模型,而資料也不比一階更好。用上面的數字做一個 30 天月份的例子,每列一項:

Question問題Calculation算式Result結果
GPU-related events per month at Llama's rate (58.7% of 419, scaled from 54 to 30 days)每月 GPU 相關事件,以 Llama 的比率(419 的 58.7%,從 54 天換算到 30 天)0.587×419×30÷540.587 \times 419 \times 30 \div 54≈137\approx 137
Cluster rate Λ\Lambda per month: GPUs + links + ToRs + software bugs at one per day每月叢集故障率 Λ\Lambda:GPU + 鏈路 + ToR + 每天一次的軟體錯誤137+9.3+0.5+30137 + 9.3 + 0.5 + 30≈177\approx 177about 5.9 per day約每天 5.9 次
Cluster MTBF MM, with 720 hours in the month叢集 MTBF MM,一個月 720 小時720÷177720 \div 177≈4.1\approx 4.1 h小時
Llama's full count per day (every row of Table 5)Llama 的完整數字,每天(Table 5 的全部項目)419÷54419 \div 54≈7.8\approx 7.8
Llama's MTBFLlama 的 MTBF54×24÷41954 \times 24 \div 419≈3.1\approx 3.1 h小時

The four terms give an MTBF of about 4.1 h (Figure 10.2). Add the host, NIC, maintenance and unknown rows and you reach Llama's full count: 419 in 54 days, 7.8 per day, an MTBF of 3.1 h. Panel 10.3 lets you move every term, and it shows that the GPU term dominates the sum at every scale: doubling the GPUs halves MM, whatever the network does.

這四項給出約 4.1 小時的 MTBF(圖 10.2)。再加上主機、NIC、維護與不明的項目,你就到達 Llama 的完整數字:54 天 419 次、每天 7.8 次,MTBF 3.1 小時。面板 10.3 讓你移動每一項,並顯示在任何規模下 GPU 項都主導總和:GPU 加倍,MM 就減半,不管網路做什麼。

GPU× 16,384link鏈路× 16,384ToR× 1,024software軟體1 bug per day每天 1 個錯誤the job runs only if every part works: rates add每個零件都正常任務才能運作:故障率相加failures per 30-day month每 30 天月份的故障數GPU 137software 30軟體 30links 9.3鏈路 9.3ToR 0.5Λ ≈ 137 + 9.3 + 0.5 + 30 ≈ 177 per month → M ≈ 720 h ÷ 177 ≈ 4.1 hΛ ≈ 137 + 9.3 + 0.5 + 30 ≈ 每月 177 次 → M ≈ 720 小時 ÷ 177 ≈ 4.1 小時
Figure 10.2. The cluster as a series system. The job runs only while every part works, so the failure rates of all parts add. The bar is the worked example above: GPUs give 137 of the 177 failures per month, software 30, links 9.3 and ToRs 0.5. The network terms are the thin slices in the middle.圖 10.2。叢集是一個串聯系統。只有每個零件都正常時任務才能運作,所以所有零件的故障率相加。長條就是上面的算例:每月 177 次故障中 GPU 占 137、軟體 30、鏈路 9.3、ToR 0.5。網路的項目是中間那幾條細片。Drawn for this primer from the worked example in this section (Llama 3 Table 5 and HPN §2.2 rates).

Silent data corruption. Silent data corruption (SDC) deserves its own paragraph even at 1.4%. Every other row announces itself: a GPU raises an error, a link goes down, a process dies, a collective times out. An SDC-affected GPU computes a wrong number and reports success. The job keeps training on bad gradients. Detection needs a check that the hardware does not give: a loss that moves in an unexpected way, a disagreement between duplicated computations, or a checksum over exchanged tensors. By the time it is caught, the work since the corruption began may be unusable. The loss is then not half a checkpoint interval but many intervals, and the operator must find the last clean checkpoint, which only exists if old checkpoints are kept.

靜默資料損毀。靜默資料損毀(SDC)即使只占 1.4%,也值得單獨一段。其他每一項都會自我宣告:GPU 拋出錯誤、鏈路斷掉、行程死亡、集體通訊逾時。受 SDC 影響的 GPU 算出錯誤的數字,卻回報成功。任務繼續用壞掉的梯度訓練。偵測需要硬體不提供的檢查:以不尋常方式移動的 loss、重複計算之間的不一致,或交換張量上的校驗和。等到被抓到時,從損毀開始以來的工作可能都不能用。那時損失的不是半個檢查點間隔,而是許多個間隔,而且營運者必須找出最後一個乾淨的檢查點,而那只有在保留舊檢查點時才存在。

10.2Why one failure stops everything為何一次故障就讓一切停下

Synchronous SGD is a barrier. In every step, each rank computes a gradient on its own micro-batch. Then all ranks combine their gradients with an all-reduce, or with a reduce-scatter followed by an all-gather. Then every rank applies the same update. The all-reduce is the barrier. It cannot produce a result without a contribution from every rank, because the sum is not defined until the last term arrives. If one rank is missing, every other rank blocks inside the collective and does no work (Figure 10.3). Nothing in the algorithm distinguishes "rank 4,311 is dead" from "rank 4,311 is slow". After a fixed time the NCCL watchdog declares a timeout and the process group aborts. PyTorch's default timeout for NCCL is 10 minutes. Llama 3's Table 5 lists seven interruptions as "NCCL watchdog timeouts" with unknown cause: a hang that the watchdog ended, and nobody learned why.

同步 SGD 是一道 barrier。每一步,每個 rank 在自己的 micro-batch 上計算梯度。然後所有 rank 用 all-reduce,或用 reduce-scatter 再接 all-gather,把梯度合併。然後每個 rank 套用同一個更新。all-reduce 就是那道 barrier。沒有每個 rank 的貢獻它就無法產生結果,因為在最後一項到達之前總和沒有定義。若一個 rank 缺席,其他每個 rank 都卡在集體通訊裡、什麼事也做不了(圖 10.3)。演算法裡沒有任何東西能區分「rank 4,311 死了」與「rank 4,311 很慢」。經過固定時間後,NCCL watchdog 宣告逾時,行程群組中止。PyTorch 對 NCCL 的預設逾時是 10 分鐘。Llama 3 的 Table 5 把七次中斷列為原因不明的「NCCL watchdog 逾時」:一次被 watchdog 結束的卡死,沒有人知道為什麼。

all-reduce startsall-reduce 開始watchdog fireswatchdog 觸發rank 0rank 1rank 2rank 3✕ dead✕ 死掉rank 4rank 5compute計算blocked inside the all-reduce卡在 all-reduce 裡,沒有進度abort中止D = watchdog timeout: 10 min, no progressD = watchdog 逾時:10 分鐘沒有進度time時間
Figure 10.3. One dead rank blocks the whole step. Rank 3 dies during its compute. The other ranks finish and enter the all-reduce, which cannot complete without rank 3's term, so they wait and do no work. Only the NCCL watchdog ends the wait: after its timeout (10 minutes by default in PyTorch) it aborts the process group on every rank. With a watchdog alone, detection DD is that timeout.圖 10.3。一個死掉的 rank 擋住整一步。Rank 3 在計算時死掉。其他 rank 算完並進入 all-reduce,而沒有 rank 3 的那一項它就無法完成,所以它們等待、什麼工作也沒做。只有 NCCL watchdog 會結束等待:逾時之後(PyTorch 預設 10 分鐘)它在每個 rank 上中止行程群組。只靠 watchdog 時,偵測 DD 就是這個逾時。Drawn for this primer.

Effective training time is the share of wall-clock time in which the job makes progress that it keeps. Three terms reduce it on every failure (Figure 10.4). (1) Detection DD: from the fault to the moment the system knows and acts. With a watchdog alone, DD is the timeout, 10 minutes. MegaScale's heartbeat cut detection plus diagnosis to under 10 minutes on average, and that figure includes running the diagnostics (MegaScale §4). (2) Restart RR: tear down the processes, allocate a replacement node, re-initialize the collective groups, load the checkpoint, and warm up. Initialization is a hidden multiplier. Megatron-LM's default initialization took 1,047 s on 2,048 GPUs, because workers registered through a single-threaded blocking store and then ran a global barrier whose cost grew with the square of the worker count. MegaScale brought it under 5 s on 2,048 GPUs and under 30 s on more than 10,000. Every one of their more than 100 restarts paid this cost once; at the old value it would have cost 29 hours in total. (3) Lost work WW: the computation since the last checkpoint, which must be redone. If failures are not correlated with the checkpoint clock, WW averages half the interval, τ/2\tau/2. A fourth term applies even with no failure: the checkpoint cost CC, paid once per interval τ\tau.

有效訓練時間是任務在其中取得並保留進度的牆上時鐘時間比例。每一次故障有三項會減少它(圖 10.4)。(1) 偵測 DD:從故障發生到系統得知並採取行動。只靠 watchdog 時,DD 就是逾時時間,10 分鐘。MegaScale 的心跳把偵測加診斷縮到平均低於 10 分鐘,而這個數字包含執行診斷(MegaScale §4)。(2) 重啟 RR:關掉行程、分配替換節點、重新初始化集體通訊群組、載入檢查點、暖機。初始化是一個隱藏的乘數。Megatron-LM 的預設初始化在 2,048 顆 GPU 上花 1,047 秒,因為 worker 透過單執行緒的阻塞式儲存註冊,然後執行一個成本隨 worker 數平方成長的全域 barrier。MegaScale 把它壓到 2,048 顆 GPU 低於 5 秒、超過 10,000 顆低於 30 秒。他們超過 100 次重啟的每一次都付了這個成本一次;以舊的數值算,總共會花掉 29 小時。(3) 損失的工作 WW:自最後一個檢查點以來的計算,必須重做。若故障與檢查點的時鐘不相關,WW 平均是半個間隔,τ/2\tau/2。第四項即使沒有故障也要付:檢查點成本 CC,每個間隔 τ\tau 付一次。

useful work有效工作useful work有效工作work工作DRredo W重做 Wuseful work有效工作CC✕ failure✕ 故障checkpoint cost C檢查點成本 Cdetect偵測lost work ≈ τ/2損失工作 ≈ τ/2restart + init重啟 + 初始化interval τ間隔 τwall-clock lost per failure = D + R + W; per interval = C每次故障損失的牆上時鐘時間 = D + R + W;每個間隔 = C
Figure 10.4. Anatomy of one interruption. Blue is work the job keeps. Purple is the checkpoint pause CC, paid every τ\tau. After a failure the job pays detection DD, restart RR (including collective initialization and checkpoint load), and then redoes the work WW since the last checkpoint, on average τ/2\tau/2.圖 10.4。一次中斷的解剖。藍色是任務保留下來的工作。紫色是每 τ\tau 付一次的檢查點暫停 CC。故障之後,任務付出偵測 DD、重啟 RR(含集體通訊初始化與載入檢查點),然後重做自最後一個檢查點以來的工作 WW,平均為 τ/2\tau/2。Drawn for this primer.

Animation 10.1 plays one interruption, from the fault to the moment the job is back where it was.

動畫 10.1 播放一次中斷:從故障發生,到任務回到原本的進度為止。

Animation 10.1動畫 10.1

One dead rank, one interruption一個 rank 死掉,一次中斷

Four ranks stand in for thousands, and the step numbers are an example. Detection relies on the watchdog alone, so DD is PyTorch's 10-minute default. RR puts together the restart, the replacement node, collective initialization and the checkpoint load. The lost work WW is everything since the last checkpoint; on average it is τ/2\tau/2. The colours follow Figure 10.4.

四個 rank 代表成千上萬個,步數只是舉例。偵測只靠 watchdog,所以 DD 是 PyTorch 預設的 10 分鐘。RR 把重啟、替換節點、集體通訊初始化與載入檢查點合在一起。損失的工作 WW 是自最後一個檢查點以來的全部工作,平均為 τ/2\tau/2。顏色與圖 10.4 相同。

The accounting. Put the terms together for one interval of useful work τ\tau, valid while all terms are small compared with MM:

算帳。把這些項放在一個有效工作間隔 τ\tau 裡,在所有項都遠小於 MM 時成立:

overhead≈Cτ+τ/2+D+RMeffective time≈1−overhead \begin{gathered} \text{overhead} \approx \frac{C}{\tau} + \frac{\tau/2 + D + R}{M} \\[6pt] \text{effective time} \approx 1 - \text{overhead} \end{gathered}
開銷≈Cτ+τ/2+D+RM有效時間≈1−開銷 \begin{gathered} \text{開銷} \approx \frac{C}{\tau} + \frac{\tau/2 + D + R}{M} \\[6pt] \text{有效時間} \approx 1 - \text{開銷} \end{gathered}

A worked example from Llama 3: 466 interruptions in 54 days, effective time above 90%. The budget that implies:

用 Llama 3 做一個例子:54 天內 466 次中斷,有效時間高於 90%。這隱含的預算是:

Question問題Calculation算式Result結果
Most lost time that 90% effective time allows in 54 days54 天內 90% 有效時間所允許的最多損失時間10%×54×1,44010\% \times 54 \times 1{,}4407,7767{,}776 min分鐘5.4 days5.4 天
Average cost per interruption, detection, restart and lost work together每次中斷的平均代價,偵測、重啟與損失的工作合計7,776÷4667{,}776 \div 466≈16.7\approx 16.7 min分鐘

So each interruption cost under 16.7 minutes on average. That one inequality tells you two things without any further data: their checkpoints were much closer together than two hours, and their restart was fast. The failure rate sets the budget; the budget sets the engineering. Panel 10.2 adds up D+R+τ/2D + R + \tau/2 for one interruption and compares the sum with this budget.

所以每次中斷平均花費低於 16.7 分鐘。這一個不等式不需要其他資料就告訴你兩件事:他們的檢查點彼此遠比兩小時更近,而且重啟很快。故障率決定預算;預算決定工程。面板 10.2 把一次中斷的 D+R+τ/2D + R + \tau/2 加起來,並與這個預算比較。

Panel 10.2面板 10.2

What one interruption costs一次中斷的代價

Cost of one interruption
一次中斷的代價
Against the 16.7-min budget
對照 16.7 分鐘預算
Lost over 466 interruptions
466 次中斷的損失
Initialization over 100 restarts
100 次重啟的初始化

Model: cost of one interruption =D+R+τ/2= D + R + \tau/2, where RR counts only collective initialization; allocation, checkpoint load and warm-up would add to it. Lost time is 466 times the cost, compared with the 54 days of Llama 3. The figures come from different systems, so this is a what-if, not a model of Llama 3. Defaults: D=10D = 10 min, PyTorch's NCCL watchdog timeout, as if detection relied on the watchdog alone; R=1,047R = 1{,}047 s, Megatron-LM's default initialization on 2,048 GPUs (MegaScale); τ=15\tau = 15 min, near the best checkpoint interval of Section 10.3. The budget is Section 10.2's 7,776÷466≈16.77{,}776 \div 466 \approx 16.7 min. The last tile reproduces Section 10.2's 29 hours for 100 restarts at 1,047 s. Try: choose 5 s, then lower DD until the cost fits the budget.

模型:一次中斷的代價 =D+R+τ/2= D + R + \tau/2,其中 RR 只計集體通訊初始化;分配節點、載入檢查點與暖機還會再加上去。損失時間是代價的 466 倍,與 Llama 3 的 54 天比較。這些數字來自不同系統,所以這是假設情境,不是 Llama 3 的模型。預設:D=10D = 10 分鐘,PyTorch 的 NCCL watchdog 逾時,等於只靠 watchdog 偵測;R=1,047R = 1{,}047 秒,Megatron-LM 在 2,048 顆 GPU 上的預設初始化(MegaScale);τ=15\tau = 15 分鐘,接近 第 10.3 節 的最佳檢查點間隔。預算是 第 10.2 節 的 7,776÷466≈16.77{,}776 \div 466 \approx 16.7 分鐘。最後一格重現 第 10.2 節 中 1,047 秒、100 次重啟共 29 小時的數字。試試:選 5 秒,再把 DD 調低到代價落入預算。

10.3Checkpoint arithmetic檢查點的算術

The derivation. This is the Young–Daly result (Young 1974, Daly 2006), and it is short enough to carry in your head. Let the job checkpoint after every τ\tau of useful work, at a cost CC. Let failures arrive at random with mean spacing MM. Per interval, the overhead from checkpointing is C/τC/\tau of the useful time. Per interval, the chance of a failure is about τ/M\tau/M when CC is small compared with τ\tau, and a failure wastes τ/2\tau/2 on average. So the overhead fraction is

推導。這是 Young–Daly 的結果(Young 1974、Daly 2006),短到可以記在腦子裡。讓任務每做 τ\tau 的有效工作就存一次檢查點,成本 CC。讓故障隨機到來,平均間隔 MM。每個間隔中,檢查點的開銷是有效時間的 C/τC/\tau。每個間隔中,在 CC 遠小於 τ\tau 時故障的機會約為 τ/M\tau/M,而一次故障平均浪費 τ/2\tau/2。所以開銷比例是

f(τ)≈Cτ+τ2M f(\tau) \approx \frac{C}{\tau} + \frac{\tau}{2M}

Differentiate and set to zero: df/dτ=−C/τ2+1/(2M)=0df/d\tau = -C/\tau^2 + 1/(2M) = 0, which gives

微分並設為零:df/dτ=−C/τ2+1/(2M)=0df/d\tau = -C/\tau^2 + 1/(2M) = 0,得到

τ∗=2CM \tau^* = \sqrt{2CM}

Substitute back: f(τ∗)=2C/Mf(\tau^*) = \sqrt{2C/M}. Two consequences follow. The minimum overhead depends only on the ratio C/MC/M of checkpoint cost to failure spacing. And halving CC, or doubling MM, cuts the minimum overhead by 2\sqrt{2}, not by 2. The restart terms D+RD + R add a constant (D+R)/M(D + R)/M that no choice of τ\tau can change. Figure 10.5 draws the two terms and their sum.

代回去:f(τ∗)=2C/Mf(\tau^*) = \sqrt{2C/M}。兩個結論隨之而來。最小開銷只取決於檢查點成本與故障間隔的比值 C/MC/M。而 CC 減半或 MM 加倍,最小開銷只減少 2\sqrt{2} 倍,不是 2 倍。重啟項 D+RD + R 加上一個常數 (D+R)/M(D + R)/M,任何 τ\tau 的選擇都改變不了它。圖 10.5 畫出這兩項與它們的總和。

HPN 2–4 hHPN 2–4 小時0%10%20%30%40%50%5 min5 分15301 h1 小時2 h2 小時4 h4 小時checkpoint interval τ (log scale)檢查點間隔 τ(對數刻度)overhead f(τ)開銷 f(τ)M = 4 hM = 4 小時C/τ, C = 30 sC/τ,C = 30 秒τ/(2M)sum, C = 30 s總和,C = 30 秒sum, C = 300 s總和,C = 300 秒min 6.5% @ 15.5 min最小 6.5%,15.5 分min 20.4% @ 49 min最小 20.4%,49 分
Figure 10.5. The Young–Daly trade-off at M=4M = 4 h. The checkpoint term C/τC/\tau falls and the lost-work term τ/2M\tau/2M rises; their sum is smallest where the two terms are equal, at τ∗=2CM\tau^* = \sqrt{2CM}. With C=30C = 30 s the minimum is 6.5% at 15.5 min; with C=300C = 300 s it is 20.4% at 49 min. HPN's 2–4 h practice (shaded) is far up the right-hand branch.圖 10.5。M=4M = 4 小時下的 Young–Daly 取捨。檢查點項 C/τC/\tau 下降、損失工作項 τ/2M\tau/2M 上升;兩項相等之處總和最小,即 τ∗=2CM\tau^* = \sqrt{2CM}。C=30C = 30 秒時最小值是 15.5 分鐘處的 6.5%;C=300C = 300 秒時是 49 分鐘處的 20.4%。HPN 2–4 小時的做法(陰影)位在右側分支的高處。Drawn for this primer from the formula in this section (analysis, not measurement).

Animation 10.2 sweeps the checkpoint interval and shows where one mean time between failures goes.

動畫 10.2 掃過不同的檢查點間隔,顯示一個平均故障間隔的時間花到哪裡去。

Animation 10.2動畫 10.2

The checkpoint interval: saving against losing檢查點間隔:存檔與損失的取捨

In this analysis, the bar is one mean time between failures, M=4M = 4 h of wall-clock time, with the failure placed τ/2\tau/2 after the last checkpoint, its average position. The percentages come from this section's first-order formula f(τ)≈C/τ+τ/2Mf(\tau) \approx C/\tau + \tau/2M, which holds while C≪τ≪MC \ll \tau \ll M; the purple share of the bar is C/(τ+C)C/(\tau + C), a little less than C/τC/\tau. D+RD + R is left out, because it adds the same (D+R)/M(D + R)/M at every τ\tau. The two checkpoint costs are those of the worked example below.

在這個分析中,長條是一個平均故障間隔 M=4M = 4 小時的牆鐘時間,故障放在最後一個檢查點之後 τ/2\tau/2 處,也就是它的平均位置。百分比來自本節的一階公式 f(τ)≈C/τ+τ/2Mf(\tau) \approx C/\tau + \tau/2M,在 C≪τ≪MC \ll \tau \ll M 時成立;長條中紫色的比例是 C/(τ+C)C/(\tau + C),略小於 C/τC/\tau。D+RD + R 沒有畫進去,因為它在每個 τ\tau 都加上同樣的 (D+R)/M(D + R)/M。兩種檢查點成本取自下方的算例。

Worked example. Take M=4 h=14,400M = 4\,\text{h} = 14{,}400 s and compare two checkpoint costs: C=30C = 30 s, the pause of a two-stage copy to host memory, and C=300C = 300 s, a direct write of a few hundred terabytes to a distributed file system. Detection plus restart is D+R=10D + R = 10 min. The arithmetic, one question per row:

算例。取 M=4 小時=14,400M = 4\,\text{小時} = 14{,}400 秒,比較兩種檢查點成本:C=30C = 30 秒,兩階段複製到主機記憶體的暫停;以及 C=300C = 300 秒,直接把幾百 TB 寫進分散式檔案系統。偵測加重啟 D+R=10D + R = 10 分鐘。逐列計算如下:

Question問題Calculation算式Result結果
Best interval τ∗\tau^* at C=30C = 30 sC=30C = 30 秒時的最佳間隔 τ∗\tau^*2×30×14,400=864,000\sqrt{2 \times 30 \times 14{,}400} = \sqrt{864{,}000}≈930\approx 930 sabout 15.5 min約 15.5 分鐘
Minimum overhead f∗f^* at C=30C = 30 sC=30C = 30 秒時的最小開銷 f∗f^*60÷14,400\sqrt{60 \div 14{,}400}≈6.45%\approx 6.45\%
Restart term (D+R)/M(D + R)/M重啟項 (D+R)/M(D + R)/M600÷14,400600 \div 14{,}400≈4.17%\approx 4.17\%
Total overhead at C=30C = 30 sC=30C = 30 秒時的總開銷6.45%+4.17%6.45\% + 4.17\%≈10.6%\approx 10.6\%effective time ≈ 89%有效時間 ≈ 89%
Best interval τ∗\tau^* at C=300C = 300 sC=300C = 300 秒時的最佳間隔 τ∗\tau^*2×300×14,400\sqrt{2 \times 300 \times 14{,}400}≈2,940\approx 2{,}940 sabout 49 min約 49 分鐘
Minimum overhead f∗f^* at C=300C = 300 sC=300C = 300 秒時的最小開銷 f∗f^*600÷14,400\sqrt{600 \div 14{,}400}≈20.4%\approx 20.4\%
What a tenfold cheaper checkpoint does to f∗f^* and τ∗\tau^*便宜十倍的檢查點對 f∗f^* 與 τ∗\tau^* 的影響10\sqrt{10}≈3.2×\approx 3.2\timeslower overhead, shorter interval開銷更低、間隔更短

With the cheap checkpoint the job checkpoints every 15.5 minutes and keeps about 89% of its time; the expensive one stretches the best interval to 49 minutes and the minimum overhead to 20.4%. A tenfold cheaper checkpoint cuts the minimum overhead by about 3.2× and allows a 3.2× shorter interval. The checkpoint cost, not the failure rate, is the lever that an engineer controls.

便宜的檢查點讓任務每 15.5 分鐘存一次、保留約 89% 的時間;昂貴的則把最佳間隔拉長到 49 分鐘、最小開銷升到 20.4%。便宜十倍的檢查點把最小開銷減少約 3.2 倍,並允許短 3.2 倍的間隔。工程師能控制的槓桿是檢查點成本,不是故障率。

What HPN observed. HPN §2.2 reports that jobs checkpointed every 2 to 4 hours. With M≈4M \approx 4 h and τ=3\tau = 3 h, a failure loses τ/2=1.5\tau/2 = 1.5 h on average, which is 37% of the time between failures, before counting restart. That is why HPN's authors describe one ToR failure as destroying hours of GPU time, and why they treat reliability as a topology problem (Section 10.5 below). Long intervals come from a high CC: a full checkpoint of a 175B-parameter model written straight to a distributed file system takes minutes and hammers the storage with thousands of simultaneous writers. The formula says the fix is to make CC small, and the two systems below did exactly that.

HPN 觀察到的。HPN §2.2 報告任務每 2 到 4 小時存一次檢查點。用 M≈4M \approx 4 小時與 τ=3\tau = 3 小時,一次故障平均損失 τ/2=1.5\tau/2 = 1.5 小時,是故障間隔時間的 37%,還沒算重啟。這就是 HPN 作者把一次 ToR 故障描述成毀掉數小時 GPU 時間的原因,也是他們把可靠性當成拓樸問題處理的原因(下面 第 10.5 節)。長間隔來自高 CC:把 1,750 億參數模型的完整檢查點直接寫進分散式檔案系統要花數分鐘,而且數千個同時寫入者會把儲存打垮。公式說解法是把 CC 變小,而下面兩個系統正是這麼做。

Two-stage checkpoints. MegaScale's two-stage checkpoint separates the pause from the write. Stage one copies each GPU's state to pinned host memory over PCIe; the job pauses for seconds. Stage two writes from host memory to HDFS in the background while training continues. The CC in the Young–Daly formula is the pause, not the write. A size check: Llama 3's checkpoints are 1 MB to 4 GB per GPU depending on sharding. Take the largest:

兩階段檢查點。MegaScale 的兩階段檢查點把暫停與寫入分開。第一階段透過 PCIe 把每顆 GPU 的狀態複製到釘住的主機記憶體;任務暫停數秒。第二階段在訓練繼續的同時,在背景把主機記憶體寫到 HDFS。Young–Daly 公式裡的 CC 是暫停,不是寫入。檢查一下大小:Llama 3 的檢查點依分片方式每顆 GPU 從 1 MB 到 4 GB。取最大的:

Question問題Calculation算式Result結果
Copy 4 GB to host memory over a PCIe 5.0 x16 slot at about 64 GB/s透過約 64 GB/s 的 PCIe 5.0 x16 插槽把 4 GB 複製到主機記憶體4÷644 \div 64≈0.06\approx 0.06 swell under a second遠不到一秒
One checkpoint at 4 GB per GPU on 16,384 GPUs16,384 顆 GPU、每顆 4 GB 的一個檢查點16,384×4 GB16{,}384 \times 4\,\text{GB}≈65.5\approx 65.5 TB
Drain it at Tectonic's 7 TB/s peak (Llama 3 §3.3.1)以 Tectonic 的 7 TB/s 峰值排空(Llama 3 §3.3.1)65.5÷765.5 \div 7≈9.4\approx 9.4 s
Drain it at Tectonic's 2 TB/s sustained rate以 Tectonic 的 2 TB/s 持續速率排空65.5÷265.5 \div 2≈33\approx 33 s

The copy to host memory takes well under a second, so the seconds that MegaScale reports are software overhead, not bandwidth. The write is the storage system's problem: 65.5 TB per checkpoint, 9 s at Tectonic's peak and 33 s at its sustained rate. This is the bursty write that Llama's authors call a major challenge, and it is why the front-end network and the storage are sized for peaks, not averages (see Chapter 9). Recovery reads are made cheap in the same spirit: one reader per data-parallel group fetches the shard from HDFS and broadcasts it to the rest over the back-end network, so the file system serves tens of readers instead of thousands.

複製到主機記憶體遠不到一秒,所以 MegaScale 報告的「數秒」是軟體開銷,不是頻寬。寫入是儲存系統的問題:每個檢查點 65.5 TB,以 Tectonic 的峰值要 9 秒、持續速率要 33 秒。這就是 Llama 作者稱為主要挑戰的突發寫入,也是前端網路與儲存依峰值而非平均值定尺寸的原因(見第 9 章)。恢復時的讀取也以同樣精神變便宜:每個資料平行群組一個讀取者從 HDFS 抓取分片,再透過後端網路廣播給其他成員,所以檔案系統只服務數十個讀取者而非數千個。

ByteDance's later ByteCheckpoint system shows the same split in a measured trace of one save (ByteCheckpoint, NSDI 2025; Figure 10.6): the training loop waits only for planning and the device-to-host copies.

字節跳動後來的 ByteCheckpoint 系統,在一次儲存的實測紀錄中顯示同樣的分割(ByteCheckpoint,NSDI 2025;圖 10.6):訓練迴圈只等待規劃與裝置到主機的複製。

Gantt chart of save phases on rank 0 for model, optimizer, loader and extra state; bytecheckpoint.save() returns at a red dashed line after planning and device-to-host copies.
Figure 10.6. From Figure 12 of the ByteCheckpoint paper: the time breakdown of one checkpoint save on rank 0 (901 MB), from the system's own monitoring (measured). The training loop is blocked only until the red dashed line; serialization, dump and upload to storage run after save() has returned. The blocked part is the CC of the Young–Daly formula.圖 10.6。取自 ByteCheckpoint 論文的圖 12:rank 0 一次 checkpoint 儲存(901 MB)的各階段時間分解,取自系統自己的監控(實測)。訓練迴圈只被擋到紅色虛線為止;序列化、傾印與上傳到儲存系統都在 save() 返回之後才進行。被擋住的那一段就是 Young–Daly 公式裡的 CC。Screenshot of Wan et al., NSDI 2025, Figure 12.
Panel 10.3面板 10.3

Cluster MTBF and the checkpoint interval叢集 MTBF 與檢查點間隔

Interruptions per day
每天中斷數
Cluster MTBF MM
叢集 MTBF MM
Llama 3 reference
Llama 3 參考值
Young–Daly optimum
Young–Daly 最佳值
Effective time, your interval
你的間隔下的有效時間
Effective time, optimum
最佳間隔下的有效時間

Model: interruptions per day=GPUs×hardware rate÷365+links×link rate÷30+ToRs×ToR rate÷30+software\text{interruptions per day} = \text{GPUs} \times \text{hardware rate} \div 365 + \text{links} \times \text{link rate} \div 30 + \text{ToRs} \times \text{ToR rate} \div 30 + \text{software} one 400G link per GPU and 16 GPUs per ToR; M=24 h÷thatM = 24\,\text{h} \div \text{that}. Effective time=1−C/τ−(τ/2+D+R)/M\text{Effective time} = 1 - C/\tau - (\tau/2 + D + R)/M Defaults: 16,384 GPUs; 14.5% per GPU-year (Llama 3's hardware, maintenance and unknown rows of Table 5 work out to 13–15% depending on which rows you count); one software bug per day (54 in 54 days); HPN's link and ToR rates; C=30C = 30 s (two-stage copy); D+R=4.5D + R = 4.5 min. The total, 7.8 per day, matches Llama 3's 419÷54=7.76419 \div 54 = 7.76 per day, an MTBF of 3.1 h, and effective time at τ∗\tau^* lands at Llama's "above 90%". Try: drag τ\tau to 120 min (HPN's practice) and to 480; set CC to 300 s; double the GPUs.

模型:每天中斷數=GPU 數×硬體率÷365+鏈路數×鏈路率÷30+ToR 數×ToR 率÷30+軟體;\text{每天中斷數} = \text{GPU 數} \times \text{硬體率} \div 365 + \text{鏈路數} \times \text{鏈路率} \div 30 + \text{ToR 數} \times \text{ToR 率} \div 30 + \text{軟體;}每顆 GPU 一條 400G 鏈路、每台 ToR 16 顆 GPU;M=24 小時÷該值M = 24\,\text{小時} \div \text{該值}。有效時間=1−C/τ−(τ/2+D+R)/M\text{有效時間} = 1 - C/\tau - (\tau/2 + D + R)/M。預設:16,384 顆 GPU;每 GPU-年 14.5%(Llama 3 Table 5 的硬體、維護與不明項目依你計入哪些項約為 13–15%);每天一個軟體錯誤(54 天 54 次);HPN 的鏈路與 ToR 比率;C=30C = 30 秒(兩階段複製);D+R=4.5D + R = 4.5 分鐘。總和每天 7.8 次,與 Llama 3 的每天 419÷54=7.76419 \div 54 = 7.76 次吻合,MTBF 3.1 小時,而 τ∗\tau^* 下的有效時間落在 Llama 的「高於 90%」。試試:把 τ\tau 拉到 120 分鐘(HPN 的做法)與 480;把 CC 設為 300 秒;把 GPU 加倍。

Stop and think停下來想一想

At Llama's rate the Young–Daly minimum, 2C/M\sqrt{2C/M}, is about 7% for C=30C = 30 s. To stay above 90% in total, the constant term (D+R)/M(D + R)/M must be under 3%, so detection plus restart must average under about 5 minutes. Use Panel 10.3 to find the largest D+RD + R that still gives 90% at τ∗\tau^*, then raise CC to 120 s and see how much faster the restart must become to compensate. This is why MegaScale's initialization fix, 1,047 s to under 5 s, belongs in a reliability section.

在 Llama 的故障率下,Young–Daly 的最小值 2C/M\sqrt{2C/M} 在 C=30C = 30 秒時約為 7%。要讓總和保持在 90% 以上,常數項 (D+R)/M(D + R)/M 必須低於 3%,所以偵測加重啟平均必須低於約 5 分鐘。用面板 10.3 找出在 τ∗\tau^* 下仍能給 90% 的最大 D+RD + R,然後把 CC 提高到 120 秒,看重啟必須快多少才能補償。這就是 MegaScale 把初始化從 1,047 秒壓到 5 秒以下的修正為何屬於可靠性章節的原因。

10.4Automated recovery loops自動化恢復迴圈

Mechanism. MegaScale turns recovery into a workflow with no operator in it (MegaScale §4). A driver process requests resources from Kubernetes and starts one executor per node, which launches the training processes. Each executor runs a daemon that sends a heartbeat to the driver. The heartbeat carries the node's IP address and pod name, hardware information, the training process status, its stdout and stderr logs, and the RDMA traffic counters of its NICs. The counters are the key signal. Training traffic is periodic and regular: every step runs the same collectives in the same order (in a mixture-of-experts model the all-to-all destinations change from step to step, but the steps still repeat), so a sudden drop raises an alert and traffic that stops entirely triggers recovery automatically, before any process has reported an error. When the driver sees an anomaly, or no heartbeat at all, it suspends the job and runs a battery of diagnostics on the suspect nodes: an intra-host loopback test from every NIC to host memory and to the GPUs, a NIC-to-NIC connectivity and bandwidth test, an NCCL all-to-all within the node, and an NCCL all-reduce with the neighboring nodes under the same ToR. Each test isolates one layer (Figure 10.7), so a result of "loopback passes, NIC-to-NIC fails" points at the link rather than the host. Nodes that fail are evicted and replaced from a standby pool, and the job restarts from the last checkpoint.

機制。MegaScale 把恢復變成一個沒有營運人員在其中的工作流程(MegaScale §4)。一個 driver 行程向 Kubernetes 申請資源,並在每個節點啟動一個 executor,由它啟動訓練行程。每個 executor 跑一個 daemon,向 driver 送心跳。心跳帶著節點的 IP 位址與 pod 名稱、硬體資訊、訓練行程狀態、它的 stdout 與 stderr 日誌,以及其 NIC 的 RDMA 流量計數器。計數器是關鍵訊號。訓練流量是週期性且規律的:每一步都以相同順序執行相同的集體操作(混合專家模型的 all-to-all 目的地每步都不同,但步驟本身仍然重複),所以突然下降就發出警報,完全停止就自動觸發恢復,在任何行程回報錯誤之前。當 driver 看到異常,或完全收不到心跳,它暫停任務並對可疑節點執行一組診斷:每張 NIC 到主機記憶體與 GPU 的主機內迴路測試、NIC 對 NIC 的連通性與頻寬測試、節點內的 NCCL all-to-all,以及與同一 ToR 下鄰近節點的 NCCL all-reduce。每個測試隔離一層(圖 10.7),所以「迴路通過、NIC 對 NIC 失敗」的結果指向鏈路而不是主機。失敗的節點被逐出並從備用池替換,任務從最後的檢查點重啟。

one host一台主機GPUsGPUhost memory主機記憶體NICcable線纜ToRneighbor hosts鄰近主機1 loopback: NIC → memory, GPUs1 迴路:NIC → 記憶體、GPU2 NIC ↔ NIC3 NCCL all-to-all in the node3 節點內 NCCL all-to-all4 NCCL all-reduce with neighbors under the same ToR4 與同一 ToR 下鄰近主機的 NCCL all-reduce1 passes ✓ and 2 fails ✗ ⇒ suspect the link, not the host1 通過 ✓、2 失敗 ✗ ⇒ 懷疑鏈路,而不是主機
Figure 10.7. What each of MegaScale's four diagnostic tests exercises. Each bar spans the parts that the test's traffic crosses. Because the spans differ, the pattern of passes and failures names a layer: when the loopback test passes and the NIC-to-NIC test fails, the host is fine and the fault is on the link side.圖 10.7。MegaScale 四個診斷測試各自涵蓋什麼。每條長條橫跨該測試流量經過的零件。因為範圍不同,通過與失敗的組合就指出一層:迴路測試通過而 NIC 對 NIC 測試失敗時,主機沒問題,故障在鏈路那一側。Drawn for this primer from MegaScale §4 as summarized above.

Why the loop and not a person. A person takes tens of minutes to notice a hang, read logs across thousands of nodes and decide which node to drain. At 7.8 interruptions per day, that alone would consume the 10% budget from Section 10.2. The loop also removes the most expensive failure mode: the one nobody notices. A job that hangs at 03:00 and is found at 09:00 has lost six hours of 16,000 GPUs, about 100,000 GPU-hours, from one event. MegaScale's numbers: in a production run of several weeks on more than 10,000 GPUs, training restarted more than 100 times; more than 90% of the software and hardware faults were handled with no human involvement; detection plus diagnosis took under 10 minutes on average; and the job caught up to its pre-failure progress within 15 minutes of the last checkpoint, keeping effective training time above 90%. Llama 3 reports the same shape at 16K GPUs: 466 interruptions in 54 days, 47 of them planned (firmware and kernel upgrades, configuration changes, dataset updates), and only three that needed significant manual intervention.

為什麼要迴圈而不是人。一個人要花數十分鐘才會注意到卡死、讀遍數千個節點的日誌、決定要排空哪個節點。在每天 7.8 次中斷下,光這一項就會吃掉 第 10.2 節 的 10% 預算。這個迴圈也移除了最昂貴的故障模式:沒有人注意到的那種。一個在 03:00 卡死、09:00 才被發現的任務,一次事件就損失了 16,000 顆 GPU 的六小時,約 100,000 GPU-小時。MegaScale 的數字:在超過 10,000 顆 GPU 上數週的生產運行中,訓練重啟超過 100 次;超過 90% 的軟硬體故障在沒有人介入下處理完畢;偵測加診斷平均低於 10 分鐘;任務在最後檢查點之後 15 分鐘內追回故障前的進度,有效訓練時間維持在 90% 以上。Llama 3 在 16K GPU 上報告同樣的形態:54 天內 466 次中斷,其中 47 次是預期內的(韌體與核心升級、設定變更、資料集更新),只有三次需要顯著的人工介入。

Shanghai AI Laboratory's Acme datacenter splits recovery the same way (Acme, NSDI 2024; Figure 10.8): automatic recovery when the diagnosis says the fault is recoverable, a person when it is not. Its authors estimate, roughly, that the diagnosis system cut manual intervention by about 90%.

上海人工智慧實驗室的 Acme 資料中心用同樣的方式分割恢復(Acme,NSDI 2024;圖 10.8):診斷判定故障可恢復時自動恢復,否則交給人。作者粗估這套診斷系統讓人工介入減少約 90%。

Flow diagram from job start through log filtering, failure, rule-based diagnosis, vector store and failure agent, to automatic or manual recovery.
Figure 10.8. From Figure 15 of the Acme paper: the workflow for failure diagnosis and model recovery (a design diagram). Follow the time axis: logs are compressed during the run, rule-based diagnosis runs first after a failure, and only unmatched cases go to the LLM-based failure agent. The diamond is the split this section counts: recoverable faults return to the loop, the rest go to a person.圖 10.8。取自 Acme 論文的圖 15:故障診斷與模型恢復的流程(設計示意圖)。沿著時間軸看:訓練期間持續壓縮日誌;故障發生後先跑規則式診斷,規則比對不到的情況才交給以 LLM 為基礎的故障代理。菱形就是本節計算的那個分岔:可恢復的故障回到迴圈,其餘交給人。Hu et al., NSDI 2024, Figure 15.

Animation 10.3 plays MegaScale's loop for a fault that it handles and for one that escapes it.

動畫 10.3 播放 MegaScale 的迴圈:一次它能處理的故障,與一次逃出它的故障。

Animation 10.3動畫 10.3

The automated recovery loop自動恢復迴圈

After MegaScale §4: the heartbeat contents, the four tests and the standby pool come from the paper, and four nodes stand for thousands. Times: detection plus diagnosis under 10 min on average and catch-up within 15 min (MegaScale); the 4 h of an escaped event is this section's assumption, as in Panel 10.4. The test results on the automated path are one example of a fault on the link side (see Figure 10.7). The time bar is to scale, from 0 to 4 h.

依 MegaScale §4:心跳內容、四項測試與備用池都來自論文,四個節點代表成千上萬個。時間:偵測加診斷平均不到 10 分鐘、15 分鐘內追上進度(MegaScale);逃出事件的 4 小時是本節的假設,與面板 10.4 相同。自動路徑上的測試結果只是鏈路側故障的一個例子(見圖 10.7)。時間條依比例繪製,從 0 到 4 小時。

The arithmetic with those numbers. Take MegaScale first: "more than 100 restarts in several weeks", reading several as three. Then Llama 3: the 7,776 lost minutes allowed by 90% over 54 days, divided by 466, gave 16.7 minutes per interruption in Section 10.2, and the three manual interventions are the risk in that budget; suppose each took four hours. One question per row:

用這些數字算一算。先看 MegaScale:「數週內超過 100 次重啟」,把「數週」當成三週。再看 Llama 3:90% 在 54 天內允許的 7,776 分鐘損失除以 466,在 第 10.2 節 得到每次中斷 16.7 分鐘,而三次人工介入是這個預算裡的風險;假設每次花四小時。逐列計算如下:

Question問題Calculation算式Result結果
MegaScale: spacing of 100 restarts in three weeksMegaScale:三週 100 次重啟的間隔3×7×24÷1003 \times 7 \times 24 \div 100≈5\approx 5 h小時
Wall-clock loss per restart: diagnosis under 10 min, catch-up within 15 min每次重啟的牆上時鐘損失:診斷低於 10 分鐘、15 分鐘內追回10+1510 + 15≈25\approx 25 min分鐘
Share of time lost損失的時間比例25÷(5×60)25 \div (5 \times 60)≈8.3%\approx 8.3\%effective time ≈ 92%有效時間 ≈ 92%
Llama 3: three manual interventions at four hours eachLlama 3:三次人工介入、每次四小時3×4×603 \times 4 \times 60720720 min分鐘
Their share of the 7,776-minute budget占 7,776 分鐘預算的比例720÷7,776720 \div 7{,}776≈9.3%\approx 9.3\%
Their share of the 466 interruptions占 466 次中斷的比例3÷4663 \div 466≈0.6%\approx 0.6\%

MegaScale's effective time of about 92% is consistent with the paper's "above 90%". For Llama 3, 0.6% of the events would consume 9% of the whole budget. That is the general rule of recovery loops: the automated 90% sets the average, and the manual 10% sets the variance. The design goal is not a faster average but fewer events that escape the loop. Panel 10.4 lets you trade automated recovery time against the events that escape.

MegaScale 約 92% 的有效時間與論文的「高於 90%」一致。對 Llama 3 而言,只占 0.6% 的事件就會吃掉整個預算的 9%。這是恢復迴圈的通則:自動化的 90% 決定平均值,人工的 10% 決定變異。設計目標不是更快的平均,而是更少逃出迴圈的事件。面板 10.4 讓你在自動恢復時間與逃出迴圈的事件之間取捨。

Panel 10.4面板 10.4

The loop sets the mean, the escapes set the risk迴圈決定平均,逃出的事件決定風險

Escaped share of events
逃出事件占事件數
Escaped time, share of the 90% budget
逃出事件的時間占 90% 預算
Effective time over 54 days
54 天的有效時間
Most automated minutes for 90%
維持 90% 的自動恢復上限

Model: lost time =(n−k)×a+k×h×60= (n - k) \times a + k \times h \times 60 minutes for nn interruptions, kk escapes, aa minutes per automated recovery and hh hours per escape; effective time =1−lost÷(54×1,440)= 1 - \text{lost} \div (54 \times 1{,}440). The 90% budget is 7,7767{,}776 min. Defaults: Llama 3's 466 interruptions in 54 days and its three events that needed significant manual intervention; 4 h per escape is this section's assumption; 15 min per automated recovery is also an assumption, chosen so that the total stays inside Llama's "above 90%". They reproduce the table above: 0.6% of the events, 9.3% of the budget. Try: add five escapes, or make each one take 12 h, and watch the automated time you can afford shrink.

模型:nn 次中斷、kk 次逃出、每次自動恢復 aa 分鐘、每次逃出 hh 小時時,損失時間 =(n−k)×a+k×h×60= (n - k) \times a + k \times h \times 60 分鐘;有效時間 =1−損失÷(54×1,440)= 1 - \text{損失} \div (54 \times 1{,}440)。90% 的預算是 7,7767{,}776 分鐘。預設:Llama 3 在 54 天內的 466 次中斷,以及需要顯著人工介入的三次事件;每次逃出 4 小時是本節的假設;每次自動恢復 15 分鐘也是假設,選來讓總和落在 Llama 的「高於 90%」之內。它們重現上表:0.6% 的事件、9.3% 的預算。試試:多加五次逃出,或讓每次花 12 小時,看你負擔得起的自動恢復時間如何縮小。

10.5Designing so that failures hurt less讓故障傷害更小的設計

Section 10.3 showed that the cost of a failure is CC, DD, RR and WW, and Section 10.4 showed how to shrink DD and RR. The remaining lever is to stop a fault from being a failure at all: to let the job continue, slower, while the part is repaired. Six published mechanisms do this, each with a number attached.

第 10.3 節 顯示一次故障的成本是 CC、DD、RR 與 WW,第 10.4 節 顯示如何縮小 DD 與 RR。剩下的槓桿是讓一個缺陷根本不成為故障:讓任務在零件修復期間以較慢的速度繼續。有六個已發表的機制做到這件事,每個都附帶一個數字。

Dual-ToR without stacking (HPN §4). Each NIC has two 200G ports wired to two rack switches that share nothing: no inter-switch link, no shared state. The host bonds the two ports under one IP and one MAC and sends its address announcements (ARP) to both switches, which turn them into routes for the network above; the host runs no routing protocol itself. When a link or a ToR fails, the host stops using that port (Section 6.5). In HPN's experiment on 256 GPUs training LLaMa-7B, failing a single NIC–ToR link cost 6.25% of training throughput, which is one of the sixteen 200G ports on a host, and throughput returned to normal when the link was repaired. In the single-ToR baseline the job halted, and if the repair took more than two minutes it could not recover at all. A link flap that stalled single-ToR training for more than nine seconds was negligible under dual-ToR. The usual stacked alternative (vPC, M-LAG) is rejected with a fleet number: more than 40% of critical failures in Alibaba's traditional data centers came from the stacked design, because a switch whose data plane dies while its control plane lives makes its healthy peer shut down too.

不堆疊的 dual-ToR(HPN §4)。每張 NIC 有兩個 200G 埠,接到兩台什麼都不共享的機櫃交換器:沒有交換器之間的鏈路、沒有共享狀態。主機把兩個埠綁在一個 IP 與一個 MAC 之下,把位址宣告(ARP)送給兩台交換器,由交換器把它轉成給上層網路的路由;主機本身不跑路由協定。當鏈路或 ToR 故障,主機就不再使用那個埠(第 6.5 節)。在 HPN 於 256 顆 GPU 上訓練 LLaMa-7B 的實驗中,弄斷一條 NIC–ToR 鏈路損失 6.25% 的訓練吞吐,即主機十六個 200G 埠之一,鏈路修復時吞吐就恢復正常。在單 ToR 基線中任務停擺,而若修復超過兩分鐘就完全無法恢復。一次讓單 ToR 訓練停擺超過九秒的鏈路抖動,在 dual-ToR 下可忽略。常見的堆疊式替代方案(vPC、M-LAG)被一個機群數字否決:阿里傳統資料中心超過 40% 的重大故障來自堆疊設計,因為一台資料平面死掉但控制平面還活著的交換器,會讓健康的同儕也關機。

Backup hosts per segment (HPN §5.1). Each HPN ToR reserves 8 of its 136 host-facing ports as backups, so a segment of 1,024 active GPUs carries 64 spare GPUs, 6.25% again. When a host fails, the job restarts on a spare in the same segment, with the same single-hop reach to its peers, instead of waiting for a repair or being re-placed across the pod. The spares also change the decision after a link failure. Under dual-ToR the degraded host costs 6.25% of throughput for the whole repair time TrepairT_{\text{repair}}. Swapping the host to a spare costs one restart from the checkpoint instead: τ/2+D+R\tau/2 + D + R. The swap is worth it when 0.0625×Trepair>τ/2+D+R0.0625 \times T_{\text{repair}} \gt \tau/2 + D + R, that is, when

每個 segment 的備用主機(HPN §5.1)。每台 HPN ToR 把 136 個面向主機的埠中保留 8 個作為備援,所以一個有 1,024 顆使用中 GPU 的 segment 帶著 64 顆備用 GPU,又是 6.25%。主機故障時,任務在同一 segment 的備用機上重啟,與同儕保持同樣的單跳可達,而不必等修復或被重新配置到 pod 的其他地方。備用機也改變鏈路故障後的決策。在 dual-ToR 下,降級的主機在整個修復時間 TrepairT_{\text{repair}} 內損失 6.25% 的吞吐。把主機換到備用機則只花一次從檢查點重啟的成本:τ/2+D+R\tau/2 + D + R。當 0.0625×Trepair>τ/2+D+R0.0625 \times T_{\text{repair}} \gt \tau/2 + D + R 時換機划得來,即

Trepair>16×(τ2+D+R) T_{\text{repair}} \gt 16 \times \left(\frac{\tau}{2} + D + R\right)

With a 15-minute interval and a 5-minute restart, that is a repair longer than about 3.3 hours; with HPN's 2-hour interval it is about 17 hours. Panel 10.5 computes this break-even for you.

用 15 分鐘的間隔與 5 分鐘的重啟,那是超過約 3.3 小時的修復;用 HPN 的 2 小時間隔則約 17 小時。面板 10.5 會替你算這個損益平衡點。

Uplink headroom (Meta RoCE §6). Meta's rack switches moved from 1:1 to 1:2 uplink bandwidth during tuning, then settled at 1:1.125: enough headroom to tolerate two failed uplinks without slowing a job, at far lower cost than 1:2. The arithmetic: with nn uplinks, two failures leave (n−2)/n(n - 2)/n of the uplink capacity. The rack stays non-blocking when (n−2)/n×1.125≥1(n - 2)/n \times 1.125 \ge 1, which requires n≥18n \ge 18. The rule generalizes: to survive kk failed uplinks out of nn at full rate, you need a ratio of n/(n−k)n/(n - k). Fewer, fatter uplinks need more headroom per link lost. The same paper lists the alarms that make a degraded link visible before it becomes a stall: out-of-sequence packet counters on the NICs (a sign of loss or reordering), link flaps, local ACK timeouts, a PFC watchdog that fires when a port stays paused for 200 ms, buffer alarms when a cluster switch buffer passes 80%, and periodic reachability pings between all hosts. Two incidents show why: a switch software upgrade raised port-to-port latency and silently slowed training until the monitoring caught it, and an outdated assumption about SRAM buffer carving caused tail drops whenever more than half the buffer was in use (Meta RoCE).

上行餘裕(Meta RoCE §6)。Meta 的機櫃交換器在調校期間從 1:1 的上行頻寬改到 1:2,然後定在 1:1.125:足以容忍兩條上行故障而不拖慢任務,成本又遠低於 1:2。算術如下:有 nn 條上行時,兩條故障留下 (n−2)/n(n - 2)/n 的上行容量。當 (n−2)/n×1.125≥1(n - 2)/n \times 1.125 \ge 1 時機櫃維持非阻塞,這需要 n≥18n \ge 18。這個規則可以推廣:要在 nn 條中失去 kk 條上行後仍全速運行,需要 n/(n−k)n/(n - k) 的比例。更少、更粗的上行每失去一條就需要更多餘裕。同一篇論文列出讓降級鏈路在變成停擺之前就被看見的警報:NIC 上的亂序封包計數器(丟包或重排序的徵兆)、鏈路抖動、本地 ACK 逾時、一個埠持續暫停 200 ms 就觸發的 PFC watchdog、叢集交換器緩衝超過 80% 的緩衝警報,以及所有主機之間週期性的可達性 ping。兩起事故說明原因:一次交換器軟體升級提高了埠對埠延遲並悄悄拖慢訓練直到監控抓到;一個關於 SRAM 緩衝切割的過時假設讓緩衝使用超過一半就出現尾端丟包(Meta RoCE)。

Rerouting the torus (TPU v4, ISCA 2023, §2.3). Google's argument for optical circuit switches leads with availability. Figure 10.4 of that paper plots goodput, the useful work delivered, against host availability from 99.0% to 99.9%. Without OCSes, a fixed torus delivers reasonable goodput only at 99.9% host availability; with OCSes, the scheduler picks other cubes and rewires the torus around the failure, and goodput is acceptable at 99.0–99.5% (TPU v4). The arithmetic behind the curve is a power. A fixed slice of NN hosts is usable only when all NN are up, with probability aNa^N. For N=256N = 256 hosts:

重新接線的環面(TPU v4,ISCA 2023,§2.3)。Google 支持光路交換器的論證以可用性開頭。該論文的 Figure 4 畫出 goodput(交付的有用工作)隨主機可用性從 99.0% 到 99.9% 的變化。沒有 OCS 時,固定環面只在 99.9% 的主機可用性下有合理的 goodput;有 OCS 時,排程器挑其他 cube 並把環面繞過故障重新接線,goodput 在 99.0–99.5% 下仍可接受(TPU v4)。曲線背後的算術是一個次方。NN 台主機的固定切片只有在全部 NN 台都正常時可用,機率為 aNa^N。以 N=256N = 256 台主機計:

Question問題Calculation算式Result結果
All 256 hosts up at 99.9% host availability主機可用性 99.9% 時 256 台全部正常0.9992560.999^{256}≈0.77\approx 0.77
All 256 hosts up at 99.5%99.5% 時 256 台全部正常0.9952560.995^{256}≈0.28\approx 0.28
All 256 hosts up at 99.0%99.0% 時 256 台全部正常0.9902560.990^{256}≈0.08\approx 0.08

At 99.0% availability a fixed 256-host slice is whole only 8% of the time. A reconfigurable slice needs only 256 working hosts out of a larger pool, which is nearly always true. Spare capacity is the limit for very large slices: a slice of one quarter of the machine reaches 75% goodput at those availabilities.

在 99.0% 的可用性下,一個固定的 256 主機切片只有 8% 的時間是完整的。可重構的切片只需要在更大的池子裡找出 256 台正常主機,這幾乎永遠成立。備用容量是極大切片的限制:占整台機器四分之一的切片在那些可用性下達到 75% 的 goodput。

Those curves are the design argument. The measured counterpart comes from Google's later operations paper (TPU v4 resiliency, NSDI 2024): job availability against job size in deployed pods (the figure in Section 6.9). Its headline of 99.98% availability has no definition or method in the paper, so this chapter does not use it as a measured number.

那些曲線是設計上的論證。量測上的對照來自 Google 後來的營運論文(TPU v4 韌性,NSDI 2024):已部署 pod 中任務可用度對任務規模的關係(第 6.9 節的圖)。它標題上的 99.98% 可用度在論文中沒有定義也沒有方法,所以本章不把它當成量測數字。

Riding through flaps (MegaScale §3.6 and §6.3). A flap drops the packets in flight and then restores the link within seconds. The danger is not the lost packets but the timers around them. In MegaScale's case study, interfaces went down for several seconds, the default NCCL timeout expired before the NIC recovered, and the job died. Setting a larger timeout explicitly let the job ride through. ByteDance also tuned NCCL's retransmit timer and retry count, and enabled the NIC's adaptive retransmission so that retries happen at shorter intervals. The root cause was poor signal quality across the NIC, the active optical cable and the switch port, fixed with tighter quality control on cabling. Under HPN's dual-ToR the same event is invisible, because the host simply uses the other port for those seconds.

撐過抖動(MegaScale §3.6 與 §6.3)。一次抖動丟掉在途的封包,然後在數秒內恢復鏈路。危險的不是丟掉的封包,而是圍繞它們的計時器。在 MegaScale 的案例中,介面斷線數秒,預設的 NCCL 逾時在 NIC 恢復前到期,任務就死了。明確設定較大的逾時讓任務得以撐過。字節跳動也調校了 NCCL 的重傳計時器與重試次數,並啟用 NIC 的自適應重傳,讓重試以更短的間隔進行。根本原因是 NIC、主動光纜與交換器埠之間的訊號品質不佳,以更嚴格的線纜品質管控修正。在 HPN 的 dual-ToR 下同一事件是看不見的,因為主機在那幾秒就是改用另一個埠。

The asymmetric link (HPN §10). A production incident at Alibaba came from a link whose optical signal was bad in the NIC-to-ToR direction but fine in the other. The ToR detected the fault and tried to tell the NIC through Link Fault Signaling, but a NIC firmware bug ignored the message. The NIC kept sending on a link it believed healthy, and packets were lost at scale. No testbed produces this fault, and no watchdog on the switch can fix a host that will not listen. Dual-ToR turned it from a crash into a slowdown, which is the whole point of the design: it does not need to know why a port is bad to stop using it.

非對稱鏈路(HPN §10)。阿里的一次生產事故來自一條在 NIC 到 ToR 方向光訊號不良、另一方向卻正常的鏈路。ToR 偵測到故障並嘗試透過 Link Fault Signaling 通知 NIC,但 NIC 韌體的錯誤忽略了訊息。NIC 持續在它以為健康的鏈路上發送,大量封包遺失。沒有任何測試環境會產生這種故障,交換器上的任何 watchdog 也修不了一台不聽話的主機。Dual-ToR 讓它從崩潰變成減速,而這正是這個設計的重點:它不需要知道一個埠為何壞掉,就能停止使用它。

Panel 10.5面板 10.5

Failure impact by design不同設計下的故障影響

Links / ToRs in the job
任務的鏈路 / ToR 數
Link + ToR failures per month
每月鏈路 + ToR 故障
Job halts per month
每月任務停擺
Lost GPU-hours per month
每月損失的 GPU-小時
Share of the month lost
每月損失比例
Swap pays off if repair >
修復時間超過此值就該換機

Model (HPN §4, §9): single-ToR has one 400G link per GPU and 64 GPUs per ToR; a link or ToR failure halts the job, which restarts from the checkpoint on spare capacity after D+RD + R and redoes τ/2\tau/2 of work; each flap stalls the job 9 s. Dual-ToR has two 200G links per GPU (twice the link events) and 128 GPUs per ToR pair; a link or ToR failure costs 6.25% of throughput for the repair time and no halt; flaps cost nothing. With backup hosts, the operator swaps the degraded host when that is cheaper than running at 93.75% until repair: break-even Trepair=16×(τ/2+D+R)T_{\text{repair}} = 16 \times (\tau/2 + D + R); a ToR failure still degrades its 128 hosts. Link and ToR rates default to HPN's 0.057% and 0.051% per month; HPN's 5K–60K flaps per day are fleet-wide, so the per-job flap count is a knob. The timeline is one sampled month; it changes with the inputs.

模型(HPN §4、§9):單 ToR 每顆 GPU 一條 400G 鏈路、每台 ToR 64 顆 GPU;鏈路或 ToR 故障讓任務停擺,經過 D+RD + R 後在備用容量上從檢查點重啟並重做 τ/2\tau/2 的工作;每次抖動讓任務停 9 秒。Dual-ToR 每顆 GPU 兩條 200G 鏈路(兩倍的鏈路事件)、每對 ToR 128 顆 GPU;鏈路或 ToR 故障在修復期間損失 6.25% 吞吐、不停擺;抖動不花錢。有備用主機時,當換機比以 93.75% 跑到修復更便宜,營運者就換掉降級的主機:損益平衡 Trepair=16×(τ/2+D+R)T_{\text{repair}} = 16 \times (\tau/2 + D + R);ToR 故障仍會讓它的 128 台主機降級。鏈路與 ToR 比率預設為 HPN 的每月 0.057% 與 0.051%;HPN 的每天 5K–60K 次抖動是整個機群的數字,所以每個任務的抖動數是一個可調的旋鈕。時間線是取樣出來的一個月;它會隨輸入改變。

Stop and think停下來想一想

Dual-ToR doubles the number of links, so it doubles the link events. Why does it still win? Use Panel 10.5 with HPN's 2-hour interval and compare the lost GPU-hours of single-ToR and dual-ToR. Then shorten the interval to 15 minutes, as Panel 10.3 recommends, and watch the gap shrink: the cheaper a halt becomes, the less a design that avoids halts is worth. At what interval and repair time do the two designs tie?

Dual-ToR 讓鏈路數加倍,所以鏈路事件也加倍。為什麼它還是贏?用面板 10.5 設 HPN 的 2 小時間隔,比較單 ToR 與 dual-ToR 損失的 GPU-小時。然後把間隔縮到面板 10.3 建議的 15 分鐘,看差距縮小:停擺越便宜,一個避免停擺的設計就越不值錢。在什麼間隔與修復時間下兩種設計打平?

10.6Stragglers: the cost of the slowest rank落後者:最慢的 rank 的代價

Mechanism. The barrier of Section 10.2 has a second consequence. The step time of a synchronous job is not the average rank's time but the maximum over all ranks, because the collective completes when the last contribution arrives. A host that is 10% slower makes the whole job 10% slower, however many thousands of healthy hosts there are (Figure 10.9). A straggler is a rank that is persistently slower than its peers; jitter is the random variation that every rank shows from step to step. Both are paid through the same maximum, and the network sees both as the same thing: ranks that finish their compute late issue their collectives late, and the other ranks wait in the collective, so the wait is recorded as communication time even when the cause is a slow GPU.

機制。第 10.2 節 的 barrier 有第二個後果。同步任務的步時間不是平均 rank 的時間,而是所有 rank 之中的最大值,因為集體通訊在最後一份貢獻到達時才完成。一台慢 10% 的主機讓整個任務慢 10%,不管有幾千台健康的主機(圖 10.9)。Straggler 是持續比同儕慢的 rank;jitter 則是每個 rank 每一步都會出現的隨機變化。兩者都透過同一個最大值付出代價,而網路把兩者看成同一件事:計算較晚完成的 rank 較晚發出集體通訊,其他 rank 在集體通訊裡等待,所以即使原因是慢的 GPU,等待仍被記成通訊時間。

typical rank finishes its compute一般 rank 完成計算rank 0rank 1rank 2rank 3rank 4rank 5rank 6rank 7step time = max步時間 = 最大值all ranks wait here所有 rank 在此等待hollow boxes: time spent waiting inside the collective空心框:在集體通訊裡等待的時間
Figure 10.9. Eight ranks in one step. Seven finish within a few percent of each other; rank 5 is 10% slow. Every other rank spends the difference waiting inside the collective (hollow boxes), so the profiler reports it as communication time. The step is as long as rank 5.圖 10.9。一步裡的八個 rank。七個在彼此幾個百分點內完成;rank 5 慢 10%。其他每個 rank 把這個差距花在集體通訊裡等待(空心框),所以 profiler 把它報成通訊時間。這一步就跟 rank 5 一樣長。Drawn for this primer.

MegaScale's numbers. A CUDA event monitor timed critical code segments on every rank with CUDA events rather than host timers, so it did not force the GPU to synchronize and could stay on in production. Its heat map of per-rank step times showed that about 0.5% of machines were substantially slower than the rest, and because every collective waits for its slowest member, that 0.5% set the pace for everyone. Excluding those machines made peak MFU consistent from run to run (MegaScale §5). In the case study of §6.3, some hosts took about 10% longer on identical forward computations; isolating and removing them gained about 0.7 MFU points. Check the arithmetic, assuming the slow hosts were 10% slower on the forward computation only:

MegaScale 的數字。一個 CUDA 事件監控器用 CUDA 事件而非主機計時器為每個 rank 的關鍵程式段計時,所以它不強迫 GPU 同步,可以在生產環境常開。它的逐 rank 步時間熱圖顯示約 0.5% 的機器明顯比其他慢,而因為每個集體通訊都等最慢的成員,那 0.5% 決定了所有人的節奏。排除那些機器後峰值 MFU 在各次運行間變得一致(MegaScale §5)。在 §6.3 的案例中,某些主機在相同的正向計算上多花約 10%;隔離並移除它們拿回約 0.7 個 MFU 百分點。驗算一下,假設慢的主機只在正向計算上慢 10%:

Question問題Calculation算式Result結果
Throughput change from 0.7 MFU points at 55.2% MFU在 55.2% MFU 下 0.7 點的吞吐變化0.7÷55.20.7 \div 55.2≈1.3%\approx 1.3\%the step got about 1.3% shorter步時間縮短約 1.3%
Forward computation's share of the step, if it ran 10% slower正向計算占步時間的比例(若它慢了 10%)1.3%÷10%1.3\% \div 10\%≈13%\approx 13\%

So the forward computation was about 13% of the step. A straggler costs the whole job its slowdown times the share of the step it slows. The paper's second case is pure jitter: MFU declined slowly over a long run because some ranks launched their gradient reduce-scatter later than others; the cause was irregular Python garbage collection and a few PyTorch operations on the critical path, and removing them stopped the decline.

所以正向計算約占步時間的 13%。一個 straggler 讓整個任務付出的成本是它的減速乘上它拖慢的那部分步時間的比例。論文的第二個案例是純粹的 jitter:長時間運行中 MFU 緩慢下滑,因為某些 rank 比其他 rank 更晚發出梯度 reduce-scatter;原因是不規律的 Python 垃圾回收與關鍵路徑上的幾個 PyTorch 操作,移除後下滑就停止。

Animation 10.4 plays four steps with a 10% straggler, its detection and its replacement.

動畫 10.4 播放四個步驟:一個慢 10% 的 straggler、它被偵測出來,以及被替換。

Animation 10.4動畫 10.4

One slow rank sets every step一個慢 rank 決定每一步

Eight ranks as in Figure 10.9; rank 5 is 10% slower on the whole step. The other ranks' times are illustrative jitter of a few percent, in units of a typical rank's step. Communication time is left out, so the hollow boxes are pure waiting. Detection follows MegaScale's CUDA event monitor, which times every rank without forcing a synchronization. In MegaScale's case the slow hosts were slow on the forward computation only, so removing them returned less than here: the 0.7 MFU points above.

八個 rank,與圖 10.9 相同;rank 5 整個步驟慢 10%。其他 rank 的時間是幾個百分點的示意性 jitter,以典型 rank 的步時間為單位。通訊時間沒有畫出,所以空心框純粹是等待。偵測依照 MegaScale 的 CUDA event 監測器,它為每個 rank 計時而不強迫同步。在 MegaScale 的案例中,慢主機只有正向計算慢,所以移除它們拿回的比這裡少:就是上面的 0.7 個 MFU 百分點。

Llama 3's observations. Meta notes that a single straggler can slow thousands of GPUs, and built tooling that ranks suspect communications from chosen process groups and lets engineers inspect the top few. The PyTorch NCCL flight recorder, a ring buffer of recent collective calls with their state, supported this; so did the ability to change configuration online, without a restart. Llama also reports a diurnal effect: throughput varied by 1–2% over each day in step with mid-day temperature, because hotter GPUs lower their clock through dynamic voltage and frequency scaling. That is a straggler made by the weather: the hottest rack in the building sets the step time for the whole job, twice a day. MegaScale's third tool, a 3-D parallel visualizer, draws the tensor, pipeline and data-parallel groups and the data flow between ranks; when a collective times out, every healthy rank logs the operation it was waiting on while the faulty rank has hung and logs nothing, and the silent rank is the one to drain.

Llama 3 的觀察。Meta 指出單一 straggler 就能拖慢數千顆 GPU,並建了工具,對選定行程群組的可疑通訊排序,讓工程師檢查前幾名。PyTorch 的 NCCL flight recorder(保留近期集體呼叫及其狀態的環形緩衝)支持了這件事;不必重啟就能線上修改設定的能力也是。Llama 也報告一個日夜效應:吞吐每天隨正午溫度有 1–2% 的變化,因為較熱的 GPU 透過動態電壓與頻率調節降低時脈。那是天氣製造出來的 straggler:建築裡最熱的機櫃每天兩次決定整個任務的步時間。MegaScale 的第三個工具,3-D 平行可視化工具,畫出張量、管線與資料平行群組以及 rank 之間的資料流;當集體通訊逾時,每個健康的 rank 記錄它正在等待的操作,而故障的 rank 已經卡住、什麼都沒記,那個沉默的 rank 就是該排空的那個。

The order-statistics view. Even with no chronic straggler, jitter, the small random variation of each rank's step time, costs more as the job grows. Suppose each rank's step time varies independently with standard deviation σ\sigma around the same mean. The step time is the maximum of NN such values. For Gaussian jitter and large NN, the expected maximum grows like

順序統計量的觀點。即使沒有長期的 straggler,jitter(每個 rank 步時間小而隨機的變化)的成本也隨任務成長而增加。假設每個 rank 的步時間繞著同一個平均值獨立變動,標準差為 σ\sigma。步時間就是 NN 個這種值的最大值。對高斯 jitter,期望最大值在 NN 很大時隨下式成長:

σ2ln⁡N \sigma \sqrt{2 \ln N}

The exact expectation, computed from the distribution of the maximum, compares with the asymptotic formula like this:

由最大值的分布算出的精確期望值,與漸近公式的比較如下:

NNExact E[max⁡]\mathrm{E}[\max]精確 E[max⁡]\mathrm{E}[\max]Formula σ2ln⁡N\sigma\sqrt{2\ln N}公式 σ2ln⁡N\sigma\sqrt{2\ln N}Formula too high by公式高估
642.3σ2.3\sigma2.9σ2.9\sigma23%
1,0243.2σ3.2\sigma3.7σ3.7\sigma15%
16,3844.0σ4.0\sigma4.4σ4.4\sigma11%
131,0724.4σ4.4\sigma4.9σ4.9\sigma9%
0123458641,02416,384131,072ranks N (log scale)rank 數 N(對數刻度)E[max] ÷ σexact E[max]精確 E[max]σ√(2 ln N)table rows表中的四列
Figure 10.10. The expected maximum of NN Gaussian jitters, in units of σ\sigma: the exact value (blue) and the asymptotic formula σ2ln⁡N\sigma\sqrt{2\ln N} (orange). Dots mark the four rows of the table. Both rise slowly: from 1,024 to 131,072 ranks, 128 times more, the exact value grows only from 3.2σ3.2\sigma to 4.4σ4.4\sigma, and the gap to the formula narrows.圖 10.10。NN 個高斯 jitter 的期望最大值,以 σ\sigma 為單位:精確值(藍色)與漸近公式 σ2ln⁡N\sigma\sqrt{2\ln N}(橘色)。圓點標出表中的四列。兩者都成長得很慢:從 1,024 到 131,072 個 rank,多了 128 倍,精確值只從 3.2σ3.2\sigma 增加到 4.4σ4.4\sigma,與公式的差距也縮小。Drawn for this primer from the order-statistics table above (analysis).

The formula is an upper estimate that tightens as NN grows (Figure 10.10). The growth is slow, which is the good news, but it never stops, and it multiplies whatever σ\sigma the hardware and software provide. With σ=1%\sigma = 1\% at 16K ranks, every step is about 4% longer than a typical rank needs, with no part broken and nothing to repair. The lever is σ\sigma: pin the garbage collector, keep the critical path free of host-side work, cool the racks evenly, and keep the network's tail latency low, because the network's own jitter adds to σ\sigma. Panel 10.6 runs this experiment with a chronic-straggler population added, and reproduces the 0.7 MFU points of MegaScale.

這個公式是偏高的估計,NN 越大越準(圖 10.10)。成長很慢,這是好消息,但它永不停止,而且它放大硬體與軟體提供的任何 σ\sigma。在 16K 個 rank 下 σ=1%\sigma = 1\%,每一步比一般 rank 所需長約 4%,沒有任何零件壞掉、沒有任何東西要修。槓桿是 σ\sigma:釘住垃圾回收器、讓關鍵路徑不含主機端工作、讓機櫃散熱均勻、讓網路的尾端延遲維持低,因為網路自己的 jitter 會加進 σ\sigma。面板 10.6 加上一群長期 straggler 來跑這個實驗,並重現 MegaScale 的 0.7 個 MFU 百分點。

Panel 10.6面板 10.6

Stragglers and jitter: the step is a maximumStraggler 與 jitter:步時間是一個最大值

Mean step inflation (shown)
平均步時間膨脹(顯示中)
Jitter only (stragglers out)
只有 jitter(排除 straggler)
MFU from a 55.2% base
以 55.2% 為基準的 MFU
MFU gained by excluding them
排除它們拿回的 MFU
Asymptotic estimate
漸近估計值

Monte Carlo, 2,000 sampled steps. Each rank's step is 1+σz1 + \sigma z with zz standard normal; a chronic straggler adds slowdown×share\text{slowdown} \times \text{share} on top. The step is the maximum over ranks; MFU=55.2%÷mean step\mathrm{MFU} = 55.2\% \div \text{mean step}. Defaults reproduce MegaScale §6.3: 12,288 ranks, 0.5% chronic stragglers 10% slower on about 15% of the step (their forward computation), and excluding them returns about 0.7 MFU points. Try: σ=1%\sigma = 1\% with no stragglers, then move NN from 256 to 131,072 and compare the mean with the asymptotic-estimate tile.

蒙地卡羅,取樣 2,000 步。每個 rank 的步時間是 1+σz1 + \sigma z,zz 為標準常態;長期 straggler 再加上 減速×比例\text{減速} \times \text{比例}。步時間是所有 rank 的最大值;MFU=55.2%÷平均步時間\mathrm{MFU} = 55.2\% \div \text{平均步時間}。預設重現 MegaScale §6.3:12,288 個 rank、0.5% 的長期 straggler 在約 15% 的步時間上(它們的正向計算)慢 10%,排除它們拿回約 0.7 個 MFU 百分點。試試:σ=1%\sigma = 1\% 且沒有 straggler,然後把 NN 從 256 移到 131,072,比較平均值與「漸近估計值」那一格。

Stop and think停下來想一想

Set the chronic stragglers to zero and σ\sigma to 0.5%. Read the mean inflation at N=1,024N = 1{,}024 and at N=65,536N = 65{,}536. The ratio of the two is the price of scale with no broken parts. Now set σ\sigma to 0.25%: the inflation halves at both sizes. To get the same halving by shrinking the job, you would have to go from 65,536 ranks to about 40, because the maximum grows only logarithmically. That is why MegaScale spends a section on garbage collection and Llama on a flight recorder: σ\sigma is the lever, not NN.

把長期 straggler 設為零、σ\sigma 設為 0.5%。讀出 N=1,024N = 1{,}024 與 N=65,536N = 65{,}536 時的平均膨脹。兩者的比值就是在沒有零件壞掉下規模的代價。現在把 σ\sigma 設為 0.25%:兩種規模的膨脹都減半。要靠縮小任務得到同樣的減半,你得從 65,536 個 rank 縮到約 40 個,因為最大值只以對數成長。這就是 MegaScale 花一節談垃圾回收、Llama 談 flight recorder 的原因:槓桿是 σ\sigma,不是 NN。

Chapter summary
本章摘要

A synchronous job is a series system: it runs only while every part works, so failure rates add. Llama 3's 16,384 GPUs saw 419 unexpected interruptions in 54 days, one every three hours, mostly GPUs and their memory; the network was about a tenth. One dead rank stops all the others, because the collective cannot finish without it; each interruption costs detection, restart and the work since the last checkpoint. The Young–Daly rule gives the best checkpoint interval, the square root of 2 × checkpoint cost × MTBF; cheap two-stage checkpoints allow short intervals. Automated loops detect, diagnose and restart without a person; wiring (dual-ToR, backup hosts, spare uplinks, optical switches) turns failures into slowdowns. Even without failures, a step lasts as long as its slowest rank, and the expected slowest of N grows like σ√(2 ln N).

同步任務是一個串聯系統:只有每個零件都正常時才能運行,所以故障率相加。Llama 3 的 16,384 顆 GPU 在 54 天內遇到 419 次非預期中斷,約每三小時一次,大多來自 GPU 與其記憶體;網路約占十分之一。一個死掉的 rank 會讓其他所有 rank 停下,因為少了它集體操作就無法完成;每次中斷都要付出偵測、重啟,以及上一個檢查點之後的工作。Young–Daly 法則給出最佳檢查點間隔:2 × 檢查點成本 × MTBF 的平方根;便宜的兩階段檢查點容許很短的間隔。自動化迴圈不需人工就能偵測、診斷與重啟;接線(雙 ToR、備用主機、多餘的上行、光路交換器)把故障變成減速。即使沒有故障,一步的長度仍由最慢的 rank 決定,而 N 個 rank 中最慢者的期望值隨 σ√(2 ln N) 成長。

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

Chapter 11 looks at clusters shared by many jobs: where each job is placed, what that does to the network, and how jobs disturb one another.

第 11 章探討由許多任務共用的叢集:每個任務放在哪裡、這對網路有什麼影響,以及任務之間如何互相干擾。

Optional · research frontier選讀 · 研究前沿Failure research: is it the network, and where?故障研究:是不是網路,問題在哪裡?R-Pingmesh, SkeletonHunter, Minder and others: finding a fault or a slow machine in a running job.R-Pingmesh、SkeletonHunter、Minder 等:在執行中的任務裡找出故障或慢機器。Open →開啟 →

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

Check your understanding檢驗你的理解