Skip to content

Commit ae34e7a

Browse files
fixup! fix: only trigger on_save if the output checkpoint path actually contains files
Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
1 parent 30b8dd7 commit ae34e7a

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

tuning/sft_trainer.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,18 +581,32 @@ def save(path: str, trainer: SFTTrainer, tc_callback, log_level="WARNING", args=
581581
if os.path.exists(path):
582582
try:
583583
saved_files = os.listdir(path)
584-
logger.info("sanity check, we found %d files at checkpoint path '%s'", len(saved_files), path)
584+
logger.info(
585+
"sanity check, we found %d files at checkpoint path '%s'",
586+
len(saved_files),
587+
path,
588+
)
585589
actually_saved = len(saved_files) > 0
586590
except Exception as e:
587-
logger.warning("sanity check, failed to list files in checkpoint path '%s' , error: %s", path, e)
591+
logger.warning(
592+
"sanity check, failed to list files in checkpoint path '%s' , error: %s",
593+
path,
594+
e,
595+
)
588596
else:
589-
logger.warning("sanity check, failed because checkpoint path '%s' doesn't exist", path)
597+
logger.warning(
598+
"sanity check, failed because checkpoint path '%s' doesn't exist", path
599+
)
590600
if actually_saved:
591601
tc_callback.on_save(
592602
args, trainer.state, trainer.control, path=path, is_final=True
593603
)
594604
else:
595-
logger.warning("skip triggering on_save event since checkpoint path is empty: '%s'", path)
605+
logger.warning(
606+
"skip triggering on_save event since checkpoint path is empty: '%s'",
607+
path,
608+
)
609+
596610

597611
def get_parser():
598612
"""Get the command-line argument parser."""

0 commit comments

Comments
 (0)