11from collections .abc import Sequence
22import ctypes as ct
3- import warnings
3+ import logging
44
55import torch
66
1010from ...cextension import ErrorHandlerMockBNBNativeLibrary , lib
1111from ..utils import triton_available
1212
13+ logger = logging .getLogger (__name__ )
14+
1315
1416def _dequantize_4bit_impl (
1517 A : torch .Tensor ,
@@ -135,6 +137,7 @@ def _gemv_4bit_impl(
135137
136138# SYCL should be faster for xpu, so at first checking if it is available.
137139if not isinstance (lib , ErrorHandlerMockBNBNativeLibrary ):
140+ logger .info ("Loading sycl bitsandbytes kernels for XPU" )
138141
139142 @register_kernel ("bitsandbytes::dequantize_4bit" , "xpu" )
140143 def _ (
@@ -201,6 +204,7 @@ def _(
201204 torch ._check (out .dtype == A .dtype , lambda : f"Expected out.dtype == { A .dtype } , got { out .dtype } " )
202205 _gemv_4bit_impl (A , B , shapeB , absmax , code , blocksize , out = out )
203206elif triton_available :
207+ logger .info ("Loading triton bitsandbytes kernels for XPU" )
204208 from ..triton import ops as triton_ops
205209
206210 register_kernel ("bitsandbytes::quantize_blockwise" , "xpu" )(triton_ops .quantize_blockwise )
@@ -211,6 +215,4 @@ def _(
211215 register_kernel ("bitsandbytes::dequantize_4bit" , "xpu" )(triton_ops .dequantize_4bit )
212216 register_kernel ("bitsandbytes::gemv_4bit" , "xpu" )(triton_ops .gemv_4bit )
213217else :
214- warnings .warn (
215- "XPU available but no native library or triton packages found. Please follow the installation instructions in the documentation."
216- )
218+ logger .warning ("Loading pytorch bitsandbytes kernels for XPU because no native library or triton packages found." )
0 commit comments