From 532da9f0b29d1bea349312bef846317de1596f5e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Jan 2024 09:19:38 -0800 Subject: [PATCH 01/12] add pynvjitlink to run_cudf --- conda/environments/all_cuda-120_arch-x86_64.yaml | 1 + dependencies.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/conda/environments/all_cuda-120_arch-x86_64.yaml b/conda/environments/all_cuda-120_arch-x86_64.yaml index 579bbb6d52d..d5f653fb5f9 100644 --- a/conda/environments/all_cuda-120_arch-x86_64.yaml +++ b/conda/environments/all_cuda-120_arch-x86_64.yaml @@ -69,6 +69,7 @@ dependencies: - protobuf>=4.21,<5 - pyarrow==14.0.1.* - pydata-sphinx-theme!=0.14.2 +- pynvjitlink - pytest - pytest-benchmark - pytest-cases<3.8.2 diff --git a/dependencies.yaml b/dependencies.yaml index 20998847a75..56a65a33932 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -527,6 +527,7 @@ dependencies: - matrix: {cuda: "12.*"} packages: - cuda-python>=12.0,<13.0a0 + - pynvjitlink - matrix: {cuda: "11.*"} packages: &run_cudf_packages_all_cu11 - cuda-python>=11.7.1,<12.0a0 From 02ef286818a7cfd6bcaf2e5b487f027f545387d3 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Jan 2024 11:39:11 -0800 Subject: [PATCH 02/12] add pynvjitlink to meta.yaml for cudf --- conda/recipes/cudf/meta.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index bc91ee61f6f..4f39a9fe452 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2023, NVIDIA CORPORATION. +# Copyright (c) 2018-2024, NVIDIA CORPORATION. {% set version = environ['RAPIDS_PACKAGE_VERSION'].lstrip('v') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} @@ -98,6 +98,7 @@ requirements: # xref: https://github.com/rapidsai/cudf/issues/12822 - cuda-nvrtc - cuda-python >=12.0,<13.0a0 + - pynvjitlink {% endif %} - {{ pin_compatible('cuda-version', max_pin='x', min_pin='x') }} - nvtx >=0.2.1 From c6ae80cd1f6a880dec26765acdf47d6a1ac26dd9 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Jan 2024 11:41:09 -0800 Subject: [PATCH 03/12] unconditionally import patching function from pynvjitlink --- python/cudf/cudf/utils/_numba.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index fc45f60cdaf..b5fb841873c 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -1,24 +1,13 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. import glob import os import sys -import warnings from numba import config as numba_config - -try: - from pynvjitlink.patch import ( - patch_numba_linker as patch_numba_linker_pynvjitlink, - ) -except ImportError: - - def patch_numba_linker_pynvjitlink(): - warnings.warn( - "CUDA Toolkit is newer than CUDA driver. " - "Numba features will not work in this configuration. " - ) - +from pynvjitlink.patch import ( + patch_numba_linker as patch_numba_linker_pynvjitlink, +) CC_60_PTX_FILE = os.path.join( os.path.dirname(__file__), "../core/udf/shim_60.ptx" From d301cb98de7a2d3a1a363f04b2fb07c4c710530f Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Jan 2024 06:49:20 -0800 Subject: [PATCH 04/12] add pynvjitlink to test_python_common --- dependencies.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dependencies.yaml b/dependencies.yaml index 56a65a33932..91fa01d9a78 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -612,6 +612,14 @@ dependencies: - pytest - pytest-cov - pytest-xdist + specific: + - output_types: [conda, requirements, pyproject] + matrices: + - matrix: {cuda: "12.*"} + packages: + - pynvjitlink + - matrix: + packages: test_python_cudf: common: - output_types: [conda, requirements, pyproject] From 8b8a12c2ba3b75008645090c3db856bb1b7518d9 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 17 Jan 2024 07:03:16 -0800 Subject: [PATCH 05/12] Fix pynvjitlink dependencies. --- ci/build_wheel.sh | 2 +- dependencies.yaml | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 9c674518810..2ee11d211bb 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -48,7 +48,7 @@ fi if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} sed -i "s/cupy-cuda11x/cupy-cuda12x/g" ${pyproject_file} - sed -i "/ptxcompiler/d" ${pyproject_file} + sed -i "s/ptxcompiler/pynvjitlink-cu12/g" ${pyproject_file} sed -i "/cubinlinker/d" ${pyproject_file} fi diff --git a/dependencies.yaml b/dependencies.yaml index 91fa01d9a78..925badd9bca 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -527,23 +527,25 @@ dependencies: - matrix: {cuda: "12.*"} packages: - cuda-python>=12.0,<13.0a0 - - pynvjitlink - matrix: {cuda: "11.*"} packages: &run_cudf_packages_all_cu11 - cuda-python>=11.7.1,<12.0a0 - {matrix: null, packages: *run_cudf_packages_all_cu11} - output_types: conda matrices: + - matrix: {cuda: "12.*"} + packages: + - pynvjitlink - matrix: {cuda: "11.*"} packages: - cubinlinker - ptxcompiler - - {matrix: null, packages: null} - output_types: [requirements, pyproject] matrices: - matrix: {cuda: "12.*"} packages: - rmm-cu12==24.2.* + - pynvjitlink-cu12 - matrix: {cuda: "11.*"} packages: - rmm-cu11==24.2.* From aefd0c0dae51e5ece52ce86f5d60c64f31c093b9 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 17 Jan 2024 07:04:38 -0800 Subject: [PATCH 06/12] Remove testing dependency on pynvjitlink. --- dependencies.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 925badd9bca..3389df99505 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -614,14 +614,6 @@ dependencies: - pytest - pytest-cov - pytest-xdist - specific: - - output_types: [conda, requirements, pyproject] - matrices: - - matrix: {cuda: "12.*"} - packages: - - pynvjitlink - - matrix: - packages: test_python_cudf: common: - output_types: [conda, requirements, pyproject] From c6b3982ca1755bd01fc64b40ac481be124e13629 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 17 Jan 2024 07:56:52 -0800 Subject: [PATCH 07/12] Remove double suffix. --- ci/build_wheel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_wheel.sh b/ci/build_wheel.sh index 2ee11d211bb..c4b794e81f7 100755 --- a/ci/build_wheel.sh +++ b/ci/build_wheel.sh @@ -48,7 +48,7 @@ fi if [[ $PACKAGE_CUDA_SUFFIX == "-cu12" ]]; then sed -i "s/cuda-python[<=>\.,0-9a]*/cuda-python>=12.0,<13.0a0/g" ${pyproject_file} sed -i "s/cupy-cuda11x/cupy-cuda12x/g" ${pyproject_file} - sed -i "s/ptxcompiler/pynvjitlink-cu12/g" ${pyproject_file} + sed -i "s/ptxcompiler/pynvjitlink/g" ${pyproject_file} sed -i "/cubinlinker/d" ${pyproject_file} fi From 687225a0a5fcdd23b282d57a1f2e8cfcfd88d922 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Jan 2024 08:49:03 -0800 Subject: [PATCH 08/12] style --- python/cudf/cudf/utils/_numba.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index 0257a068324..fb96ad81941 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -3,7 +3,6 @@ import glob import os import sys - from functools import lru_cache from numba import config as numba_config @@ -11,6 +10,7 @@ patch_numba_linker as patch_numba_linker_pynvjitlink, ) + # Use an lru_cache with a single value to allow a delayed import of # strings_udf. This is the easiest way to break an otherwise circular import # loop of _lib.*->cudautils->_numba->_lib.strings_udf From 92c6bb1c0f93f2328b26eba8d6126ed893d70f48 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Jan 2024 10:02:51 -0800 Subject: [PATCH 09/12] locally import patch_numba_linker --- python/cudf/cudf/utils/_numba.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index fb96ad81941..10041253dac 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -6,9 +6,6 @@ from functools import lru_cache from numba import config as numba_config -from pynvjitlink.patch import ( - patch_numba_linker as patch_numba_linker_pynvjitlink, -) # Use an lru_cache with a single value to allow a delayed import of @@ -135,7 +132,9 @@ def _setup_numba(): if driver_version < (12, 0): patch_numba_linker_cuda_11() else: - patch_numba_linker_pynvjitlink() + from pynvjitlink.patch import patch_numba_linker + + patch_numba_linker() def _get_cuda_version_from_ptx_file(path): From 7dbf9f22dbb63b6d33cfd9ad783dee60ec41555c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Jan 2024 11:46:40 -0800 Subject: [PATCH 10/12] update comment --- python/cudf/cudf/utils/_numba.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index 10041253dac..3c9c3fb03a2 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -104,11 +104,13 @@ def _setup_numba(): version of the CUDA Toolkit used to build the PTX files shipped with the user cuDF package. """ - # ptxcompiler is a requirement for cuda 11.x packages but not - # cuda 12.x packages. However its version checking machinery - # is still necessary. If a user happens to have ptxcompiler - # in a cuda 12 environment, it's use for the purposes of - # checking the driver and runtime versions is harmless + # ptxcompiler needed for MVC for CUDA 11.x packages but not + # CUDA 12.x packages. However its version checking machinery + # is still necessary. In a CUDA 12.x environment, ptxcompiler + # provides version checking, but not MVC directly, which is + # provided by pynvjitlink instead. The presence of either package + # does not perturb cuDF's operation in situations where they + # are not necessary. try: from ptxcompiler.patch import NO_DRIVER, safe_get_versions except ModuleNotFoundError: From e8a90b9ee26c8e365f5df8e705ed7e8c9f21681a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Jan 2024 14:01:26 -0800 Subject: [PATCH 11/12] update comment --- python/cudf/cudf/utils/_numba.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index 3c9c3fb03a2..669dece89f7 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -104,13 +104,13 @@ def _setup_numba(): version of the CUDA Toolkit used to build the PTX files shipped with the user cuDF package. """ - # ptxcompiler needed for MVC for CUDA 11.x packages but not - # CUDA 12.x packages. However its version checking machinery - # is still necessary. In a CUDA 12.x environment, ptxcompiler - # provides version checking, but not MVC directly, which is - # provided by pynvjitlink instead. The presence of either package - # does not perturb cuDF's operation in situations where they - # are not necessary. + + # Either ptxcompiler, or our vendored version (_ptxcompiloer.py) + # is needed to determine the driver and runtime CUDA versions in + # the environment. In a CUDA 11.x environment, ptxcompiler is used + # to provide MVC directly, whereas for CUDA 12.x this is provided + # through pynvjitlink. The presence of either package does not + # perturb cuDF's operation in situations where they aren't used. try: from ptxcompiler.patch import NO_DRIVER, safe_get_versions except ModuleNotFoundError: From 698f1a27f1f24f95c3f6914d1cc717cf373ccf5a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 17 Jan 2024 17:17:50 -0600 Subject: [PATCH 12/12] Fix typo. --- python/cudf/cudf/utils/_numba.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/utils/_numba.py b/python/cudf/cudf/utils/_numba.py index 669dece89f7..6d00fd397df 100644 --- a/python/cudf/cudf/utils/_numba.py +++ b/python/cudf/cudf/utils/_numba.py @@ -105,7 +105,7 @@ def _setup_numba(): with the user cuDF package. """ - # Either ptxcompiler, or our vendored version (_ptxcompiloer.py) + # Either ptxcompiler, or our vendored version (_ptxcompiler.py) # is needed to determine the driver and runtime CUDA versions in # the environment. In a CUDA 11.x environment, ptxcompiler is used # to provide MVC directly, whereas for CUDA 12.x this is provided