Skip to content

Commit c250c92

Browse files
rparolinclaude
andcommitted
fix(test): reset _V2_BINDINGS cache so legacy-signature tests take the legacy path
The _V2_BINDINGS cache in _buffer.pyx persists across tests, so monkeypatching get_binding_version alone is insufficient when earlier tests have already populated the cache with the v2 value. Promote _V2_BINDINGS from cdef int to a Python-level variable so tests can monkeypatch it directly via monkeypatch.setattr, and reset it to -1 in both legacy-signature tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ae1de36 commit c250c92

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

cuda_core/cuda/core/_memory/_buffer.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ cdef unsigned long long _MANAGED_OPERATION_FLAGS = 0
124124
# Lazily cached values for immutable runtime properties.
125125
cdef object _CU_DEVICE_CPU = None
126126
cdef dict _ADVICE_ENUM_TO_ALIAS = None
127-
cdef int _V2_BINDINGS = -1
127+
_V2_BINDINGS = -1
128128
cdef int _DISCARD_PREFETCH_SUPPORTED = -1
129129

130130

cuda_core/tests/test_memory.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,7 @@ def fake_cuMemAdvise(ptr, size, advice, location):
13141314
return (driver.CUresult.CUDA_SUCCESS,)
13151315

13161316
monkeypatch.setattr(_buffer, "get_binding_version", lambda: _LEGACY_BINDINGS_VERSION)
1317+
monkeypatch.setattr(_buffer, "_V2_BINDINGS", -1)
13171318
monkeypatch.setattr(_buffer.driver, "cuMemAdvise", fake_cuMemAdvise)
13181319

13191320
managed_memory.advise(buffer, "set_read_mostly")
@@ -1338,6 +1339,7 @@ def fake_cuMemPrefetchAsync(ptr, size, location, hstream):
13381339
return (driver.CUresult.CUDA_SUCCESS,)
13391340

13401341
monkeypatch.setattr(_buffer, "get_binding_version", lambda: _LEGACY_BINDINGS_VERSION)
1342+
monkeypatch.setattr(_buffer, "_V2_BINDINGS", -1)
13411343
monkeypatch.setattr(_buffer.driver, "cuMemPrefetchAsync", fake_cuMemPrefetchAsync)
13421344

13431345
managed_memory.prefetch(buffer, device, stream=stream)

0 commit comments

Comments
 (0)