Skip to content

Commit

Permalink
bug fix (#2426)
Browse files Browse the repository at this point in the history
  • Loading branch information
faaany authored Feb 9, 2024
1 parent b0b867d commit 9c1d5ba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/accelerate/accelerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,10 +1754,11 @@ def _prepare_ipex(self, *args):
for obj in result:
if isinstance(obj, torch.nn.Module):
model = obj
model.train()
elif isinstance(obj, (torch.optim.Optimizer)):
optimizer = obj
if optimizer is not None and model is not None:
dtype = torch.bfloat16 if self.state.mixed_precision == "bf16" else torch.float32
dtype = torch.bfloat16 if self.state.mixed_precision == "bf16" else None
if self.device.type == "xpu" and is_xpu_available():
model = model.to(self.device)
model, optimizer = torch.xpu.optimize(
Expand Down

0 comments on commit 9c1d5ba

Please sign in to comment.