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

Use pynvjitlink for MVC #23

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
521be20
off the ground
brandon-b-miller Jul 12, 2024
0f9bc4a
cleanup
brandon-b-miller Jul 15, 2024
b25db1f
Merge remote-tracking branch 'upstream/develop' into develop
brandon-b-miller Jul 16, 2024
1c3517f
enough to launch a kernel
brandon-b-miller Jul 29, 2024
cbcbbab
pass through kwargs
brandon-b-miller Jul 29, 2024
4406809
patch_cuda once
brandon-b-miller Jul 29, 2024
dc887b6
refactor
brandon-b-miller Jul 30, 2024
7d17759
Merge remote-tracking branch 'upstream/develop' into develop
brandon-b-miller Aug 4, 2024
b9898ec
merge latest/resolve conflicts
brandon-b-miller Aug 4, 2024
60d4ca7
style and other fixes
brandon-b-miller Aug 4, 2024
db32cfa
Merge remote-tracking branch 'upstream/develop' into develop
brandon-b-miller Aug 5, 2024
bc424ae
merge latest/resolve conflict
brandon-b-miller Aug 5, 2024
56db9c8
cleanup
brandon-b-miller Aug 8, 2024
c57053c
bifurcate error messages
brandon-b-miller Aug 8, 2024
363b86d
partially address reviews
brandon-b-miller Aug 12, 2024
32164e9
move add_file_guess_ext logic to Linker base class
brandon-b-miller Aug 12, 2024
c3b9084
refactor __new__ logic
brandon-b-miller Aug 19, 2024
2c940ee
address reviews
brandon-b-miller Aug 19, 2024
a8c38b6
refactor config logic
brandon-b-miller Aug 21, 2024
421fdfb
continue addressing reviews
brandon-b-miller Aug 22, 2024
16314a7
rename errors
brandon-b-miller Aug 22, 2024
41d85a9
minor cleanup
brandon-b-miller Aug 22, 2024
f7939b6
Apply suggestions from code review
brandon-b-miller Aug 22, 2024
91f06a8
address reviews
brandon-b-miller Aug 22, 2024
0541dcf
bug fixes and map ltoir to CU_JIT_INPUT_NVVM
brandon-b-miller Aug 22, 2024
710f8cb
CU_JIT_INPUT_LTO_IR -> CU_JIT_INPUT_NVVM
brandon-b-miller Sep 4, 2024
a8cb6c2
only use cuda if CUDA_USE_NVIDIA_BINDING
brandon-b-miller Sep 4, 2024
b8b671f
fixes
brandon-b-miller Sep 4, 2024
7c384a3
tests
brandon-b-miller Sep 26, 2024
6327ec2
fix bug
brandon-b-miller Sep 30, 2024
c97767c
add a new ci job for testing with pynvjitlink
brandon-b-miller Sep 30, 2024
aa3aaf7
fixes
brandon-b-miller Sep 30, 2024
f01c0d6
more small fixes
brandon-b-miller Oct 2, 2024
f512bed
Merge remote-tracking branch 'upstream/develop' into develop
brandon-b-miller Oct 3, 2024
15e16a6
merge/resolve
brandon-b-miller Oct 3, 2024
519f0c1
update matrix filter
brandon-b-miller Oct 3, 2024
1201f1f
simple filter
brandon-b-miller Oct 3, 2024
883d817
clean
brandon-b-miller Oct 3, 2024
f41b931
.1
brandon-b-miller Oct 3, 2024
e5aa41e
revert
brandon-b-miller Oct 3, 2024
a0ea97d
refactor
brandon-b-miller Oct 3, 2024
b979054
try and fix conda workflow
brandon-b-miller Oct 3, 2024
beb3301
readenv boolify string values
brandon-b-miller Oct 3, 2024
3f5a865
fix imports
brandon-b-miller Oct 3, 2024
4770c40
update
brandon-b-miller Oct 4, 2024
2820ee6
use local workflow matrix
brandon-b-miller Oct 4, 2024
dc20cce
cu12 suffix
brandon-b-miller Oct 4, 2024
ff18c5c
Update ci/test_conda.sh
brandon-b-miller Oct 7, 2024
b2f4245
small updates
brandon-b-miller Oct 8, 2024
f40d3ed
fix logic :)
brandon-b-miller Oct 8, 2024
c24ec67
try hardcoding ENABLE_PYNVJITLINK
brandon-b-miller Oct 8, 2024
dccd6db
fix passing of ENABLE_PYNVJITLINK
brandon-b-miller Oct 9, 2024
9aaa21f
ship makefile, find and build tests
brandon-b-miller Oct 9, 2024
d3ca53c
minor fix
brandon-b-miller Oct 9, 2024
4ce95a7
bifurcate pynvjitlink test scripts
brandon-b-miller Oct 9, 2024
d65f80d
pass test bin dir as an env var
brandon-b-miller Oct 9, 2024
5097bcf
more minor fixes
brandon-b-miller Oct 9, 2024
e29744c
Retry installation of pynvjitlink
gmarkall Oct 10, 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
22 changes: 21 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
- compute-matrix
- build-conda
- test-conda
- test-conda-pynvjitlink
- build-wheels
- test-wheels
- test-wheels-pynvjitlink
- build-docs
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/[email protected]
Expand Down Expand Up @@ -57,6 +59,16 @@ jobs:
script: "ci/test_conda.sh"
run_codecov: false
matrix_filter: ${{ needs.compute-matrix.outputs.TEST_MATRIX }}
test-conda-pynvjitlink:
needs:
- build-conda
- compute-matrix
uses: ./.github/workflows/conda-python-tests.yaml
with:
build_type: pull-request
script: "ci/test_conda_pynvjitlink.sh"
run_codecov: false
matrix_filter: map(select(.ARCH == "amd64" and .CUDA_VER == "12.5.1" and .PY_VER == "3.11"))
build-wheels:
needs:
- compute-matrix
Expand All @@ -71,7 +83,15 @@ jobs:
uses: ./.github/workflows/wheels-test.yaml
with:
build_type: pull-request
script: "ci/test_wheel.sh"
script: "ci/test_wheel.sh false"
test-wheels-pynvjitlink:
needs:
- build-wheels
uses: ./.github/workflows/wheels-test.yaml
with:
build_type: pull-request
script: "ci/test_wheel_pynvjitlink.sh"
matrix_filter: map(select(.ARCH == "amd64" and .CUDA_VER == "12.5.1" and .PY_VER == "3.12"))
build-docs:
needs:
- build-conda
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ __pycache__
build
.*.swp
*.so
numba_cuda/numba/cuda/tests/cudadrv/test_device_functions.*
numba_cuda/numba/cuda/tests/cudadrv/undefined_extern.*
77 changes: 77 additions & 0 deletions ci/test_conda_pynvjitlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION

set -euo pipefail

. /opt/conda/etc/profile.d/conda.sh

if [ "${CUDA_VER%.*.*}" = "11" ]; then
CTK_PACKAGES="cudatoolkit"
else
CTK_PACKAGES="cuda-nvcc-impl cuda-nvrtc"
fi

rapids-logger "Install testing dependencies"
# TODO: Replace with rapids-dependency-file-generator
rapids-mamba-retry create -n test \
c-compiler \
cxx-compiler \
${CTK_PACKAGES} \
cuda-python \
cuda-version=${CUDA_VER%.*} \
make \
psutil \
pytest \
python=${RAPIDS_PY_VERSION}

# Temporarily allow unbound variables for conda activation.
set +u
conda activate test
set -u

rapids-mamba-retry install -c `pwd`/conda-repo numba-cuda

RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/
mkdir -p "${RAPIDS_TESTS_DIR}"
pushd "${RAPIDS_TESTS_DIR}"

rapids-print-env

rapids-logger "Check GPU usage"
nvidia-smi

rapids-logger "Show Numba system info"
python -m numba --sysinfo

EXITCODE=0
trap "EXITCODE=1" ERR
set +e


rapids-logger "Install pynvjitlink"
set +u
rapids-mamba-retry install -c rapidsai pynvjitlink
set -u

rapids-logger "Build tests"

PY_SCRIPT="
import numba_cuda
root = numba_cuda.__file__.rstrip('__init__.py')
test_dir = root + \"numba/cuda/tests/test_binary_generation/\"
print(test_dir)
"

NUMBA_CUDA_TEST_BIN_DIR=$(python -c "$PY_SCRIPT")
pushd $NUMBA_CUDA_TEST_BIN_DIR
make
popd


rapids-logger "Run Tests"
ENABLE_PYNVJITLINK=1 NUMBA_CUDA_TEST_BIN_DIR=$NUMBA_CUDA_TEST_BIN_DIR python -m numba.runtests numba.cuda.tests -v

popd

rapids-logger "Test script exiting with value: $EXITCODE"
exit ${EXITCODE}
47 changes: 47 additions & 0 deletions ci/test_wheel_pynvjitlink.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash
# Copyright (c) 2023-2024, NVIDIA CORPORATION

set -euo pipefail

rapids-logger "Install testing dependencies"
# TODO: Replace with rapids-dependency-file-generator
python -m pip install \
psutil \
cuda-python \
pytest

rapids-logger "Install pynvjitlink"
python -m pip install pynvjitlink-cu12

rapids-logger "Build tests"
PY_SCRIPT="
import numba_cuda
root = numba_cuda.__file__.rstrip('__init__.py')
test_dir = root + \"numba/cuda/tests/test_binary_generation/\"
print(test_dir)
"

NUMBA_CUDA_TEST_BIN_DIR=$(python -c "$PY_SCRIPT")
pushd $NUMBA_CUDA_TEST_BIN_DIR
make
popd

rapids-logger "Install wheel"
package=$(realpath wheel/numba_cuda*.whl)
echo "Package path: $package"
python -m pip install $package

rapids-logger "Check GPU usage"
nvidia-smi

RAPIDS_TESTS_DIR=${RAPIDS_TESTS_DIR:-"${PWD}/test-results"}/
mkdir -p "${RAPIDS_TESTS_DIR}"
pushd "${RAPIDS_TESTS_DIR}"

rapids-logger "Show Numba system info"
python -m numba --sysinfo

rapids-logger "Run Tests"
ENABLE_PYNVJITLINK=1 NUMBA_CUDA_TEST_BIN_DIR=$NUMBA_CUDA_TEST_BIN_DIR python -m numba.runtests numba.cuda.tests -v

popd
18 changes: 14 additions & 4 deletions numba_cuda/numba/cuda/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,18 @@ class CUDACodeLibrary(serialize.ReduceMixin, CodeLibrary):
get_cufunc), which may be of different compute capabilities.
"""

def __init__(self, codegen, name, entry_name=None, max_registers=None,
nvvm_options=None):
def __init__(
self,
codegen,
name,
entry_name=None,
max_registers=None,
lto=False,
nvvm_options=None
):
"""
codegen:
Codegen object.
Codegen object.
name:
Name of the function in the source.
entry_name:
Expand Down Expand Up @@ -103,6 +110,7 @@ def __init__(self, codegen, name, entry_name=None, max_registers=None,
self._cufunc_cache = {}

self._max_registers = max_registers
self._lto = lto
if nvvm_options is None:
nvvm_options = {}
self._nvvm_options = nvvm_options
Expand Down Expand Up @@ -178,7 +186,9 @@ def get_cubin(self, cc=None):
if cubin:
return cubin

linker = driver.Linker.new(max_registers=self._max_registers, cc=cc)
linker = driver.Linker.new(
max_registers=self._max_registers, cc=cc, lto=self._lto
)

if linker.lto:
ltoir = self.get_ltoir(cc=cc)
Expand Down
Loading