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

Drop torch re-imports in npu and mlu paths #2856

Merged
merged 1 commit into from
Jun 14, 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
4 changes: 1 addition & 3 deletions src/accelerate/utils/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ def is_mlu_available(check_device=False):
if importlib.util.find_spec("torch_mlu") is None:
return False

import torch
import torch_mlu # noqa: F401

if check_device:
Expand All @@ -359,10 +358,9 @@ def is_mlu_available(check_device=False):
@lru_cache
def is_npu_available(check_device=False):
"Checks if `torch_npu` is installed and potentially if a NPU is in the environment"
if importlib.util.find_spec("torch") is None or importlib.util.find_spec("torch_npu") is None:
if importlib.util.find_spec("torch_npu") is None:
return False

import torch
import torch_npu # noqa: F401

if check_device:
Expand Down
Loading