Skip to content

test(cuda.core): cover the forkserver start method for VMM IPC buffers - #3124

Open
Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/vmm-ipc-forkserver-test
Open

Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/vmm-ipc-forkserver-test

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

Summary

The VMM IPC tests from #3028 ran under spawn only. forkserver is safe after CUDA initialization because the forkserver is a fresh interpreter and children fork from it, not from the test process, and it is the Linux default start method since Python 3.14. Its Popen collects file descriptors during pickling and sends them afterwards, like spawn, so the Process-argument path in VirtualMemoryBuffer.__reduce__ has to work there too. This PR adds the tests that confirm it.

Changes

  • tests/memory_ipc/test_vmm_ipc.py: new TestForkserver class with two tests under mp.get_context("forkserver"): a VirtualMemoryBuffer passed as a Process argument, and the same buffer sent through a Queue. Each child reads the parent's fill pattern and writes one back. The class skips where forkserver is unavailable (Windows).

Related Work

Closes #3111. Suggested by @juenglin in the #3028 review.

🤖 Generated with Claude Code

The forkserver is a fresh interpreter and children fork from it, so it
is safe after CUDA initialization, and it is the Linux default since
Python 3.14. Its Popen collects file descriptors during pickling and
sends them afterwards, like spawn, so the Process-argument path in
VirtualMemoryBuffer.__reduce__ has to work there too. Add a Process
argument test and a Queue round trip under mp.get_context("forkserver"),
skipped where that start method is unavailable.

Closes NVIDIA#3111

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Andy-Jost Andy-Jost added this to the cuda.core 1.3.0 milestone Oct 15, 2026
@Andy-Jost Andy-Jost added enhancement Any code-related improvements P2 Low priority - Nice to have cuda.core Everything related to the cuda.core module labels Oct 15, 2026
@Andy-Jost Andy-Jost self-assigned this Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuda-python/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 4b14af62-c166-42fb-b4e7-4f96f3859686
📥 Commits

Reviewing files that changed from the base of the PR and between 2224499 and 219be4f.

📒 Files selected for processing: 1
  • cuda_core/tests/memory_ipc/test_vmm_ipc.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Tests
    • Expanded validation of shared-memory communication between processes using the forkserver start method. Coverage now checks that processes can receive shared buffers directly or through queues, read and update shared data, and exit cleanly. These checks run only on platforms that support forkserver, helping ensure consistent behavior across supported environments.

The VMM IPC tests now cover forkserver child processes that receive buffers as process arguments or through a queue. The tests verify child reads, shared writes, and clean child exit. They skip when forkserver is unavailable.

Changes: Forkserver VMM IPC coverage

Layer / File(s) Summary
Process-argument transfer
cuda_core/tests/memory_ipc/test_vmm_ipc.py
A forkserver child receives the buffer as a process argument, reads the parent’s data, writes to the shared buffer, and closes it. The parent checks the write and child exit.
Queue buffer transfer
cuda_core/tests/memory_ipc/test_vmm_ipc.py
A forkserver child receives the buffer through a queue, reports its data, writes to the shared buffer, and closes it. The parent checks the write and child exit.

Assessment against linked issues

Objective Addressed Explanation
Add forkserver VMM IPC tests for process arguments and queues, skipping where forkserver is unavailable [#3111] ✅

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to 219be

The new forkserver tests are mergeable after normal checks; no blocking issue was identified.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

@Andy-Jost
Andy-Jost requested a review from juenglin October 15, 2026 22:19
"""The conftest forces ``spawn``; a forkserver context passes descriptors the same way and must work too."""

@pytest.mark.agent_authored(model="claude-sonnet-5-5")
def test_process_argument(self, vmm_ipc_device):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this test checks the data round trip, but not that the parent's file descriptors are released. The spawn counterpart, test_process_argument_releases_with_the_process_object, also checks that the open file descriptor count returns to its baseline once the Process object is released. The same check under forkserver would catch a stash that outlives the Process.

It would need thread_unsafe (it counts process-wide file descriptors) and _settled_open_fds() for the baseline. Start the forkserver before taking the baseline (for example with one throwaway process), because its first start leaves a permanent file descriptor open in the parent.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda.core Everything related to the cuda.core module enhancement Any code-related improvements P2 Low priority - Nice to have

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cuda.core: test VMM IPC under the forkserver start method

2 participants