# 检查点

检查点（Checkpointing）是指定期保存正在运行的程序或计算状态的实践，以便在随机故障后从上次保存点而非从头重新启动。<sup>[1](https://cacm.acm.org/research/a-first-order-approximation-to-the-optimum-checkpoint-interval/)</sup> 它是高性能计算（HPC）领域事实上的标准容错技术，<sup>[2](https://library.eecs.utk.edu/storage/files/ut-eecs-14-734.pdf)</sup> 同时也是可恢复的机器学习训练和分布式系统中回滚恢复的基础。同一个术语涵盖两种相关用途：保存状态以使作业在故障中存活，以及保存中间值以便能以较低成本重新访问某项计算。

| 关键事实 | 详情 |
|---|---|
| 检查点捕获的内容 | 应用程序的内存、所有寄存器的值，以及任何打开的文件描述符及其指向的文件<sup>[3](https://arxiv.org/html/2208.02884v1)</sup> |
| 最优间隔（一阶） | \( \tau_{\mathrm{opt}} = \sqrt{2 \delta \cdot M} \)，其中 \( \delta \) 为检查点写入时间，\( M \) 为平均中断间隔<sup>[4](https://graal.ens-lyon.fr/~abenoit/CR02/papers/daly.pdf)</sup> |
| 规模化下的故障率 | 运行在 \( p \) 个处理器上的应用，其平均无故障时间随处理器数量增长而下降；百亿亿次系统预计每 3–26 分钟发生一次故障<sup>[5](https://www.osti.gov/servlets/purl/1225695)</sup> |
| 开销范围 | 当前 HPC 系统上的检查点/重启效率在计划机器时间的 85% 到 55% 之间<sup>[6](https://arcb.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/icpads10-2.pdf)</sup> |
| 同步与异步成本 | 一次同步并行文件系统检查点增加 13% 开销，而异步为 1.3%，伙伴级为 1%<sup>[7](https://blogs.fau.de/hager/files/2013/02/asyn_ckpt_130115.pdf)</sup> |
| 机器学习检查点 | TensorFlow 检查点存储所有 `tf.Variable` 对象的精确值，但不存储计算的描述<sup>[8](https://www.tensorflow.org/guide/checkpoint)</sup> |

## 工作原理

检查点是写入稳定存储的进程状态快照。必须捕获三样东西：应用程序的内存，它保存执行所需的全部状态；寄存器值，它告诉恢复后的程序从内存的何处继续；以及打开的文件描述符及其指向的文件。<sup>[3](https://arxiv.org/html/2208.02884v1)</sup> 在分布式系统中，全局快照还要加上每个进程的本地状态（堆、寄存器、程序计数器）和每条通信信道的状态，即传输中的消息。<sup>[9](https://www.cs.princeton.edu/courses/archive/spring22/cos418/docs/precept4_distributed_snapshots.pdf)</sup>

一致的分布式快照通过标记消息构建。每个进程记录自己的状态，然后在每条出站信道上发送一条标记消息，之后再在该信道上发送后续消息；由于信道是先进先出的，标记将属于快照的消息与不属于快照的消息分隔开来，信道两端的两个进程协作记录该信道的状态。<sup>[10](https://www.cs.swarthmore.edu/~newhall/readings/snapshots.pdf)</sup> 该算法与计算并发运行，不改变计算本身。<sup>[9](https://www.cs.princeton.edu/courses/archive/spring22/cos418/docs/precept4_distributed_snapshots.pdf)</sup>

重启是捕获的逆过程。一种实现是派生一个子“转储器”进程来读取父进程的寄存器（父进程若自行转储则会破坏内存映像）；在恢复时，加载器进程逐渐变形为应用程序，重建精确的内存布局、寄存器值和打开的文件描述符。<sup>[3](https://arxiv.org/html/2208.02884v1)</sup> 使用增量检查点时，重启首先恢复最近的增量映像，然后按逆序应用先前增量检查点的页，一直回溯到上一个完整检查点，因此每一页只写入一次。<sup>[6](https://arcb.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/icpads10-2.pdf)</sup>

核心的定量问题是检查点的频率。扬的一阶答案为 \( \tau_{\mathrm{opt}} = \sqrt{2 \delta \cdot M} \)，其中 \( \delta \) 是写入检查点文件的时间，\( M \) 是平均中断间隔；其最大相对误差低于 5%，最坏情况出现在 \( \delta = M/2 \) 时。<sup>[4](https://graal.ens-lyon.fr/~abenoit/CR02/papers/daly.pdf)</sup> 戴利的高阶改进适用于 \( \delta < 2M \)，

\[ \tilde{\tau}_{\mathrm{opt}} = \sqrt{2 \delta \cdot M}\left(1 + \tfrac{1}{3}\sqrt{\tfrac{\delta}{2M}} + \tfrac{1}{9}\tfrac{\delta}{2M}\right) - \delta, \]

使用前三项即可保证总求解时间的相对误差不超过 0.2%，并表明重启时间 \( R \) 实际上对最优间隔没有贡献，这与一阶模型相反。<sup>[4](https://graal.ens-lyon.fr/~abenoit/CR02/papers/daly.pdf)</sup> 在常见的 \( W_{\mathrm{YD}} = \sqrt{2 \mu \cdot C} \) 形式中，\( \mu \) 是应用的平均无故障时间，\( C \) 是检查点持续时间；所有这些都是第一阶近似，没有一个是完全正确的。<sup>[11](https://par.nsf.gov/servlets/purl/10581045)</sup><sup> • </sup><sup>[2](https://library.eecs.utk.edu/storage/files/ut-eecs-14-734.pdf)</sup> 实测开销说明了为什么写入路径比间隔更重要：在一项基准测试中，改变间隔对性能影响甚微，而增加检查点提交时间则显著增加了求解时间。<sup>[12](https://spcl.inf.ethz.ch/Publications/.pdf/ferreira-checkpointing_at_scale.pdf)</sup>

## 实现方式

实践者首先选择检查点级别（系统级、应用级或混合级，见“变体”一节）和存储布局。间隔根据实测的检查点成本和平台故障率，由 Young/Daly 公式得出。在 MPI 代码中，所有任务协调一致的全局状态，相当于一个内部屏障，在写入前排空传输中的消息；在典型的增量实现中，第一个线程只保存自上次检查点以来修改的脏内存页，其他线程保存寄存器和信号信息，最后的屏障关闭检查点。<sup>[6](https://arcb.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/icpads10-2.pdf)</sup>

有两项持久性规则在各系统中反复出现。IBM 的 OS/VS 手册要求检查点条目绝不能覆盖前一个条目，因为在新条目写入过程中可能发生故障。<sup>[13](https://www.bitsavers.org/pdf/ibm/370/OS_VS2/Release_3.0_1975/GC26-3784-5_OS_VS_Checkpoint_Restart_Rel_3_Feb75.pdf)</sup> 框架则转而管理保留策略：TensorFlow 的 `CheckpointManager` 可以只保留最近三个检查点，存储为一个索引文件加上数据文件，前缀如 `./tf_ckpts/ckpt-10`。<sup>[8](https://www.tensorflow.org/guide/checkpoint)</sup> SCR 的设计基于这样一个观察：作业只需要其最近的检查点，因此它将检查点缓存在计算节点上，并定期刷新到并行文件系统。<sup>[5](https://www.osti.gov/servlets/purl/1225695)</sup>

## 起源

检查点/重启在 20 世纪 60 年代末已在第三代计算机上实际使用，IBM 的 OS/VS 检查点/重启设施（1975 年 2 月）允许程序发出 CHKPT 宏，将其虚拟存储区和系统控制信息作为检查点条目写入磁带或直接存取卷。<sup>[14](https://sol.sbc.org.br/index.php/wtf/article/download/24679/24500/)</sup><sup> • </sup><sup>[13](https://www.bitsavers.org/pdf/ibm/370/OS_VS2/Release_3.0_1975/GC26-3784-5_OS_VS_Checkpoint_Restart_Rel_3_Feb75.pdf)</sup> 间隔理论始于 约翰·W·扬 1974 年发表在《ACM 通讯》上的论文《最优检查点间隔的一阶近似》；<sup>[15](https://doi.org/10.1145/361147.361115)</sup> 埃罗尔·盖伦贝 1979 年发表在《ACM 期刊》上的论文《论最优检查点间隔》改进了分析。<sup>[16](https://doi.org/10.1145/322123.322131)</sup> 对于分布式系统，罗布·斯特罗姆和肖拉·耶米尼 1985 年关于乐观恢复的论文引入了分段确定性假设，后来被基于日志的恢复所采用，<sup>[17](https://doi.org/10.1145/3959.3962)</sup> R. 库和 S. 图埃格 1987 年发表在《IEEE 软件工程汇刊》上的论文给出了一致检查点和回滚恢复算法，其中每个进程最多存储两个检查点，并被证明在一般假设下是最少的。<sup>[18](https://doi.org/10.1109/tse.1987.232562)</sup> 后来的库工作包括 J.S. 普兰克和李凯的 ickp（1994），这是第一个针对多计算机的通用一致检查点器，在 Intel iPSC/860 上实现；<sup>[19](https://doi.org/10.1109/88.311574)</sup> N.H. 瓦伊迪亚 1998 年的两级恢复方案，是 SCR 的概念基础；<sup>[20](https://doi.org/10.1109/12.689645)</sup> 以及 普兰克、[李凯](https://www.edgepedia.org/zh/kai-li)和 M.A. 普宁 1998 年的无盘检查点。<sup>[21](https://doi.org/10.1109/71.730527)</sup>

## 变体

**系统级与应用级。** 系统级检查点（BLCR、MOSIX、Condor、Libckpt）透明地复制原始应用程序内存字节；应用级检查点在源代码中实现，在某些美国能源部实验室代码上可将检查点大小缩减 90%，在标准基准上开销为 5–10%。混合级检查点结合两者。<sup>[22](https://www.cecs.uci.edu/~papers/ipdps06/pdfs/08-NSFNGS-paper-1.pdf)</sup>

**增量与混合。** 增量检查点只保存自上次检查点以来程序中发生变化的部分，减少了开销但使恢复复杂化。<sup>[23](https://link.springer.com/article/10.1007/s11227-013-0884-0)</sup> 混合方案交替使用完整和增量检查点；最优的完整与增量比例 1:9 优于始终完整和始终增量的策略。<sup>[6](https://arcb.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/icpads10-2.pdf)</sup>

**分布式协议。** 回滚恢复协议分为基于检查点的（协调式、非协调式或通信诱导式检查点）和基于日志的（悲观、乐观或因果记录确定性因素，即非确定性事件的日志编码）。<sup>[24](https://psycnet.apa.org/doi/10.1145/568522.568525)</sup> 协调式检查点保存系统范围内的一致状态；非协调式检查点允许进程独立设置检查点，但有多米诺效应风险；通信诱导式检查点在应用消息上搭载信息。<sup>[23](https://link.springer.com/article/10.1007/s11227-013-0884-0)</sup>

**多级。** 多级方案为每一级分配不同的成本和恢复能力，第 1 级成本最低、恢复能力最弱，第 L 级成本最高、恢复能力最强。<sup>[5](https://www.osti.gov/servlets/purl/1225695)</sup> FTI 提供四个级别：本地磁盘、伙伴复制、Reed-Solomon 编码和并行文件系统；使用 RS 编码时，即使一半的检查点文件丢失也能恢复。<sup>[25](https://graal.ens-lyon.fr/~abenoit/CR02/papers/ipdps14-Di.pdf)</sup>

## 应用

**规模化 HPC。** 即使每个节点的平均无故障时间为数年，大型平台每天也会经历多次故障，因此使用大量处理器的应用通常每隔几小时就会遇到一次故障；百亿亿次系统预计每 3–26 分钟发生一次故障。<sup>[26](https://icl.utk.edu/~herault/papers/108%20-%20Checkpointing%20a%20la%20Young-Daly:%20an%20Overview%20-%20IC3%20%282022%29.pdf)</sup><sup> • </sup><sup>[5](https://www.osti.gov/servlets/purl/1225695)</sup> 在一项集群研究中，每次同步检查点增加 5.6% 开销，而异步为 0.2%；在一个模拟的 65,536 节点系统上，每个进程 2 GiB 检查点，同时写入造成的文件系统争用是协调式检查点的主要成本。<sup>[7](https://blogs.fau.de/hager/files/2013/02/asyn_ckpt_130115.pdf)</sup><sup> • </sup><sup>[12](https://spcl.inf.ethz.ch/Publications/.pdf/ferreira-checkpointing_at_scale.pdf)</sup> 由于 I/O 瓶颈，大规模应用可能承受高达 25% 的检查点/重启开销。<sup>[25](https://graal.ens-lyon.fr/~abenoit/CR02/papers/ipdps14-Di.pdf)</sup>

**机器学习。** TensorFlow 检查点捕获所有 `tf.Variable` 对象的精确值，不包含计算图，因此仅在源代码可用时才有用。<sup>[8](https://www.tensorflow.org/guide/checkpoint)</sup> PyTorch 的 `torch.distributed.checkpoint` 提供拓扑无关的分片检查点，`async_save` 先暂存到固定 CPU 内存，然后在后台线程中写入；一种常见的失败模式是保存权重时丢弃了优化器状态，导致恢复的运行从零重新预热动量。<sup>[27](https://prakashkagitha.github.io/llm-stack-book/03-pretraining/12-checkpointing-fault-tolerance.html)</sup>

**2023 年以来的大语言模型规模训练。** 在字节跳动的生产追踪中，在 4096 个 GPU 上向 HDFS 保存 GPT-175B 检查点平均耗时 200 秒，超过单次训练迭代时间。<sup>[28](https://www.usenix.org/system/files/nsdi25-wan-borui.pdf)</sup> 近期系统着手解决这一问题：DataStates-LLM（毛里亚等，2024）利用模型和优化器张量在前向和反向传播期间的不变性，实现高达 48 倍的检查点加速；<sup>[29](https://doi.org/10.48550/arxiv.2406.10707)</sup> ByteCheckpoint 平均减少 54.20 倍的检查点停顿，并支持跨 [Megatron-LM](https://www.edgepedia.org/zh/megatron-lm)、FSDP 和 DDP 的加载时重分片；<sup>[28](https://www.usenix.org/system/files/nsdi25-wan-borui.pdf)</sup> MegaScale（蒋等，2024）、FastPersist（王、鲁瓦斯、谢、何，2024）和 ExCP（李等，2024）分别解决超过 10,000 个 GPU 的训练、检查点加速和权重-动量压缩问题。<sup>[30](https://doi.org/10.48550/arxiv.2402.15627)</sup><sup> • </sup><sup>[31](https://doi.org/10.48550/arxiv.2406.13768)</sup><sup> • </sup><sup>[32](https://doi.org/10.48550/arxiv.2406.11257)</sup> 一篇 2026 年的综述将这些工作组织为异步检查点、压缩、容错机制和跨框架兼容性。<sup>[33](http://www.jfdc.cnic.cn/EN/10.11871/jfdc.issn.2096-742X.2026.03.017)</sup>

## 局限与替代方案

回滚恢复不能防止设计故障：回滚后系统继续像以前一样处理，因此由设计错误引起的故障会再次出现。<sup>[23](https://link.springer.com/article/10.1007/s11227-013-0884-0)</sup> 非协调式检查点遭受多米诺效应，极端情况下初始状态成为唯一一致的状态；协调式检查点避免了这一问题，但增加了同步开销。<sup>[23](https://link.springer.com/article/10.1007/s11227-013-0884-0)</sup> 同步写入可能大幅降低吞吐量，写时复制或模糊检查点等优化以一致性换取可用性，因为模糊检查点不代表完整的一致快照。<sup>[14](https://sol.sbc.org.br/index.php/wtf/article/download/24679/24500/)</sup> 快照只有在不包含孤儿消息且所有保存的信道消息都是缺失消息时才是一致的。<sup>[2](https://library.eecs.utk.edu/storage/files/ut-eecs-14-734.pdf)</sup>

**替代方案。** [状态机复制](https://www.edgepedia.org/zh/state-machine-replication)曾被评估为百亿亿次系统的主要容错机制，因为建模预测检查点-重启开销在这些规模下将使求解时间增加一倍以上。<sup>[34](https://dl.acm.org/doi/10.1145/2063384.2063443)</sup> 当平均无故障时间较低时，消息日志通过更快的恢复实现比协调式检查点更好的性能，但承担较高的无故障开销；一种改进的悲观日志模型将开销降至应用性能的 5% 以下。<sup>[35](https://www.netlib.org/utk/people/JackDongarra-20130-07-11/PAPERS/207_2010_Redesigning-the-Message-Logging-Model-for-High-Performance.pdf)</sup> 乐观日志不阻塞接收方，但使恢复复杂化，因为一个进程的状态只有在其上次检查点以来收到的所有消息都被记录时才可恢复。<sup>[36](https://cs.rice.edu/~dbj/pubs/jalg-recovery.pdf)</sup> 虚拟机复制是另一种替代方案：Remus 异步将 VM 状态变更传输到备份主机。<sup>[14](https://sol.sbc.org.br/index.php/wtf/article/download/24679/24500/)</sup>

## References

1. [A first order approximation to the optimum checkpoint interval (John W. Young, CACM, Sept 1974)](https://cacm.acm.org/research/a-first-order-approximation-to-the-optimum-checkpoint-interval/)
2. [Fault tolerance techniques for high-performance computing (UTK report)](https://library.eecs.utk.edu/storage/files/ut-eecs-14-734.pdf)
3. [CheckSync: Using Runtime-Integrated Checkpoints to Achieve High Availability](https://arxiv.org/html/2208.02884v1)
4. [A higher order estimate of the optimum checkpoint interval for restart dumps (Daly, Future Generation Computer Systems 22(3):303-312, 2006)](https://graal.ens-lyon.fr/~abenoit/CR02/papers/daly.pdf)
5. [Detailed Modeling and Evaluation of a Scalable Multilevel Checkpointing System (SCR journal version)](https://www.osti.gov/servlets/purl/1225695)
6. [Hybrid Checkpointing for MPI Jobs in HPC Environments (ICPADS 2010)](https://arcb.csc.ncsu.edu/~mueller/ftp/pub/mueller/papers/icpads10-2.pdf)
7. [An Evaluation of Different I/O Techniques for Checkpoint/Restart (asynchronous checkpointing benchmark)](https://blogs.fau.de/hager/files/2013/02/asyn_ckpt_130115.pdf)
8. [Training checkpoints | TensorFlow Core](https://www.tensorflow.org/guide/checkpoint)
9. [COS 418 Precept 4: Distributed Snapshot (Princeton, Feb 2022)](https://www.cs.princeton.edu/courses/archive/spring22/cos418/docs/precept4_distributed_snapshots.pdf)
10. [Distributed Snapshots: Determining Global States of Distributed Systems (Chandy & Lamport, ACM TOCS 1985)](https://www.cs.swarthmore.edu/~newhall/readings/snapshots.pdf)
11. [A survey on checkpointing strategies: Should we always checkpoint à la Young/Daly? (Benoit, Du, Herault)](https://par.nsf.gov/servlets/purl/10581045)
12. [Understanding the Effects of Communication and Coordination on Checkpointing at Scale (Ferreira da Silva et al.)](https://spcl.inf.ethz.ch/Publications/.pdf/ferreira-checkpointing_at_scale.pdf)
13. [IBM OS/VS Checkpoint/Restart (GC26-3784-5, Release 3, Feb 1975)](https://www.bitsavers.org/pdf/ibm/370/OS_VS2/Release_3.0_1975/GC26-3784-5_OS_VS_Checkpoint_Restart_Rel_3_Feb75.pdf)
14. [Checkpointing Techniques in Distributed Systems: A Synopsis of Diverse Strategies Over the Last Decades](https://sol.sbc.org.br/index.php/wtf/article/download/24679/24500/)
15. [John W. Young (1974). A first order approximation to the optimum checkpoint interval. Communications of the ACM.](https://doi.org/10.1145/361147.361115)
16. [Erol Gelenbe (1979). On the Optimum Checkpoint Interval. Journal of the ACM.](https://doi.org/10.1145/322123.322131)
17. [Rob Strom, Shaula Yemini (1985). Optimistic recovery in distributed systems. ACM Transactions on Computer Systems.](https://doi.org/10.1145/3959.3962)
18. [R. Koo, S. Toueg (1987). Checkpointing and Rollback-Recovery for Distributed Systems. IEEE Transactions on Software Engineering.](https://doi.org/10.1109/tse.1987.232562)
19. [J.S. Plank, Kai Li (1994). ickp: a consistent checkpointer for multicomputers. IEEE Parallel & Distributed Technology Systems & Applications.](https://doi.org/10.1109/88.311574)
20. [N.H. Vaidya (1998). A case for two-level recovery schemes. IEEE Transactions on Computers.](https://doi.org/10.1109/12.689645)
21. [J.S. Plank, Kai Li, M.A. Puening (1998). Diskless checkpointing. IEEE Transactions on Parallel and Distributed Systems.](https://doi.org/10.1109/71.730527)
22. [Recent Advances in Checkpoint/Recovery Systems (Plank et al., IPDPS 2006)](https://www.cecs.uci.edu/~papers/ipdps06/pdfs/08-NSFNGS-paper-1.pdf)
23. [A survey of fault tolerance mechanisms and checkpoint/restart implementations for high performance computing systems (Journal of Supercomputing)](https://link.springer.com/article/10.1007/s11227-013-0884-0)
24. [A survey of rollback-recovery protocols in message-passing systems (Elnozahy et al., ACM Computing Surveys 2002)](https://psycnet.apa.org/doi/10.1145/568522.568525)
25. [Optimization of Multi-level Checkpoint Model for Large Scale HPC Applications (IPDPS 2014)](https://graal.ens-lyon.fr/~abenoit/CR02/papers/ipdps14-Di.pdf)
26. [108   Checkpointing a la Young Daly: an Overview   IC3 (2022) (icl.utk.edu)](https://icl.utk.edu/~herault/papers/108%20-%20Checkpointing%20a%20la%20Young-Daly:%20an%20Overview%20-%20IC3%20%282022%29.pdf)
27. [Checkpointing, Fault Tolerance & Long-Running Jobs, The LLM Stack](https://prakashkagitha.github.io/llm-stack-book/03-pretraining/12-checkpointing-fault-tolerance.html)
28. [ByteCheckpoint: A Unified Checkpointing System for Large Foundation Model Development (NSDI '25)](https://www.usenix.org/system/files/nsdi25-wan-borui.pdf)
29. [Maurya, Avinash and colleagues (2024). DataStates-LLM: Lazy Asynchronous Checkpointing for Large Language Models. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2406.10707)
30. [Jiang, Ziheng and colleagues (2024). MegaScale: Scaling Large Language Model Training to More Than 10,000 GPUs. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2402.15627)
31. [Wang, Guanhua and colleagues (2024). FastPersist: Accelerating Model Checkpointing in Deep Learning. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2406.13768)
32. [Li, Wenshuo and colleagues (2024). ExCP: Extreme LLM Checkpoint Compression via Weight-Momentum Joint Shrinking. arXiv (Cornell University).](https://doi.org/10.48550/arxiv.2406.11257)
33. [A survey of Checkpointing Techniques for Large-Scale Language Models (Journal of Frontiers of Data Computing, 2026)](http://www.jfdc.cnic.cn/EN/10.11871/jfdc.issn.2096-742X.2026.03.017)
34. [Evaluating the viability of process replication reliability for exascale systems (SC'11)](https://dl.acm.org/doi/10.1145/2063384.2063443)
35. [Redesigning the message logging model for high performance](https://www.netlib.org/utk/people/JackDongarra-20130-07-11/PAPERS/207_2010_Redesigning-the-Message-Logging-Model-for-High-Performance.pdf)
36. [Recovery in distributed systems using optimistic message logging and checkpointing (Johnson & Zwaenepoel, Journal of Algorithms)](https://cs.rice.edu/~dbj/pubs/jalg-recovery.pdf)

---
*Initially written Sep 29, 2026 · Edited: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Algorithms and computational methods

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/checkpointing

English original: https://www.edgepedia.org/checkpointing
