Skip to main content

Customized sparse solver with Numba support

Project description

Sparse_Numba

A lightweight, Numba-compatible sparse linear solver designed for efficient parallel computations in Python.

PyPI version Build Status Python Versions

Why Sparse_Numba?

Python is widely used for rapid prototyping and demonstration, despite its limitations in computationally intensive tasks. Existing sparse linear solvers (e.g., SciPy, CVXOPT, and KVXOPT) are efficient for single-task scenarios but face performance bottlenecks if there are frequent data exchanges and Python's Global Interpreter Lock (GIL).

Sparse_Numba addresses these limitations by providing a sparse linear solver fully compatible with Numba's Just-In-Time (JIT) compilation. This design allows computationally intensive tasks to run efficiently in parallel, bypassing Python's GIL and significantly improving multi-task solving speed.

Installation

pip install sparse-numba

Due to the license issue, this package cannot include DLLs from umfpack. To run the existing function in this package, the user needs to install umfpack by yourself and add the necessary DLLs to the system path or put under:

.venv/site-packages/sparse_numba/vendor/suitesparse/bin
  • Support for SuperLU solver has been added in the version 0.1.6.
  • Github workflow is under testing in version 0.1.10.
  • Current Compatibility
    • Windows Platform for Python Version from 3.8 - 3.12
    • Most modern Linux distributions (Ubuntu, Debian, CentOS, Fedora, etc.) for Python Version from 3.8 - 3.12
    • MacOS version > 13.0 and intel x86_64 CPU

Installing from source (Windows)

If installing from source on Windows, you need to have MinGW installed and configured for Python:

  1. Install MinGW-w64 (x86_64-posix-seh)
  2. Add MinGW bin directory to your PATH
  3. Create or edit your distutils.cfg file:
    • Location: %USERPROFILE%\.distutils.cfg
    • Content:
      [build]
      compiler=mingw32
      
  4. Then:
python -m build --wheel
pip install dist/sparse_numba-%YOURVERSION%.whl

Note: Despite installing MinGW-w64 (64-bit), the compiler setting is still mingw32. This is the correct name for the distutils compiler specification and does not affect the bitness of the compiled extension.

Detailed installation information can be found here.

Usage

import numpy as np
from sparse_numba.sparse_superlu.superlu_numba_interface import superlu_solve_csc
from sparse_numba.sparse_umfpack.umfpack_numba_interface import umfpack_solve_csc

# Example with CSC format (Compressed Sparse Column)
# Create a sparse matrix in CSC format
indptr = np.array([0, 2, 3, 6])
indices = np.array([0, 2, 2, 0, 1, 2])
data = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
b = np.array([1.0, 2.0, 3.0])

# Solve the linear system Ax = b
    # umfpack solver
x_umfpack = umfpack_solve_csc(data, indices, indptr, b)
print(x_umfpack)

    # superlu solver
x_superlu = superlu_solve_csc(data, indices, indptr, b)
print(x_superlu)

# More examples for COO and CSR formats...

Performance Comparison

Single Problem Performance

We compare the computational speed with SciPy for solving single problems of different sizes. The test result on an Intel Ultra 7 258V processor.

  1. UMFPACK V.S. SciPy (spsolve):

Single Problem Benchmark

  1. SuperLU V.S. SciPy (spsolve):

Single Problem Benchmark

Multi-task Performance

We compare the multi-task performance of Sparse_Numba with sequential SciPy.

  1. SuperLU V.S. SciPy (spsolve) with 258V:

Parallel Solver Benchmark Speedup Factor

  1. SuperLU V.S. Scipy (spsolve) with Xeon W-2255:

Parallel Solver Benchmark Speedup Factor

Note: The initialization time is included in single problem benchmarks. This is why the Numba-compatible function is initially slower, but the performance advantage becomes evident as parallelization takes effect.

Features and Limitations

Current Features

  • UMFPACK solver integration with Numba compatibility
  • SuperLU solver integration with Numba compatibility
  • Support for CSC, COO, and CSR sparse matrix formats
  • Efficient parallel solving for multiple systems

Limitations

  • The UMFPACK DLL files are not redistributed in this tool
  • Other solvers are under development
  • Performance may be limited for extremely ill-conditioned matrices
  • Only developed/tested for Windows, the support for other platforms (Linux and MacOS) are added without testing

Roadmap

This package serves as a temporary solution until Python's no-GIL and improved JIT features become widely available. At that time, established libraries like SciPy and KVXOPT will likely offer more comprehensive implementations with parallel computing features.

License

BSD 3-Clause License

License Statement of OpenBLAS:

DLLs of OpenBLAS can be obtained from build: https://github.com/OpenMathLib/OpenBLAS

License Statement of SuperLU:

DLLs of SuperLU can be obtained from build: https://github.com/xiaoyeli/superlu

License Acknowledgment

  • libgcc_s_seh-1.dll
  • libgfortran-5.dll
  • libgomp-1.dll
  • libquadmath-0.dll
  • libwinpthread-1.dll

These components are redistributed from the GNU toolchain.

Citation

If you use Sparse_Numba in your research, you can consider to cite:

@software{hong2025sparse_numba,
  author = {Hong, Tianqi},
  title = {Sparse_Numba: A Numba-Compatible Sparse Solver},
  year = {2025},
  publisher = {GitHub},
  url = {https://github.com/th1275/sparse_numba}
}

Contributing to Sparse_Numba

As an entry-level (or baby-level) developer, I still need more time to figure out the workflow. Due to my limited availability, this tool will also be updated very slowly. Please be patient.

Thank you!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparse_numba-0.1.10.tar.gz (14.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sparse_numba-0.1.10-cp312-cp312-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.12Windows x86-64

sparse_numba-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

sparse_numba-0.1.10-cp312-cp312-macosx_13_0_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.12macOS 13.0+ x86-64

sparse_numba-0.1.10-cp311-cp311-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.11Windows x86-64

sparse_numba-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

sparse_numba-0.1.10-cp311-cp311-macosx_13_0_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.11macOS 13.0+ x86-64

sparse_numba-0.1.10-cp310-cp310-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.10Windows x86-64

sparse_numba-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

sparse_numba-0.1.10-cp310-cp310-macosx_13_0_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.10macOS 13.0+ x86-64

sparse_numba-0.1.10-cp39-cp39-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.9Windows x86-64

sparse_numba-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (14.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

sparse_numba-0.1.10-cp39-cp39-macosx_13_0_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.9macOS 13.0+ x86-64

sparse_numba-0.1.10-cp38-cp38-win_amd64.whl (16.8 MB view details)

Uploaded CPython 3.8Windows x86-64

sparse_numba-0.1.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

sparse_numba-0.1.10-cp38-cp38-macosx_13_0_x86_64.whl (13.9 MB view details)

Uploaded CPython 3.8macOS 13.0+ x86-64

File details

Details for the file sparse_numba-0.1.10.tar.gz.

File metadata

  • Download URL: sparse_numba-0.1.10.tar.gz
  • Upload date:
  • Size: 14.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sparse_numba-0.1.10.tar.gz
Algorithm Hash digest
SHA256 384b81981d9d186f63129a7c10d3dad98700ed3bbf0e27e48e333f6946d066bb
MD5 dedd3b029ed2dbc34851ef764a8b5535
BLAKE2b-256 b533ad362b0f273876bd861a53fa9c382a69db2c20ba966c2c338a3f2b4eb70d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10.tar.gz:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 df954fc03529e730910b0120836e12b0ca0d39b0168f5fe6a6848ecade7de7a0
MD5 19a98784c5216bc142295a1cbb38dc74
BLAKE2b-256 fad3e12fe834a78f1f0cada4cef2a1a2993722d0f8688055294320034684ee21

See more details on using hashes here.

File details

Details for the file sparse_numba-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d18c0bd12e52d55a530210bd01c40e35eeca602105f71dc028110d269cf5b757
MD5 45e7cc647bdf34d9f3f9ba6f18efb2b9
BLAKE2b-256 e4c05f5fa2a30a07c37cbab90dc6381cd57a2700137fd13210f6ffb24a082abe

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 e36ee26a4c7386fa319e9593792bd3726e62bbc1816fb5fbe71a71f33740497a
MD5 ad0f5fd8140f429e7966027b64696e10
BLAKE2b-256 7c19e2e02cc5875c9eb5f12601a61985c43298e53884a4136ee3ea1ac57adbea

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp312-cp312-macosx_13_0_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd60c3243e392eff170ad2f452eff96a7313e9093a1199cabec947c4f81e8cf4
MD5 f490c24313e3ba2c56ac46eb8f1259d1
BLAKE2b-256 17b6f1972449fca58e26b64bc23181a7e0560af7a3c52af3b8a0f9779b23eddd

See more details on using hashes here.

File details

Details for the file sparse_numba-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c0e43d456e9f3cb6e4fd02edc304bc4125c8c79ace56a6b88b0c006889ecf4d
MD5 1a7209a84f2b8f95e4183a94c8ad38e5
BLAKE2b-256 106c8d1a51ef08908d3cf9d2c264f0217eba9d0b5e40999d81c7ad9fd9be0a3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 df1f62b277761691f73ecbc4eee4efdae909214458b5b679caffaa7b2af0e134
MD5 2b15b2288e954df520c2fdda8e926a1c
BLAKE2b-256 203ac12fa47857c1fab650f9035e2ae2c75b0cbdab9e94ace81e017cb2f99359

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp311-cp311-macosx_13_0_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 574c4d92f88b0a07ea3cfacc883b32e284d8f510332485676f5dd4ec506812e2
MD5 6ed23e025c69a07d095a8ce0db95c28d
BLAKE2b-256 be13f1c4db30fc2736f10af3cd963767a160465aa3ac283c50ccc7e7f2d951be

See more details on using hashes here.

File details

Details for the file sparse_numba-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18bc315a1101974b973da2ddbb417f383f28b5079a32bc62748fa9398850ec1d
MD5 31486e896c56ed4b408956e3436e42df
BLAKE2b-256 c50996003c2a0014b1b0ef0497330f2bb55e891dd60c84b2598ec218941aeacd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 e501e221b2026baed4d6cf625d2f8e611e5ba6c971caa64453641461cc143753
MD5 292a7130b98db6bc87be03ae4a1c1b0b
BLAKE2b-256 66791a3bfca3cecf2eec6e3e8bbaf1aeb2504e4f2a91cdd966528dfca0cc9723

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp310-cp310-macosx_13_0_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a46a93fa5a1df72ab9471290c416921628b954b24f42fbe58b40ad9d6fb61a1b
MD5 70ee29741a553649ca649999d27a5698
BLAKE2b-256 545d67c7343f7977e6e77fce3c422bf6f1c8c80a33a0ff823149b93b13da7db8

See more details on using hashes here.

File details

Details for the file sparse_numba-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9239c3d01d733f922e28f13e4aa751b4c288d8be67f549f154c1e7c86b636645
MD5 9e467ef38f285aab891ecda0e7030568
BLAKE2b-256 63cb2667f5b597bbb29031599572707662f1fdb50f92772f771e57e96f6f28a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp39-cp39-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 83b1f377a9c5ec4f7729152d0f3fca5d17f7c860c3f8140775530d079ca65541
MD5 bb0aa770d8d106eeb564f98937169fae
BLAKE2b-256 b5741e6292c38c0b50ac2321b791ba83b500b9d586673dbb7a36d109bb1c47df

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp39-cp39-macosx_13_0_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3f0684d5b975046a435722c17fcd6656611ed7a5eb1286069656bd4841ab754e
MD5 f80600f5c8d2d8e1335e78cdf3215538
BLAKE2b-256 bfdf1c8f3f3573924ca53f33285e7cec41fbe7fdb6444828a57c324da14199c3

See more details on using hashes here.

File details

Details for the file sparse_numba-0.1.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac02749d9393f67a9f4d1ce02d38e39e7545a4e9e4b51908c601fe8dcc1fabd7
MD5 382887349f0888a5ac35d32002bfef15
BLAKE2b-256 0a859a322dca1ec9efb7068d923d402e526d524b532c2b54e37541e2635ab7f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sparse_numba-0.1.10-cp38-cp38-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for sparse_numba-0.1.10-cp38-cp38-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 f8e23929e4a82a20e76b43a1754ce2d6d23f3ae4527a57ecd1ee6397587111ce
MD5 bc3bfd84c040d48963cf087f1f7a3dcf
BLAKE2b-256 31583e065274c0f53fda5369e098ef5920a1d2c37319e6d0977b2393980eed6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sparse_numba-0.1.10-cp38-cp38-macosx_13_0_x86_64.whl:

Publisher: build_wheels.yml on th1275/sparse_numba

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page