Skip to content

Commit

Permalink
Fix _cache_founf_inf (PaddlePaddle#7997)
Browse files Browse the repository at this point in the history
* Fix

* Fix

* Fix
  • Loading branch information
co63oc authored Mar 4, 2024
1 parent a574900 commit 77a23d1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion examples/RLHF/ppo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,11 @@ def full_training_step(self: Trainer, inputs: Dict[str, paddle.Tensor], **kwargs
self.scaler.step(self.optimizer)
self.scaler.update()
scale_after = self.scaler._scale
optimizer_was_run = not self.scaler._cache_founf_inf
# Compatible with paddlepaddle 2.6.0 using typo word.
if hasattr(self.scaler, "_cache_founf_inf"):
optimizer_was_run = not self.scaler._cache_founf_inf
else:
optimizer_was_run = not self.scaler._cache_found_inf
if not optimizer_was_run:
scale_before_value = scale_before.cpu().numpy()
scale_after_value = scale_after.cpu().numpy()
Expand Down
6 changes: 5 additions & 1 deletion paddlenlp/trainer/auto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ def optimizer_step(self):
self.scaler.step(self.optimizer)
self.scaler.update()
scale_after = self.scaler._scale
optimizer_was_run = not self.scaler._cache_founf_inf
# Compatible with paddlepaddle 2.6.0 using typo word.
if hasattr(self.scaler, "_cache_founf_inf"):
optimizer_was_run = not self.scaler._cache_founf_inf
else:
optimizer_was_run = not self.scaler._cache_found_inf
if not optimizer_was_run:
scale_before_value = scale_before.cpu().numpy()
scale_after_value = scale_after.cpu().numpy()
Expand Down
6 changes: 5 additions & 1 deletion paddlenlp/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,11 @@ def _inner_training_loop(
self.scaler.step(self.optimizer)
self.scaler.update()
scale_after = self.scaler._scale
optimizer_was_run = not self.scaler._cache_founf_inf
# Compatible with paddlepaddle 2.6.0 using typo word.
if hasattr(self.scaler, "_cache_founf_inf"):
optimizer_was_run = not self.scaler._cache_founf_inf
else:
optimizer_was_run = not self.scaler._cache_found_inf
if not optimizer_was_run:
scale_before_value = scale_before.cpu().numpy()
scale_after_value = scale_after.cpu().numpy()
Expand Down

0 comments on commit 77a23d1

Please sign in to comment.