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

Fix is_torch_tpu_available in ORT Trainer #2028

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
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
10 changes: 5 additions & 5 deletions optimum/onnxruntime/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@
from transformers.deepspeed import deepspeed_init, deepspeed_load_checkpoint, is_deepspeed_zero3_enabled

if check_if_transformers_greater("4.39"):
from transformers.utils import is_torch_xla_available
from transformers.utils import is_torch_xla_available as is_torch_tpu_xla_available

if is_torch_xla_available():
if is_torch_tpu_xla_available():
import torch_xla.core.xla_model as xm
else:
from transformers.utils import is_torch_tpu_available
from transformers.utils import is_torch_tpu_available as is_torch_tpu_xla_available

if is_torch_tpu_available(check_device=False):
if is_torch_tpu_xla_available(check_device=False):
import torch_xla.core.xla_model as xm

if TYPE_CHECKING:
Expand Down Expand Up @@ -735,7 +735,7 @@ def get_dataloader_sampler(dataloader):

if (
args.logging_nan_inf_filter
and not is_torch_tpu_available()
and not is_torch_tpu_xla_available()
and (torch.isnan(tr_loss_step) or torch.isinf(tr_loss_step))
):
# if loss is nan or inf simply add the average of previous logged losses
Expand Down
Loading