Skip to content

Commit b5827ef

Browse files
Andy-Jostclaude
andcommitted
test(cuda.core): mark the VMM re-export test thread-unsafe
TestReexport._derived asserts that a grow moved the buffer after a decoy took the adjacent range. Under pytest-run-parallel another thread can free that range between the decoy attempt and the grow, so the grow extends in place and the assertion fails. Mark the test thread_unsafe like the other address-probing tests in the file. Also record in VMM_DESIGN.md the numbers behind the no-cache export rule and the age of the multiprocessing machinery the Process path relies on. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent f87e5c5 commit b5827ef

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎cuda_core/cuda/core/_cpp/rt/VMM_DESIGN.md‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,19 @@ exists, in every process that holds one, and nothing else does. The exporting
239239
buffer keeps no descriptor: `ipc_descriptor` exports again on every access and
240240
returns a new descriptor that owns one file descriptor per allocation, and
241241
`VirtualMemoryBuffer.__reduce__` builds a transient one while `multiprocessing`
242-
pickles the buffer, so a sender holds no file descriptors between sends. One
242+
pickles the buffer, so a sender holds no file descriptors between sends. The
243+
numbers set that rule: PyTorch's expandable segments grow in 2 MB to 20 MB
244+
chunks, so a buffer of several GB holds several hundred allocations, against a
245+
default process limit of 1024 file descriptors. One
243246
transport needs more: a `Queue`, `Pipe`, or `Pool` duplicates the file
244247
descriptors while pickling (the resource sharer), but a spawned `Process`
245248
records their numbers during pickling and passes them to the child only when
246249
it is created (`spawnv_passfds`), so `__reduce__` keeps the transient
247250
descriptor on the spawning `Popen` object, which dies with the `Process`
248251
object. Without that, the numbers are reused by the spawn's own pipes
249-
("bad value(s) in fds_to_keep") or the child imports a stranger's fd. The
252+
("bad value(s) in fds_to_keep") or the child imports a stranger's fd. That
253+
machinery (`spawnv_passfds`, `get_spawning_popen()`) has not changed since
254+
Python 3.4 (2014). The
250255
driver copies
251256
each shared allocation into a handle of its own during the import and keeps no
252257
reference to the file descriptor, so the imported buffer does not keep the

‎cuda_core/tests/memory_ipc/test_vmm_ipc.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def _derived(mr, imported, gran):
470470
return derived
471471

472472
@pytest.mark.agent_authored(model="claude-fable-5-1")
473+
@pytest.mark.thread_unsafe(reason="checks mapping state by address; another thread can reuse a freed address")
473474
def test_export_and_pickling_raise_before_any_driver_call(self, vmm_ipc_device):
474475
device = vmm_ipc_device
475476
stream = device.default_stream

0 commit comments

Comments
 (0)