feat(agent): package the cuinterpose shim and coordinator - #212
galletas1712 wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueComment |
f56c837 to
624b6cc
Compare
624b6cc to
be3cdea
Compare
4ac3fb5 to
4eef8f4
Compare
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>
4eef8f4 to
d7e380d
Compare
|
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? |
|
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. |
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/Makefilebuildslibcuinterpose.sowithout linking CUDA, builds a staticcuinterpose-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-cudafor restore.protocol.hdefines the fixed header and state-record layouts, participant and allocation identity, diagnostics, and the final operation vocabulary:Allocation content is represented generically by
ALLOCATION_CONTENTandCONTENT_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_RIGHTSdescriptor. They suppressSIGPIPE, 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 underagent/cmd/cuinterpose/util/; feature modules keep domain-specific logic.Stack boundary
Based on
main. The next PR, #213, deliverscuda-checkpointand 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 testpasses 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
0eae9c4f9b66093332f00a332afaf56048e1e64apassed the fullmake checkgate, 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, exercisedBindAddr, and passed its collective and captured-graph replay. Detailed hardware evidence and measurements are in #220.