Repository navigation
Commit 68f832c
committed
test(cuda.core): request init_cuda for memory resource tests
Tests that allocate through Device.memory_resource /
Device.allocate or construct any memory resource without init_cuda did
Device() + set_current() by hand, leaving a stale cached
default MemoryResource on the thread-local Device: no teardown
gc.collect(), no cuCtxSynchronize, and the context never popped.
The stale slot is the aliasing route for the planned
live-resource-count gc.collect() gate, and the tests violate the
tests/AGENTS.md rule that constructing a memory resource counts as
touching CUDA.
Route both groups onto init_cuda (using the yielded device) so the
fixture teardown clears the cached slot via del _tls.devices:
- device.memory_resource allocators: 6 test_from_buffer* functions in
test_utils.py and test_buffer_external_device in test_memory.py.
- resource constructors: 28 functions in test_memory.py (buffers,
dlpack, vmm, pinned/managed ipc, legacy pinned, abstract stubs)
and 4 launch-scalar tests in test_launcher.py.
test_buffer_external_device and test_buffer_external_pinned_alloc still
select Device(n - 1) as before; init_cuda only supplies the context
and teardown. The no-context tests (test_close_with_default_stream_requires_context,
test_from_handle_mr_default_stream_requires_context) keep their no_current_context()
body. Assertions are unchanged.
Add a sentence to tests/AGENTS.md that allocating through
device.memory_resource or Device.allocate, or constructing any memory
resource, counts as touching CUDA and requires init_cuda.1 parent 106da2f commit 68f832c
4 files changed
Lines changed: 75 additions & 100 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | | - | |
| 247 | + | |
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
262 | 261 | | |
263 | 262 | | |
264 | 263 | | |
| |||
592 | 591 | | |
593 | 592 | | |
594 | 593 | | |
595 | | - | |
596 | | - | |
597 | | - | |
| 594 | + | |
| 595 | + | |
598 | 596 | | |
599 | 597 | | |
600 | 598 | | |
| |||
825 | 823 | | |
826 | 824 | | |
827 | 825 | | |
828 | | - | |
| 826 | + | |
829 | 827 | | |
830 | 828 | | |
831 | 829 | | |
| |||
836 | 834 | | |
837 | 835 | | |
838 | 836 | | |
839 | | - | |
840 | | - | |
| 837 | + | |
841 | 838 | | |
842 | 839 | | |
843 | 840 | | |
| |||
939 | 936 | | |
940 | 937 | | |
941 | 938 | | |
942 | | - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
943 | 942 | | |
944 | 943 | | |
945 | 944 | | |
| |||
948 | 947 | | |
949 | 948 | | |
950 | 949 | | |
951 | | - | |
952 | | - | |
| 950 | + | |
953 | 951 | | |
954 | 952 | | |
955 | 953 | | |
| |||
0 commit comments