Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion cuda_core/cuda/core/_linker.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class LinkerOptions:
incremental : bool, optional
Perform an incremental link. The result can be passed
directly to a later :class:`Linker`. Requires nvJitLink 13.2 or newer
and is not supported by the driver linker backend.
and is not supported by the driver linker backend. Intermediate
caching is disabled automatically when combined with link-time
optimization.
Default: False.
ptx : bool, optional
Emit PTX after linking instead of CUBIN; only supported with ``link_time_optimization=True``.
Expand Down Expand Up @@ -198,6 +200,8 @@ class LinkerOptions:
Default: 1.
no_cache : bool, optional
Do not cache the intermediate steps of nvJitLink.
This is also enabled automatically for incremental links that use
link-time optimization.
Default: False.
numba_debug : bool, optional
Non-functional. ``numba_debug`` is an NVVM/NVRTC *compiler* option;
Expand Down
11 changes: 9 additions & 2 deletions cuda_core/cuda/core/_linker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ class LinkerOptions:
incremental : bool, optional
Perform an incremental link. The result can be passed
directly to a later :class:`Linker`. Requires nvJitLink 13.2 or newer
and is not supported by the driver linker backend.
and is not supported by the driver linker backend. Intermediate
caching is disabled automatically when combined with link-time
optimization.
Default: False.
ptx : bool, optional
Emit PTX after linking instead of CUBIN; only supported with ``link_time_optimization=True``.
Expand Down Expand Up @@ -316,6 +318,8 @@ class LinkerOptions:
Default: 1.
no_cache : bool, optional
Do not cache the intermediate steps of nvJitLink.
This is also enabled automatically for incremental links that use
link-time optimization.
Default: False.
numba_debug : bool, optional
Non-functional. ``numba_debug`` is an NVVM/NVRTC *compiler* option;
Expand Down Expand Up @@ -431,7 +435,10 @@ class LinkerOptions:
options.append(f"-split-compile={self.split_compile}")
if self.split_compile_extended is not None:
options.append(f"-split-compile-extended={self.split_compile_extended}")
if self.no_cache is True:
# Repeated incremental LTO links can crash in nvJitLink's intermediate
# cache (reproduced with 13.4.92 on Windows). Avoid reusing cached
# state for each incremental stage.
if self.no_cache is True or (self.incremental and self.link_time_optimization):
options.append("-no-cache")

if as_bytes:
Expand Down
13 changes: 13 additions & 0 deletions cuda_core/tests/test_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ def test_linker_options_incremental_as_bytes(value, expected_count):
assert options.as_bytes().count(b"-r") == expected_count


@pytest.mark.agent_authored(model="gpt-6")
@pytest.mark.skipif(is_culink_backend, reason="as_bytes() only supported for nvjitlink backend")
def test_linker_options_incremental_lto_disables_cache():
options = LinkerOptions(arch="sm_80", incremental=True, link_time_optimization=True)
assert b"-no-cache" in options.as_bytes()

options = LinkerOptions(arch="sm_80", incremental=True)
assert b"-no-cache" not in options.as_bytes()

options = LinkerOptions(arch="sm_80", link_time_optimization=True)
assert b"-no-cache" not in options.as_bytes()


@pytest.mark.parametrize("backend", ("invalid", "driver"))
def test_linker_options_as_bytes_invalid_backend(backend):
"""Test LinkerOptions.as_bytes() with invalid backend"""
Expand Down
Loading