refactor: 简化 _disable_random_init,scheduler 移入同步块

- _disable_random_init: enable=False 提前返回,dict 推导替代空字典
- scheduler.step() 移入 sync_gradients 守卫内
This commit is contained in:
2026-05-26 17:05:25 +08:00
parent 65ab69543b
commit b558e61f63
2 changed files with 13 additions and 12 deletions
+2 -2
View File
@@ -84,8 +84,8 @@ class Trainer:
context.optimizer.step()
context.optimizer.zero_grad()
if context.scheduler:
context.scheduler.step()
if context.scheduler:
context.scheduler.step()
self._call_callbacks("on_epoch_end", context)