Skip to content

Commit 229217a

Browse files
Remove legacy sparse functionality
1 parent d5cb0f2 commit 229217a

20 files changed

+17
-1180
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
cuda: ${{ matrix.cuda_version }}
8787
method: "network"
8888
# The "crt" "nvvm" and "nvptxcompiler" components are added for CUDA 13.
89-
sub-packages: ${{ format('["nvcc"{0},"cudart","cusparse","cublas","thrust","cublas_dev","cusparse_dev"]', startsWith(matrix.cuda_version, '13.') && ',"crt","nvvm","nvptxcompiler"' || '') }}
89+
sub-packages: ${{ format('["nvcc"{0},"cudart","cublas","thrust","cublas_dev"]', startsWith(matrix.cuda_version, '13.') && ',"crt","nvvm","nvptxcompiler"' || '') }}
9090
use-github-cache: false
9191
use-local-cache: false
9292
log-file-suffix: ${{matrix.os}}-${{matrix.cuda_version}}.txt

.github/workflows/test-runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
with:
149149
cuda: ${{ inputs.cuda_version }}
150150
method: "network"
151-
sub-packages: '["nvcc","cudart","cusparse","cublas","thrust","nvrtc_dev","cublas_dev","cusparse_dev"]'
151+
sub-packages: '["nvcc","cudart","cublas","thrust","nvrtc_dev","cublas_dev"]'
152152
use-github-cache: false
153153

154154
# Windows: Setup MSVC (needed for both CPU and CUDA builds)

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ endif()
349349

350350
if(BUILD_CUDA)
351351
target_include_directories(bitsandbytes PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
352-
target_link_libraries(bitsandbytes PUBLIC CUDA::cudart CUDA::cublas CUDA::cublasLt CUDA::cusparse)
352+
target_link_libraries(bitsandbytes PUBLIC CUDA::cudart CUDA::cublas CUDA::cublasLt)
353353
set_target_properties(bitsandbytes
354354
PROPERTIES
355355
CUDA_SEPARABLE_COMPILATION ON
@@ -369,7 +369,6 @@ if(BUILD_HIP)
369369
endmacro()
370370
find_package_and_print_version(hipblas REQUIRED)
371371
find_package_and_print_version(hiprand REQUIRED)
372-
find_package_and_print_version(hipsparse REQUIRED)
373372

374373
## hacky way of excluding hip::amdhip64 (with it linked many tests unexpectedly fail e.g. adam8bit because of inaccuracies)
375374
## On Windows, we need to link amdhip64 explicitly
@@ -381,7 +380,7 @@ if(BUILD_HIP)
381380

382381
target_include_directories(bitsandbytes PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include ${ROCM_PATH}/include /include)
383382
target_link_directories(bitsandbytes PRIVATE ${ROCM_PATH}/lib /lib)
384-
target_link_libraries(bitsandbytes PUBLIC roc::hipblas hip::hiprand roc::hipsparse)
383+
target_link_libraries(bitsandbytes PUBLIC roc::hipblas hip::hiprand)
385384

386385
# On Windows, rocblas is not pulled in transitively by roc::hipblas
387386
# and is needed because ops_hip.cuh uses rocblas_handle directly.

agents/api_surface.md

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -860,57 +860,7 @@ F.batched_igemm(
860860
Batched int8 matrix multiplication.
861861
**Stability:** Stable (internal).
862862

863-
### 4.9 Sparse Operations
864-
865-
#### `COOSparseTensor`
866-
867-
```python
868-
class F.COOSparseTensor:
869-
def __init__(self, rows, cols, nnz, rowidx, colidx, values): ...
870-
```
871-
872-
**Stability:** Legacy — used internally for sparse decomposition.
873-
874-
#### `CSRSparseTensor` / `CSCSparseTensor`
875-
876-
Similar sparse tensor containers.
877-
**Stability:** Legacy.
878-
879-
#### `coo_zeros`
880-
881-
```python
882-
F.coo_zeros(rows, cols, nnz, device, dtype=torch.half) -> COOSparseTensor
883-
```
884-
885-
#### `coo2csr` / `coo2csc`
886-
887-
```python
888-
F.coo2csr(cooA: COOSparseTensor) -> CSRSparseTensor
889-
F.coo2csc(cooA: COOSparseTensor) -> CSCSparseTensor
890-
```
891-
892-
#### `spmm_coo`
893-
894-
```python
895-
F.spmm_coo(
896-
cooA: COOSparseTensor, B: torch.Tensor,
897-
out: Optional[torch.Tensor] = None,
898-
) -> torch.Tensor
899-
```
900-
901-
Sparse matrix-dense matrix multiply using cusparse.
902-
**Stability:** Legacy.
903-
904-
#### `spmm_coo_very_sparse`
905-
906-
```python
907-
F.spmm_coo_very_sparse(cooA, B, dequant_stats=None, out=None) -> torch.Tensor
908-
```
909-
910-
Optimized for very sparse matrices with custom kernel.
911-
**Stability:** Legacy.
912-
913-
### 4.10 Paged Memory
863+
### 4.9 Paged Memory
914864

915865
#### `get_paged`
916866

@@ -930,7 +880,7 @@ F.prefetch_tensor(A: torch.Tensor, to_cpu: bool = False) -> None
930880
Prefetch a paged tensor to GPU or CPU.
931881
**Stability:** Stable (internal).
932882

933-
### 4.11 CPU-Specific Functions
883+
### 4.10 CPU-Specific Functions
934884

935885
#### `_convert_weight_packed_for_cpu`
936886

@@ -963,7 +913,7 @@ F.has_avx512bf16() -> bool
963913
Detects AVX512BF16 CPU support.
964914
**Stability:** Internal but may be useful externally.
965915

966-
### 4.12 Utility Functions
916+
### 4.11 Utility Functions
967917

968918
#### `is_on_gpu`
969919

@@ -983,7 +933,7 @@ F.get_ptr(A: Optional[Tensor]) -> Optional[ct.c_void_p]
983933
Gets the data pointer of a tensor for ctypes calls.
984934
**Stability:** Internal.
985935

986-
### 4.13 Singleton Managers
936+
### 4.12 Singleton Managers
987937

988938
#### `GlobalPageManager`
989939

@@ -1003,15 +953,6 @@ F.CUBLAS_Context.get_instance() -> CUBLAS_Context
1003953
Manages cuBLAS context handles per device.
1004954
**Stability:** Internal.
1005955

1006-
#### `Cusparse_Context`
1007-
1008-
```python
1009-
F.Cusparse_Context.get_instance() -> Cusparse_Context
1010-
```
1011-
1012-
Manages cusparse context handle.
1013-
**Stability:** Internal.
1014-
1015956
---
1016957

1017958
## 5. Autograd Functions
@@ -1234,7 +1175,7 @@ bitsandbytes.utils.replace_linear(
12341175
| Class | Description |
12351176
|-------|-------------|
12361177
| `BNBNativeLibrary` | Base wrapper for the ctypes-loaded native library |
1237-
| `CudaBNBNativeLibrary` | CUDA-specific subclass (sets up context/cusparse/managed ptr) |
1178+
| `CudaBNBNativeLibrary` | CUDA-specific subclass (sets up context/managed ptr) |
12381179
| `ErrorHandlerMockBNBNativeLibrary` | Fallback mock that defers error messages to call time |
12391180

12401181
### Module-level symbols
@@ -1396,11 +1337,9 @@ A PR that changes any of these symbols MUST consider downstream impact:
13961337

13971338
- `bitsandbytes.cextension.*` (native library loading)
13981339
- `bitsandbytes.functional.get_ptr`, `is_on_gpu`, `_get_tensor_stream`
1399-
- `bitsandbytes.functional.GlobalPageManager`, `CUBLAS_Context`, `Cusparse_Context`
1340+
- `bitsandbytes.functional.GlobalPageManager`, `CUBLAS_Context`
14001341
- `bitsandbytes.functional._convert_weight_packed_for_cpu*`
14011342
- `bitsandbytes.functional.check_matmul`, `elementwise_func`, `fill`, `_mul`
1402-
- `bitsandbytes.functional.spmm_coo`, `spmm_coo_very_sparse`
1403-
- `bitsandbytes.functional.COOSparseTensor`, `CSRSparseTensor`, `CSCSparseTensor`
14041343
- `bitsandbytes.utils.pack_dict_to_tensor`, `unpack_tensor_to_dict`
14051344
- `bitsandbytes.utils.execute_and_return`, `sync_gpu`
14061345
- `bitsandbytes.optim.optimizer.MockArgs`

agents/architecture_guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -962,8 +962,8 @@ The `COMPUTE_BACKEND` CMake variable selects the target:
962962
| Backend | Library name | Languages | Dependencies |
963963
|---|---|---|---|
964964
| `cpu` | `libbitsandbytes_cpu.so` | C++17 | OpenMP (optional) |
965-
| `cuda` | `libbitsandbytes_cuda{VER}.so` | C++17 + CUDA | cudart, cublas, cublasLt, cusparse |
966-
| `hip` | `libbitsandbytes_rocm{VER}.so` | C++17 + HIP | hipblas, hiprand, hipsparse |
965+
| `cuda` | `libbitsandbytes_cuda{VER}.so` | C++17 + CUDA | cudart, cublas, cublasLt |
966+
| `hip` | `libbitsandbytes_rocm{VER}.so` | C++17 + HIP | hipblas, hiprand |
967967
| `mps` | `libbitsandbytes_mps.dylib` | C++17 + ObjC++ | Metal framework |
968968
| `xpu` | `libbitsandbytes_xpu.so` | C++20 + SYCL | Intel oneAPI |
969969

agents/code_standards.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class GlobalOptimManager:
152152
```
153153

154154
This pattern is used by: `GlobalOptimManager`, `GlobalPageManager`, `CUBLAS_Context`,
155-
`Cusparse_Context`, `GlobalOutlierPooler`, `OutlierTracer`.
155+
`GlobalOutlierPooler`, `OutlierTracer`.
156156

157157
---
158158

@@ -867,7 +867,6 @@ Use the project's error checking macros:
867867
868868
```cpp
869869
CUDA_CHECK_RETURN(cudaMemcpy(...));
870-
CHECK_CUSPARSE(cusparseCreate(...));
871870
```
872871

873872
The `checkCublasStatus` function returns an error code rather than throwing — the Python

agents/issue_patterns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ These are the single largest category of issues. Most are environment problems o
3434
>
3535
> If you're still hitting problems on the **latest** bitsandbytes (v0.45+), please open a new issue with the output of `python -m bitsandbytes` and your environment details.
3636
37-
### Missing `libcusparse.so.11` / shared library mismatch
37+
### Missing shared CUDA library / shared library mismatch
3838

39-
**How to identify:** `OSError: libcusparse.so.11: cannot open shared object file: No such file or directory`. Or similar errors for `libcusparse.so.12`, `libcublasLt.so.11`, etc.
39+
**How to identify:** `OSError: libcublasLt.so.11: cannot open shared object file: No such file or directory`. Or similar errors for `libcudart`, `libcublas`, etc.
4040

4141
**What happened:** The bnb binary was compiled against one CUDA version (e.g., 11.x) but the system only has another (e.g., 12.x). The shared library dependencies don't exist. Modern releases ship platform-specific wheels with better CUDA version detection and multiple binary variants.
4242

bitsandbytes/backends/cuda/ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _(
171171
A: torch.Tensor,
172172
threshold=0.0,
173173
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:
174-
# Use CUDA kernel for rowwise and COO tensor
174+
# Use CUDA kernel for rowwise quant and outlier column detection
175175
quant_row, row_stats, outlier_cols = torch.ops.bitsandbytes.int8_vectorwise_quant.default(
176176
A,
177177
threshold=threshold,

bitsandbytes/cextension.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class CudaBNBNativeLibrary(BNBNativeLibrary):
9090
def __init__(self, lib: ct.CDLL):
9191
super().__init__(lib)
9292
lib.get_context.restype = ct.c_void_p
93-
lib.get_cusparse.restype = ct.c_void_p
9493
lib.cget_managed_ptr.restype = ct.c_void_p
9594

9695

0 commit comments

Comments
 (0)