Skip to content

Commit ca81199

Browse files
committed
Merge branch 'branch-23.04' into 23.02-lobpcg
2 parents 6694ae4 + a6e0e6b commit ca81199

File tree

591 files changed

+32255
-11986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

591 files changed

+32255
-11986
lines changed

.flake8

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
2+
3+
[flake8]
4+
filename = *.py, *.pyx, *.pxd, *.pxi
5+
exclude = __init__.py, *.egg, build, docs, .git
6+
force-check = True
7+
ignore =
8+
# line break before binary operator
9+
W503,
10+
# whitespace before :
11+
E203
12+
per-file-ignores =
13+
# Rules ignored only in Cython:
14+
# E211: whitespace before '(' (used in multi-line imports)
15+
# E225: Missing whitespace around operators (breaks cython casting syntax like <int>)
16+
# E226: Missing whitespace around arithmetic operators (breaks cython pointer syntax like int*)
17+
# E227: Missing whitespace around bitwise or shift operator (Can also break casting syntax)
18+
# E275: Missing whitespace after keyword (Doesn't work with Cython except?)
19+
# E402: invalid syntax (works for Python, not Cython)
20+
# E999: invalid syntax (works for Python, not Cython)
21+
# W504: line break after binary operator (breaks lines that end with a pointer)
22+
*.pyx: E211, E225, E226, E227, E275, E402, E999, W504
23+
*.pxd: E211, E225, E226, E227, E275, E402, E999, W504
24+
*.pxi: E211, E225, E226, E227, E275, E402, E999, W504

.github/workflows/build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
branch: ${{ inputs.branch }}
5353
date: ${{ inputs.date }}
5454
sha: ${{ inputs.sha }}
55+
skip_upload_pkgs: libraft-template
5556
docs-build:
5657
if: github.ref_type == 'branch' && github.event_name == 'push'
5758
needs: python-build

.github/workflows/pr.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
package-name: pylibraft
8484
test-before-amd64: "pip install cupy-cuda11x"
8585
# On arm also need to install cupy from the specific webpage.
86-
test-before-arm64: "pip install cupy-cuda11x -f https://pip.cupy.dev/aarch64"
86+
test-before-arm64: "pip install 'cupy-cuda11x<12.0.0' -f https://pip.cupy.dev/aarch64"
8787
test-unittest: "python -m pytest -v ./python/pylibraft/pylibraft/test"
8888
test-smoketest: "python ./ci/wheel_smoke_test_pylibraft.py"
8989
wheel-build-raft-dask:
@@ -105,7 +105,7 @@ jobs:
105105
build_type: pull-request
106106
package-name: raft_dask
107107
# Always want to test against latest dask/distributed.
108-
test-before-amd64: "RAPIDS_PY_WHEEL_NAME=pylibraft_cu11 rapids-download-wheels-from-s3 ./local-pylibraft-dep && pip install --no-deps ./local-pylibraft-dep/pylibraft*.whl && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
109-
test-before-arm64: "RAPIDS_PY_WHEEL_NAME=pylibraft_cu11 rapids-download-wheels-from-s3 ./local-pylibraft-dep && pip install --no-deps ./local-pylibraft-dep/pylibraft*.whl && pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
108+
test-before-amd64: "RAPIDS_PY_WHEEL_NAME=pylibraft_cu11 rapids-download-wheels-from-s3 ./local-pylibraft-dep && pip install --no-deps ./local-pylibraft-dep/pylibraft*.whl && pip install git+https://github.com/dask/dask.git@2023.3.2 git+https://github.com/dask/distributed.git@2023.3.2.1 git+https://github.com/rapidsai/[email protected]"
109+
test-before-arm64: "RAPIDS_PY_WHEEL_NAME=pylibraft_cu11 rapids-download-wheels-from-s3 ./local-pylibraft-dep && pip install --no-deps ./local-pylibraft-dep/pylibraft*.whl && pip install git+https://github.com/dask/dask.git@2023.3.2 git+https://github.com/dask/distributed.git@2023.3.2.1 git+https://github.com/rapidsai/[email protected]"
110110
test-unittest: "python -m pytest -v ./python/raft-dask/raft_dask/test"
111111
test-smoketest: "python ./ci/wheel_smoke_test_raft_dask.py"

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
sha: ${{ inputs.sha }}
4141
package-name: pylibraft
4242
test-before-amd64: "pip install cupy-cuda11x"
43-
test-before-arm64: "pip install cupy-cuda11x -f https://pip.cupy.dev/aarch64"
43+
test-before-arm64: "pip install 'cupy-cuda11x<12.0.0' -f https://pip.cupy.dev/aarch64"
4444
test-unittest: "python -m pytest -v ./python/pylibraft/pylibraft/test"
4545
wheel-tests-raft-dask:
4646
secrets: inherit
@@ -51,6 +51,6 @@ jobs:
5151
date: ${{ inputs.date }}
5252
sha: ${{ inputs.sha }}
5353
package-name: raft_dask
54-
test-before-amd64: "pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
55-
test-before-arm64: "pip install git+https://github.com/dask/dask.git@main git+https://github.com/dask/distributed.git@main git+https://github.com/rapidsai/[email protected]"
54+
test-before-amd64: "pip install git+https://github.com/dask/dask.git@2023.3.2 git+https://github.com/dask/distributed.git@2023.3.2.1 git+https://github.com/rapidsai/[email protected]"
55+
test-before-arm64: "pip install git+https://github.com/dask/dask.git@2023.3.2 git+https://github.com/dask/distributed.git@2023.3.2.1 git+https://github.com/rapidsai/[email protected]"
5656
test-unittest: "python -m pytest -v ./python/raft-dask/raft_dask/test"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ log
2424
.DS_Store
2525
dask-worker-space/
2626
*.egg-info/
27+
*.bin
2728

2829
## scikit-build
2930
_skbuild

.pre-commit-config.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121
rev: 5.0.4
2222
hooks:
2323
- id: flake8
24-
args: ["--config=setup.cfg"]
24+
args: ["--config=.flake8"]
2525
files: python/.*$
2626
types: [file]
2727
types_or: [python, cython]
@@ -31,15 +31,17 @@ repos:
3131
hooks:
3232
- id: mypy
3333
additional_dependencies: [types-cachetools]
34-
args: ["--config-file=setup.cfg",
34+
args: ["--config-file=pyproject.toml",
3535
"python/pylibraft/pylibraft",
3636
"python/raft-dask/raft_dask"]
3737
pass_filenames: false
3838
- repo: https://github.com/PyCQA/pydocstyle
3939
rev: 6.1.1
4040
hooks:
4141
- id: pydocstyle
42-
args: ["--config=setup.cfg"]
42+
# https://github.com/PyCQA/pydocstyle/issues/603
43+
additional_dependencies: [toml]
44+
args: ["--config=pyproject.toml"]
4345
- repo: https://github.com/pre-commit/mirrors-clang-format
4446
rev: v11.1.0
4547
hooks:
@@ -60,7 +62,7 @@ repos:
6062
entry: ./cpp/scripts/run-cmake-format.sh cmake-format
6163
language: python
6264
types: [cmake]
63-
exclude: .*/thirdparty/.*
65+
exclude: .*/thirdparty/.*|.*FindAVX.cmake.*
6466
# Note that pre-commit autoupdate does not update the versions
6567
# of dependencies, so we'll have to update this manually.
6668
additional_dependencies:
@@ -92,12 +94,14 @@ repos:
9294
language: python
9395
additional_dependencies: [gitpython]
9496
- repo: https://github.com/codespell-project/codespell
95-
rev: v2.1.0
97+
rev: v2.2.2
9698
hooks:
9799
- id: codespell
100+
additional_dependencies: [tomli]
101+
args: ["--toml", "pyproject.toml"]
98102
exclude: (?x)^(^CHANGELOG.md$)
99103
- repo: https://github.com/rapidsai/dependency-file-generator
100-
rev: v1.4.0
104+
rev: v1.5.1
101105
hooks:
102106
- id: rapids-dependency-file-generator
103107
args: ["--clean"]

README.md

Lines changed: 33 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# <div align="left"><img src="https://rapids.ai/assets/images/rapids_logo.png" width="90px"/>&nbsp;RAFT: Reusable Accelerated Functions and Tools</div>
22

3+
![Navigating the canyons of accelerated possibilities](img/raft.png)
4+
35
## Resources
46

57
- [RAFT Reference Documentation](https://docs.rapids.ai/api/raft/stable/): API Documentation.
@@ -32,12 +34,16 @@ While not exhaustive, the following general categories help summarize the accele
3234
| **Tools & Utilities** | common utilities for developing CUDA applications, multi-node multi-gpu infrastructure |
3335

3436

35-
All of RAFT's C++ APIs can be accessed header-only and optional pre-compiled shared libraries can 1) speed up compile times and 2) enable the APIs to be used without CUDA-enabled compilers.
37+
RAFT is a C++ header-only template library with an optional shared library that
38+
1) can speed up compile times for common template types, and
39+
2) provides host-accessible "runtime" APIs, which don't require a CUDA compiler to use
3640

37-
In addition to the C++ library, RAFT also provides 2 Python libraries:
38-
- `pylibraft` - lightweight low-level Python wrappers around RAFT's host-accessible "runtime" APIs.
41+
In addition being a C++ library, RAFT also provides 2 Python libraries:
42+
- `pylibraft` - lightweight Python wrappers around RAFT's host-accessible "runtime" APIs.
3943
- `raft-dask` - multi-node multi-GPU communicator infrastructure for building distributed algorithms on the GPU with Dask.
4044

45+
![RAFT is a C++ header-only template library with optional shared library and lightweight Python wrappers](img/arch.png)
46+
4147
## Getting started
4248

4349
### RAPIDS Memory Manager (RMM)
@@ -46,7 +52,7 @@ RAFT relies heavily on RMM which eases the burden of configuring different alloc
4652

4753
### Multi-dimensional Arrays
4854

49-
The APIs in RAFT currently accept raw pointers to device memory and we are in the process of simplifying the APIs with the [mdspan](https://arxiv.org/abs/2010.06474) multi-dimensional array view for representing data in higher dimensions similar to the `ndarray` in the Numpy Python library. RAFT also contains the corresponding owning `mdarray` structure, which simplifies the allocation and management of multi-dimensional data in both host and device (GPU) memory.
55+
The APIs in RAFT accept the [mdspan](https://arxiv.org/abs/2010.06474) multi-dimensional array view for representing data in higher dimensions similar to the `ndarray` in the Numpy Python library. RAFT also contains the corresponding owning `mdarray` structure, which simplifies the allocation and management of multi-dimensional data in both host and device (GPU) memory.
5056

5157
The `mdarray` forms a convenience layer over RMM and can be constructed in RAFT using a number of different helper functions:
5258

@@ -78,9 +84,9 @@ raft::device_resources handle;
7884
int n_samples = 5000;
7985
int n_features = 50;
8086

81-
auto input = raft::make_device_matrix<float>(handle, n_samples, n_features);
82-
auto labels = raft::make_device_vector<int>(handle, n_samples);
83-
auto output = raft::make_device_matrix<float>(handle, n_samples, n_samples);
87+
auto input = raft::make_device_matrix<float, int>(handle, n_samples, n_features);
88+
auto labels = raft::make_device_vector<int, int>(handle, n_samples);
89+
auto output = raft::make_device_matrix<float, int>(handle, n_samples, n_samples);
8490

8591
raft::random::make_blobs(handle, input.view(), labels.view());
8692

@@ -192,8 +198,7 @@ RAFT itself can be installed through conda, [CMake Package Manager (CPM)](https:
192198

193199
The easiest way to install RAFT is through conda and several packages are provided.
194200
- `libraft-headers` RAFT headers
195-
- `libraft-nn` (optional) contains shared libraries for the nearest neighbors primitives.
196-
- `libraft-distance` (optional) contains shared libraries for distance primitives.
201+
- `libraft` (optional) shared library of pre-compiled template specializations and runtime APIs.
197202
- `pylibraft` (optional) Python wrappers around RAFT algorithms and primitives.
198203
- `raft-dask` (optional) enables deployment of multi-node multi-GPU algorithms that use RAFT `raft::comms` in Dask clusters.
199204

@@ -202,73 +207,35 @@ Use the following command to install all of the RAFT packages with conda (replac
202207
mamba install -c rapidsai -c conda-forge -c nvidia raft-dask pylibraft
203208
```
204209

205-
You can also install the `libraft-*` conda packages individually using the `mamba` command above.
210+
You can also install the conda packages individually using the `mamba` command above.
206211

207-
After installing RAFT, `find_package(raft COMPONENTS nn distance)` can be used in your CUDA/C++ cmake build to compile and/or link against needed dependencies in your raft target. `COMPONENTS` are optional and will depend on the packages installed.
212+
After installing RAFT, `find_package(raft COMPONENTS compiled distributed)` can be used in your CUDA/C++ cmake build to compile and/or link against needed dependencies in your raft target. `COMPONENTS` are optional and will depend on the packages installed.
208213

209214
### Pip
210215

211216
pylibraft and raft-dask both have experimental packages that can be [installed through pip](https://rapids.ai/pip.html#install):
212217
```bash
213-
pip install pylibraft-cu11 --extra-index-url=https://pypi.ngc.nvidia.com
214-
pip install raft-dask-cu11 --extra-index-url=https://pypi.ngc.nvidia.com
218+
pip install pylibraft-cu11 --extra-index-url=https://pypi.nvidia.com
219+
pip install raft-dask-cu11 --extra-index-url=https://pypi.nvidia.com
215220
```
216221

217222
### CMake & CPM
218223

219-
RAFT uses the [RAPIDS-CMake](https://github.com/rapidsai/rapids-cmake) library, which makes it simple to include in downstream cmake projects. RAPIDS CMake provides a convenience layer around CPM.
220-
221-
After [installing](https://github.com/rapidsai/rapids-cmake#installation) rapids-cmake in your project, you can begin using RAFT by placing the code snippet below in a file named `get_raft.cmake` and including it in your cmake build with `include(get_raft.cmake)`. This will make available several targets to add to configure the link libraries for your artifacts.
222-
223-
```cmake
224-
225-
set(RAFT_VERSION "22.12")
226-
set(RAFT_FORK "rapidsai")
227-
set(RAFT_PINNED_TAG "branch-${RAFT_VERSION}")
228-
229-
function(find_and_configure_raft)
230-
set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARIES)
231-
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
232-
"${multiValueArgs}" ${ARGN} )
233-
234-
#-----------------------------------------------------
235-
# Invoke CPM find_package()
236-
#-----------------------------------------------------
237-
238-
rapids_cpm_find(raft ${PKG_VERSION}
239-
GLOBAL_TARGETS raft::raft
240-
BUILD_EXPORT_SET projname-exports
241-
INSTALL_EXPORT_SET projname-exports
242-
CPM_ARGS
243-
GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git
244-
GIT_TAG ${PKG_PINNED_TAG}
245-
SOURCE_SUBDIR cpp
246-
OPTIONS
247-
"BUILD_TESTS OFF"
248-
"BUILD_BENCH OFF"
249-
"RAFT_COMPILE_LIBRARIES ${PKG_COMPILE_LIBRARIES}"
250-
)
251-
252-
endfunction()
253-
254-
# Change pinned tag here to test a commit in CI
255-
# To use a different RAFT locally, set the CMake variable
256-
# CPM_raft_SOURCE=/path/to/local/raft
257-
find_and_configure_raft(VERSION ${RAFT_VERSION}.00
258-
FORK ${RAFT_FORK}
259-
PINNED_TAG ${RAFT_PINNED_TAG}
260-
COMPILE_LIBRARIES NO
261-
)
262-
```
224+
RAFT uses the [RAPIDS-CMake](https://github.com/rapidsai/rapids-cmake) library, which makes it easy to include in downstream cmake projects. RAPIDS-CMake provides a convenience layer around CPM. Please refer to [these instructions](https://github.com/rapidsai/rapids-cmake#installation) to install and use rapids-cmake in your project.
225+
226+
#### Example Template Project
227+
228+
You can find an [example RAFT](cpp/template/README.md) project template in the `cpp/template` directory, which demonstrates how to build a new application with RAFT or incorporate RAFT into an existing cmake project.
229+
230+
#### CMake Targets
263231

264-
Several CMake targets can be made available by adding components in the table below to the `RAFT_COMPONENTS` list above, separated by spaces. The `raft::raft` target will always be available. RAFT headers require, at a minimum, the CUDA toolkit libraries and RMM dependencies.
232+
Additional CMake targets can be made available by adding components in the table below to the `RAFT_COMPONENTS` list above, separated by spaces. The `raft::raft` target will always be available. RAFT headers require, at a minimum, the CUDA toolkit libraries and RMM dependencies.
265233

266-
| Component | Target | Description | Base Dependencies |
267-
| --- | --- | --- | --- |
268-
| n/a | `raft::raft` | Full RAFT header library | CUDA toolkit library, RMM, Thrust (optional), NVTools (optional) |
269-
| distance | `raft::distance` | Pre-compiled template specializations for raft::distance | raft::raft, cuCollections (optional) |
270-
| nn | `raft::nn` | Pre-compiled template specializations for raft::neighbors | raft::raft, FAISS (optional) |
271-
| distributed | `raft::distributed` | No specializations | raft::raft, UCX, NCCL |
234+
| Component | Target | Description | Base Dependencies |
235+
|-------------|---------------------|-----------------------------------------------------------|---------------------------------------|
236+
| n/a | `raft::raft` | Full RAFT header library | CUDA toolkit, RMM, NVTX, CCCL, CUTLASS |
237+
| compiled | `raft::compiled` | Pre-compiled template specializations and runtime library | raft::raft |
238+
| distributed | `raft::distributed` | Dependencies for `raft::comms` APIs | raft::raft, UCX, NCCL |
272239

273240
### Source
274241

@@ -279,7 +246,7 @@ mamba env create --name raft_dev_env -f conda/environments/all_cuda-118_arch-x86
279246
mamba activate raft_dev_env
280247
```
281248
```
282-
./build.sh raft-dask pylibraft libraft tests bench --compile-libs
249+
./build.sh raft-dask pylibraft libraft tests bench --compile-lib
283250
```
284251

285252
The [build](docs/source/build.md) instructions contain more details on building RAFT from source and including it in downstream projects. You can also find a more comprehensive version of the above CPM code snippet the [Building RAFT C++ from source](docs/source/build.md#building-raft-c-from-source-in-cmake) section of the build instructions.
@@ -316,6 +283,7 @@ The folder structure mirrors other RAPIDS repos, with the following folders:
316283
- `internal`: A private header-only component that hosts the code shared between benchmarks and tests.
317284
- `scripts`: Helpful scripts for development
318285
- `src`: Compiled APIs and template specializations for the shared libraries
286+
- `template`: A skeleton template containing the bare-bones file structure and cmake configuration for writing applications with RAFT.
319287
- `test`: Googletests source code
320288
- `docs`: Source code and scripts for building library documentation (Uses breath, doxygen, & pydocs)
321289
- `python`: Source code for Python libraries.

0 commit comments

Comments
 (0)