Skip to content

Commit

Permalink
fix issue when there is mps fallback enabled during training
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhirwa committed Dec 9, 2024
1 parent d57b0bb commit a7f6491
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pytorch_forecasting/models/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ def step(
loss = self.loss(prediction, y)
else:
loss = None
# ensure that loss has require_grad
if loss is not None and loss.device.type == "mps":
loss.requires_grad_(True)
self.log(
f"{self.current_stage}_loss",
loss,
Expand Down

0 comments on commit a7f6491

Please sign in to comment.