Skip to content

Commit 283be54

Browse files
committed
comments
1 parent 4adc4e4 commit 283be54

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

bitsandbytes/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
from .backends.cuda import ops as cuda_ops
3636

3737
# xpu was introduced in PyTorch 2.3
38-
if torch.__version__ >= (2, 3):
39-
if torch.xpu.is_available():
40-
from .backends.xpu import ops as xpu_ops
38+
if torch.__version__ >= (2, 3) and torch.xpu.is_available():
39+
from .backends.xpu import ops as xpu_ops
4140

4241

4342
def _import_backends():

bitsandbytes/backends/xpu/ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from ..._ops import register_kernel
77
from ..utils import ipex_xpu, triton_available
88

9-
# With default torch, error:
10-
# NotImplementedError: The operator 'aten::_int_mm' for XPU
9+
# _int_mm is available in torch starting from 2.7 version,
10+
# but currently it's don't have xpu implementation.
1111
if ipex_xpu and torch.__version__ >= (2, 7):
1212

1313
@register_kernel("bitsandbytes::int8_linear_matmul", "xpu")
@@ -18,6 +18,7 @@ def _(A: torch.Tensor, B: torch.Tensor):
1818
).reshape(*A.shape[:-1], B.shape[0])
1919

2020

21+
# IPEX should be faster for xpu, so at first checking if it is available.
2122
if ipex_xpu:
2223

2324
@register_kernel("bitsandbytes::dequantize_nf4_ipex", "xpu")
@@ -53,7 +54,6 @@ def _(
5354

5455
return out.reshape(shape)
5556
elif triton_available:
56-
# IPEX should be faster for xpu, so at first checking if it is available.
5757
from ..triton import ops as triton_ops
5858

5959
register_kernel("bitsandbytes::quantize_blockwise", "xpu")(triton_ops.quantize_blockwise)
@@ -64,4 +64,4 @@ def _(
6464
register_kernel("bitsandbytes::dequantize_4bit", "xpu")(triton_ops.dequantize_4bit)
6565
register_kernel("bitsandbytes::gemv_4bit", "xpu")(triton_ops.gemv_4bit)
6666
else:
67-
warnings.warn("XPU available, but nor ipex or trtion package is found.")
67+
warnings.warn("XPU available but no ipex or triton packages found.")

0 commit comments

Comments
 (0)