Skip to content

Commit

Permalink
CPU/XPU: disable torch.compile if g++ is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
Xia-Weiwen committed Jun 17, 2024
1 parent 517eaf2 commit 27d7bbd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bitsandbytes/backends/cpu_xpu_common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional
import warnings
import subprocess

import torch

Expand All @@ -19,6 +20,14 @@
ipex_xpu = None


gxx_available = False
try:
subprocess.run(["g++", "--version"])
gxx_available = True
except BaseException:
warnings.warn(f"g++ not found, torch.compile disabled for CPU/XPU.")


Tensor = torch.Tensor


Expand All @@ -45,8 +54,8 @@ def _ipex_xpu_version_prereq(major, minor):


def _maybe_torch_compile(func):
# torch.compile requires pytorch >= 2.0
if _torch_version_prereq(2, 0):
# torch.compile requires g++ and pytorch >= 2.0
if gxx_available and _torch_version_prereq(2, 0):
options = {}
# fx_graph_cache requires pytorch >= 2.2
if _torch_version_prereq(2, 2):
Expand Down

0 comments on commit 27d7bbd

Please sign in to comment.