Skip to content

test(cuda.core): synchronize IPC buffer initialization - #2657

Open
Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/ipc-peer-access-sync
Open

test(cuda.core): synchronize IPC buffer initialization#2657
Andy-Jost wants to merge 1 commit into
NVIDIA:mainfrom
Andy-Jost:ajost/ipc-peer-access-sync

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

Description

Follow-up to #1308.

Synchronize the exporting device after asynchronously initializing the IPC buffer and before spawning the importing process. CUDA IPC does not carry the exporter's stream ordering into the importer, so the previous test could access the allocation before its initialization completed and compare stale data.

Keep the existing flaky reruns because they cover general multiprocessing timeouts on busy CI runners, independently of this ordering race. The targeted test requires two peer-accessible, IPC-capable GPUs and is left to CI for validation.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Ensure the exporting process completes asynchronous allocation and initialization before an importing child accesses the shared buffer.
@Andy-Jost Andy-Jost added this to the cuda.core 1.2.0 milestone Aug 17, 2026
@Andy-Jost Andy-Jost added bug Something isn't working P0 High priority - Must do! cuda.core Everything related to the cuda.core module labels Aug 17, 2026
@Andy-Jost Andy-Jost self-assigned this Aug 17, 2026
@github-actions

Copy link
Copy Markdown

@Andy-Jost
Andy-Jost requested a review from rwgk August 18, 2026 16:50
@Andy-Jost Andy-Jost added P1 Medium priority - Should do test Improvements or additions to tests and removed bug Something isn't working P0 High priority - Must do! labels Aug 18, 2026
@@ -82,6 +82,8 @@ def test_main(self, ipc_mempool_device_x2, grant_access_in_parent):
buffer = mr.allocate(NBYTES, stream=dev1.default_stream)

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.

codex gpt-5.6-sol ultra found:

This allocates asynchronously on dev1.default_stream, while PatternGen(dev1, ...) creates a separate nonblocking stream and initializes the buffer there. The later dev1.sync() waits for both streams, but does not establish allocation-before-copy ordering. CUDA defines that cross-stream access as undefined unless explicitly ordered. CUDA documentation (https://docs.nvidia.com/cuda/cuda-programming-guide/04-special-topics/stream-ordered-memory-allocation.html).

I’d use one stream throughout:

        stream = dev1.default_stream
        buffer = mr.allocate(NBYTES, stream=stream)
        pgen = PatternGen(dev1, NBYTES, stream=stream)
        pgen.fill_buffer(buffer, seed=False)
        stream.sync()

That also avoids a device-wide barrier.

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 P1 Medium priority - Should do test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants