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

The front end: data, checkpoints and control前端網路:資料、檢查點與控制

Learn why every training cluster has a second network, what travels on it (training data, checkpoints, management and monitoring), why checkpoints are the burst that sizes it, and how to size it.了解為何每個訓練叢集都有第二個網路、它承載什麼(訓練資料、檢查點、管理與監控)、為何檢查點是決定它規模的突發流量,以及如何決定它的大小。

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

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

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

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

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

  • Checkpoint檢查點(checkpoint) A saved copy of the training state (weights and optimizer state) from which a job can resume after a failure. 訓練狀態(權重與最佳化器狀態)的存檔,工作故障後可從此處恢復。
  • Front-end and back-end networks前端網路與後端網路 The back end carries only GPU-to-GPU training traffic; the front end carries data, checkpoints, logs and management. 後端只承載 GPU 之間的訓練流量;前端承載資料、檢查點、日誌與管理流量。
  • Distributed storage分散式儲存 Many storage servers that act as one file system or object store; its throughput is set by the number of servers. 許多儲存伺服器合為一個檔案系統或物件儲存;吞吐量由伺服器數決定。
  • Two-stage checkpoint兩階段檢查點 Copy the state to host memory first (the GPUs pause for seconds), then write it to storage in the background. 先把狀態複製到主機記憶體(GPU 暫停數秒),再在背景寫入儲存。
  • Erasure coding糾刪碼 Protecting data with k data fragments and m parity fragments instead of three full copies. 以 k 個資料片段加 m 個同位片段保護資料,而非存三份完整副本。
  • Out-of-band management頻外管理 A separate slow network that reaches each server's management controller even when the host is down. 一條獨立的低速網路,即使主機當機也能連到每台伺服器的管理控制器。
  • Telemetry遙測(telemetry) Counters and logs collected from hosts and switches to watch the network. 從主機與交換器收集的計數器與日誌,用來監看網路。

9.1Two networks, four kinds of traffic兩個網路、四種流量

The training traffic described so far is only one part. A job must also read its training data, write checkpoints (a full copy of the model, saved every few hours), send logs and metrics, and talk to the scheduler. This traffic has a different shape: it is TCP, it goes to storage servers, and a slow moment is annoying but not fatal. Mixing it with RDMA traffic would be dangerous. A burst of checkpoint writes could trigger PFC pauses that stall a collective.

前面描述的訓練流量只是其中一部分。一個任務還必須讀訓練資料、寫檢查點(模型的完整副本,每隔幾小時存一次)、送出日誌與指標,並與排程器溝通。這類流量形狀不同:它是 TCP、目的地是儲存伺服器,慢一下令人煩躁但不致命。把它和 RDMA 流量混在一起會很危險:一波檢查點寫入就可能觸發 PFC 暫停,讓集體通訊停擺。

So every design separates them. The back-end network (Meta's BE, Alibaba's "backend") carries only GPU-to-GPU RDMA. It is non-blocking inside a zone, lossless, and tuned for a few elephant flows. The front-end network (FE) carries everything else over the normal data center fabric. Each server has ports on both. Meta notes that the front-end must still have enough bandwidth to keep the GPUs fed with data; HPN builds the front end at 1:1 so it can also serve inference and mixed workloads.

所以每個設計都把它們分開。後端網路(Meta 的 BE、Alibaba 的「backend」)只承載 GPU 到 GPU 的 RDMA。它在區域內非阻塞、無損,並針對少數大象流調校。前端網路(FE)則透過一般的資料中心網路承載其他所有東西。每台伺服器在兩個網路上都有埠。Meta 指出前端仍必須有足夠頻寬,才能持續餵資料給 GPU;HPN 把前端做成 1:1,讓它也能服務推論與混合負載。

Mechanism. Every training host has ports on two fabrics. In Meta's Grand Teton server, eight RDMA NICs, one per GPU, each run at 400 Gb/s into the rack training switch (RTSW) of the back end; separate front-end NICs at 100 or 200 Gb/s connect to the ordinary rack switch (RSW), which leads through the fabric switches to the storage warehouse (Meta RoCE paper, Section 9.3). In HPN a host has nine NICs: NIC 0 serves the front end with two 200 Gb/s ports, and NICs 1–8 serve the back end, one per GPU, also at 2×200 Gb/s (HPN §3). The back end therefore offers 3.2 Tb/s per host and the front end 400 Gb/s. Figure 9.1 shows Meta's version of this split.

機制。每台訓練主機在兩個網路上都有埠。在 Meta 的 Grand Teton 伺服器裡,八張 RDMA NIC、每顆 GPU 一張,各以 400 Gb/s 接到後端的機櫃訓練交換器(RTSW);另有 100 或 200 Gb/s 的前端 NIC 接到一般的機櫃交換器(RSW),再經 fabric 交換器通往儲存倉庫(Meta RoCE 論文 §3)。在 HPN 裡一台主機有九張 NIC:NIC 0 以兩個 200 Gb/s 埠服務前端,NIC 1–8 服務後端、每顆 GPU 一張,同樣是 2×200 Gb/s(HPN §3)。因此後端每台主機有 3.2 Tb/s,前端有 400 Gb/s。圖 9.1 是 Meta 版本的這種分工。

One AI rack with two hosts; each host connects to the front-end network through an RSW and to the back-end network through an RTSW at 400G per GPU
Figure 9.1. Meta's rack. Left: the front end, a normal rack switch (RSW), fabric switches and storage. Right: the back end, a dedicated RoCE fabric with one 400G link per GPU into the RTSW. Data ingestion, checkpoints and logging never touch the back end.圖 9.1。Meta 的機櫃。左:前端,一般的機櫃交換器(RSW)、fabric 交換器與儲存。右:後端,專用的 RoCE 網路,每顆 GPU 一條 400G 鏈路接到 RTSW。資料載入、檢查點與日誌永遠不碰後端。 Gangidi et al., "RDMA over Ethernet for Distributed AI Training at Meta Scale", ACM SIGCOMM 2024 (figure as published on the Meta Engineering blog).

The traffic that must stay off the GPU fabric. Four kinds of traffic travel on the front end, and HPN adds a fifth. Each has a different shape, and the shape decides how it is sized.

必須遠離 GPU 網路的流量。四種流量走在前端上,HPN 再加上第五種。每一種的形狀不同,而形狀決定了它怎麼定規模。

Traffic流量Direction and shape方向與形狀What sets its size決定大小的因素If it is slow變慢的後果
Dataset reads資料集讀取Storage → hosts; steady, prefetched儲存 → 主機;穩定,預先抓取Tokens per second×bytes per token\text{Tokens per second} \times \text{bytes per token}每秒 token 數×每個 token 的位元組數\text{每秒 token 數} \times \text{每個 token 的位元組數}GPUs wait for input; usually hiddenGPU 等待輸入;通常被遮住
Checkpoint writes檢查點寫入Hosts → storage; one synchronized burst主機 → 儲存;一次同步的突發Bytes per GPU×GPUs÷absorbing rate\text{Bytes per GPU} \times \text{GPUs} \div \text{absorbing rate}每顆 GPU 位元組數×GPU 數÷吸收速率\text{每顆 GPU 位元組數} \times \text{GPU 數} \div \text{吸收速率}All GPUs stall until absorbed所有 GPU 停頓到吸收完
Checkpoint reads檢查點讀取Storage → hosts; one burst per restart儲存 → 主機;每次重啟一次突發Shards without a copy on the fabric網路上沒有副本的分片Longer restart after every failure每次故障後重啟更久
Logs and telemetry日誌與遙測Hosts → collectors; many small flows主機 → 收集器;許多小流Hosts×bytes per host per second\text{Hosts} \times \text{bytes per host per second}主機數×每台主機每秒位元組數\text{主機數} \times \text{每台主機每秒位元組數}Faults are found late故障發現得晚
Control and management控制與管理Scheduler, heartbeats, images, PXE boot, SSH排程器、心跳、映像、PXE 開機、SSHSmall, except image pulls很小,拉取映像除外Slow start-up and recovery啟動與恢復變慢
Inference (HPN)推論(HPN)Clients ↔ hosts; request/response客戶端 ↔ 主機;請求/回應Requests per second; front-end heavy每秒請求數;以前端為主User-visible latency使用者看得見的延遲

Why they are separated. Meta gives the direct reason: a burst of checkpoint writes must never pause a collective, and the back end must be upgradable on its own schedule (Meta RoCE paper, Section 9.3). The mechanism is priority flow control: the back end is lossless, so a switch whose buffer fills sends a pause frame upstream, and the pause spreads hop by hop. A checkpoint is a many-to-one pattern, thousands of hosts writing to a few hundred storage servers at once. If those servers sat on the lossless fabric, the ports in front of them would fill and pause their upstream ports, and the pauses would reach the ports the collectives use: one slow storage server could stall an all-reduce on 16,000 GPUs. On a lossy TCP network the same incast drops packets, TCP backs off, and the checkpoint takes a little longer, the right failure mode for traffic nobody waits on microsecond by microsecond.

為什麼要分開。Meta 給出直接的理由:一波檢查點寫入永遠不能讓集體通訊暫停,而且後端必須能依自己的時程升級(Meta RoCE 論文 §3)。機制是優先權流量控制:後端是無損的,緩衝填滿的交換器向上游送出暫停幀,暫停一跳一跳地擴散。檢查點是多對一的模式,數千台主機同時寫向幾百台儲存伺服器。如果那些伺服器坐在無損網路上,它們前面的埠會填滿並暫停其上游埠,而暫停會一路傳到集體通訊使用的埠:一台慢的儲存伺服器就可能讓 16,000 顆 GPU 的 all-reduce 停擺。在有損的 TCP 網路上,同樣的 incast 只是丟包、TCP 退讓、檢查點多花一點時間,對沒有人以微秒為單位等待的流量來說,這才是正確的故障模式。

HPN's three reasons. The back end has eight times the front end's bandwidth, so HPN's authors considered putting storage there and rejected it for three reasons (HPN §8). Customers' datasets and container images live in other data centers, and an isolated back end cannot reach them without a proxy that copies every byte. Storage traffic injected into the back end as an experiment made training performance fluctuate: the PFC mechanism above, observed in practice. And storage servers consume ToR ports: a HPN ToR has 128 active host-facing 200G ports, and each one given to a storage server is one not given to a GPU. Storage stays on the front end, built non-blocking at 2×200 Gb/s per host so that the same machines can serve inference, whose traffic is front-end heavy. The HPN overview figure in Section 6.4 shows the result: the storage cluster sits inside HPN's front-end network.

HPN 的三個理由。後端有前端八倍的頻寬,所以 HPN 的作者曾考慮把儲存放到那裡,並基於三個理由拒絕(HPN §8)。客戶的資料集與容器映像放在其他資料中心,隔離的後端沒有一台逐位元組轉送的代理就無法到達它們。實驗中注入後端的儲存流量讓訓練效能出現波動:正是上面的 PFC 機制在實務中的樣子。而且儲存伺服器會消耗 ToR 埠:一台 HPN ToR 有 128 個使用中的面向主機 200G 埠,每一個給儲存伺服器的埠就是沒給 GPU 的埠。儲存留在前端,前端以每台主機 2×200 Gb/s 建成非阻塞,讓同樣的機器也能服務以前端流量為主的推論。第 6.4 節的 HPN 全貌圖顯示了結果:儲存叢集位在 HPN 的前端網路之內。

Meta's storage system is Tectonic, a distributed file system that spreads data over thousands of storage servers (Section 9.4). Panel 9.1 tests the case for the back end: does eight times more bandwidth per host (HPN) make a checkpoint faster?

Meta 的儲存系統是 Tectonic,一個把資料分散到數千台儲存伺服器上的分散式檔案系統(第 9.4 節)。面板 9.1 檢驗把儲存放上後端的理由:每台主機多八倍的頻寬(HPN),會讓檢查點變快嗎?

Panel 9.1面板 9.1

Would the back end write a checkpoint faster?後端會讓檢查點寫得更快嗎?

Back end : front end per host
每台主機的後端 : 前端
Stall, storage on the front end
停頓,儲存在前端
Stall, storage on the back end
停頓,儲存在後端
Time saved per checkpoint
每個檢查點省下的時間

The model uses the stall formula of Section 9.3, stall=max⁡(total÷storage peak, per-host bytes÷NIC rate)\text{stall} = \max(\text{total} \div \text{storage peak},\ \text{per-host bytes} \div \text{NIC rate}) with 4 GB per GPU (Llama 3's upper figure) and 8 GPUs per host. The back end is 8×400 Gb/s=3.2 Tb/s8 \times 400\,\text{Gb/s} = 3.2\,\text{Tb/s} per host in both designs. Defaults: HPN's front end, 16,384 GPUs and Tectonic's 7 TB/s peak. Both paths then stall for the same 9.4 s, because the storage system, not the host NIC, sets the stall. The model leaves out what HPN measured: storage traffic on the back end made training fluctuate. Try 256 GPUs, where the back end does save time.

這個模型使用 第 9.3 節 的停頓公式 停頓=max⁡(總量÷儲存峰值, 每台主機位元組數÷NIC 速率)\text{停頓} = \max(\text{總量} \div \text{儲存峰值},\ \text{每台主機位元組數} \div \text{NIC 速率})每顆 GPU 4 GB(Llama 3 的上限),每台主機 8 顆 GPU。兩種設計的後端都是每台主機 8×400 Gb/s=3.2 Tb/s8 \times 400\,\text{Gb/s} = 3.2\,\text{Tb/s}。預設值:HPN 的前端、16,384 顆 GPU 與 Tectonic 的 7 TB/s 峰值。這時兩條路徑的停頓都是 9.4 秒,因為決定停頓的是儲存系統,而不是主機 NIC。模型沒有包含 HPN 量到的現象:後端上的儲存流量讓訓練出現波動。試試 256 顆 GPU,這時後端確實能省時間。

How the two networks differ. The table is the whole argument in one place. The back end is engineered never to drop a packet; the front end is engineered so that a drop is harmless.

兩個網路有何不同。下表把整個論證放在一處。後端的工程目標是永不丟包;前端的工程目標是丟包無害。

Property性質Front end (FE)前端(FE)Back end (BE)後端(BE)
Transport傳輸層TCP/IP; storage and HTTP protocolsTCP/IP;儲存與 HTTP 協定RoCEv2 (RDMA in UDP/IP)RoCEv2(UDP/IP 中的 RDMA)
Loss丟包Lossy; drops are TCP's congestion signal有損;丟包是 TCP 的壅塞訊號Lossless; PFC pauses and deep buffers無損;PFC 暫停與深緩衝
Oversubscription超額認購Several to one; HPN's 1:1 is the exception數比一;HPN 的 1:1 是例外1:1 in a zone; 1:7 or 15:1 between podszone 內 1:1;pod 之間 1:7 或 15:1
Sharing共用Shared with the data center與資料中心共用Dedicated to one training cluster專屬於一個訓練叢集
Flows流Thousands of small flows; ECMP works數千條小流;ECMP 能用Tens of elephant flows per host; ECMP fails每台主機幾十條大象流;ECMP 失效
Per host每台主機Meta 100/200G; HPN 2×200GMeta 100/200G;HPN 2×200G8×400G (3.2 Tb/s) in both兩者都是 8×400G(3.2 Tb/s)
Cost of a slow second慢一秒的代價A later checkpoint or log line檢查點或日誌晚一點16,000 GPUs idle for that second16,000 顆 GPU 閒置那一秒

9.2Dataset traffic: smaller than you think資料集流量:比你想的小

Mechanism. A language model consumes tokens. Each step processes one global batch, and the loader must deliver the next batch before the next step begins, so the front end must supply bytes/s=tokens per step÷seconds per step×bytes per token\text{bytes/s} = \text{tokens per step} \div \text{seconds per step} \times \text{bytes per token} Llama 3 used a global batch of 16M tokens on 16,384 GPUs (Llama 3 Table 4). The step time is not published, but it can be derived from two facts: a dense transformer does about 6N6N FLOP per token, and the cluster achieved about 400 TFLOP/s per GPU (Table 4, row 2). The arithmetic, one question per row:

機制。語言模型消耗 token。每一步處理一個全域批次,載入器必須在下一步開始前送到下一個批次,所以前端必須供應 每秒位元組數=每步 token 數÷每步秒數×每個 token 的位元組數\text{每秒位元組數} = \text{每步 token 數} \div \text{每步秒數} \times \text{每個 token 的位元組數}Llama 3 在 16,384 顆 GPU 上使用 16M token 的全域批次(Llama 3 Table 4)。步時間沒有公布,但可以由兩個事實推導:稠密 transformer 每個 token 約做 6N6N FLOP,而叢集達到每顆 GPU 約 400 TFLOP/s(Table 4 第二行)。逐列計算如下:

Question問題Calculation算式Result結果
FLOP in one step of a 405B model over 16.8M tokens405B 模型對 16.8M 個 token 的一步 FLOP6×405×109×16.8×1066 \times 405 \times 10^{9} \times 16.8 \times 10^{6}≈4.1×1019\approx 4.1 \times 10^{19} FLOP
Cluster rate: 16,384 GPUs at 400 TFLOP/s叢集速率:16,384 顆 GPU、每顆 400 TFLOP/s16,384×4.0×101416{,}384 \times 4.0 \times 10^{14}≈6.6×1018\approx 6.6 \times 10^{18} FLOP/s
Step time步時間4.1×1019÷6.6×10184.1 \times 10^{19} \div 6.6 \times 10^{18}≈6.2\approx 6.2 sabout 6 seconds約 6 秒
Tokens consumed per second每秒消耗的 token 數16.8×106÷6.216.8 \times 10^{6} \div 6.2≈2.7×106\approx 2.7 \times 10^{6}2.7 million tokens per second每秒約 270 萬個 token

One step therefore took about 6 seconds, and the job consumed about 2.7 million tokens per second.

因此一步約 6 秒,任務每秒消耗約 270 萬個 token。

Bytes per token. Tokenized text is stored as integer ids: 2 bytes for a vocabulary up to 65,536, 4 bytes for Llama 3's 128K vocabulary in the usual integer formats. The dataset rate of the whole cluster is then 2.7×106×4≈112.7 \times 10^{6} \times 4 \approx 11 MB/s, about 5 KB/s for each of 2,048 hosts. A 100G front-end NIC moves 12.5 GB/s, so dataset reads use about one millionth of it. The whole 15.6-trillion-token dataset is about 62 TB and is read once over the run.

每個 token 的位元組數。token 化後的文字以整數 id 儲存:詞彙表在 65,536 以內是 2 個位元組,Llama 3 的 128K 詞彙表在常見的整數格式下是 4 個位元組。整個叢集的資料集速率於是是 2.7×106×4≈112.7 \times 10^{6} \times 4 \approx 11 MB/s,2,048 台主機每台約 5 KB/s。一張 100G 前端 NIC 能搬 12.5 GB/s,所以資料集讀取只用了它的百萬分之一左右。整個 15.6 兆 token 的資料集約 62 TB,整段訓練只讀一遍。

Why it is small. A 405B model spends about 2.4×10122.4 \times 10^{12} FLOP on every token, and the token arrives as 4 bytes: about 6×10116 \times 10^{11} FLOP per byte. No network is a bottleneck at that ratio. What matters for text is the access pattern: shuffled reads across many shards, hidden by keeping batches in flight.

為什麼這麼小。405B 模型對每個 token 花約 2.4×10122.4 \times 10^{12} FLOP,而 token 以 4 個位元組到達:每位元組約 6×10116 \times 10^{11} FLOP。在這個比率下沒有任何網路會是瓶頸。對文字重要的是存取模式:打亂的讀取分散在許多分片上,靠讓批次在途來遮住延遲。

Panel 9.2 repeats this derivation for other models, clusters and token sizes.

面板 9.2 對其他模型、叢集與 token 大小重做這個推導。

Panel 9.2面板 9.2

Dataset rate from the compute rate由計算速率推出資料集速率

Tokens per second
每秒 token 數
Dataset rate, whole cluster
資料集速率,整個叢集
Per host (8 GPUs)
每台主機(8 顆 GPU)
Share of a 100G NIC
占一張 100G NIC 的比例

A model: tokens/s=GF/(6N)\text{tokens/s} = G F / (6N) for GG GPUs that each achieve FF FLOP/s on a model of NN parameters, from the 6N6N FLOP per token of this section. The batch size cancels out. Then bytes/s=tokens/s×bytes per token\text{bytes/s} = \text{tokens/s} \times \text{bytes per token} Defaults are Llama 3 405B on 16,384 GPUs at 400 TFLOP/s with 4-byte token ids, which give the 2.7 million tokens per second and about 11 MB/s derived above. The 1 KB and 10 KB settings are this section's estimates for image and video tokens; the second bar shows eight readers per host instead of one loader.

這是模型:每秒 token 數=GF/(6N)\text{每秒 token 數} = G F / (6N),其中 GG 顆 GPU 每顆達到 FF FLOP/s,模型有 NN 個參數,取自本節每個 token 6N6N FLOP 的關係。批次大小會被消掉。接著 每秒位元組數=每秒 token 數×每 token 位元組數\text{每秒位元組數} = \text{每秒 token 數} \times \text{每 token 位元組數}預設值是 Llama 3 405B 在 16,384 顆 GPU 上、每顆 400 TFLOP/s、token id 4 位元組,得出上面推導的每秒 270 萬個 token 與約 11 MB/s。1 KB 與 10 KB 是本節對影像與影片 token 的估計;第二條長條是每台主機八個讀者、而不是一個載入器的情況。

Why it is large for images and video. The same formula with a different bytes-per-token changes the answer by orders of magnitude. A JPEG of a few hundred kilobytes that becomes a few hundred image tokens gives roughly 1 KB per token, about 250 times text; video can be 10 KB per token or more, depending on the tokenizer. At 2.7 million tokens per second, 1 KB per token is 2.7 GB/s for the cluster (22 Gb/s) and 10 KB per token is 27 GB/s (216 Gb/s): over 2,048 hosts still only about 100 Mb/s per host, so even a multimodal job does not fill a front-end NIC. What it fills is the request rate and the CPUs: at 256 tokens per image, 2.7 million tokens per second is about 10,000 image reads and JPEG decodes every second. Figure 9.2 puts these rates on one scale.

為什麼對影像與影片就變大。同一個公式換上不同的每 token 位元組數,答案差好幾個數量級。一張幾百 KB 的 JPEG 變成幾百個影像 token,大約每個 token 1 KB,是文字的 250 倍左右;影片依 token 化方式可達每個 token 10 KB 以上。在每秒 270 萬個 token 下,每 token 1 KB 是整個叢集 2.7 GB/s(22 Gb/s),每 token 10 KB 是 27 GB/s(216 Gb/s):分到 2,048 台主機仍只有每台約 100 Mb/s,所以即使多模態任務也不會塞滿前端 NIC。它塞滿的是請求速率與 CPU:每張影像 256 個 token 時,每秒 270 萬個 token 就是每秒約 10,000 次影像讀取與 JPEG 解碼。圖 9.2 把這些速率放在同一個尺度上。

1 × 100G NIC1 張 100G NIC12.5 GB/s2,048 × 100G2,048 張 100G25.6 TB/stext, 4 B文字,4 B11 MB/simage, 1 KB影像,1 KB2.7 GB/svideo, 10 KB影片,10 KB27 GB/scheckpoint檢查點7 TB/s burst7 TB/s 突發1 MB/s1 GB/s1 TB/s100 TB/scluster-wide read rate, log scale · 2.7 M tokens/s整個叢集的讀取速率,對數尺度 · 每秒 270 萬個 token
Figure 9.2. One formula, four answers: the cluster-wide read rate for Llama 3's 2.7 million tokens per second, on a log scale. Text at 4 bytes per token needs 11 MB/s. Image and video tokens of about 1 KB and 10 KB raise it to 2.7 and 27 GB/s; even video needs only about two 100G NICs' worth for the whole cluster. All 2,048 front-end NICs together move 25.6 TB/s, and the checkpoint burst of Section 9.3 is 7 TB/s.圖 9.2。一個公式,四個答案:Llama 3 每秒 270 萬個 token 在整個叢集的讀取速率,對數尺度。每個 token 4 位元組的文字需要 11 MB/s。約 1 KB 與 10 KB 的影像與影片 token 把它提高到 2.7 與 27 GB/s;即使是影片,整個叢集也只需要約兩張 100G NIC 的量。2,048 張前端 NIC 合計能搬 25.6 TB/s,而 第 9.3 節 的檢查點突發是 7 TB/s。Drawn for this primer from the numbers of this section (Llama 3 Table 4; the image and video bytes per token are our estimates).

Data loaders. MegaScale describes the loader design most large jobs use (MegaScale §3.4). The eight GPUs of a tensor-parallel group need identical inputs, so one loader per machine reads the batch into shared memory and each GPU copies from there; eight separate readers would multiply the storage request rate by eight for no gain. Preprocessing of the next step's data runs during the gradient synchronization at the end of the current step, hidden behind communication the GPUs wait for anyway. Prefetching keeps one or two batches ahead, and caching on local NVMe turns repeated reads of the same shards into a one-time fill.

資料載入器。MegaScale 描述了多數大型任務採用的載入器設計(MegaScale §3.4)。張量平行群組的八顆 GPU 需要相同的輸入,所以每台機器一個載入器把批次讀進共享記憶體,每顆 GPU 從那裡複製;八個各自的讀者會讓儲存請求速率無謂地乘以八。下一步資料的前處理在這一步結尾的梯度同步期間執行,藏在 GPU 本來就在等的通訊後面。預先抓取維持一到兩個批次的領先,本地 NVMe 快取則把同樣分片的重複讀取變成一次性的填充。

Worked example. A 16K-GPU multimodal job at 10 KB per token reads 27 GB/s, or 216 Gb/s, cluster-wide: 105 Mb/s per host with one shared-memory loader, 840 Mb/s with eight readers, still under 1% of a 100G NIC. The constraint is the 10,000 object reads per second and the CPU time to decode them, not the NIC. The checkpoint burst of the next section, for the same job, is 27 Gb/s per host and 7 TB/s for the storage system. Figure 9.3 draws the two loader designs with these numbers.

算一題。一個 16K 顆 GPU 的多模態任務,每個 token 10 KB,整個叢集讀 27 GB/s,即 216 Gb/s:用一個共享記憶體載入器是每台主機 105 Mb/s,八個讀者則是 840 Mb/s,仍不到 100G NIC 的 1%。限制是每秒 10,000 次物件讀取與解碼它們的 CPU 時間,不是 NIC。下一節的檢查點突發,對同一個任務,是每台主機 27 Gb/s,對儲存系統則是 7 TB/s。圖 9.3 用這些數字畫出兩種載入器設計。

(a)storage儲存host主機G0G1G2G3G4G5G6G78 readers: 8 × the reads8 個讀者:讀取次數 × 8840 Mb/s per host每台主機 840 Mb/s(b)storage儲存host主機G0G1G2G3G4G5G6G71 loader → shared memory1 個載入器 → 共享記憶體1 reader: 1 × the reads1 個讀者:讀取次數 × 1105 Mb/s per host每台主機 105 Mb/s
Figure 9.3. Two loader designs for the 10 KB-per-token job of the worked example. (a) Each of the eight GPUs reads its own copy of the batch: eight times the storage reads, 840 Mb/s per host. (b) MegaScale's design: one loader per machine reads the batch into shared memory, and each GPU copies it from there: 105 Mb/s per host. Both fit easily in a 100G NIC; the saving that matters is in storage requests.圖 9.3。算例中每 token 10 KB 任務的兩種載入器設計。(a) 八顆 GPU 各自讀取一份批次:儲存讀取次數變成八倍,每台主機 840 Mb/s。(b) MegaScale 的設計:每台機器一個載入器把批次讀進共享記憶體,每顆 GPU 再從那裡複製:每台主機 105 Mb/s。兩者都輕鬆放進一張 100G NIC;真正省下的是儲存請求。Drawn for this primer from MegaScale §3.4 (Jiang et al., NSDI 2024) and the worked example of this section.

Animation 9.1 plays one training step of this pipeline on one host, for either loader design.

動畫 9.1 在一台主機上播放這條管線的一個訓練步,可切換兩種載入器設計。

Animation 9.1動畫 9.1

One step of the data pipeline資料管線的一個訓練步

One host of the worked example: a 16K-GPU multimodal job at 10 KB per token. The rate bars use this section's numbers: 105 Mb/s per host with one shared-memory loader and 840 Mb/s with eight readers, against the 27 Gb/s checkpoint burst of Section 9.3, on the scale of a 100G NIC. Simplified: one batch is prefetched (real loaders keep one or two ahead), and the phases are not drawn to time scale.

工作範例中的一台主機:每 token 10 KB、16K 顆 GPU 的多模態任務。速率條用本節的數字:一個共享記憶體載入器時每台主機 105 Mb/s,八個讀取程序時 840 Mb/s,對照 第 9.3 節 每台主機 27 Gb/s 的檢查點突發,以 100G NIC 為刻度。簡化:只預取一個批次(實際的載入器會超前一到兩個),各階段也不按時間比例繪製。

Stop and think停下來想一想

In Panel 9.6 below, set bytes per token to 1,000 and the step time to 1 second. How large is the dataset bar next to the checkpoint burst? Now switch Panel 9.3 to two-stage. Which bar moved, and why did the dataset bar not move at all?

在下面的面板 9.6 把每個 token 的位元組數設為 1,000、步時間設為 1 秒。資料集那一段和檢查點突發相比有多大?現在把面板 9.3 切到兩階段。哪一段動了?為什麼資料集那一段完全沒動?

9.3Checkpoint traffic: the burst that sizes everything檢查點流量:決定一切規模的突發

What is in a checkpoint. A checkpoint is the state needed to resume training: weights, optimizer state and a little bookkeeping. In mixed-precision training with Adam, each parameter carries a 2-byte BF16 weight, a 4-byte FP32 master weight and two 4-byte Adam moments. How much one GPU writes depends on sharding. With fully sharded data parallelism every GPU owns a different slice. Sharded only across the tensor- and pipeline-parallel positions and replicated across the data-parallel group, each GPU holds a larger piece, and one replica writes. The sizes, one question per row:

檢查點裡有什麼。檢查點是恢復訓練所需的狀態:權重、優化器狀態與少量簿記。在使用 Adam 的混合精度訓練中,每個參數帶著 2 位元組的 BF16 權重、4 位元組的 FP32 主權重與兩個 4 位元組的 Adam 動量。一顆 GPU 寫多少取決於分片。在完全分片的資料平行下每顆 GPU 擁有不同的一片。若只沿張量與管線平行位置分片、並在資料平行群組內複製,每顆 GPU 持有較大的一塊,且只需一個副本寫入。逐列計算大小如下:

Question問題Calculation算式Result結果
Bytes per parameter: BF16 weight, FP32 master weight, two Adam moments每個參數的位元組數:BF16 權重、FP32 主權重、兩個 Adam 動量2+4+4+42 + 4 + 4 + 41414 bytes位元組
Checkpoint of the 405B model405B 模型的檢查點405×109×14405 \times 10^{9} \times 14≈5.67\approx 5.67 TBabout 5.7 TB約 5.7 TB
Per GPU, fully sharded over 16,384 GPUs每顆 GPU,完全分片到 16,384 顆 GPU5.67 TB÷16,3845.67\,\text{TB} \div 16{,}384≈350\approx 350 MB
Per GPU, sharded only over the tensor- and pipeline-parallel positions (TP = 8, PP = 16)每顆 GPU,只沿張量與管線平行位置分片(TP = 8、PP = 16)5.67 TB÷(8×16)5.67\,\text{TB} \div (8 \times 16)≈44\approx 44 GB128 positions128 個位置

Llama 3 reports 1 MB to 4 GB per GPU depending on sharding (§3.3.1); the upper figure times 16,384 exceeds one copy of the state, so the layout matters.

Llama 3 報告每顆 GPU 從 1 MB 到 4 GB,取決於分片(§3.3.1);上限乘以 16,384 超過一份狀態,所以配置很重要。

Total per checkpoint. Multiply by the GPU count: at 1 MB per GPU, 16,384 GPUs write 16 GB; at 350 MB, 5.7 TB; at 4 GB, 65.5 TB. Storage must be designed for the one your sharding produces, not the average.

每個檢查點的總量。乘上 GPU 數:每顆 1 MB 時,16,384 顆 GPU 寫 16 GB;每顆 350 MB 時 5.7 TB;每顆 4 GB 時 65.5 TB。儲存必須為你的分片產生的那一個設計,而不是為平均值。

The burst problem. Training is synchronous: every GPU reaches the checkpoint step at the same iteration, starts writing in the same second, and writes at no other time. The storage sees nothing, then 65 TB, then nothing for an hour. Averaged over the hour, 65.5 TB is only 18 GB/s; the burst is what hurts, and the Llama 3 paper calls bursty checkpoint writes a major challenge (§3.3.1). This is why Tectonic is specified with two numbers, 2 TB/s sustained and 7 TB/s peak: the peak is sized for the burst. When GPUs write directly, stall=total bytes÷peak rate\text{stall} = \text{total bytes} \div \text{peak rate}: 65.5 TB at 7 TB/s is 9.4 seconds, at 2 TB/s 33 seconds; the 5.7 TB case takes 0.8 seconds.

突發的問題。訓練是同步的:每顆 GPU 在同一個迭代到達檢查點那一步、在同一秒開始寫入,其他時間都不寫。儲存先看到什麼都沒有,然後是 65 TB,然後又一個小時什麼都沒有。平均到一小時,65.5 TB 只有 18 GB/s;傷人的是突發,Llama 3 論文稱突發的檢查點寫入是主要挑戰(§3.3.1)。這就是 Tectonic 用兩個數字規格化的原因,2 TB/s 持續與 7 TB/s 峰值:峰值是為突發定的。GPU 直接寫入時,停頓=總位元組數÷峰值速率\text{停頓} = \text{總位元組數} \div \text{峰值速率}:65.5 TB 在 7 TB/s 下是 9.4 秒,在 2 TB/s 下是 33 秒;5.7 TB 的情況需要 0.8 秒。

The second limit: the host's own NIC. A host with eight GPUs at 4 GB each has 32 GB to send: 2.6 seconds at 100 Gb/s, 0.64 seconds at 400 Gb/s. The stall is the larger of the two bounds: stall=max⁡(total÷storage peak, per-host bytes÷NIC rate)\text{stall} = \max(\text{total} \div \text{storage peak},\ \text{per-host bytes} \div \text{NIC rate}) With 2,048 hosts the storage limit dominates (9.4 s against 2.6 s); a 256-GPU job on the same Tectonic is the opposite, 0.15 seconds of storage time against 2.6 seconds through 100G NICs. Small jobs are NIC-bound, large ones storage-bound. Panel 9.3 computes both. Figure 9.4 shows the burst as the storage sees it.

第二個限制:主機自己的 NIC。一台有八顆 GPU、每顆 4 GB 的主機要送 32 GB:在 100 Gb/s 下 2.6 秒,在 400 Gb/s 下 0.64 秒。停頓是兩個上限中較大者:停頓=max⁡(總量÷儲存峰值, 每台主機位元組數÷NIC 速率)\text{停頓} = \max(\text{總量} \div \text{儲存峰值},\ \text{每台主機位元組數} \div \text{NIC 速率})有 2,048 台主機時儲存限制主導(9.4 秒對 2.6 秒);同一套 Tectonic 上的 256 顆 GPU 任務則相反,儲存只要 0.15 秒,穿過 100G NIC 卻要 2.6 秒。小任務受 NIC 限制,大任務受儲存限制。面板 9.3 兩個都算。圖 9.4 畫出儲存眼中的這波突發。

246807 TB/s peak7 TB/s 峰值direct write直接寫入65.5 TB in 9.4 s9.4 秒寫完 65.5 TBGPUs stalledGPU 停頓2468065.5 TB in 33 s · GPUs running33 秒寫完 65.5 TB · GPU 照常運行two-stage drain兩階段排空after a 0.8 s copy to host memory先花 0.8 秒複製到主機記憶體2 TB/s sustained2 TB/s 持續05101520253035time (s)時間(秒)same area under both shapes: the bytes do not change, only the rate兩個形狀面積相同:位元組數不變,只有速率變green line: hourly average 18 GB/s (0.26 % of peak)綠線:每小時平均 18 GB/s(峰值的 0.26 %)write rate (TB/s)寫入速率(TB/s)
Figure 9.4. One 65.5 TB checkpoint as the storage sees it, with the direct write in the upper panel and the two-stage drain in the lower one, both drawn on the same scales. Direct writes need the 7 TB/s peak and stall the GPUs for 9.4 s. A two-stage checkpoint, which copies to host memory first, drains the same bytes at the 2 TB/s sustained rate while the GPUs compute. The hourly average is the thin green line along the bottom of each panel, which is invisible at this scale and useless for sizing.圖 9.4。一次 65.5 TB 檢查點在儲存眼中的樣子,上圖是直接寫入,下圖是兩階段排空,兩者用相同的刻度。直接寫入需要 7 TB/s 的峰值,並讓 GPU 停頓 9.4 秒。兩階段檢查點先複製到主機記憶體,在 GPU 計算的同時以 2 TB/s 的持續速率排空同樣的位元組。每小時平均是每個面板底部那條細綠線,在這個尺度上看不見,對定規模也沒用。Drawn for this primer from numbers in Grattafiori et al., 2024 (Tectonic) and Jiang et al., NSDI 2024 (two-stage checkpoint).

The power swing. A stall is also a grid event. When 16,384 GPUs stop and resume in the same second, the site's draw drops and jumps by their full load: 16,384 H100s at 700 W are 11.5 MW of GPU power alone, and the Llama 3 paper says the synchronized swing reaches tens of megawatts, enough to strain the power grid.

功率擺動。停頓也是電網事件。當 16,384 顆 GPU 在同一秒停下又恢復,站點的用電會以它們的全部負載下降再跳升:16,384 顆 700 W 的 H100 單是 GPU 功率就有 11.5 MW,而 Llama 3 論文說同步的擺動達數十兆瓦,足以對電網造成壓力。

Fraction of time lost. lost fraction=stall÷interval\text{lost fraction} = \text{stall} \div \text{interval}. With hourly checkpoints, a 9.4-second stall loses 0.26% of the run and a 33-second stall 0.9%. If failures force checkpoints every 15 minutes, the 33-second stall costs 3.7%, more than a generation of network tuning gains. The storage peak rate, not its capacity, is what matters for training efficiency.

損失的時間比例。損失比例=停頓÷間隔\text{損失比例} = \text{停頓} \div \text{間隔}。每小時存一次時,9.4 秒的停頓損失整段訓練的 0.26%,33 秒的停頓損失 0.9%。如果故障迫使每 15 分鐘存一次,33 秒的停頓要花 3.7%,比一整代網路調校的收益還多。對訓練效率重要的是儲存的峰值速率,而不是容量。

Two-stage checkpoints. MegaScale breaks the link between the stall and the storage system (MegaScale §4.3). Each GPU copies its state into pinned host memory, which takes seconds, and resumes; a background process then writes from host memory to HDFS. The stall becomes per-host bytes÷host copy rate\text{per-host bytes} \div \text{host copy rate}: 32 GB at a few tens of GB/s over PCIe is under one second. The storage then drains total bytes÷sustained rate\text{total bytes} \div \text{sustained rate}, 33 seconds for 65.5 TB at 2 TB/s, which must finish before the next checkpoint. The host needs the memory, 32 GB per host here, twice that if the next copy may start before the previous drain ends. Checkpoints can then be taken more often, and the storage needs only its sustained rate.

兩階段檢查點。MegaScale 切斷了停頓與儲存系統之間的連結(MegaScale §4.3)。每顆 GPU 把狀態複製到釘住的主機記憶體,只需數秒,隨即恢復;一個背景行程再從主機記憶體寫到 HDFS。停頓變成 每台主機位元組數÷主機複製速率\text{每台主機位元組數} \div \text{主機複製速率}32 GB 以 PCIe 上幾十 GB/s 的速率不到一秒。儲存接著以 總位元組數÷持續速率\text{總位元組數} \div \text{持續速率} 排空,65.5 TB 在 2 TB/s 下是 33 秒,必須在下一次檢查點前完成。主機需要這些記憶體,本例每台 32 GB,若下一次複製可能在上一次排空結束前開始則要兩倍。檢查點於是可以存得更頻繁,儲存也只需要持續速率。

Animation 9.2 plays one Llama 3 checkpoint, written directly or in two stages.

動畫 9.2 播放 Llama 3 的一次檢查點,可選直接寫入或兩階段寫入。

Animation 9.2動畫 9.2

A checkpoint, direct or two-stage一次檢查點:直接寫入或兩階段

Llama 3 numbers from this section: 16,384 GPUs at 4 GB each (65.5 TB) and storage at 7 TB/s peak and 2 TB/s sustained. Three of the 2,048 hosts are drawn, and the per-host rates are the storage rate shared by 2,048 hosts. The host copy is drawn as 0.8 s (32 GB at 40 GB/s, the default of Panel 9.3); the page says only that it takes under one second. The NIC bound is not drawn.

本節的 Llama 3 數字:16,384 顆 GPU、每顆 4 GB(共 65.5 TB),儲存峰值 7 TB/s、持續 2 TB/s。圖中畫出 2,048 台主機中的 3 台,每台主機的速率是儲存速率由 2,048 台主機分攤。主機複製畫成 0.8 秒(32 GB 以 40 GB/s,面板 9.3 的預設值);本章只說它不到一秒。NIC 的限制沒有畫出。

Recovery reads. After a failure every GPU needs its shard back; if all 16,384 read from storage, the read burst is as large as the write burst. MegaScale makes it cheap: one worker per data-parallel group reads its shard from HDFS and broadcasts it to the others over the back-end fabric (MegaScale §4.3). This works when state is replicated across the data-parallel group, as in MegaScale's ZeRO-2 layout, where parameters are replicated and only optimizer state is sharded. In its 175B job with TP=8 and PP=8 on 12,288 GPUs there are 64 distinct shard positions and 12,288÷64=19212{,}288 \div 64 = 192 copies of each, so 64 readers replace 12,288 and storage sees 192 times fewer bytes. The broadcast moves each shard of a few tens of gigabytes over 400 Gb/s links in about a second per hop. Figure 9.5 draws the two read patterns.

恢復時的讀取。故障後每顆 GPU 都需要拿回自己的分片;如果 16,384 顆全部從儲存讀,讀取突發和寫入突發一樣大。MegaScale 讓它變便宜:每個資料平行群組一個 worker 從 HDFS 讀取它的分片,再透過後端網路廣播給其他成員(MegaScale §4.3)。這在狀態於資料平行群組內有副本時有效,例如 MegaScale 的 ZeRO-2 配置:參數有副本、只有優化器狀態分片。在它於 12,288 顆 GPU 上 TP=8、PP=8 的 175B 任務中,有 64 個不同的分片位置、每個有 12,288÷64=19212{,}288 \div 64 = 192 份副本,所以 64 個讀者取代 12,288 個,儲存看到的位元組少了 192 倍。廣播把每個幾十 GB 的分片在 400 Gb/s 鏈路上以每跳約一秒搬完。圖 9.5 畫出這兩種讀取模式。

HDFS storage, reached over the front endHDFS 儲存,經前端網路到達12,288 reads12,288 次讀取copy 1副本 1…copy 2副本 2…copy 3副本 3…copy 192副本 192…⋮⋮⋮⋮shard分片12364…(a) every GPU reads its own shard(a) 每顆 GPU 讀自己的分片storage sends each shard 192 times儲存把每個分片送出 192 次64 reads64 次讀取copy 1副本 1…copy 2副本 2…copy 3副本 3…copy 192副本 192…shard分片12364…(b) one read per data-parallel group(b) 每個資料平行群組讀一次the back end makes the other 191其餘 191 份經後端廣播read from storage從儲存讀取broadcast over the back end經後端廣播
Figure 9.5. Recovery reads in MegaScale's 175B job on 12,288 GPUs (TP = 8, PP = 8). Each square is one GPU's copy of a shard; the columns are the 64 shard positions, the rows the 192 copies of each. (a) If every GPU reads its own shard, storage serves 12,288 reads and sends every shard 192 times. (b) MegaScale reads each shard once per data-parallel group (blue) and broadcasts it over the back end (orange): 64 reads, and 192 times fewer bytes from storage.圖 9.5。MegaScale 在 12,288 顆 GPU 上(TP = 8、PP = 8)的 175B 任務恢復時的讀取。每個方塊是一顆 GPU 持有的一份分片;直欄是 64 個分片位置,橫列是每個位置的 192 份副本。(a) 如果每顆 GPU 都自己讀,儲存要服務 12,288 次讀取,每個分片送出 192 次。(b) MegaScale 每個資料平行群組只讀一次(藍色),再經後端廣播(橘色):64 次讀取,儲存送出的位元組少 192 倍。Drawn for this primer from MegaScale §4.3 (Jiang et al., NSDI 2024).

Animation 9.3 plays the two read patterns of Figure 9.5 step by step.

動畫 9.3 逐步播放圖 9.5 的兩種讀取方式。

Animation 9.3動畫 9.3

Recovery reads after a failure故障後的恢復讀取

MegaScale's 175B job (MegaScale §4.3): TP = 8 and PP = 8 on 12,288 GPUs give 64 shard positions with 192 copies each. The drawing shows 8 positions and 6 copies; the counters are for the whole job. One read per group works only when the state is replicated across the data-parallel group, as in MegaScale's ZeRO-2 layout. The broadcast is drawn as one wave down each column; its algorithm and timing are not modelled.

MegaScale 的 175B 任務(MegaScale §4.3):12,288 顆 GPU 上 TP = 8、PP = 8,得到 64 個分片位置,每個有 192 份副本。圖中畫出 8 個位置與 6 份副本;計數器是整個任務的數字。每組只讀一次的做法,只在狀態於資料平行群組內複製時才成立,例如 MegaScale 的 ZeRO-2 配置。廣播畫成沿每一欄往下的一道波;它的演算法與時間沒有建模。

Checkpoint arithmetic
檢查點的算術

A checkpoint holds the 16-bit weights and the optimizer state in 32-bit numbers. HPN reports checkpoint intervals of two to four hours and about 30 GB per GPU. For a 405B model, the arithmetic is:

檢查點包含 16 位元的權重,以及以 32 位元儲存的優化器狀態。HPN 報告的檢查點間隔是兩到四小時、每顆 GPU 約 30 GB。以 405B 模型計算:

Question問題Calculation算式Result結果
Bytes per checkpoint: per parameter, 2 for the weight and three 4-byte optimizer values每個檢查點的位元組:每個參數有 2 位元組的權重,加上三個 4 位元組的優化器數值405×109×(2+4+4+4)405 \times 10^{9} \times (2 + 4 + 4 + 4)≈5.7\approx 5.7 TB
Storage bandwidth to write it in one minute一分鐘內寫完所需的儲存頻寬5.7×1012×8÷605.7 \times 10^{12} \times 8 \div 60≈760\approx 760 Gb/sacross the whole cluster整個叢集合計

So one checkpoint is about 5.7 TB, and writing it in a minute needs about 760 Gb/s of storage bandwidth across the cluster. That is why the front end cannot be an afterthought.

所以一個檢查點約 5.7 TB;要在一分鐘內寫完,整個叢集需要約 760 Gb/s 的儲存頻寬。這就是前端網路不能隨便設計的原因。

Panel 9.3面板 9.3

Checkpoint burst planner檢查點突發規劃器

Bytes per checkpoint
每個檢查點的位元組數
GPU stall per checkpoint
每個檢查點的 GPU 停頓
Rate during the stall
停頓期間的速率
Background drain
背景排空
Wall-clock lost
損失的牆上時間
Host memory per host
每台主機所需記憶體

Defaults are Llama 3: 16,384 GPUs, 4 GB per GPU, Tectonic at 7 TB/s peak and 2 TB/s sustained, which gives the 65.5 TB burst and the 9.4 s stall of Section 9.3. Direct write: stall=max⁡(total÷peak, per-host bytes÷NIC)\text{stall} = \max(\text{total} \div \text{peak},\ \text{per-host bytes} \div \text{NIC}) Two-stage (MegaScale): stall=per-host bytes÷copy rate\text{stall} = \text{per-host bytes} \div \text{copy rate}, then the storage drains at the sustained rate in the background. Try 5-minute intervals in both modes, and try 256 GPUs to see the NIC become the limit.

預設值是 Llama 3:16,384 顆 GPU、每顆 4 GB、Tectonic 峰值 7 TB/s 與持續 2 TB/s,得出 第 9.3 節 的 65.5 TB 突發與 9.4 秒停頓。直接寫入:停頓=max⁡(總量÷峰值, 每台主機位元組數÷NIC)\text{停頓} = \max(\text{總量} \div \text{峰值},\ \text{每台主機位元組數} \div \text{NIC})兩階段(MegaScale):停頓=每台主機位元組數÷複製速率\text{停頓} = \text{每台主機位元組數} \div \text{複製速率}之後儲存在背景以持續速率排空。試試兩種模式下 5 分鐘的間隔,再試 256 顆 GPU,看 NIC 變成限制。

Stop and think停下來想一想

With the defaults, move the interval from 60 to 5 minutes. The lost fraction rises twelvefold. Now switch to two-stage. What is the lost fraction, and does the drain still finish before the next checkpoint? Lower the sustained rate to 0.5 TB/s and watch the drain tile.

在預設值下把間隔從 60 分鐘移到 5 分鐘。損失比例升了十二倍。現在切到兩階段。損失比例是多少?排空還能在下一次檢查點前完成嗎?把持續速率降到 0.5 TB/s,看看排空那一格。

Looking ahead
預告
How often to write a checkpoint depends on how often the job fails. Chapter 10 counts the failures and derives the best interval.
多久寫一次檢查點,取決於任務多常故障。第 10 章會統計故障並推導出最佳的間隔。

9.4Storage systems in one page一頁看懂儲存系統

Distributed file systems. Llama 3's checkpoints and data live in Tectonic, Meta's distributed file system: 240 PB on 7,500 SSD servers, 2 TB/s sustained and 7 TB/s peak (Llama 3 §3.3.1). Per server that is about 32 TB of flash, 0.93 GB/s at peak and 0.27 GB/s sustained. A single NVMe drive reads at several GB/s, so the flash is not the limit; the storage servers' network ports, the erasure-coding (a way to protect data with less redundancy than copies, described below) and metadata work per write, and the share reserved for Meta's other services are. MegaScale writes to HDFS, the Hadoop file system, which stores large blocks on many data nodes under a single metadata server and suits sequential writes from a moderate number of clients; hence the two-stage writes and the one reader per group.

分散式檔案系統。Llama 3 的檢查點與資料放在 Meta 的分散式檔案系統 Tectonic:7,500 台 SSD 伺服器上的 240 PB,2 TB/s 持續與 7 TB/s 峰值(Llama 3 §3.3.1)。每台伺服器約 32 TB 的快閃記憶體、峰值 0.93 GB/s、持續 0.27 GB/s。單顆 NVMe 硬碟就能以數 GB/s 讀取,所以快閃記憶體不是限制;儲存伺服器的網路埠、每次寫入的糾刪碼(一種比多存幾份副本更省空間的資料保護方式,下面會說明)與中繼資料工作,以及留給 Meta 其他服務的份額才是。MegaScale 寫到 HDFS,即 Hadoop 檔案系統,它把大區塊放在單一中繼資料伺服器之下的許多資料節點上,適合來自適量客戶端的順序寫入;兩階段寫入與每組一個讀者正是因此而來。

Why server count, not capacity, sets the peak. Throughput is servers×rate per server\text{servers} \times \text{rate per server}; capacity is servers×terabytes per server\text{servers} \times \text{terabytes per server}. Larger drives raise the second product and leave the first unchanged, so the checkpoint sizing question is "how many servers and ports", not "how many petabytes". To absorb a 65.5 TB burst in 10 seconds you need 6.5 TB/s; at about 1 GB/s per server that is about 6,500 servers, close to Tectonic's 7,500, although 65.5 TB is 0.03% of its 240 PB. A 10 PB system built from 300 dense servers has plenty of room and a stall of several minutes. Panel 9.4 computes both products for a system of your choice.

為什麼決定峰值的是伺服器數而非容量。吞吐是 伺服器數×每台速率\text{伺服器數} \times \text{每台速率};容量是 伺服器數×每台 TB 數\text{伺服器數} \times \text{每台 TB 數}。更大的硬碟提高第二個乘積、第一個不變,所以檢查點的規模問題是「多少台伺服器與多少個埠」,不是「多少 PB」。要在 10 秒內吸收 65.5 TB 的突發需要 6.5 TB/s;以每台約 1 GB/s 計約需 6,500 台伺服器,接近 Tectonic 的 7,500 台,儘管 65.5 TB 只是其 240 PB 的 0.03%。一個由 300 台高密度伺服器組成的 10 PB 系統空間綽綽有餘,停頓卻要好幾分鐘。面板 9.4 為你選的系統算出這兩個乘積。

Panel 9.4面板 9.4

Capacity is not throughput容量不等於吞吐

Capacity
容量
Peak rate
峰值速率
GPU stall per checkpoint
每個檢查點的 GPU 停頓
Share of capacity used
用掉的容量比例

A model: capacity is servers×TB per server\text{servers} \times \text{TB per server}, the peak rate is servers×rate per server\text{servers} \times \text{rate per server}, and a direct write stalls the GPUs for checkpoint÷peak rate\text{checkpoint} \div \text{peak rate}. Defaults are Tectonic: 7,500 servers with about 32 TB and 0.93 GB/s each, which give 240 PB and 7 TB/s; the 65.5 TB burst of Section 9.3 then takes 9.4 s. The three checkpoint sizes are the totals of Section 9.3 for 1 MB, 350 MB and 4 GB per GPU on 16,384 GPUs. Try 300 servers with 34 TB each: about 10 PB, and the stall grows to about four minutes. Drive size changes only the capacity.

這是模型:容量是 伺服器數×每台 TB 數\text{伺服器數} \times \text{每台 TB 數},峰值速率是 伺服器數×每台速率\text{伺服器數} \times \text{每台速率},直接寫入讓 GPU 停頓 檢查點÷峰值速率\text{檢查點} \div \text{峰值速率}。預設值是 Tectonic:7,500 台伺服器、每台約 32 TB 與 0.93 GB/s,得出 240 PB 與 7 TB/s;第 9.3 節 的 65.5 TB 突發於是要 9.4 秒。三種檢查點大小是 第 9.3 節 在 16,384 顆 GPU 上每顆 1 MB、350 MB 與 4 GB 時的總量。試試 300 台、每台 34 TB:約 10 PB,停頓變成約四分鐘。硬碟大小只改變容量。

Object stores. Datasets usually live in an object store, the S3-style service of the cloud, as packed shards of hundreds of megabytes. Object stores give very high aggregate throughput and tens of milliseconds per request, so they suit sequential prefetch of large shards and punish millions of small files.

物件儲存。資料集通常放在物件儲存裡,也就是雲端 S3 式的服務,以數百 MB 的打包分片存放。物件儲存提供非常高的總吞吐與每次請求數十毫秒的延遲,所以適合大分片的順序預先抓取,而懲罰數百萬個小檔案。

RDMA to storage. Some clusters run storage protocols over RDMA, such as NFS over RDMA or NVMe over Fabrics, on the front end or a third network. None of the four papers here does. What HPN did measure is the alternative: storage traffic injected into the back end made training fluctuate (HPN §8). RDMA storage, if used, needs its own lossless priority class or its own fabric, so that a storage incast cannot pause the collectives. Figure 9.6 shows why.

RDMA 到儲存。有些叢集在前端或第三個網路上以 RDMA 跑儲存協定,例如 NFS over RDMA 或 NVMe over Fabrics。本章的四篇論文都沒有這樣做。HPN 量到的是另一個選項:注入後端的儲存流量讓訓練出現波動(HPN §8)。若要用 RDMA 儲存,它需要自己的無損優先權類別或自己的網路,讓儲存的 incast 無法暫停集體通訊。圖 9.6 說明原因。

(a) storage RDMA in(a) 儲存 RDMA 與the training class訓練共用同一類別(b) storage RDMA in(b) 儲存 RDMA 有its own lossless class自己的無損類別(c) storage over TCP(c) 儲存走 TCPon the front end在前端網路上collectives + storage集體通訊 + 儲存PAUSE: shared classPAUSE:共用類別✗ collectives stop too✗ 集體通訊也停了collectives集體通訊storage儲存PAUSE: storage classPAUSE:儲存類別✓ collectives keep going✓ 集體通訊照常進行back end: collectives後端:集體通訊front end: storage, TCP前端:儲存,TCPdrop → TCP slows down丟包 → TCP 降速✓ a drop costs only time✓ 丟包只花時間
Figure 9.6. Why RDMA storage needs its own class or its own network. Each bar is a link that carries the named traffic, and a PFC pause stops a whole priority class on a link. (a) Storage in the training class: a storage incast pauses the collectives on the same links. HPN saw training fluctuate when it put storage traffic on its back end (HPN §8). (b) Storage in its own lossless class: the pause stops only storage. (c) Storage over TCP on the front end: the incast drops packets, and TCP slows down.圖 9.6。為什麼 RDMA 儲存需要自己的類別或自己的網路。每一條代表一條承載所標流量的鏈路,而 PFC 暫停會停下一條鏈路上的整個優先權類別。(a) 儲存與訓練同一類別:儲存的 incast 會暫停同一批鏈路上的集體通訊。HPN 把儲存流量放上後端時看到訓練出現波動(HPN §8)。(b) 儲存有自己的無損類別:暫停只停下儲存。(c) 儲存在前端走 TCP:incast 造成丟包,TCP 降速。Drawn for this primer from the PFC mechanism of Section 9.1, HPN §8 and Guo et al., ACM SIGCOMM 2016.

Erasure coding versus replication. A storage system protects data by writing three copies or by erasure coding, which splits a block into kk data and mm parity fragments. Three-way replication writes 3 bytes per byte stored; a 10+4 code writes 1.4. For a 65.5 TB checkpoint the servers absorb about 197 TB of internal writes with replication and 92 TB with the code, more than a two-to-one difference in the servers the burst needs. The code costs CPU time and spreads each write over more servers; the papers here do not state their choice. Figure 9.7 compares the two.

糾刪碼與複製。儲存系統保護資料的方式,是寫三份副本,或是用糾刪碼把一個區塊切成 kk 個資料片段加 mm 個校驗片段。三份複製每存一個位元組要寫 3 個;10+4 的碼寫 1.4 個。對一個 65.5 TB 的檢查點,伺服器在複製下要吸收約 197 TB 的內部寫入,在編碼下約 92 TB,突發所需的伺服器數相差兩倍以上。編碼要花 CPU 時間,並把每次寫入分散到更多伺服器;本章的論文沒有說明它們的選擇。圖 9.7 比較兩者。

(a) 3 copies(a) 3 份副本3 bytes written per byte每存 1 位元組寫 3 個(b) 10+4 code(b) 10+4 碼1.4 bytes written per byte每存 1 位元組寫 1.4 個data資料copy副本parity校驗one 65.5 TB checkpoint: internal writes一個 65.5 TB 檢查點的內部寫入replication複製≈197 TB10+4 code10+4 碼≈92 TB65.5 TB stored儲存了 65.5 TB
Figure 9.7. What data protection costs in writes. (a) Three-way replication writes every byte three times. (b) A 10+4 erasure code splits a block into 10 data and 4 parity fragments and writes 1.4 bytes per byte. For one 65.5 TB checkpoint the storage servers absorb about 197 TB of internal writes with replication and about 92 TB with the code. The papers in this chapter do not say which scheme they use.圖 9.7。資料保護在寫入上的代價。(a) 三份複製把每個位元組寫三次。(b) 10+4 糾刪碼把一個區塊切成 10 個資料片段與 4 個校驗片段,每存 1 位元組寫 1.4 個。對一個 65.5 TB 的檢查點,儲存伺服器在複製下要吸收約 197 TB 的內部寫入,在編碼下約 92 TB。本章的論文沒有說明它們用哪一種。Drawn for this primer from the numbers of this section.

9.5Control and management控制與管理

In-band and out-of-band. Management traffic has two paths. The out-of-band path reaches each server's baseboard management controller over a separate slow network, commonly 1 Gb/s, and works when the host's operating system is dead: power cycling, console, firmware. The in-band path uses the front end and the host's own OS: the scheduler's agent, SSH, container image pulls, heartbeats. The out-of-band path must not depend on anything the in-band path needs.

帶內與帶外。管理流量有兩條路。帶外的路透過另一個慢速網路、通常是 1 Gb/s,到達每台伺服器的基板管理控制器,在主機作業系統死掉時仍可用:重新上電、主控台、韌體。帶內的路使用前端與主機自己的作業系統:排程器的代理程式、SSH、拉取容器映像、心跳。帶外的路不能依賴帶內的路需要的任何東西。

PXE boot and Microsoft's DSCP story. Servers are provisioned by network boot: before any operating system exists, the NIC broadcasts a request and loads an image from a boot server. Microsoft's 2016 RoCE paper shows this colliding with a lossless network. PFC identifies a packet's priority by a field in the VLAN tag; Microsoft's servers booted over PXE before they had any VLAN configuration, and a trunk-mode switch port, which VLAN tagging requires, would not exchange untagged packets with a booting NIC, so provisioning failed. The fix moved the priority into the DSCP field of the IP header and kept server ports in access mode (Microsoft RoCE paper, Section 9.3). The lesson: the boot path must work with no per-host configuration, because it runs before any exists. Figure 9.8 shows the two markings.

PXE 開機與微軟的 DSCP 故事。伺服器透過網路開機來配置:在任何作業系統存在之前,NIC 廣播一個請求,並從開機伺服器載入映像。微軟 2016 年的 RoCE 論文顯示它與無損網路相撞。PFC 用 VLAN 標籤中的一個欄位識別封包的優先權;微軟的伺服器在有任何 VLAN 設定之前就經 PXE 開機,而 VLAN 標籤所需的 trunk 模式交換器埠不會與正在開機的 NIC 交換無標籤封包,配置因此失敗。修法是把優先權移到 IP 標頭的 DSCP 欄位,伺服器埠維持 access 模式(微軟 RoCE 論文 §3)。教訓:開機路徑必須在沒有任何每台主機設定的情況下運作,因為它跑在任何設定存在之前。圖 9.8 畫出兩種標記方式。

(a) PFC priority in the VLAN tag (PCP field)(a) PFC 優先權放在 VLAN 標籤(PCP 欄位)EthernetVLAN tag: PCPVLAN 標籤:PCPIPUDPRDMAbooting NIC開機中的 NICuntagged PXE無標籤的 PXEtrunk-mode porttrunk 模式的埠✗ provisioning fails✗ 配置失敗(b) PFC priority in the IP header (DSCP field)(b) PFC 優先權放在 IP 標頭(DSCP 欄位)EthernetIP: DSCPUDPRDMAbooting NIC開機中的 NICuntagged PXE無標籤的 PXEaccess-mode portaccess 模式的埠✓ the boot works✓ 開機成功
Figure 9.8. Microsoft's boot problem and its fix. (a) PFC read the priority from the PCP field of the VLAN tag, so server ports had to be in trunk mode. A trunk port does not exchange untagged packets with a NIC that is still booting over PXE, so provisioning failed. (b) With the priority in the DSCP field of the IP header, server ports stay in access mode and the untagged boot request works. Switches map DSCP value ii to PFC priority ii.圖 9.8。微軟的開機問題與修法。(a) PFC 從 VLAN 標籤的 PCP 欄位讀取優先權,所以伺服器埠必須是 trunk 模式。trunk 埠不會與仍在經 PXE 開機的 NIC 交換無標籤封包,配置因此失敗。(b) 優先權放在 IP 標頭的 DSCP 欄位時,伺服器埠維持 access 模式,無標籤的開機請求就能運作。交換器把 DSCP 值 ii 對應到 PFC 優先權 ii。Drawn for this primer from Guo et al., "RDMA over Commodity Ethernet at Scale", ACM SIGCOMM 2016, §3.

Telemetry: what is collected. Meta monitors per-NIC counters of out-of-sequence packets, link flaps and local ACK timeouts, a PFC watchdog that fires when a port stays paused for 200 ms, buffer alarms at 80%, and periodic reachability pings between all hosts (Meta RoCE paper, Section 9.6). HPN sends in-band network telemetry (INT) probes that record the switch and port ID at every hop and compares them with the wiring blueprint, because miswired cables had shown up as mysterious slowdowns (HPN §10). MegaScale's executor on every node sends the driver a heartbeat with the node's identity, hardware information, process status, logs and RDMA traffic counters; the counters are the key signal, because training traffic is regular and a sudden drop means trouble before any process has crashed (MegaScale §4.1). Its CUDA event monitor times critical code on every rank at almost no cost and found the 0.5% of slow machines that set everyone's pace (MegaScale §5).

遙測:收集什麼。Meta 監看每張 NIC 的亂序封包、鏈路抖動與本地 ACK 逾時計數器、埠持續暫停 200 ms 就觸發的 PFC watchdog、80% 的緩衝警報,以及所有主機之間定期的可達性 ping(Meta RoCE 論文 §6)。HPN 送出帶內網路遙測(INT)探測封包,記錄每一跳的交換器與埠 ID,並與接線藍圖比對,因為接錯的線纜曾表現為莫名的減速(HPN §10)。MegaScale 每個節點上的 executor 向 driver 送心跳,內含節點的身分、硬體資訊、行程狀態、日誌與 RDMA 流量計數器;計數器是關鍵訊號,因為訓練流量有規律,突然下降表示在任何行程崩潰之前就出了問題(MegaScale §4.1)。它的 CUDA 事件監控器以幾乎為零的成本為每個 rank 的關鍵程式計時,找出了決定所有人節奏的那 0.5% 慢機器(MegaScale §5)。

Telemetry: how much. The volume is small per host and grows with the host count, not the model. A few hundred 8-byte counters read once a second from nine NICs is tens of kilobytes per second. Logs dominate: a verbose training process writes about 1 MB/s. At 2,048 hosts that is 2 GB/s, or 16 Gb/s; at 16,384 hosts (131,072 GPUs) it is about 131 Gb/s. Telemetry grows with hosts, checkpoint bursts with GPUs×bytes per GPU\text{GPUs} \times \text{bytes per GPU}, dataset reads with tokens per second×bytes per token\text{tokens per second} \times \text{bytes per token} Panel 9.6 adds them up. Panel 9.5 shows how telemetry grows with the host count.

遙測:有多少。每台主機的量很小,且隨主機數增長,不隨模型增長。幾百個 8 位元組的計數器每秒從九張 NIC 讀一次,是每秒幾十 KB。日誌占大宗:一個囉嗦的訓練行程寫約 1 MB/s。2,048 台主機就是 2 GB/s,即 16 Gb/s;16,384 台主機(131,072 顆 GPU)則是約 131 Gb/s。遙測隨主機數增長,檢查點突發隨 GPU 數×每顆 GPU 位元組數\text{GPU 數} \times \text{每顆 GPU 位元組數} 增長,資料集讀取隨 每秒 token 數×每 token 位元組數\text{每秒 token 數} \times \text{每 token 位元組數} 增長。面板 9.6 把它們加起來。面板 9.5 顯示遙測如何隨主機數增長。

Panel 9.5面板 9.5

Telemetry grows with hosts遙測隨主機數增長

Counters per host
每台主機的計數器
Logs, whole cluster
日誌,整個叢集
Total, whole cluster
總量,整個叢集
Logs' share of the total
日誌占總量的比例

A model: counters per host are counters per NIC×9 NICs×8 bytes×reads per second\text{counters per NIC} \times 9\ \text{NICs} \times 8\,\text{bytes} \times \text{reads per second} logs add their own rate; the cluster total is the per-host sum times the host count. Defaults are this section's examples: 300 counters per NIC read once a second, about 22 KB/s per host, and 1 MB/s of logs per host on 2,048 hosts, which gives the 16 Gb/s of logs. At 16,384 hosts the logs reach about 131 Gb/s. No control depends on the model size.

這是模型:每台主機的計數器是 每張 NIC 計數器數×9 張 NIC×8 位元組×每秒讀取次數\text{每張 NIC 計數器數} \times 9\ \text{張 NIC} \times 8\,\text{位元組} \times \text{每秒讀取次數}日誌另加自己的速率;整個叢集是每台主機的總和乘上主機數。預設值是本節的例子:每張 NIC 300 個計數器、每秒讀一次,約每台主機 22 KB/s,以及 2,048 台主機、每台 1 MB/s 的日誌,得出 16 Gb/s 的日誌。16,384 台主機時日誌約 131 Gb/s。沒有任何一個控制項與模型大小有關。

Monitoring must not depend on the network it monitors. If a heartbeat travelled over the back end, a back-end failure and a host failure would look identical to the driver, and the diagnosis could not tell them apart. MegaScale's heartbeats carry the back end's RDMA counters but travel to a driver in the Kubernetes control plane, so the back end is observed from outside itself (MegaScale §4.1). HPN's stacked-ToR failure is the same lesson: a switch whose data plane was dead still answered on its control plane, so a monitor that trusted control-plane health saw a healthy switch (HPN §4). Measure the data plane with traffic, as Meta's pings and HPN's INT probes do, and report over a path the measured network does not control. Section 6.5 shows the stacked-ToR case.

監控不能依賴它所監控的網路。如果心跳走在後端上,後端故障和主機故障對 driver 而言會一模一樣,診斷無法分辨兩者。MegaScale 的心跳帶著後端的 RDMA 計數器,但送往 Kubernetes 控制平面中的 driver,所以後端是從它自身之外被觀察的(MegaScale §4.1)。HPN 堆疊式 ToR 的故障是同一個教訓:資料平面已死的交換器仍在控制平面上有回應,信任控制平面健康狀態的監控會看到一台健康的交換器(HPN §4)。用流量量測資料平面,如 Meta 的 ping 與 HPN 的 INT 探測,並透過被量測網路無法控制的路徑回報。第 6.5 節畫出堆疊式 ToR 的情況。

9.6Sizing the front end決定前端網路的大小

What the two designs chose. Meta gives each host 100 or 200 Gb/s of front end for data ingestion beside 3.2 Tb/s of back end. HPN gives each host 2×200 Gb/s and builds the front-end fabric non-blocking, because the same hosts serve inference when not training, and inference traffic is front-end heavy (HPN §8). The difference is what else the hosts do, not the checkpoints.

兩個設計的選擇。Meta 給每台主機 100 或 200 Gb/s 的前端用於資料載入,旁邊是 3.2 Tb/s 的後端。HPN 給每台主機 2×200 Gb/s 並把前端網路建成非阻塞,因為同樣的主機不訓練時要服務推論,而推論流量以前端為主(HPN §8)。差別在主機還做什麼,不在檢查點。

A worked sizing. Take a 16K-GPU cluster: 2,048 hosts, 4 GB per GPU checkpointed hourly into a 7 TB/s storage system, a multimodal dataset read at 1 TB/s, and 1 MB/s of logs per host. Now also add 100 Gb/s of inference per host, our assumption to show the effect, since HPN gives no number. Per host, one question per row:

算一次規模。取一個 16K 顆 GPU 的叢集:2,048 台主機、每顆 GPU 4 GB 每小時存一次到 7 TB/s 的儲存系統、以 1 TB/s 讀取的多模態資料集,以及每台主機 1 MB/s 的日誌。再加上每台主機 100 Gb/s 的推論——這是我們為了顯示效果而假設的數字,HPN 沒有給。每台主機逐列計算如下:

Question問題Calculation算式Result結果
Dataset資料集1 TB/s÷2,0481\,\text{TB/s} \div 2{,}048≈488\approx 488 MB/s3.9 Gb/s3.9 Gb/s
Checkpoint, hourly average (8 GPUs at 4 GB)檢查點的每小時平均(8 顆 GPU、每顆 4 GB)32 GB÷3,600 s32\,\text{GB} \div 3{,}600\,\text{s}≈8.9\approx 8.9 MB/s71 Mb/s71 Mb/s
Checkpoint burst, for 9.4 seconds檢查點突發,持續 9.4 秒7 TB/s÷2,0487\,\text{TB/s} \div 2{,}048≈3.4\approx 3.4 GB/s27 Gb/s27 Gb/s
Logs, 1 MB/s in bits日誌,1 MB/s 換成位元1×81 \times 888 Mb/s
Peak demand: dataset, burst and logs峰值需求:資料集、突發與日誌3.9+27+0.0083.9 + 27 + 0.008≈31\approx 31 Gb/s
Average demand: dataset, average checkpoint and logs平均需求:資料集、檢查點平均與日誌3.9+0.071+0.0083.9 + 0.071 + 0.008≈4\approx 4 Gb/s
Peak with 100 Gb/s of inference added加上 100 Gb/s 推論後的峰值31+10031 + 100≈130\approx 130 Gb/s
Burst with two-stage checkpoints, drained at the 2 TB/s sustained rate兩階段檢查點的突發,以 2 TB/s 持續速率排空2 TB/s÷2,0482\,\text{TB/s} \div 2{,}048≈0.98\approx 0.98 GB/s7.8 Gb/s, for 33 seconds7.8 Gb/s,持續 33 秒

Without inference, peak demand per host is about 31 Gb/s and the average about 4 Gb/s. A 100G NIC covers the peak three times over, which matches Meta's 100/200G. With inference the peak becomes about 130 Gb/s, which calls for a 200G port, and dual-ToR redundancy makes it two. That is HPN's 2×200G. Switch to two-stage checkpoints and the burst per host falls to 7.8 Gb/s, spread over 33 seconds while the GPUs run. Figure 9.9 stacks the classes per host.

不計推論時,每台主機的峰值需求約 31 Gb/s,平均約 4 Gb/s。一張 100G NIC 有三倍餘裕,與 Meta 的 100/200G 相符。加上推論後峰值變成約 130 Gb/s,需要一個 200G 埠,dual-ToR 冗餘讓它變成兩個。這就是 HPN 的 2×200G。切到兩階段檢查點,每台主機的突發降到 7.8 Gb/s,在 GPU 運行的同時分攤到 33 秒。圖 9.9 把每台主機的各類流量疊起來。

100G200G400Gtraining, direct訓練,直接寫入≈31 Gb/s → one 100G port≈31 Gb/s → 一個 100G 埠+ 100 Gb/s inference+ 100 Gb/s 推論≈130 Gb/s → a 200G port≈130 Gb/s → 一個 200G 埠training, two-stage訓練,兩階段≈12 Gb/s: 3.9 + 7.8 for 33 s≈12 Gb/s:3.9 + 7.8,持續 33 秒two ports for dual-ToR: HPN's 2×200Gdual-ToR 要兩個埠:HPN 的 2×200G0100200300400Gb/s per host每台主機 Gb/sdataset資料集checkpoint檢查點logs (8 Mb/s)日誌(8 Mb/s)inference (assumed)推論(假設)
Figure 9.9. Peak front-end demand per host in the worked sizing, on a linear scale. Training alone peaks at about 31 Gb/s, almost all of it the 9.4-second checkpoint burst, so one 100G port is enough, as Meta chose. Adding 100 Gb/s of inference, our assumption, gives about 130 Gb/s: a 200G port, and two for dual-ToR, as HPN chose. Two-stage checkpoints cut the burst to 7.8 Gb/s for 33 seconds. Logs, at 8 Mb/s, are too thin to see.圖 9.9。算例中每台主機的前端峰值需求,線性尺度。只有訓練時峰值約 31 Gb/s,幾乎全是 9.4 秒的檢查點突發,所以一個 100G 埠就夠,正如 Meta 的選擇。加上我們假設的 100 Gb/s 推論後約 130 Gb/s:需要一個 200G 埠,dual-ToR 則要兩個,正如 HPN 的選擇。兩階段檢查點把突發降到 7.8 Gb/s、持續 33 秒。日誌只有 8 Mb/s,細到看不見。Drawn for this primer from the worked sizing of this section.

The fabric behind the NICs. The ToR uplinks are the second number. The checkpoint burst converges on the storage servers, so the fabric between racks and storage must carry the storage peak, 7 TB/s or 56 Tb/s, plus the dataset's 8 Tb/s. The hosts' NICs add up to 2,048×100 Gb/s=2052{,}048 \times 100\,\text{Gb/s} = 205 Tb/s, so 3:1 oversubscription at the ToR uplinks would still pass the burst. Inference changes this: 100 Gb/s per host leaving the rack is another 205 Tb/s of east-west demand, and the tolerable oversubscription falls toward 1:1, which is what HPN built. The storage side needs the same 56 Tb/s of ports spread over its servers, one more reason the server count matters. Figure 9.10 puts these totals side by side.

NIC 後面的網路。ToR 上行是第二個數字。檢查點突發會收斂到儲存伺服器,所以機櫃與儲存之間的網路必須承載儲存峰值,7 TB/s 即 56 Tb/s,再加上資料集的 8 Tb/s。主機的 NIC 合計 2,048×100 Gb/s=2052{,}048 \times 100\,\text{Gb/s} = 205 Tb/s,所以 ToR 上行 3:1 的超額認購仍能讓突發通過。推論改變了這點:每台主機 100 Gb/s 離開機櫃的流量是另外 205 Tb/s 的東西向需求,可容忍的超額認購朝 1:1 掉,而那正是 HPN 建的。儲存側需要同樣 56 Tb/s 的埠分布在它的伺服器上,這是伺服器數重要的又一個理由。圖 9.10 把這些總量並排比較。

Tb/s, whole cluster (2,048 hosts)Tb/s,整個叢集(2,048 台主機)host NICs, 2,048 × 100G主機 NIC,2,048 × 100GToR uplinks at 3:1ToR 上行,3:1burst + dataset突發 + 資料集+ 100 Gb/s inference+ 100 Gb/s 推論205 Tb/s68 Tb/s64 Tb/s ✓ fits64 Tb/s ✓ 放得下≈269 Tb/s ✗3:1 uplink capacity, 68 Tb/s3:1 上行容量,68 Tb/scheckpoint檢查點dataset資料集inference推論
Figure 9.10. The fabric behind the NICs for the 2,048-host example. The checkpoint burst (56 Tb/s, the 7 TB/s storage peak) and the dataset (8 Tb/s) together fit under ToR uplinks oversubscribed 3:1, which carry 68 of the 205 Tb/s of host NICs. Inference at 100 Gb/s per host that leaves the rack adds another 205 Tb/s, which 3:1 uplinks cannot carry; the tolerable oversubscription falls toward 1:1, as in HPN.圖 9.10。2,048 台主機算例中 NIC 後面的網路。檢查點突發(56 Tb/s,即 7 TB/s 的儲存峰值)加上資料集(8 Tb/s)放得進 3:1 超額認購的 ToR 上行,它承載主機 NIC 合計 205 Tb/s 中的 68 Tb/s。每台主機 100 Gb/s、離開機櫃的推論再加 205 Tb/s,3:1 的上行承載不了;可容忍的超額認購朝 1:1 掉,正如 HPN。Drawn for this primer from the worked sizing of this section.

DPUs on the front end. HPN's front-end NIC is an NVIDIA BlueField-3, a data processing unit: a 400 Gb/s-class NIC with its own Arm cores and memory. It can run the storage client, the TCP/IP stack, encryption and the virtual switch that isolates tenants, so host CPUs stay free for data loading and a tenant's network policy is enforced outside the tenant's own OS, which matters in HPN's serverless setting where several tenants share a host. The HPN paper does not quantify the offload; treat this as what the device is for, not a measured gain.

前端上的 DPU。HPN 的前端 NIC 是 NVIDIA BlueField-3,一顆資料處理單元:400 Gb/s 等級的 NIC,帶有自己的 Arm 核心與記憶體。它可以跑儲存客戶端、TCP/IP 堆疊、加密,以及隔離租戶的虛擬交換器,讓主機 CPU 留給資料載入,並讓租戶的網路政策在租戶自己的作業系統之外執行,這在多個租戶共享一台主機的 HPN serverless 情境中很重要。HPN 論文沒有量化卸載的效益;把這當作裝置的用途,而不是量到的收益。

Panel 9.6面板 9.6

Front-end bandwidth planner前端頻寬規劃器

Hosts (from Panel 9.1)
主機數(來自面板 9.1)
Tokens per second
每秒 token 數
Dataset per host
每台主機的資料集
Checkpoint per host: average / burst
每台主機的檢查點:平均 / 突發
Peak per host
每台主機的峰值
Average per host
每台主機的平均
Suggested front-end NIC
建議的前端 NIC
Tolerable ToR oversubscription
ToR 可容忍的超額認購
Dataset資料集Checkpoint檢查點Logs and telemetry日誌與遙測Inference推論

Hosts and the checkpoint burst come from Panel 9.3 (direct write: storage peak÷hosts\text{storage peak} \div \text{hosts}, capped by the NIC; two-stage: sustained rate÷hosts\text{sustained rate} \div \text{hosts}). Defaults: Llama 3's 16M-token batch at the derived 6 s per step, 4 bytes per token, 1 MB/s of logs, and 100 Gb/s of inference per host, our assumption for a host that also serves inference. The suggested NIC is the smallest standard rate that covers the peak with 25% headroom; with dual ports each port must carry the whole peak alone when one ToR fails. The defaults reproduce HPN's 2×200G. Set inference to 0 to see Meta's 100G suffice.

主機數與檢查點突發來自面板 9.3(直接寫入:儲存峰值÷主機數\text{儲存峰值} \div \text{主機數},受 NIC 上限限制;兩階段:持續速率÷主機數\text{持續速率} \div \text{主機數})。預設值:Llama 3 的 16M token 批次、推導出的每步 6 秒、每 token 4 位元組、1 MB/s 日誌,以及每台主機 100 Gb/s 的推論——這是我們對一台同時服務推論的主機所做的假設。建議的 NIC 是能以 25% 餘裕覆蓋峰值的最小標準速率;雙埠時每個埠都必須在一台 ToR 故障時獨自承載整個峰值。預設值重現 HPN 的 2×200G。把推論設為 0,看 Meta 的 100G 就夠了。

Stop and think停下來想一想

Set inference to 0 and bytes per token to 1,000. Which class now sets the suggested NIC? Then change Panel 9.3 to 131,072 GPUs: the per-host checkpoint burst falls, because the same 7 TB/s is shared by eight times more hosts, while logs stay the same. Which number on the page says that the storage system, not the NIC, must grow?

把推論設為 0、每 token 位元組數設為 1,000。現在是哪一類決定建議的 NIC?接著把面板 9.3 改成 131,072 顆 GPU:每台主機的檢查點突發下降,因為同樣的 7 TB/s 被八倍多的主機分攤,日誌卻不變。頁面上哪個數字說該長大的是儲存系統而不是 NIC?

Chapter summary
本章摘要

A training cluster has two networks because it has two kinds of traffic. The back end carries GPU-to-GPU RDMA and is engineered never to drop a packet; the front end is an ordinary TCP/IP network for training data, checkpoints, logs, management and, at Alibaba, serving traffic. Text data is tiny: Llama 3 405B needs about 11 MB/s for the whole cluster. Checkpoints are the burst: 16,384 GPUs writing up to 4 GB each in the same second, so the GPUs stall until storage absorbs it, and two-stage checkpoints copy to host memory first and drain in the background. Storage throughput follows the number of storage servers, not their capacity. Monitoring must not depend on the network it monitors. A 100G front-end NIC per host covers training; serving on the same hosts needs more.

訓練叢集有兩個網路,是因為它有兩種流量。後端承載 GPU 對 GPU 的 RDMA,被設計成永不丟包;前端是一般的 TCP/IP 網路,承載訓練資料、檢查點、日誌、管理,以及(在 Alibaba)推論服務流量。文字資料量極小:Llama 3 405B 整個叢集約只需 11 MB/s。檢查點才是突發:16,384 顆 GPU 在同一秒各寫最多 4 GB,GPU 要停到儲存系統吸收完為止;兩階段檢查點先複製到主機記憶體,再在背景排出。儲存吞吐由儲存伺服器的數量決定,而不是容量。監控不能依賴它所監控的網路。每台主機一張 100G 前端 NIC 就足以應付訓練;同一批主機若還要做推論服務,就需要更多。

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

Chapter 10 looks at what goes wrong at scale: how often parts fail, how a job survives, and how to find the one slow GPU or link among thousands.

第 10 章探討大規模時會出什麼錯:零件多常故障、任務如何存活,以及如何在數千個元件中找出那一顆慢 GPU 或那一條慢鏈路。

Optional · research frontier選讀 · 研究前沿Checkpoint and front-end research: ByteCheckpoint, Checkmate, DistDPU檢查點與前端網路研究:ByteCheckpoint、Checkmate、DistDPUCheaper saving and loading, checkpoints taken without the GPU, and the front-end NIC as a programmable device.更便宜的存與讀、不靠 GPU 的檢查點,以及把前端 NIC 當成可程式化的裝置。Open →開啟 →

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

Check your understanding檢驗你的理解