-
Notifications
You must be signed in to change notification settings - Fork 698
Enable CPU/XPU native and ipex path #1628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 27 commits
ba79025
958d75b
f5c0b01
7f2d8a8
97d5bd1
5563c35
7b72673
52e32af
fda3d70
5ce3296
f51678e
7c9281c
83cea6b
bc8723e
3c07023
9fbed05
59e682d
c17e2ff
974c60a
a21c290
a5d4a27
959a0d4
f44d4a2
b9f3c40
21cf8c1
a9e5c4a
1a77949
b0cd993
539f5d4
005afe0
4471ada
cddeec6
8492010
25d01a4
8ff8947
82651f9
413bba9
cf8bc14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,11 +283,28 @@ def get_native_library() -> BNBNativeLibrary: | |
return BNBNativeLibrary(dll) | ||
|
||
|
||
try: | ||
# to support Intel CPU/GPU (XPU) backend | ||
import intel_extension_for_pytorch as ipex | ||
|
||
ipex_cpu = ipex if ipex._C._has_cpu() else None | ||
ipex_xpu = ipex if ipex._C._has_xpu() else None | ||
except BaseException: | ||
ipex_cpu = None | ||
ipex_xpu = None | ||
|
||
|
||
try: | ||
lib = get_native_library() | ||
if not ipex_cpu: | ||
logger.warning( | ||
"The installed version of bitsandbytes was compiled without IPEX support. " | ||
"You can install ipex by running `pip install intel_extension_for_pytorch`to get better performance if you use the Intel CPU.", | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like extra noise that we'd want to avoid. Something to point out is that we still plan to ship libbitsandbytes_cpu in our wheels, so for most users, it's going to load a CPU, CUDA, or eventually ROCm or Metal library and we'll hit this logging line. At most we should really only raise this warning when:
Any other thoughts @Titus-von-Koeller ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You were right. I also agree that the log should only exist if no devices like cuda/xpu are available and the CPU is an Intel product. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have changed it, please review again. Thanks! |
||
except Exception as e: | ||
error_msg = str(e) | ||
logger.error(f"bitsandbytes library load error: {error_msg}\n", exc_info=True) | ||
if not ipex_xpu: | ||
logger.error(f"bitsandbytes library load error: {error_msg}\n", exc_info=True) | ||
|
||
# create a mock with error messaging as fallback | ||
lib = ErrorHandlerMockBNBNativeLibrary(error_msg) |
Uh oh!
There was an error while loading. Please reload this page.