From 343bfd58df383e42a9305eb47060e82e2f9341f5 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Thu, 29 May 2025 13:04:50 +0000 Subject: [PATCH 1/5] update bnb log Signed-off-by: jiqing-feng --- bitsandbytes/cextension.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index b112df2f7..8f0ee1484 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -298,7 +298,16 @@ def get_native_library() -> BNBNativeLibrary: try: - lib = get_native_library() + if hasattr(torch, "xpu") and torch.xpu.is_available(): + if not (ipex_cpu or ipex_xpu): + logger.warning( + "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. " + "IPEX is recommended for Intel XPU support in bitsandbytes to get better performance. " + "Please check the installation doc to install `intel_extension_for_pytorch`. " + ) + lib = ErrorHandlerMockBNBNativeLibrary("XPU does not need native library") + else: + lib = get_native_library() except Exception as e: error_msg = str(e) if not (ipex_cpu or ipex_xpu): From ccc645d05f1263e20b374967836b51912bb5d4a1 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Thu, 29 May 2025 13:21:28 +0000 Subject: [PATCH 2/5] fix lib Signed-off-by: jiqing-feng --- bitsandbytes/cextension.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index 8f0ee1484..7409ab172 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -299,13 +299,13 @@ def get_native_library() -> BNBNativeLibrary: try: if hasattr(torch, "xpu") and torch.xpu.is_available(): - if not (ipex_cpu or ipex_xpu): + if not ipex_xpu: logger.warning( "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. " "IPEX is recommended for Intel XPU support in bitsandbytes to get better performance. " "Please check the installation doc to install `intel_extension_for_pytorch`. " ) - lib = ErrorHandlerMockBNBNativeLibrary("XPU does not need native library") + lib = None else: lib = get_native_library() except Exception as e: From 09ceea27b0d97c3bc3e1fe3947dd083df11540f9 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Fri, 30 May 2025 09:13:46 +0000 Subject: [PATCH 3/5] update warning Signed-off-by: jiqing-feng --- bitsandbytes/cextension.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index 7409ab172..b787d8163 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -301,9 +301,8 @@ def get_native_library() -> BNBNativeLibrary: if hasattr(torch, "xpu") and torch.xpu.is_available(): if not ipex_xpu: logger.warning( - "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. " - "IPEX is recommended for Intel XPU support in bitsandbytes to get better performance. " - "Please check the installation doc to install `intel_extension_for_pytorch`. " + "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. Triton implementation will be used." + "Please check the installation doc to install `intel_extension_for_pytorch` to get better performance." ) lib = None else: From 47539fa91e8248d237953613ff2ad8e4572437ac Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Tue, 3 Jun 2025 13:10:02 +0000 Subject: [PATCH 4/5] add mock lib for xpu Signed-off-by: jiqing-feng --- bitsandbytes/cextension.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index b787d8163..b2b90abe2 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -304,7 +304,8 @@ def get_native_library() -> BNBNativeLibrary: "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. Triton implementation will be used." "Please check the installation doc to install `intel_extension_for_pytorch` to get better performance." ) - lib = None + # 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: From bc4a54032ba04b86962b0239bd3b08698e17ea81 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Thu, 5 Jun 2025 09:41:11 +0000 Subject: [PATCH 5/5] update log Signed-off-by: jiqing-feng --- bitsandbytes/cextension.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bitsandbytes/cextension.py b/bitsandbytes/cextension.py index b2b90abe2..a68d6751e 100644 --- a/bitsandbytes/cextension.py +++ b/bitsandbytes/cextension.py @@ -301,8 +301,7 @@ def get_native_library() -> BNBNativeLibrary: if hasattr(torch, "xpu") and torch.xpu.is_available(): if not ipex_xpu: logger.warning( - "Detected Intel XPU but no Intel Extension for PyTorch (IPEX) installed. Triton implementation will be used." - "Please check the installation doc to install `intel_extension_for_pytorch` to get better performance." + "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")