mindx_elastic.terminating_message.ExceptionCheckpoint(prefix='Exception', directory=os.getcwd(), config=None, partial_save=False, replicas=1)
功能说明
在训练每一轮或者每一次迭代执行的固定动作,用于捕捉INT和TERM信号,触发临终checkpoint的保存。
参数:
- prefix(str)- 指定checkpoint文件的前缀名称。
- directory(str)- 指定保存checkpoint文件的文件夹路径。默认情况下,文件保存在当前目录下。
- config(CheckpointConfig)- 指定checkpoint策略配置。
- partial_save(bool)- 指定是否开启部分保存。
- replicas(int)- 指定部分保存的副本数量,最小值1,最大值5。
使用样例如下:
from mindx_elastic.terminating_message import ExceptionCheckpoint ... ckpt_append_info = [{"epoch_num": args_param.has_trained_epoches, "step_num": args_param.has_trained_steps}] ckpt_config = CheckpointConfig(save_checkpoint_steps=20, keep_checkpoint_max=1, integrated_save=False, append_info=ckpt_append_info ) # save checkpoint into rank directory ckpoint_cb = ModelCheckpoint(prefix="pangu" + str(rank_id), directory=os.path.join("current_path", f"rank_{rank_id}"), config=ckpt_config) callback.append(ckpoint_cb) exp_ckpt_cb = ExceptionCheckpoint(prefix="pangu" + str(rank_id), directory=os.path.join(args_param.save_checkpoint_path, f"rank_{rank_id}"), config=ckpt_config) callback.append(exp_ckpt_cb)