refactor: rename optimizer step callback hooks to before and after

- rename on_optimizer_step to before_optimizer_step across the callback protocol, built-in callbacks, and trainer call site
- rename on_after_optimizer_step to after_optimizer_step for the symmetric post-step hook
- document the hook pair and the checkpoint save location in developer and training guides
This commit is contained in:
2026-09-01 14:22:54 +08:00
parent 08721f6d31
commit 0e7dafad8e
5 changed files with 24 additions and 19 deletions
+2 -2
View File
@@ -93,7 +93,7 @@ class Trainer:
self._call_callbacks("on_batch_end", context)
if executor.sync_gradients:
self._call_callbacks("on_optimizer_step", context)
self._call_callbacks("before_optimizer_step", context)
context.optimizer.step()
context.strategy.on_optimizer_step()
context.optimizer.zero_grad()
@@ -101,7 +101,7 @@ class Trainer:
if context.scheduler:
context.scheduler.step()
self._call_callbacks("on_after_optimizer_step", context)
self._call_callbacks("after_optimizer_step", context)
self._call_callbacks("on_epoch_end", context)