diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index b112df2f7..a68d6751e 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -298,7 +298,15 @@ def get_native_library() -> BNBNativeLibrary: try: - lib = get_native_library() + if hasattr(torch, "xpu") and torch.xpu.is_available(): + if not ipex_xpu: + logger.warning( + "Detected Intel XPU without intel_extension_for_pytorch installed. Triton implementation will be used." + ) + # create a mock with error messaging as fallback + lib = ErrorHandlerMockBNBNativeLibrary("XPU does not need library loading") + else: + lib = get_native_library() except Exception as e: error_msg = str(e) if not (ipex_cpu or ipex_xpu):