Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grad norm tensor fix #938

Merged
merged 3 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix
  • Loading branch information
regisss committed May 1, 2024
commit 5535812e61b2390a6e8fb4dc0188ead72ba318f3
4 changes: 2 additions & 2 deletions optimum/habana/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1184,11 +1184,11 @@ def _maybe_log_save_evaluate(self, tr_loss, _grad_norm, model, trial, epoch, ign
grad_norm = model.get_global_grad_norm()
else:
if _grad_norm is not None and self.accelerator.distributed_type != GaudiDistributedType.FSDP:
grad_norm = _grad_norm.item() if _grad_norm.size() == 1 else _grad_norm.tolist()
grad_norm = _grad_norm.item() if _grad_norm.size() == torch.Size([1]) else _grad_norm.tolist()
else:
grad_norm = None

if grad_norm is not None:
if grad_norm is not None and not isinstance(grad_norm, list):
logs["grad_norm"] = grad_norm
logs["learning_rate"] = self._get_learning_rate()

Expand Down
Loading