From bbe68d7f576ab3c1d5c7bd66bd6f6ace4a876302 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Wed, 25 Nov 2026 13:21:34 -0500 Subject: [PATCH] fix(cuda.bindings): return False from check_nvvm_compiler_options without libNVVM check_nvvm_compiler_options() raised DynamicLibNotFoundError when libNVVM could not be found, but test_check_nvvm_compiler_options_no_libnvvm expected False. The test skipped whenever libNVVM was present, so it never ran in CI and the mismatch went unnoticed. Catch DynamicLibNotFoundError around the libNVVM lookup and return False. Rewrite the test to simulate a missing libNVVM in a fresh interpreter, so it runs in every configuration. Add paired cuda-bindings and cuda-python 13.6.0 release notes recording the behavior change. Closes #3565. Co-Authored-By: Claude Opus 5.5 --- .../cuda/bindings/utils/_nvvm_utils.py | 8 +++++- .../docs/source/release/13.6.0-notes.rst | 14 ++++++++++ cuda_bindings_13/tests/test_utils.py | 27 ++++++++++++++++--- .../docs/source/release/13.6.0-notes.rst | 16 +++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 cuda_bindings_13/docs/source/release/13.6.0-notes.rst create mode 100644 cuda_python/docs/source/release/13.6.0-notes.rst diff --git a/cuda_bindings_13/cuda/bindings/utils/_nvvm_utils.py b/cuda_bindings_13/cuda/bindings/utils/_nvvm_utils.py index be5c4d58d403..2ec0c6d02e51 100644 --- a/cuda_bindings_13/cuda/bindings/utils/_nvvm_utils.py +++ b/cuda_bindings_13/cuda/bindings/utils/_nvvm_utils.py @@ -32,6 +32,8 @@ def check_nvvm_compiler_options(options: Sequence[str]) -> bool: If the test program compiles successfully, True is returned. + If libNVVM cannot be found, False is returned. + cuda.bindings.nvvm returns exceptions instead of return codes. Parameters @@ -58,8 +60,12 @@ def check_nvvm_compiler_options(options: Sequence[str]) -> bool: raise from cuda.bindings._internal.nvvm import _inspect_function_pointer + from cuda.pathfinder import DynamicLibNotFoundError - if _inspect_function_pointer("__nvvmCreateProgram") == 0: + try: + if _inspect_function_pointer("__nvvmCreateProgram") == 0: + return False + except DynamicLibNotFoundError: return False program = nvvm.create_program() diff --git a/cuda_bindings_13/docs/source/release/13.6.0-notes.rst b/cuda_bindings_13/docs/source/release/13.6.0-notes.rst new file mode 100644 index 000000000000..3af15e703114 --- /dev/null +++ b/cuda_bindings_13/docs/source/release/13.6.0-notes.rst @@ -0,0 +1,14 @@ +.. SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +.. SPDX-License-Identifier: Apache-2.0 + +.. module:: cuda.bindings + +``cuda-bindings`` 13.6.0 Release notes +====================================== + +Behavior changes +---------------- + +- ``cuda.bindings.utils.check_nvvm_compiler_options()`` now returns ``False`` when libNVVM + cannot be found. Previously it raised ``cuda.pathfinder.DynamicLibNotFoundError``. + (`Issue #3565 `_) diff --git a/cuda_bindings_13/tests/test_utils.py b/cuda_bindings_13/tests/test_utils.py index adddfe764c64..9356a0f73a7b 100644 --- a/cuda_bindings_13/tests/test_utils.py +++ b/cuda_bindings_13/tests/test_utils.py @@ -8,6 +8,7 @@ from pathlib import Path import pytest +from cuda_python_test_helpers.subprocess_runner import run_python_snippet from cuda.bindings import driver, runtime from cuda.bindings._internal.utils import get_c_compiler @@ -197,8 +198,26 @@ def test_check_nvvm_compiler_options_arch_detection(): assert check_nvvm_compiler_options(["-arch=compute_99999"]) is False -# This test is not currently run in any CI job +@pytest.mark.agent_authored(model="claude-opus-5-5") def test_check_nvvm_compiler_options_no_libnvvm(): - if _libnvvm_available: - pytest.skip("libNVVM is available; this test targets the fallback path") - assert check_nvvm_compiler_options(["-arch=compute_90"]) is False + # The NVVM function table is process-global and filled in only once, so + # simulate a missing libNVVM in a fresh interpreter. + result = run_python_snippet( + """ +import cuda.bindings._internal.nvvm as nvvm_internal +from cuda.bindings.utils import check_nvvm_compiler_options +from cuda.pathfinder import DynamicLibNotFoundError + +calls = [] + + +def load_nvidia_dynamic_lib(libname): + calls.append(libname) + raise DynamicLibNotFoundError(f"simulated: {libname} not found") + + +nvvm_internal.load_nvidia_dynamic_lib = load_nvidia_dynamic_lib +print(check_nvvm_compiler_options(["-arch=compute_90"]), calls) +""" + ) + assert result.stdout.strip() == "False ['nvvm']" diff --git a/cuda_python/docs/source/release/13.6.0-notes.rst b/cuda_python/docs/source/release/13.6.0-notes.rst new file mode 100644 index 000000000000..6cf205e89f7e --- /dev/null +++ b/cuda_python/docs/source/release/13.6.0-notes.rst @@ -0,0 +1,16 @@ +.. SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +.. SPDX-License-Identifier: Apache-2.0 + +CUDA Python 13.6.0 Release notes +================================= + +Highlights +---------- + +* ``cuda-python`` 13.6.0 pulls in ``cuda-bindings`` 13.6.0. See the + ``cuda-bindings`` 13.6.0 release notes for its changes. + +Known issues +------------ + +* Updating from older versions (v12.6.2.post1 and below) via ``pip install -U cuda-python`` might not work. Please do a clean re-installation by uninstalling ``pip uninstall -y cuda-python`` followed by installing ``pip install cuda-python``.