概述
A resumable training checkpoint also records the state needed to continue an interrupted run, and restart tests establish what it can restore.
深入探討
A weight checkpoint contains model parameters; a resumable training checkpoint also needs relevant optimizer, scheduler, step, random-number-generator, and data-loading state. Sharding divides large tensors or state across files and workers so saving and loading can avoid gathering everything on one rank. PyTorch Distributed Checkpoint supports distributed state saving and resharding during loading when supported by the chosen state and configuration. Sharded model weights on the Hugging Face Hub can use an index mapping parameter names to files, but weight shards alone do not capture a training run’s full progress. Applications must include their required state and validate recovery after an interrupted save or a changed environment.
現實世界的實施
前沿模型運行在數千個 GPU 上,每隔幾百步自動保存分片檢查點,因此單一失敗的節點只需要幾分鐘,而不是幾天。
Hugging Face 將大型開放式模型分發為多個 safetensors 分片和一個 index.json,以便用戶可以逐一下載和載入它。
研究人員恢復中斷的微調,恢復精確的優化器動力、步數和資料載入器位置以無縫繼續。
在廉價的可搶佔式雲端 GPU 上進行現貨實例訓練,其中頻繁的分片檢查點使作業能夠在被驅逐和重新安排的情況下倖存下來。
檢查點分片和可恢復訓練的未來
檢查點正在從週期性的停止世界事件轉變為非同步且幾乎免費的事件。預計會有更多的記憶體中和重疊檢查點,在訓練繼續的同時在後台寫入分片,加上糾刪碼和複製檢查點,可以在千個 GPU 規模上常見的節點故障中倖存下來。雲端物件儲存和更快的本地 NVMe 層將託管分片,而安全張量等標準化格式將不斷改進訓練復原和推理部署的安全性、快速、部分載入。
付諸實踐
為什麼這很重要
- 成本與預算. 多年來,架構決策決定著效能和營運成本。
- 更明確的決策. 技術教育幫助團隊選擇正確的堆疊,而不僅僅是最新的堆疊。
- 品質管控. 更好的工程選擇可以減少生產中的可靠性事故。
留意
- 優化一項基準測試可以隱藏更廣泛的系統弱點。
- 基礎設施和維護成本常常被低估。
- 隨著系統變得更加複雜,安全性和可觀察性差距可能會擴大。
後續步驟
- 在實施之前定義延遲、品質和成本目標。
- 在實際負載和資料條件下進行基準測試。
- 儀器監控錯誤、漂移和使用者影響。
- 在擴展之前準備回滾和事件回應路徑。
不斷探索
常見問題
什麼是檢查點分片與可恢復訓練?
Checkpoint sharding saves a large model or training state across multiple pieces for manageable storage and loading. A resumable training checkpoint also records the state needed to continue an interrupted run, and restart tests establish what it can restore.
為什麼大模型檢查點要分成分片?
將巨大的檢查點(數百 GB)作為一個檔案是不切實際的;分片允許許多佇列並行寫入其切片並啟用分段載入。
Which extra state is typically needed for training resumption beyond model weights?
Weight shards alone do not restore optimizer history or the next intended batch. The application must save the required training progress and randomness state.
長期工作可恢復培訓的主要好處是什麼?
透過可恢復的檢查點,中斷的運行會重新載入其上次保存的狀態並繼續,而不是丟棄數天的計算。
In a sharded distributed checkpoint, how can ranks avoid gathering the entire state on one worker?
Distributed checkpointing uses local state partitions and metadata. Ordinary replicated data parallelism does not automatically shard every tensor.
索引檔案在分片檢查點中扮演什麼角色?
索引(例如,index.json)記錄哪個分片保存每個參數,以便載入器可以取得並重新組裝正確的片段。