Skip to content

Commit 5299b05

Browse files
mini-trainer-improveclaudemultica-agent
committed
fix: fire on_step_end before incrementing global_step
on_step_begin(step=N) was followed by on_step_end(step=N+1) because global_step was incremented before on_step_end fired. Move on_step_end before the increment so begin/end see the same step number. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
1 parent c6578c5 commit 5299b05

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/instructlab/training/main_ds.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,14 @@ def _save_and_exit(checkpoint_location: str) -> None:
420420
ckpt_path = os.path.join(args.output_dir, "hf_format", subdir)
421421
callback_manager.fire("on_save", checkpoint_path=ckpt_path)
422422

423+
if callback_manager:
424+
callback_manager.fire("on_step_end")
425+
423426
global_step += 1
424427
if local_rank == 0:
425428
inner_pb.update(1)
426429
torch.cuda.empty_cache()
427430

428-
if callback_manager:
429-
callback_manager.context.step = global_step
430-
callback_manager.fire("on_step_end")
431-
432431
if args.checkpoint_at_epoch:
433432
base_logger.debug(f"Saving checkpoint at epoch {epoch}")
434433
save_checkpoint(

0 commit comments

Comments
 (0)