Skip to content

Commit

Permalink
Add kwargs back to the closure (mosaicml#292)
Browse files Browse the repository at this point in the history
* add kwargs back to the closure

* woops
  • Loading branch information
jbloxham authored and coryMosaicML committed Feb 23, 2022
1 parent 196cfc4 commit a6bb3fd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions composer/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,10 +636,11 @@ def _train_loop(self) -> None:
elif self._use_closures():
for optimizer in state.optimizers:
if use_grad_scaling:
total_loss = state.scaler.step(optimizer,
closure=lambda: self._train_batch(microbatches))
total_loss = state.scaler.step(
optimizer, closure=lambda **kwargs: self._train_batch(microbatches, **kwargs))
else:
total_loss = optimizer.step(closure=lambda: self._train_batch(microbatches).item())
total_loss = optimizer.step(
closure=lambda **kwargs: self._train_batch(microbatches, **kwargs).item())
else:
total_loss = self._train_batch(microbatches)
for optimizer in state.optimizers:
Expand Down

0 comments on commit a6bb3fd

Please sign in to comment.