"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "9dd2c86033d1f883e80c8688dd370e5399c4a400"
Unverified Commit 9322576e authored by Zach Mueller's avatar Zach Mueller Committed by GitHub
Browse files

Fix test failure on DeepSpeed (#29444)

* Fix test failure

* use item
parent 0a5b0516
...@@ -2011,7 +2011,10 @@ class Trainer: ...@@ -2011,7 +2011,10 @@ class Trainer:
is_accelerate_available() is_accelerate_available()
and self.accelerator.distributed_type == DistributedType.DEEPSPEED and self.accelerator.distributed_type == DistributedType.DEEPSPEED
): ):
grad_norm = model.get_global_grad_norm().item() grad_norm = model.get_global_grad_norm()
# In some cases the grad norm may not return a float
if hasattr(grad_norm, "item"):
grad_norm = grad_norm.item()
else: else:
grad_norm = _grad_norm.item() if _grad_norm is not None else None grad_norm = _grad_norm.item() if _grad_norm is not None else None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment