@@ -634,15 +634,19 @@ def _probe(label: str, fn):
634634 cuda_core_ver = _probe ("cuda_core" , _cuda_core_version )
635635 if cuda_core_ver is not None :
636636 _update ("cuda_core" , cuda_core_ver .encode ("ascii" ))
637- driver_ver = _probe ("driver" , _driver_version )
638- if driver_ver is not None :
639- _update ("driver" , str (driver_ver ).encode ("ascii" ))
640637 if backend == "nvrtc" :
641638 nvrtc_ver = _probe ("nvrtc" , _nvrtc_version )
642639 if nvrtc_ver is not None :
643640 nv_major , nv_minor = nvrtc_ver
644641 _update ("nvrtc" , f"{ nv_major } .{ nv_minor } " .encode ("ascii" ))
645642 elif backend == "linker" :
643+ # Only the linker (PTX inputs) actually invokes the driver for
644+ # codegen via cuLink, so the driver version belongs only here.
645+ # Keying NVRTC/NVVM on the driver would invalidate caches across
646+ # benign driver upgrades that don't affect compiled bytes.
647+ driver_ver = _probe ("driver" , _driver_version )
648+ if driver_ver is not None :
649+ _update ("driver" , str (driver_ver ).encode ("ascii" ))
646650 linker = _probe ("linker" , _linker_backend_and_version )
647651 if linker is not None :
648652 lb_name , lb_version = linker
@@ -1046,6 +1050,30 @@ class FileStreamProgramCache(ProgramCacheResource):
10461050 partially-written entry. There is no cross-process LRU tracking; size
10471051 enforcement is best-effort by file mtime.
10481052
1053+ .. note:: **Best-effort writes.**
1054+
1055+ On Windows, ``os.replace`` raises ``PermissionError`` (winerror
1056+ 32 / 33) when another process holds the target file open. This
1057+ backend retries with bounded backoff (~185 ms) and, if still
1058+ failing, drops the cache write silently and returns success-shaped
1059+ control flow. The next call will see no entry and recompile. POSIX
1060+ and other ``PermissionError`` codes propagate.
1061+
1062+ .. note:: **Atomic for readers, not crash-durable.**
1063+
1064+ Each entry's temp file is ``fsync``-ed before ``os.replace``, but
1065+ the containing directory is **not** ``fsync``-ed. A host crash
1066+ between write and the next directory commit may lose recently
1067+ added entries; surviving entries remain consistent.
1068+
1069+ .. note:: **Cross-version sharing.**
1070+
1071+ ``_FILESTREAM_SCHEMA_VERSION`` guards on-disk format changes: a
1072+ cache written by an incompatible version is wiped on open. Within
1073+ a single schema version, the cache is safe to share across
1074+ ``cuda.core`` patch releases because every entry's key already
1075+ encodes ``cuda_core``, NVRTC, NVVM, driver, and linker fingerprints.
1076+
10491077 Parameters
10501078 ----------
10511079 path:
0 commit comments