Skip to content

Commit 0789bf6

Browse files
rparolinclaude
andcommitted
test(cuda.core): share one DummyUnifiedMemoryResource per batched test
Both batched-advise tests previously created a throwaway DummyUnifiedMemoryResource per allocation inside a list comprehension: bufs = [DummyUnifiedMemoryResource(device).allocate(size) for _ in range(2)] The Buffer holds a reference to the throwaway MR via mr=self, so the MR should stay alive — but on CUDA 12.9.1 CI test_batched_same_advice fails with bufs[0] showing ptr=0x0 size=0 (the post-close state). On CUDA 13 the same pattern works. Switch to one MR shared across both allocations. This is cleaner anyway and removes the throwaway-per-iteration pattern as a possible source of the cu12 issue. If the failure persists, we'll know the MR lifetime wasn't the cause. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 782f6a9 commit 0789bf6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

cuda_core/tests/test_memory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,8 @@ def test_batched_same_advice(self, init_cuda):
22422242
device = Device()
22432243
_skip_if_managed_location_ops_unsupported(device)
22442244
device.set_current()
2245-
bufs = [DummyUnifiedMemoryResource(device).allocate(_MANAGED_TEST_ALLOCATION_SIZE) for _ in range(2)]
2245+
mr = DummyUnifiedMemoryResource(device)
2246+
bufs = [mr.allocate(_MANAGED_TEST_ALLOCATION_SIZE) for _ in range(2)]
22462247
advise(bufs, "set_read_mostly")
22472248
for buf in bufs:
22482249
assert (
@@ -2260,7 +2261,8 @@ def test_batched_per_buffer_location(self, init_cuda):
22602261
device = Device()
22612262
_skip_if_managed_location_ops_unsupported(device)
22622263
device.set_current()
2263-
bufs = [DummyUnifiedMemoryResource(device).allocate(_MANAGED_TEST_ALLOCATION_SIZE) for _ in range(2)]
2264+
mr = DummyUnifiedMemoryResource(device)
2265+
bufs = [mr.allocate(_MANAGED_TEST_ALLOCATION_SIZE) for _ in range(2)]
22642266
advise(
22652267
bufs,
22662268
"set_preferred_location",

0 commit comments

Comments
 (0)