Skip to content

Commit fe6cd17

Browse files
update doc-string
1 parent d4df4b7 commit fe6cd17

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

bitsandbytes/cextension.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,23 @@ def parse_cuda_version(version_str: str) -> str:
9393

9494
class ErrorHandlerMockBNBNativeLibrary(BNBNativeLibrary):
9595
"""
96-
Mock BNBNativeLibrary that raises an error when trying to use native library
97-
functionality without successfully loading the library.
98-
Any method or attribute access will raise a RuntimeError with a message that
99-
points to the original error and provides troubleshooting steps.
96+
Mock library handler that defers errors until native methods are called.
97+
98+
This class serves as a fallback when the native bitsandbytes library fails to load.
99+
It captures the original error and generates detailed troubleshooting guidance.
100+
101+
Key behaviors:
102+
- Allows attribute access and method assignment without immediate errors
103+
- Throws a RuntimeError with diagnostic information only when a native method is called, as otherwise it would error out on import, breaking backward compatibility
104+
- Handles both missing CUDA dependencies and version mismatch scenarios
105+
106+
Error scenarios covered:
107+
1. Missing shared library dependencies (e.g., libcudart.so not in LD_LIBRARY_PATH or through PyTorch CUDA installation)
108+
2. CUDA version mismatch between PyTorch and available pre-compiled binaries
109+
3. Completely missing pre-compiled binaries when CUDA is detected
110+
4. Custom BNB_CUDA_VERSION override but mismatch
111+
5. CPU-only installation attempts when GPU functionality is requested
112+
100113
"""
101114

102115
def __init__(self, error_msg: str):

0 commit comments

Comments
 (0)