-
Notifications
You must be signed in to change notification settings - Fork 34
Move to nanobind #455
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
Open
Intron7
wants to merge
54
commits into
main
Choose a base branch
from
move-to-nanobind
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Move to nanobind #455
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
7d2c62b
add precommit
Intron7 7bc5367
add first implementation
Intron7 dc76b24
clang format
Intron7 dc3648b
format
Intron7 ef8a756
format c++
Intron7 76ae7aa
Merge branch 'main' into move-to-nanobind
Intron7 7ed481d
change clang-format
Intron7 48ba592
fix version
Intron7 1d2f12a
test docs
Intron7 60c4863
fix yml
Intron7 9a2b113
fix sparse to dense kernel launch
Intron7 2d5ea85
test read the docs
Intron7 9878e5d
try env
Intron7 6b46e8a
test cmakeargs
Intron7 55027f7
add system back
Intron7 b780405
add failsafe
Intron7 24104ff
remove print and slim down toml
Intron7 dddd9e8
Add almost unchanged cibw
flying-sheep 5981d50
No macOS
flying-sheep b3c3853
test build wheels
Intron7 b24bf7b
next
Intron7 56aca24
remove wheels workflow
Intron7 7068b19
remove windows
Intron7 9a58ff0
remove optional parts
flying-sheep 7f65657
test publish
Intron7 56f837a
3.12
flying-sheep 3a9a9f1
fix path
Intron7 474de68
remove bad/useless
flying-sheep 646ba23
fix container
Intron7 ae57cb1
try CUDA_PATH
flying-sheep 33ac5af
skip musl again
flying-sheep a529a58
add next kernels
Intron7 0685436
add pca and make safe docs
Intron7 24551bd
Merge branch 'main' into move-to-nanobind
Intron7 5d327bd
make aggr safe
Intron7 30414ab
add harmony
Intron7 d46ab83
make qc smaller
Intron7 d45d6bf
add ligrec
Intron7 20cf11e
move decoupler
Intron7 134d2e0
remove rawkernels
Intron7 a872962
add release note
Intron7 2825de7
fix shape qc
Intron7 66e930f
fix entropy
Intron7 d386000
fix version
Intron7 cfdec19
add streams
Intron7 4876400
Merge branch 'main' into move-to-nanobind
Intron7 3a20dc2
fix pointer
Intron7 948b86a
fix test
Intron7 3fdde98
terse args
flying-sheep 8abaab0
kw-only for aggr.cu
flying-sheep 84a34c4
remaining cleanup
flying-sheep e53c87a
add keywords
Intron7 ad7ed53
fix keywords ligrec
Intron7 a62a596
add 120
Intron7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
BasedOnStyle: Google | ||
Language: Cpp | ||
|
||
# Make braces stay on the same line (like your diffs) | ||
BreakBeforeBraces: Attach | ||
AllowShortFunctionsOnASingleLine: None | ||
|
||
# Compact/“binpack” parameter lists (what produced your earlier diffs) | ||
BinPackParameters: true | ||
BinPackArguments: true | ||
|
||
# Typical CUDA/C++ ergonomics | ||
IndentWidth: 2 | ||
ColumnLimit: 100 | ||
PointerAlignment: Left | ||
DerivePointerAlignment: false | ||
|
||
# Don’t reorder #includes if you don’t want surprise churn | ||
SortIncludes: false | ||
|
||
# Optional: make templates break more aggressively | ||
AlwaysBreakTemplateDeclarations: Yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,95 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | ||
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | ||
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Upload Python Package | ||
name: Build and upload to PyPI | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
deploy: | ||
build_wheels: | ||
name: Build wheels for ${{ matrix.os }} | ||
runs-on: ${{ matrix.runs-on }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: linux-intel | ||
runs-on: ubuntu-latest | ||
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_x86_64_cuda12.9" | ||
dockerfile: "docker/manylinux_2_28_x86_64_cuda12.9.Dockerfile" | ||
- os: linux-arm | ||
runs-on: ubuntu-24.04-arm | ||
cibw_image: "ghcr.io/scverse/rapids_singlecell:manylinux_2_28_aarch64_cuda12.9" | ||
dockerfile: "docker/manylinux_2_28_aarch64_cuda12.9.Dockerfile" | ||
|
||
steps: | ||
- uses: actions/checkout@v5 | ||
|
||
- name: Build CUDA manylinux image | ||
run: | | ||
docker build -t "${{ matrix.cibw_image }}" -f "${{ matrix.dockerfile }}" docker | ||
|
||
# cibuildwheel action (Linux-only wheels inside our custom manylinux+CUDA images) | ||
- name: Build wheels (CUDA 12.9) | ||
uses: pypa/[email protected] | ||
env: | ||
# Skip musllinux | ||
CIBW_SKIP: '*-musllinux*' | ||
# Point cibuildwheel to our CUDA manylinux images (per-arch) | ||
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.os == 'linux-intel' && matrix.cibw_image || '' }} | ||
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.os == 'linux-arm' && matrix.cibw_image || '' }} | ||
# Make CUDA visible inside the build container | ||
CIBW_ENVIRONMENT: > | ||
CUDA_PATH=/usr/local/cuda | ||
LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH | ||
PATH=/usr/local/cuda/bin:$PATH | ||
# Tooling to build a nanobind/scikit-build-core extension | ||
CIBW_BEFORE_BUILD: > | ||
python -m pip install -U pip | ||
scikit-build-core cmake ninja nanobind | ||
# No runtime tests (CI has no GPU) | ||
CIBW_TEST_SKIP: "*" | ||
CIBW_TEST_COMMAND: "" | ||
# Bundle redistributable CUDA libs & ensure manylinux compliance | ||
CIBW_REPAIR_WHEEL_COMMAND: "auditwheel repair -w {dest_dir} {wheel}" | ||
# Be somewhat chatty to see compile/link flags | ||
CIBW_BUILD_VERBOSITY: "1" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
path: ./wheelhouse/*.whl | ||
|
||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v5 | ||
- name: Build sdist | ||
run: pipx run build --sdist | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-sdist | ||
path: dist/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: [build_wheels, build_sdist] | ||
runs-on: ubuntu-latest | ||
environment: publish | ||
|
||
permissions: | ||
id-token: write | ||
|
||
if: github.event_name == 'release' && github.event.action == 'published' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
- name: Install CLI tool | ||
run: pip install build | ||
- name: Build package | ||
run: python -m build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
- uses: actions/download-artifact@v5 | ||
with: | ||
# unpacks all CIBW artifacts into dist/ | ||
pattern: cibw-* | ||
path: dist | ||
merge-multiple: true | ||
|
||
- uses: pypa/gh-action-pypi-publish@release/v1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
cmake_minimum_required(VERSION 3.24) | ||
|
||
project(rapids_singlecell_cuda LANGUAGES CXX) | ||
|
||
# Option to disable building compiled extensions (for docs/RTD) | ||
option(RSC_BUILD_EXTENSIONS "Build CUDA/C++ extensions" ON) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
if (RSC_BUILD_EXTENSIONS) | ||
enable_language(CUDA) | ||
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module ${SKBUILD_SABI_COMPONENT}) | ||
find_package(nanobind CONFIG REQUIRED) | ||
find_package(CUDAToolkit REQUIRED) | ||
else() | ||
message(STATUS "RSC_BUILD_EXTENSIONS=OFF -> skipping compiled extensions for docs") | ||
endif() | ||
|
||
# Helper to declare a nanobind CUDA module uniformly | ||
function(add_nb_cuda_module target src) | ||
if (RSC_BUILD_EXTENSIONS) | ||
nanobind_add_module(${target} STABLE_ABI LTO | ||
${src} | ||
) | ||
target_link_libraries(${target} PRIVATE CUDA::cudart) | ||
set_target_properties(${target} PROPERTIES | ||
CUDA_SEPARABLE_COMPILATION ON | ||
) | ||
install(TARGETS ${target} LIBRARY DESTINATION rapids_singlecell/_cuda) | ||
# Also copy built module into source tree for editable installs | ||
add_custom_command(TARGET ${target} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy | ||
$<TARGET_FILE:${target}> | ||
${PROJECT_SOURCE_DIR}/src/rapids_singlecell/_cuda/$<TARGET_FILE_NAME:${target}> | ||
) | ||
endif() | ||
endfunction() | ||
|
||
if (RSC_BUILD_EXTENSIONS) | ||
# CUDA modules | ||
add_nb_cuda_module(_mean_var_cuda src/rapids_singlecell/_cuda/mean_var/mean_var.cu) | ||
add_nb_cuda_module(_sparse2dense_cuda src/rapids_singlecell/_cuda/sparse2dense/sparse2dense.cu) | ||
add_nb_cuda_module(_scale_cuda src/rapids_singlecell/_cuda/scale/scale.cu) | ||
add_nb_cuda_module(_qc_cuda src/rapids_singlecell/_cuda/qc/qc.cu) | ||
add_nb_cuda_module(_qc_dask_cuda src/rapids_singlecell/_cuda/qc_dask/qc_kernels_dask.cu) | ||
add_nb_cuda_module(_bbknn_cuda src/rapids_singlecell/_cuda/bbknn/bbknn.cu) | ||
add_nb_cuda_module(_norm_cuda src/rapids_singlecell/_cuda/norm/norm.cu) | ||
add_nb_cuda_module(_pr_cuda src/rapids_singlecell/_cuda/pr/pr.cu) | ||
add_nb_cuda_module(_nn_descent_cuda src/rapids_singlecell/_cuda/nn_descent/nn_descent.cu) | ||
add_nb_cuda_module(_aucell_cuda src/rapids_singlecell/_cuda/aucell/aucell.cu) | ||
add_nb_cuda_module(_nanmean_cuda src/rapids_singlecell/_cuda/nanmean/nanmean.cu) | ||
add_nb_cuda_module(_autocorr_cuda src/rapids_singlecell/_cuda/autocorr/autocorr.cu) | ||
add_nb_cuda_module(_cooc_cuda src/rapids_singlecell/_cuda/cooc/cooc.cu) | ||
add_nb_cuda_module(_aggr_cuda src/rapids_singlecell/_cuda/aggr/aggr.cu) | ||
add_nb_cuda_module(_spca_cuda src/rapids_singlecell/_cuda/spca/spca.cu) | ||
add_nb_cuda_module(_ligrec_cuda src/rapids_singlecell/_cuda/ligrec/ligrec.cu) | ||
add_nb_cuda_module(_pv_cuda src/rapids_singlecell/_cuda/pv/pv.cu) | ||
# Harmony CUDA modules | ||
add_nb_cuda_module(_harmony_scatter_cuda src/rapids_singlecell/_cuda/harmony/scatter/scatter.cu) | ||
add_nb_cuda_module(_harmony_outer_cuda src/rapids_singlecell/_cuda/harmony/outer/outer.cu) | ||
add_nb_cuda_module(_harmony_colsum_cuda src/rapids_singlecell/_cuda/harmony/colsum/colsum.cu) | ||
add_nb_cuda_module(_harmony_kmeans_cuda src/rapids_singlecell/_cuda/harmony/kmeans/kmeans.cu) | ||
add_nb_cuda_module(_harmony_normalize_cuda src/rapids_singlecell/_cuda/harmony/normalize/normalize.cu) | ||
add_nb_cuda_module(_harmony_pen_cuda src/rapids_singlecell/_cuda/harmony/pen/pen.cu) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM quay.io/pypa/manylinux_2_28_aarch64 | ||
|
||
RUN yum -y install dnf-plugins-core && \ | ||
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/sbsa/cuda-rhel8.repo && \ | ||
yum -y clean all && yum -y makecache && \ | ||
yum -y install \ | ||
cuda-nvcc-12-9 \ | ||
cuda-cudart-12-9 \ | ||
cuda-cudart-devel-12-9 \ | ||
libcublas-12-9 \ | ||
libcublas-devel-12-9 \ | ||
libcusparse-12-9 \ | ||
libcusparse-devel-12-9 && \ | ||
yum clean all | ||
|
||
ENV CUDA_HOME=/usr/local/cuda | ||
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} | ||
ENV PATH=/usr/local/cuda/bin:${PATH} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM quay.io/pypa/manylinux_2_28_x86_64 | ||
|
||
# Add NVIDIA CUDA repo (RHEL8/Alma8 base in manylinux_2_28) | ||
RUN yum -y install dnf-plugins-core && \ | ||
dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && \ | ||
yum -y clean all && yum -y makecache && \ | ||
# Install only what you actually link against | ||
yum -y install \ | ||
cuda-nvcc-12-9 \ | ||
cuda-cudart-12-9 \ | ||
cuda-cudart-devel-12-9 \ | ||
libcublas-12-9 \ | ||
libcublas-devel-12-9 \ | ||
libcusparse-12-9 \ | ||
libcusparse-devel-12-9 && \ | ||
yum clean all | ||
|
||
ENV CUDA_HOME=/usr/local/cuda | ||
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} | ||
ENV PATH=/usr/local/cuda/bin:${PATH} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from __future__ import annotations | ||
|
||
# Subpackage for CUDA extensions (built via scikit-build-core/nanobind) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.