Skip to content

Commit 60d431f

Browse files
authored
Revert nvJitLink driver-major compatibility fallback (NVIDIA#2355)
* Revert "Check nvJitLink driver major compatibility (NVIDIA#2320)" This reverts commit e83d434. * Fix cuLink state storage lifetimes * Preserve linker backend validation test fix * Skip unsupported cuLink time option tests --------- Co-authored-by: Michael Wang <isVoid@users.noreply.github.com>
1 parent fb653f3 commit 60d431f

4 files changed

Lines changed: 19 additions & 83 deletions

File tree

cuda_core/cuda/core/_linker.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ class LinkerOptions:
112112
113113
Since the linker may choose to use nvJitLink or the driver APIs as the linking backend,
114114
not all options are applicable. When the system's installed nvJitLink is too old (<12.3),
115-
not installed, or older than the CUDA driver major version, the driver APIs (cuLink)
116-
will be used instead.
115+
or not installed, the driver APIs (cuLink) will be used instead.
117116
118117
Attributes
119118
----------

cuda_core/cuda/core/_linker.pyx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ from cuda.core._utils.cuda_utils import (
3939
driver,
4040
is_sequence,
4141
)
42-
from cuda.core._utils.version import driver_version
4342
from cuda.core.typing import CompilerBackendType, ObjectCodeFormatType
4443

4544
if TYPE_CHECKING:
@@ -218,8 +217,7 @@ class LinkerOptions:
218217

219218
Since the linker may choose to use nvJitLink or the driver APIs as the linking backend,
220219
not all options are applicable. When the system's installed nvJitLink is too old (<12.3),
221-
not installed, or older than the CUDA driver major version, the driver APIs (cuLink)
222-
will be used instead.
220+
or not installed, the driver APIs (cuLink) will be used instead.
223221

224222
Attributes
225223
----------
@@ -696,22 +694,12 @@ def _decide_nvjitlink_or_driver() -> bool:
696694
from cuda.bindings._internal import nvjitlink
697695

698696
if _nvjitlink_has_version_symbol(nvjitlink):
699-
nvjitlink_version = nvjitlink_module.version()
700-
driver_major = driver_version()[0]
701-
if driver_major <= nvjitlink_version[0]:
702-
_use_nvjitlink_backend = True
703-
return False # Use nvjitlink
704-
705-
warn_txt = (
706-
f"CUDA driver major version {driver_major} is newer than "
707-
f"nvJitLink major version {nvjitlink_version[0]}; therefore "
708-
f"{warn_txt_common} nvJitLink."
709-
)
710-
else:
711-
warn_txt = (
712-
f"{'nvJitLink*.dll' if sys.platform == 'win32' else 'libnvJitLink.so*'} is too old (<12.3)."
713-
f" Therefore cuda.bindings.nvjitlink is not usable and {warn_txt_common} nvJitLink."
714-
)
697+
_use_nvjitlink_backend = True
698+
return False # Use nvjitlink
699+
warn_txt = (
700+
f"{'nvJitLink*.dll' if sys.platform == 'win32' else 'libnvJitLink.so*'} is too old (<12.3)."
701+
f" Therefore cuda.bindings.nvjitlink is not usable and {warn_txt_common} nvJitLink."
702+
)
715703

716704
warn(warn_txt, stacklevel=2, category=RuntimeWarning)
717705
_use_nvjitlink_backend = False

cuda_core/tests/test_optional_dependency_imports.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
from cuda.core import _linker, _program
88

99

10-
class FakeNvJitLinkModule:
11-
def __init__(self, version):
12-
self._version = version
13-
14-
def version(self):
15-
return self._version
16-
17-
1810
@pytest.fixture(autouse=True)
1911
def restore_optional_import_state():
2012
saved_nvvm_module = _program._nvvm_module
@@ -111,43 +103,3 @@ def fake__optional_cuda_import(modname, probe_function=None):
111103

112104
assert use_driver_backend is True
113105
assert _linker._use_nvjitlink_backend is False
114-
115-
116-
@pytest.mark.agent_authored(model="gpt-5")
117-
@pytest.mark.parametrize(
118-
("driver_version", "nvjitlink_version"),
119-
[
120-
((12, 8, 0), (12, 9)),
121-
((12, 9, 0), (13, 0)),
122-
],
123-
)
124-
def test_decide_nvjitlink_or_driver_uses_nvjitlink_when_driver_is_not_newer(
125-
monkeypatch, driver_version, nvjitlink_version
126-
):
127-
monkeypatch.setattr(
128-
_linker,
129-
"_optional_cuda_import",
130-
lambda *_args, **_kwargs: FakeNvJitLinkModule(nvjitlink_version),
131-
)
132-
monkeypatch.setattr(_linker, "_nvjitlink_has_version_symbol", lambda _nvjitlink: True)
133-
monkeypatch.setattr(_linker, "driver_version", lambda: driver_version)
134-
135-
assert _linker._decide_nvjitlink_or_driver() is False
136-
assert _linker._use_nvjitlink_backend is True
137-
138-
139-
@pytest.mark.agent_authored(model="gpt-5")
140-
def test_decide_nvjitlink_or_driver_falls_back_when_driver_is_newer(monkeypatch):
141-
monkeypatch.setattr(
142-
_linker,
143-
"_optional_cuda_import",
144-
lambda *_args, **_kwargs: FakeNvJitLinkModule((12, 9)),
145-
)
146-
monkeypatch.setattr(_linker, "_nvjitlink_has_version_symbol", lambda _nvjitlink: True)
147-
monkeypatch.setattr(_linker, "driver_version", lambda: (13, 0, 0))
148-
149-
with pytest.warns(RuntimeWarning, match="is newer than nvJitLink major version"):
150-
use_driver_backend = _linker._decide_nvjitlink_or_driver()
151-
152-
assert use_driver_backend is True
153-
assert _linker._use_nvjitlink_backend is False

cuda_core/tests/test_program_cache.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,14 @@ def test_make_program_cache_key_ignores_name_expressions_for_non_nvrtc(code_type
375375
{"link_time_optimization": None},
376376
id="lto_false_eq_none",
377377
),
378+
# ``time`` is a presence gate: the linker emits ``-time`` for any
379+
# non-None value, so True / "path" produce the same flag.
380+
pytest.param(
381+
{"time": True},
382+
{"time": "timing.csv"},
383+
id="time_true_eq_path",
384+
marks=pytest.mark.skipif(is_culink_backend, reason="-time is not supported in cuLink"),
385+
),
378386
# ``no_cache`` has an ``is True`` gate; False and None equivalent.
379387
pytest.param({"no_cache": False}, {"no_cache": None}, id="no_cache_false_eq_none"),
380388
],
@@ -393,18 +401,6 @@ def test_make_program_cache_key_ptx_linker_equivalent_options_hash_same(a, b, mo
393401
assert k_a == k_b
394402

395403

396-
@pytest.mark.skipif(is_culink_backend, reason="test requires nvJitLink backend")
397-
@pytest.mark.agent_authored(model="gpt-5")
398-
def test_make_program_cache_key_ptx_nvjitlink_time_values_hash_same(monkeypatch):
399-
"""nvJitLink emits ``-time`` for any non-None value."""
400-
from cuda.core.utils import _program_cache
401-
402-
monkeypatch.setattr(_program_cache._keys, "_linker_backend_and_version", lambda _use_driver: ("nvJitLink", "12030"))
403-
k_true = _make_key(code=".version 7.0", code_type="ptx", options=_opts(time=True))
404-
k_path = _make_key(code=".version 7.0", code_type="ptx", options=_opts(time="timing.csv"))
405-
assert k_true == k_path
406-
407-
408404
@pytest.mark.parametrize(
409405
"field, a, b",
410406
[
@@ -1014,9 +1010,10 @@ def test_make_program_cache_key_rejects_side_effect_options_nvrtc(option_kw, ext
10141010
pytest.param({"time": "whatever.csv"}, id="time_path"),
10151011
],
10161012
)
1017-
@pytest.mark.skipif(is_culink_backend, reason="test requires nvJitLink backend")
1013+
@pytest.mark.skipif(is_culink_backend, reason="-time is not supported in cuLink")
10181014
def test_make_program_cache_key_accepts_side_effect_options_for_ptx(option_kw):
1019-
"""nvJitLink ``-time`` writes only to its info log, not the filesystem."""
1015+
"""The side-effect guard is NVRTC-specific: PTX (linker) and NVVM must
1016+
not be blocked by options whose side effects only apply under NVRTC."""
10201017
_make_key(code=".version 7.0", code_type="ptx", options=_opts(**option_kw)) # no raise
10211018

10221019

0 commit comments

Comments
 (0)