Skip to content

feat(agent): package the cuinterpose shim and coordinator - #212

Closed
galletas1712 wants to merge 1 commit into
mainfrom
feat/cuinterpose-packaging
Closed

galletas1712 wants to merge 1 commit into
mainfrom
feat/cuinterpose-packaging

Conversation

@galletas1712

@galletas1712 galletas1712 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This is the first layer of the eleven-PR cuinterpose stack #293: #212#213#222#223#215#216#217#292#218#219#220. Closed PR #214 is intentionally not part of the active stack.

Cuinterpose lets Snapshot checkpoint and restore same-node CUDA memory shared between processes, including CUDA multicast objects. This PR establishes only the build, packaging, and shared wire contract. The shim and coordinator are placeholders at this layer.

agent/cmd/cuinterpose/Makefile builds libcuinterpose.so without linking CUDA, builds a static cuinterpose-coordinator, enforces hidden visibility and the glibc 2.34 ceiling, and discovers the fake-driver test suites added by later layers. The CUDA helper image installs CUDA 13.1 headers and packages both binaries under /snapshot-binaries/snapshot-cuda for restore.

protocol.h defines the fixed header and state-record layouts, participant and allocation identity, diagnostics, and the final operation vocabulary:

HANDSHAKE → INSPECT
capture: PREPARE_MULTICAST → SAVE_ALLOCATIONS → PREPARE_UNICAST
restore: LOAD_ALLOCATIONS → RESTORE_UNICAST → RESTORE_MULTICAST_*

Allocation content is represented generically by ALLOCATION_CONTENT and CONTENT_ONLY; host carriers are an implementation behind the save/load operations in #292 and #218. The protocol also reports live raw imports and unsupported exportable CUDA resource creations so #216 can refuse checkpoint before destructive work.

The bounded Unix-socket helpers support fixed messages, optional records, and one SCM_RIGHTS descriptor. They suppress SIGPIPE, reject malformed ancillary data, and close received descriptors on every error path. Generic arrays, cleanup, identity, I/O, parsing/randomness, tables/ranges, and timing are centralized under agent/cmd/cuinterpose/util/; feature modules keep domain-specific logic.

Stack boundary

Based on main. The next PR, #213, delivers cuda-checkpoint and the shim into workload containers. This layer does not inject the shim, discover participants, intercept CUDA, or execute lifecycle operations.

Validation

On the final stack, make test passes in all three Go modules. The pinned CUDA 13.1 builder compiles the production shared shim and static coordinator with -Werror, then passes 9 protocol, 9 table/cache, 6 utility, 14 coordinator, 12 forwarding, 4 lifecycle, 6 multicast, and 13 tracking tests with ASan/UBSan where configured.

The final published stack head 0eae9c4f9b66093332f00a332afaf56048e1e64a passed the full make check gate, the CUDA 13.1 production build, and all 73 sanitizer-backed native cuinterpose tests. Its physical-GPU suite passed all 3 tests with no skips on two DRA-assigned NVIDIA B200 GPUs. The unicast test kept an explicit allocation-ID ticket-backed peer mapping per worker live across capture and restore; the multicast test required a nonzero multicast VA and shim-logical handle, exercised BindAddr, and passed its collective and captured-graph replay. Detailed hardware evidence and measurements are in #220.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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

@galletas1712

Copy link
Copy Markdown
Contributor Author

Stack order (bottom to top):

@copy-pr-bot

copy-pr-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@galletas1712
galletas1712 force-pushed the feat/cuinterpose-packaging branch from 624b6cc to be3cdea Compare September 11, 2026 06:10
@galletas1712
galletas1712 removed this pull request from stack #221 September 11, 2026 06:11
@galletas1712
galletas1712 added this pull request to stack #293 September 11, 2026 06:11
@galletas1712
galletas1712 force-pushed the feat/cuinterpose-packaging branch 2 times, most recently from 4ac3fb5 to 4eef8f4 Compare September 11, 2026 06:41
cuinterpose is the CUDA interposer that lets Snapshot checkpoint and restore
CUDA memory shared between processes (tensor-parallel workers, NCCL,
FlashInfer, PyTorch symmetric memory) and CUDA multicast objects. This is
the first of eleven changes and carries only the shared build, packaging,
and protocol contract. Later changes deliver and preload the shim, connect
the agent, implement forwarding and coordination, track CUDA state, isolate
allocation-content storage, add unicast and multicast lifecycle behavior,
and exercise the result on real GPUs.

The Dockerfile's cuda-helper-builder stage installs CUDA 13.1 headers and
GoogleTest and runs `make all test` for agent/cmd/cuinterpose; the image
ships libcuinterpose.so and the static cuinterpose-coordinator and bundles
both under /snapshot-binaries/snapshot-cuda for the restore-time mount. The
Makefile is written once: every C file is part of the shim except
coordinator.c; tests are found by name; the shim exports only cu*, cuda*,
and dlsym, links with -z defs, and is held to the glibc 2.34 baseline.
protocol.h defines the fixed control messages, records, phases, identities,
and generic allocation save/load operations. The socket helpers provide
bounded I/O with descriptor passing and close descriptors on every malformed
message path.

The shim and coordinator are placeholders at this layer: the shim exports
its build information, while the coordinator reports that no implementation
is present. Loading the placeholder is harmless, and nothing invokes the
coordinator until the agent orchestration change.

Compared with the earlier scaffold (#110), everything is named cuinterpose,
the Dockerfile copies the source directory with build output ignored, the
tests run during the image build, and the placeholder image stage remains
untouched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
@dfeigin-nv

Copy link
Copy Markdown
Contributor

I think, when looking at the over 1000+ LOCs in https://github.com/ai-dynamo/snapshot/blob/b657304f6001902a595ce2775c792bd470101e38/agent/cmd/cuinterpose/coordinator.c in #216 , that using C has its downsides. Let's consider using C++ since we have some complex logic here?

@galletas1712

Copy link
Copy Markdown
Contributor Author

Superseded by the replacement 13-PR C-frontend/Rust-backend cuinterpose draft stack: https://github.com/ai-dynamo/snapshot/stack/339 (#326#338), tracking approved proposal #295. The new stack preserves one reviewable stage per PR, with tests collected in #338 and the design in #337. PageBroker transfer changes remain a separate dependency. Closing this older C implementation; retaining its branch and discussion for reference.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants