@@ -344,17 +344,20 @@ def _linker_backend_and_version() -> tuple[str, str]:
344344def _nvvm_fingerprint () -> str :
345345 """Stable identifier for the loaded NVVM toolchain.
346346
347- NVVM lacks a direct version API (nvbugs 5312315), but ``ir_version()``
348- reports the IR major/minor/debug pair the toolchain emits -- enough to
349- keep pre-/post-upgrade caches separate. Paired with the driver and
350- cuda-core versions already in the digest, this is a practical substitute
351- for a true libNVVM version.
347+ Combines the libNVVM library version (``cuda.bindings.nvvm.version()``)
348+ with the IR version reported by ``ir_version()``. The library version is
349+ the primary invalidation lever: a libNVVM patch upgrade can change
350+ codegen while keeping the same IR major/minor, so keying only on the IR
351+ pair would silently reuse stale entries. Paired with cuda-core, the IR
352+ pair adds defence in depth without making the key any less stable.
352353 """
354+ from cuda .bindings import nvvm
353355 from cuda .core ._program import _get_nvvm_module
354356
355- nvvm = _get_nvvm_module ()
356- major , minor , debug_major , debug_minor = nvvm .ir_version ()
357- return f"ir={ major } .{ minor } .{ debug_major } .{ debug_minor } "
357+ module = _get_nvvm_module ()
358+ lib_major , lib_minor = nvvm .version ()
359+ major , minor , debug_major , debug_minor = module .ir_version ()
360+ return f"lib={ lib_major } .{ lib_minor } ;ir={ major } .{ minor } .{ debug_major } .{ debug_minor } "
358361
359362
360363def _cuda_core_version () -> str :
@@ -1083,8 +1086,11 @@ class FileStreamProgramCache(ProgramCacheResource):
10831086 ``cuda.core`` patch releases because every entry's key encodes
10841087 the relevant backend/compiler/runtime fingerprints for its
10851088 compilation path (NVRTC entries pin the NVRTC version, NVVM
1086- entries pin the NVVM IR version, PTX/linker entries pin the
1087- chosen linker backend, its version, and the driver version).
1089+ entries pin the libNVVM library and IR versions, PTX/linker
1090+ entries pin the chosen linker backend and its version -- and,
1091+ when the cuLink/driver backend is selected, the driver version
1092+ too; nvJitLink-backed PTX entries are deliberately driver-version
1093+ independent).
10881094
10891095 Parameters
10901096 ----------
0 commit comments