Skip to content
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

add wheel output #369

Merged
merged 82 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
d650fa7
WIP: add wheel output
msarahan Apr 17, 2024
1faa517
reorganize python folder to allow for libkvikio wheel
msarahan Apr 17, 2024
ea1992b
fix matrix_filter in the wrong place
msarahan Apr 17, 2024
3b35c05
fix executability and add missing pyproject.toml
msarahan Apr 17, 2024
3f9e1fe
fix version file location
msarahan Apr 17, 2024
a3e25f1
fix missing lib files
msarahan Apr 22, 2024
f8b55e0
remove load.py (kvikio is header-only)
msarahan Apr 23, 2024
1c7ebd9
renaming workflows for consistency. Fix path for build.sh python
msarahan Apr 30, 2024
f3cfff0
straighten out paths from python deeper nesting
msarahan Apr 30, 2024
3dceb00
linting cmake format
msarahan Apr 30, 2024
4ebecce
add librmm wheel dep from PR, disable cmake find debugging
msarahan May 1, 2024
9206dcd
adapt devcontainer run to account for different python package path
msarahan May 1, 2024
3298a1a
adjust cpm path; add cpm init to libkvikio wheel
msarahan May 1, 2024
5002499
fix relpath to findcufile
msarahan May 1, 2024
0a9b650
rapids cuda init architectures fix
msarahan May 1, 2024
eebdb55
Apply suggestions from code review
msarahan May 3, 2024
7f2a9d7
adjusting dependencies and wheel tagging
msarahan May 3, 2024
e016651
remove build deps from py_wheel_cpp
msarahan May 3, 2024
e056546
remove findCufile in libkvikio wheel cmakelists
msarahan May 3, 2024
55349a0
add wheel-python-tests in pr.yaml
msarahan May 3, 2024
3bc31e2
comment librmm inclusion
msarahan May 3, 2024
1249409
fix dependency on scikit-build for wheel
msarahan May 3, 2024
430ffd2
fix dependency on scikit-build for wheel
msarahan May 3, 2024
977d905
fix dependency on scikit-build for wheel
msarahan May 3, 2024
28f0dbd
add wheel dep
msarahan May 3, 2024
4fd111f
wheel has to be installed in build scripts
msarahan May 3, 2024
e2e73b8
wheel has to be installed in build scripts
msarahan May 3, 2024
550b21d
fix s3 download cpp wheel filename
msarahan May 3, 2024
71ba140
move libkvikio wheel to build reqs for kvikio wheel (header-only!)
msarahan May 3, 2024
33d5b8a
add wheel.py-api to libkvikio wheel
msarahan May 6, 2024
04801ef
fix missing -cuXY version for libkvikio
msarahan May 6, 2024
ff4e2bb
add install_aliased_imported_targets for nvcomp
msarahan May 7, 2024
abef47d
style
msarahan May 7, 2024
4331fd8
try to get CMake install_aliased_imported_targets working
msarahan May 7, 2024
899f249
remove unused get_nvcomp.cmake
msarahan May 7, 2024
ab4deb5
fix wrong WheelHelpers.cmake
msarahan May 7, 2024
a048172
reorganize python kvikio cmake
msarahan May 7, 2024
a58f445
restore get_nvcomp.cmake, move WheelHelpers.cmake
msarahan May 7, 2024
e8d1f22
typo in cmake thirdparty include
msarahan May 7, 2024
891c1ce
set cython lib dir
msarahan May 7, 2024
a8d7377
install nvcomp stuff into _lib subfolder alongside cython .so's
msarahan May 7, 2024
f4fbf11
add simple wheel install/test script
msarahan May 7, 2024
5e1f76b
Merge remote-tracking branch 'upstream/branch-24.06' into wheel-build
msarahan May 7, 2024
a33f3fa
chmod +x test_wheel.sh
msarahan May 7, 2024
efa116e
fix nesting too deep in test folder
msarahan May 7, 2024
5eb6b80
Apply suggestions from code review
msarahan May 7, 2024
798c60b
fix cuda-python not adjusting for cuda version
msarahan May 7, 2024
de87c1c
adjust more copyright dates
msarahan May 7, 2024
2b22c5a
add sed for cupy-cuda11x -> cupy-cuda12x on cuda 12
msarahan May 7, 2024
3d97ce3
add early cmake exit in libkvikio wheel if kvikio is already available
msarahan May 8, 2024
0860a99
add wheel publishing in build.yaml
msarahan May 8, 2024
9b89b29
cmake style fix
msarahan May 8, 2024
0e4beee
Update .github/workflows/build.yaml
msarahan May 8, 2024
649397d
Merge branch 'branch-24.06' into wheel-build
hcho3 May 28, 2024
d04de8b
Merge branch 'branch-24.08' into wheel-build
hcho3 Jun 4, 2024
d82635e
Bump libkvikio version
hcho3 Jun 6, 2024
619b9a1
Merge remote-tracking branch 'origin/branch-24.08' into wheel-build
hcho3 Jun 6, 2024
bbed671
Use latest workflows
hcho3 Jun 6, 2024
3dce076
Address reviewers' comments
hcho3 Jun 6, 2024
ff2182a
Fix formatting
hcho3 Jun 6, 2024
1b415f0
Defer to existing FindcuFile module
hcho3 Jun 6, 2024
3d1ac24
Remove unneeded build.sh
hcho3 Jun 6, 2024
8f058b9
Apply suggestions from code review
hcho3 Jun 7, 2024
ccbfd22
Removed outdated comment
hcho3 Jun 7, 2024
84d9e33
Use a separate build.sh
hcho3 Jun 7, 2024
eb127c4
Merge branch 'branch-24.08' into wheel-build
hcho3 Jun 7, 2024
e5c322b
Merge branch 'branch-24.08' of github.com:rapidsai/kvikio into wheel-…
msarahan Jun 17, 2024
5b9da4a
rapids-build-backend for python extension-only wheel
msarahan Jun 17, 2024
7c83f47
fix dependencies-file relative path
msarahan Jun 17, 2024
e2e46fe
always set cython_lib_dir
msarahan Jun 17, 2024
cbfd5f5
attempt to cut out sed stuff that RBB obviates
msarahan Jun 17, 2024
a32ad58
add RBB for libkvikio
msarahan Jun 17, 2024
df85d25
install RBB in build_wheel_*scripts
msarahan Jun 18, 2024
db0ce3b
rbb in build deps for libkvikio
msarahan Jun 18, 2024
bf7dc54
tweak build-backend in libkvikio pyproject.toml
msarahan Jun 18, 2024
f461ab2
libkvikio dynamic dep for pyproject
msarahan Jun 18, 2024
5e2560b
allow alpha specs
msarahan Jun 18, 2024
dd2d246
clean up some unnecessary changes
msarahan Jun 18, 2024
5706ee3
revert WheelHelpers removal and add note about install_aliased_import…
msarahan Jun 18, 2024
b728c93
Apply suggestions from code review
msarahan Jun 18, 2024
5a8ab66
clean up extraneous skbuild stuff (from review)
msarahan Jun 18, 2024
3cf7f82
Apply suggestions from code review
vyasr Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,45 @@ jobs:
node_type: "gpu-v100-latest-1"
run_script: "ci/build_docs.sh"
sha: ${{ inputs.sha }}
wheel-build-cpp:
vyasr marked this conversation as resolved.
Show resolved Hide resolved
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber)))
vyasr marked this conversation as resolved.
Show resolved Hide resolved
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
script: ci/build_wheel_cpp.sh
wheel-build-python:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
script: ci/build_wheel_python.sh
wheel-publish-cpp:
needs: wheel-build-cpp
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: libkvikio
package-type: cpp
wheel-publish-python:
needs: wheel-build-python
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: ${{ inputs.build_type || 'branch' }}
branch: ${{ inputs.branch }}
sha: ${{ inputs.sha }}
date: ${{ inputs.date }}
package-name: kvikio
package-type: python
24 changes: 24 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- conda-python-tests
- docs-build
- devcontainer
- wheel-cpp-build
- wheel-python-build
- wheel-python-tests
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
checks:
Expand Down Expand Up @@ -68,3 +71,24 @@ jobs:
sccache -z;
build-all --verbose;
sccache -s;
wheel-cpp-build:
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
matrix_filter: group_by([.ARCH, (.CUDA_VER|split(".")|map(tonumber)|.[0])]) | map(max_by(.PY_VER|split(".")|map(tonumber)))
build_type: pull-request
script: ci/build_wheel_cpp.sh
wheel-python-build:
msarahan marked this conversation as resolved.
Show resolved Hide resolved
needs: wheel-cpp-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
script: ci/build_wheel_python.sh
wheel-python-tests:
needs: wheel-python-build
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
with:
build_type: pull-request
script: ci/test_wheel.sh
21 changes: 21 additions & 0 deletions ci/build_wheel_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -euo pipefail

package_name="libkvikio"
package_dir="python/libkvikio"

source rapids-configure-sccache
source rapids-date-string

rapids-generate-version > ./VERSION

cd "${package_dir}"

python -m pip install wheel
python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check
vyasr marked this conversation as resolved.
Show resolved Hide resolved
python -m wheel tags --platform any dist/* --remove

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 cpp dist
28 changes: 28 additions & 0 deletions ci/build_wheel_python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -euo pipefail

package_name="kvikio"
package_dir="python/kvikio"

source rapids-configure-sccache
source rapids-date-string


RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"

vyasr marked this conversation as resolved.
Show resolved Hide resolved

rapids-generate-version > ./VERSION

CPP_WHEELHOUSE=$(RAPIDS_PY_WHEEL_NAME="libkvikio_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 cpp /tmp/libkvikio_dist)

cd "${package_dir}"

python -m pip install wheel
vyasr marked this conversation as resolved.
Show resolved Hide resolved
python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check --find-links ${CPP_WHEELHOUSE}

mkdir -p final_dist
python -m auditwheel repair -w final_dist dist/*

RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist
12 changes: 12 additions & 0 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

set -eou pipefail

RAPIDS_PY_CUDA_SUFFIX="$(rapids-wheel-ctk-name-gen ${RAPIDS_CUDA_VERSION})"
WHEELHOUSE="${PWD}/dist/"
RAPIDS_PY_WHEEL_NAME="kvikio_${RAPIDS_PY_CUDA_SUFFIX}" rapids-download-wheels-from-s3 python "${WHEELHOUSE}"

python -m pip install "$(echo ${WHEELHOUSE}/kvikio_${RAPIDS_PY_CUDA_SUFFIX}*.whl)[test]"

python -m pytest ./python/kvikio/tests
12 changes: 10 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ add_library(kvikio::kvikio ALIAS kvikio)

# Enable CUDA in KvikIO
if(CUDAToolkit_FOUND)
target_link_libraries(kvikio INTERFACE $<BUILD_LOCAL_INTERFACE:CUDA::toolkit>)
if(CUDA_STATIC_RUNTIME)
target_link_libraries(kvikio INTERFACE $<BUILD_LOCAL_INTERFACE:CUDA::cudart_static>)
else()
target_link_libraries(kvikio INTERFACE $<BUILD_LOCAL_INTERFACE:CUDA::cudart>)
endif()
target_compile_definitions(kvikio INTERFACE $<BUILD_LOCAL_INTERFACE:KVIKIO_CUDA_FOUND>)
else()
message(WARNING "Building KvikIO without CUDA")
Expand Down Expand Up @@ -167,7 +171,11 @@ if(NOT already_set_kvikio)

find_package(CUDAToolkit QUIET)
if(CUDAToolkit_FOUND)
target_link_libraries(kvikio::kvikio INTERFACE CUDA::toolkit)
if(CUDA_STATIC_RUNTIME)
target_link_libraries(kvikio::kvikio INTERFACE CUDA::cudart_static)
else()
target_link_libraries(kvikio::kvikio INTERFACE CUDA::cudart)
endif()
target_compile_definitions(kvikio::kvikio INTERFACE KVIKIO_CUDA_FOUND)
else()
message(WARNING "Building KvikIO without CUDA")
Expand Down
57 changes: 49 additions & 8 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ files:
cuda: ["11.8", "12.2"]
arch: [x86_64]
includes:
- build
- build-universal
- build-cpp
- build-py-wrapper
- checks
- cuda
- cuda_version
Expand Down Expand Up @@ -44,14 +46,13 @@ files:
table: build-system
includes:
- rapids_build_skbuild
py_rapids_build:
py_build_cpp_wheel:
output: pyproject
pyproject_dir: python/kvikio
pyproject_dir: python/libkvikio
extras:
table: tool.rapids-build-backend
key: requires
table: build-system
includes:
- build
- rapids_build_skbuild
py_run:
output: pyproject
pyproject_dir: python/kvikio
Expand All @@ -60,6 +61,25 @@ files:
includes:
- depends_on_cupy
- run
py_wheel_cpp:
output: pyproject
pyproject_dir: python/libkvikio
extras:
table: tool.rapids-build-backend
key: requires
includes:
- build-universal
py_wheel_python:
output: pyproject
pyproject_dir: python/kvikio
extras:
table: tool.rapids-build-backend
key: requires
includes:
- build-universal
- build-cpp
- build-py-wrapper
- build-use-libkvikio-wheel
py_optional_test:
output: pyproject
pyproject_dir: python/kvikio
Expand All @@ -74,13 +94,14 @@ channels:
- conda-forge
- nvidia
dependencies:
build:
build-universal:
common:
- output_types: [conda, requirements, pyproject]
packages:
- cmake>=3.26.4
- cython>=3.0.0
- ninja
build-cpp:
common:
- output_types: conda
packages:
- c-compiler
Expand Down Expand Up @@ -114,6 +135,26 @@ dependencies:
cuda: "12.*"
packages:
- cuda-nvcc
build-use-libkvikio-wheel:
common:
- output_types: conda
packages: &libkvikio_packages
- libkvikio==24.8.*,>=0.0.0a0
specific:
- output_types: [requirements, pyproject]
matrices:
- matrix: {cuda: "12.*"}
packages:
- libkvikio-cu12==24.8.*,>=0.0.0a0
- matrix: {cuda: "11.*"}
packages:
- libkvikio-cu11==24.8.*,>=0.0.0a0
- {matrix: null, packages: *libkvikio_packages}
build-py-wrapper:
common:
- output_types: [conda, requirements, pyproject]
packages:
- cython>=3.0.0
checks:
common:
- output_types: [conda, requirements]
Expand Down
1 change: 0 additions & 1 deletion python/.gitattributes
msarahan marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

11 changes: 10 additions & 1 deletion python/kvikio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ endif()

find_package(CUDAToolkit REQUIRED)

set(cython_lib_dir kvikio)

if(NOT KvikIO_FOUND)
add_subdirectory(../../cpp kvikio-cpp)
set(cython_lib_dir kvikio)
install(TARGETS kvikio DESTINATION ${cython_lib_dir})
endif()

include(rapids-cython-core)
rapids_cython_init()

add_subdirectory(cmake)

# It would be better to factor nvcomp out into its own wheel. Until that is available, we vendor it
# here.
install_aliased_imported_targets(
TARGETS nvcomp::nvcomp nvcomp::nvcomp_gdeflate nvcomp::nvcomp_bitcomp DESTINATION
${cython_lib_dir}/_lib
)

add_subdirectory(kvikio/_lib)
4 changes: 3 additions & 1 deletion python/kvikio/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand All @@ -13,3 +13,5 @@
# =============================================================================

include(thirdparty/get_nvcomp.cmake)
# Needed for install_aliased_imported_targets
include(thirdparty/WheelHelpers.cmake)
59 changes: 59 additions & 0 deletions python/kvikio/cmake/thirdparty/WheelHelpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# =============================================================================
# Copyright (c) 2022-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
include_guard(GLOBAL)

# Making libraries available inside wheels by installing the associated targets.
function(install_aliased_imported_targets)
list(APPEND CMAKE_MESSAGE_CONTEXT "install_aliased_imported_targets")

set(options "")
set(one_value "DESTINATION")
set(multi_value "TARGETS")
cmake_parse_arguments(_ "${options}" "${one_value}" "${multi_value}" ${ARGN})

message(VERBOSE "Installing targets '${__TARGETS}' into lib_dir '${__DESTINATION}'")

foreach(target IN LISTS __TARGETS)

if(NOT TARGET ${target})
message(VERBOSE "No target named ${target}")
continue()
endif()

get_target_property(alias_target ${target} ALIASED_TARGET)
if(alias_target)
set(target ${alias_target})
endif()

get_target_property(is_imported ${target} IMPORTED)
if(NOT is_imported)
# If the target isn't imported, install it into the wheel
install(TARGETS ${target} DESTINATION ${__DESTINATION})
message(VERBOSE "install(TARGETS ${target} DESTINATION ${__DESTINATION})")
else()
# If the target is imported, make sure it's global
get_target_property(type ${target} TYPE)
if(${type} STREQUAL "UNKNOWN_LIBRARY")
install(FILES $<TARGET_FILE:${target}> DESTINATION ${__DESTINATION})
message(VERBOSE "install(FILES $<TARGET_FILE:${target}> DESTINATION ${__DESTINATION})")
else()
install(IMPORTED_RUNTIME_ARTIFACTS ${target} DESTINATION ${__DESTINATION})
message(
VERBOSE
"install(IMPORTED_RUNTIME_ARTIFACTS $<TARGET_FILE:${target}> DESTINATION ${__DESTINATION})"
)
endif()
endif()
endforeach()
endfunction()
3 changes: 2 additions & 1 deletion python/kvikio/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ nvcomp_batch = "kvikio.nvcomp_codec:NvCompBatchCodec"

[tool.rapids-build-backend]
build-backend = "scikit_build_core.build"
dependencies-file = "../dependencies.yaml"
dependencies-file = "../../dependencies.yaml"
requires = [
"cmake>=3.26.4",
"cython>=3.0.0",
"libkvikio==24.8.*,>=0.0.0a0",
"ninja",
] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`.

Expand Down
Loading