chore: refactor SaveModelCallback to stop handle fractional save_steps (#2291) [skip ci]

This commit is contained in:
NanoCode012
2025-01-29 11:22:10 +07:00
committed by GitHub
parent 0b52f06227
commit 067b442596

View File

@@ -4,7 +4,6 @@ from __future__ import annotations
import gc
import logging
import math
import os
import traceback
from shutil import copyfile
@@ -830,13 +829,6 @@ class SaveModelCallback(TrainerCallback):
# Save
if state.global_step >= state.max_steps:
control.should_save = True
elif (
args.save_strategy == IntervalStrategy.STEPS
and state.save_steps < 1.0
and state.global_step % math.ceil(state.save_steps * state.max_steps) == 0
):
# workaround to save model on fractional save_steps
control.should_save = True
def on_train_end( # pylint: disable=unused-argument
self, args, state, control, **kwargs