Skip to content

Commit 7b04eac

Browse files
committed
test(cuda.core): use shared memory resource instrumentation
Keep the deallocation-stream tests aligned with the centralized test helper merged in NVIDIA#2624.
1 parent 82a8088 commit 7b04eac

1 file changed

Lines changed: 5 additions & 28 deletions

File tree

cuda_core/tests/test_memory.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -516,30 +516,6 @@ def test_mr_deallocate_receives_stream():
516516
assert telemetry["deallocations"][-1]["stream"].handle == stream.handle
517517

518518

519-
class _StreamCaptureMemoryResource(MemoryResource):
520-
def __init__(self, device):
521-
self.device = device
522-
self.deallocation_streams = []
523-
524-
@property
525-
def is_device_accessible(self):
526-
return True
527-
528-
@property
529-
def is_host_accessible(self):
530-
return False
531-
532-
@property
533-
def device_id(self):
534-
return self.device.device_id
535-
536-
def allocate(self, size, *, stream):
537-
raise NotImplementedError
538-
539-
def deallocate(self, ptr, size, *, stream):
540-
self.deallocation_streams.append(stream)
541-
542-
543519
@pytest.mark.agent_authored(model="gpt-5.6")
544520
@pytest.mark.parametrize(
545521
("configuration", "destruction"),
@@ -559,7 +535,8 @@ def test_buffer_deallocation_stream_configuration_paths(configuration, destructi
559535
device.set_current()
560536
initial_stream = device.create_stream()
561537
target_stream = device.create_stream()
562-
mr = _StreamCaptureMemoryResource(device)
538+
CapturingMR, telemetry = make_instrumented_memory_resource(record_streams=True)
539+
mr = CapturingMR(device)
563540

564541
stream = target_stream if configuration == "initialization" else initial_stream
565542
buf = Buffer.from_handle(1, 1024, mr=mr, stream=stream)
@@ -575,16 +552,16 @@ def test_buffer_deallocation_stream_configuration_paths(configuration, destructi
575552
del buf
576553
gc.collect()
577554

578-
assert len(mr.deallocation_streams) == 1
579-
assert mr.deallocation_streams[0].handle == target_stream.handle
555+
assert len(telemetry["deallocations"]) == 1
556+
assert telemetry["deallocations"][0]["stream"].handle == target_stream.handle
580557

581558

582559
@pytest.mark.agent_authored(model="gpt-5.6")
583560
def test_set_deallocation_stream_rejects_none_and_closed_buffer():
584561
device = Device()
585562
device.set_current()
586563
stream = device.create_stream()
587-
mr = _StreamCaptureMemoryResource(device)
564+
mr = StubMemoryResource(device)
588565
buf = Buffer.from_handle(1, 1024, mr=mr, stream=stream)
589566

590567
with pytest.raises(TypeError, match="stream is required"):

0 commit comments

Comments
 (0)