Skip to content

Commit c70c473

Browse files
XucShPanAndy
authored andcommitted
(fix): handle is_last_step in DeepSpeedTrainStrategy.save_checkpoint
Previously, is_last_step was passed via **kwargs and transparently forwarded to DeepSpeedEngine.save_checkpoint(), which does not accept this argument, causing a TypeError at checkpoint time. Fix by explicitly declaring is_last_step=None in the signature (consistent with megatron_strategy and fsdp2_strategy), and applying the same async_upload guard logic as the other strategies. Signed-off-by: Xuchun Shang <xuchun.shang@linux.alibaba.com>
1 parent ae69fd8 commit c70c473

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

roll/distributed/strategy/deepspeed_strategy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def train_step(
503503
self.offload_states(include=[OffloadStateType.optimizer_states], non_blocking=True)
504504
return metrics
505505

506-
def save_checkpoint(self, save_dir, global_step, ckpt_id, tag="checkpoint", local_state_path=None, **kwargs):
506+
def save_checkpoint(self, save_dir, global_step, ckpt_id, tag="checkpoint", local_state_path=None, is_last_step=None, **kwargs):
507507
"""
508508
save ckpt/hf model/tokenizer to local dir
509509
save_dir/actor_train/{hf files}
@@ -540,7 +540,7 @@ def save_checkpoint(self, save_dir, global_step, ckpt_id, tag="checkpoint", loca
540540
# save tokenizer
541541
self.model.save_checkpoint(save_dir, tag=tag, **kwargs)
542542

543-
if self.worker_config.checkpoint_config.get("async_upload", True):
543+
if self.worker_config.checkpoint_config.get("async_upload", True) and not is_last_step:
544544
self.thread_executor.submit(self.checkpoint_manager.upload, ckpt_id=ckpt_id, local_state_path=local_state_path)
545545
else:
546546
self.checkpoint_manager.upload(ckpt_id=ckpt_id, local_state_path=local_state_path)

0 commit comments

Comments
 (0)