Repository navigation
Feat: checkpoint resharding - #196
Open
JYMiracle305 wants to merge 6 commits into
Open
JYMiracle305 wants to merge 6 commits into
JYMiracle305 wants to merge 6 commits into
Conversation
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
3 times, most recently
from
August 3, 2026 10:17
5153a9e to
a3f6181
Compare
JYMiracle305
changed the base branch from
master
to
feat/checkpoint-consumed-micro-batches
August 3, 2026 10:17
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 4, 2026 07:43
57ab888 to
7689011
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
2 times, most recently
from
August 6, 2026 07:13
e0540b5 to
c85e813
Compare
JYMiracle305
changed the base branch from
feat/checkpoint-consumed-micro-batches
to
feat/checkpoint-optimizer-state-control
August 6, 2026 07:16
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
August 6, 2026 07:19
c85e813 to
7028203
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-optimizer-state-control
branch
from
August 6, 2026 08:12
5514a0b to
cf3cce5
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
August 6, 2026 08:12
7028203 to
8e4012b
Compare
JYMiracle305
changed the base branch from
feat/checkpoint-optimizer-state-control
to
feat/checkpoint-consumed-micro-batches
August 6, 2026 08:14
JYMiracle305
changed the base branch from
feat/checkpoint-consumed-micro-batches
to
feat/checkpoint-optimizer-state-control
August 6, 2026 08:16
JYMiracle305
changed the base branch from
feat/checkpoint-optimizer-state-control
to
feat/checkpoint-consumed-micro-batches
August 6, 2026 08:17
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
August 6, 2026 08:44
8e4012b to
83a73ee
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 6, 2026 08:44
59a9674 to
9d99035
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
August 6, 2026 09:47
83a73ee to
57bc905
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 6, 2026 09:47
9d99035 to
862a378
Compare
kilinchange
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 7, 2026 02:18
862a378 to
f6f4715
Compare
kilinchange
force-pushed
the
feat/checkpoint_resharding
branch
from
August 7, 2026 02:18
57bc905 to
9928ff2
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 12, 2026 01:37
f6f4715 to
9d30401
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
5 times, most recently
from
August 12, 2026 08:27
845f617 to
8ba9890
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 12, 2026 14:55
9d30401 to
6799ce4
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
2 times, most recently
from
August 14, 2026 09:19
d64951e to
770fc02
Compare
JYMiracle305
force-pushed
the
feat/checkpoint-consumed-micro-batches
branch
from
August 14, 2026 09:20
6799ce4 to
9d406c9
Compare
chen2021673
reviewed
Sep 21, 2026
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
5 times, most recently
from
October 9, 2026 12:15
60025fd to
19ecce6
Compare
chen2021673
approved these changes
Oct 10, 2026
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
October 10, 2026 09:49
ec23a11 to
4da68ad
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
2 times, most recently
from
October 13, 2026 07:35
e90b032 to
a5323c5
Compare
Collaborator
|
对于 PR 描述中 “当前限制” 的部分,建议在代码中对应位置加上 TODO/FIXME |
Chamberlain0w0
requested changes
Oct 16, 2026
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
from
October 16, 2026 07:21
a5323c5 to
b807f9a
Compare
Chamberlain0w0
approved these changes
Oct 16, 2026
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
4 times, most recently
from
October 21, 2026 01:13
23f4311 to
c24e5ef
Compare
JYMiracle305
force-pushed
the
feat/checkpoint_resharding
branch
2 times, most recently
from
October 22, 2026 02:51
1c8f559 to
2822081
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
现有 distributed checkpoint 与保存时的 TP/PP 拓扑绑定,恢复训练时要求使用相同的并行配置。本 PR 引入基于全局张量坐标的 checkpoint resharding,使 checkpoint 可以在不同 TP/PP 配置之间恢复。
设计文档:Checkpoint Resharding 设计
主要修改
ShardedTensor/ShardedStateDict,描述张量的全局形状、本地分片、全局偏移和切分方式。SavePlanner,统一规划模型参数和 Adam optimizer state 的本地写入布局,并生成可用于 reshard 的全局 metadata。LoadPlanner,根据源 checkpoint 与当前目标拓扑的分片坐标计算重叠区间。IndexedRegionLoadStrategy,按 metadata 中的文件和 offset 直接读取所需区域,在加载阶段完成重组,无需预先生成中间 checkpoint。segments保持目标张量中的局部排列及其对应的全局区间;覆盖模型权重、Adamm/v和 packed LoRA-B。m/v共用参数分片信息,训练状态和 LR scheduler 状态随 checkpoint 一并恢复。dp_rank=0的 TP/PP ranks 写入 shard,并在所有 rank metadata 就绪后原子发布全局 metadata;后续将由 shard 的replica_id选择 writer。trainer_state.json保存训练语义、模型配置和运行时并行配置;metadata.json仅保存 checkpoint version/format 以及 tensor shard 的 shape、offset、segments 和文件位置。当前限制
metadata.json,不兼容旧 distributed checkpoint 文件。segments表达。DistributedOptimizer/ ZeRO optimizer state 的保存和恢复。wte.weight和lm_head.weight可能是独立张量,而 PP=1 目标端会将两个 key 映射到同一 Tensor;在实现 canonical tied key 或跨 stage weight tying 前应避免该拓扑转换。测试
metadata.json不写入 iteration、parallel_config 和 model_config;TrainerState 保存并恢复 VPP 配置。