Skip to content

Support Python 3.11–3.14, numba ≥ 0.61 with numba-cuda, and matchms 0.34 - #10

Closed
BioGeek wants to merge 4 commits into
PangeAI:mainfrom
BioGeek:chore/update-dependencies
Closed

BioGeek wants to merge 4 commits into
PangeAI:mainfrom
BioGeek:chore/update-dependencies

Conversation

@BioGeek

@BioGeek BioGeek commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

SimMS currently declares requires-python = ">=3.8,<3.13" and leaves Numba to whatever matchms pulls in. On a current GPU node that combination either doesn't install or crashes. This PR:

  • Python 3.11–3.14 (was ≥ 3.8, < 3.13). Python 3.10 reached end of life in October 2026, and Numba ≥ 0.61 needs ≥ 3.10 anyway.
  • Declares numba>=0.61 and numba-cuda>=0.30. Numba's built-in CUDA target is deprecated in favour of NVIDIA's numba-cuda, which Numba ≥ 0.61 picks up automatically. The old built-in driver bindings segfaulted for me on a current driver (see below).
  • Extras cu12 / cu13 install NVVM and libdevice from pip, through numba-cuda[cu12] / [cu13]. A conda cudatoolkit is no longer required.
    • cu12 caps cuda-core below 1.3 (see step 9).
    • cu13 requires PyTorch 2.11 or newer, the first PyPI release built for CUDA 13 (see step 10).
  • Raises the PyTorch floor to 2.4, so the cu12 extra can't resolve to a CUDA 11 PyTorch (see step 8 below).
  • Declares numpy and sparsestack, which SimMS imports directly but only got through matchms.
  • Tests: matchms 0.34 renamed ModifiedCosine to ModifiedCosineGreedy. Two test modules now import either name. SimMS's own code is unaffected.
  • CI runs Python 3.11, 3.12, 3.13 and 3.14 (was 3.9 only).
  • README: added instructions to pip install with the CUDA extra and updated to a current PyTorch image for Docker.

What went wrong getting SimMS running

I needed SimMS on an H100 node of a Kubernetes cluster (current NVIDIA driver), from a Docker image. In order:

  1. Python 3.13 is excluded. Our project image is Python 3.13, and requires-python <3.13 stops pip. So I followed the README and built a separate image from pytorch/pytorch:2.2.1-cuda12.1-cudnn8-devel (Python 3.10).

  2. Importing SimMS failed in that image. pip install simms pulled the latest networkx through matchms, and on the image's Python 3.10 import networkx raised a SyntaxError inside networkx/utils/configs.py (a dataclass built from the backend name nx-loopback). So from simms.similarity import ... failed before any SimMS code ran. Fix in the image: networkx<3.4.

  3. NumPy 2 against PyTorch 2.2. Current releases pull NumPy 2, and the image's PyTorch 2.2 is built against NumPy 1. Fix in the image: numpy<2.

  4. Segfault on the GPU. With those pins, the process died silently right after Numba's CUDA driver logged init. With python -X faulthandler, the trace showed a segmentation fault in numba/cuda/cudadrv/driver.py (safe_cuda_api_call), while creating a CUDA context to compile the kernel: CudaCosineGreedy.__init__ → cosine_kernel → cuda.jit → get_current_device. PyTorch had already used the same GPU without trouble. With those pins, the resolver had picked matchms 0.27.0 and Numba 0.59.1, so this was Numba's old built-in ctypes driver binding against a much newer driver.

  5. Numba ≥ 0.61 doesn't resolve with those pins. Adding numba>=0.61 and numba-cuda[cu12] to the numpy<2 and networkx<3.4 pins on 3.10 is unsatisfiable: the matchms releases compatible with those pins each cap Numba (numba<0.57.1, ==0.60.*, …). Without the pins, newer matchms and Numba resolve, but then the old PyTorch image breaks (step 3). The way out is a newer Python and PyTorch.

  6. Python 3.11 resolves cleanly: matchms 0.34.0, numba 0.68.1, numba-cuda 0.30.4, NumPy 2, PyTorch 2.4.1 (pytorch/pytorch:2.4.1-cuda12.4-cudnn9-devel). SimMS's simulator tests pass there, and on the H100 (driver 580.105.08) it works: Numba detects the GPU as supported, the kernel compiles in about 2 s, a self-similarity probe scores 1.0, and a search over 550k spectra ran at about 30 s per 400k-spectrum file.

  7. matchms 0.34 renamed ModifiedCosine. That broke tests/similarity/test_matchms_compatibility.py and tests/stress/test_stress.py at import.

  8. pip install simms[cu12] in a fresh environment resolved PyTorch 2.0.1. Testing this branch from scratch on the H100, pip picked torch==2.0.1 with CUDA 11.7 wheels. That build has no kernels for the H100 (CUDA error: no kernel image is available) and isn't compatible with NumPy 2, so 40 GPU tests failed.

    The cause is the CUDA major version. Recent PyTorch wheels on PyPI depend on CUDA 13 libraries, while the cu12 extra brings numba-cuda's CUDA 12 toolkit. pip backtracked through PyTorch releases until it found one whose CUDA 11 wheels don't clash.

    With torch>=2.4 declared, the same install resolves PyTorch 2.10.0 (CUDA 12.8), and [cu13] resolves PyTorch 2.15.0 (CUDA 13.2). The README now says the extra has to match torch.version.cuda.

  9. Then cu12 installed but couldn't import.

    • cuda-core 1.3.0 (released 2026-11-11), which numba-cuda pulls in without an upper bound, refuses at import: cuda.core 1.3.0 requires cuda-bindings >= 12.9.8 for CUDA 12, but cuda-bindings 12.9.4 is installed.
    • PyTorch 2.10.0, the last PyPI PyTorch built for CUDA 12, pins cuda-bindings==12.9.4.
    • cuda-core declares its cuda-bindings floor only under its own cu12 extra, which nothing requests, so pip installs the clashing pair without complaint.
    • Every earlier cuda-core release accepts any 12.x bindings. The cu12 extra caps cuda-core<1.3 until the clash is resolved upstream.
  10. And cu13 resolved a CUDA 12 PyTorch.

    • pip picked PyTorch 2.9.1+cu128 next to the CUDA 13.5 toolkit, and 29 GPU tests failed with nvJitLinkError: ERROR_INTERNAL ("may need newer version of nvJitLink library").
    • PyPI PyTorch is built for CUDA 12 up to 2.10 and for CUDA 13 from 2.11. With torch>=2.11 in the cu13 extra it resolves PyTorch 2.15.0+cu132 and passes.

Steps 2–5 and 8–10 are what this PR prevents: declared dependency floors that resolve to a working Numba/CUDA stack on every supported Python, and a supported way to get NVVM from pip.

Testing

NUMBA_ENABLE_CUDASIM=1 pytest -m github_ci (the CI selection), with the resolved versions:

Python numba numba-cuda matchms torch numpy Result
3.11 0.68.1 0.30.4 0.34.0 2.15.0+cpu 2.4.6 24 passed
3.14 0.68.1 0.30.4 0.34.0 2.15.0+cpu 2.5.5 24 passed

Rerun on all four Python versions in the new CI matrix (3.11, 3.12, 3.13, 3.14), with the CI job's steps: flake8's strict selection passes and pytest -m github_ci gives 24 passed on each.

On a real GPU: an H100, driver 580.105.08, Python 3.11. Each extra was installed in a fresh venv with pip install "simms[<extra>] @ git+https://github.com/BioGeek/SimMS@3031b95" and nothing else pinned, then the full test suite ran without the simulator:

Extra Resolved tests/similarity + tests/usecase tests/stress
cu12 PyTorch 2.10.0+cu128, numba-cuda 0.30.4, cuda-core 1.2.2, cuda-bindings 12.9.4, cuda-toolkit 12.8.2 34 passed 8 passed
cu13 PyTorch 2.15.0+cu132, numba-cuda 0.30.4, cuda-core 1.3.0, cuda-bindings 13.5.0, cuda-toolkit 13.2.2 34 passed 8 passed

Merged with the peak-array PR, on PyTorch 2.4.1+cu124, numba 0.68.1 and numba-cuda[cu12] 0.30.4: 45 passed, plus 8 in tests/stress.

Notes for review

  • numba-cuda>=0.30 is the version I tested. Older numba-cuda releases may work, but I haven't checked them.
  • .github/workflows/docker-image.yml builds --file Dockerfile, but the repository has no Dockerfile, so that workflow would fail on a release. I left it alone, it's out of scope here.
  • Dropping Python 3.8, 3.9 and 3.10: all three are past end of life, and Numba ≥ 0.61 already rules out 3.8 and 3.9. Python 3.14 is supported by every dependency in the table.

…atchms 0.34

- requires-python >=3.10,<3.14 (was >=3.8,<3.13): numba >= 0.61 needs 3.10.
- numba >= 0.61 and numba-cuda as dependencies. Numba's built-in CUDA target is deprecated in favour of
  NVIDIA's numba-cuda, which numba >= 0.61 uses automatically; numba 0.59's built-in driver bindings
  segfault creating a context on recent drivers. Extras cu12 / cu13 install NVVM and libdevice from pip.
- numpy and sparsestack declared: SimMS imports both directly.
- Tests: matchms 0.34 renamed ModifiedCosine to ModifiedCosineGreedy; import either.
- CI tests Python 3.10, 3.11, 3.12 and 3.13 (was 3.9 only).
- README: pip install with the CUDA extra; a current PyTorch image for Docker.
…A 11 PyTorch; say the extra must match torch's CUDA
@tornikeo

tornikeo commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you so much for this thorough dependency & CUDA investigation, @BioGeek! We incorporated your Python 3.11–3.14, numba-cuda, and cu12/cu13 extras work into #12 (v1.0.0, packaged as simms-gpu to resolve the PyPI simms name collision) alongside the full matchms 1.0.0 migration, and credited you in CHANGELOG.md. Verified on both cu12 (RTX 4090) and cu13 (RTX 4060 & A100-SXM4-80GB)!

@tornikeo tornikeo closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants