Skip to content

feat(agent): join a pod group's coordination session - #826

Open
galletas1712 wants to merge 22 commits into
coordinator-natsfrom
schwinns/agent-group-member
Open

galletas1712 wants to merge 22 commits into
coordinator-natsfrom
schwinns/agent-group-member

Conversation

@galletas1712

@galletas1712 galletas1712 commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • enhancement

What this PR does / why we need it:

SNEP-324 runs the capture or restore of each Pod of a pod group as one member's part in the group's. Every member joins the attempt's coordination session, exchanges an admission with the others, and passes the group's barriers. #762 serves those sessions and ships the client. This PR is the agent's side of it: the group member, and the points in the capture and restore flows where a member synchronizes with the others.

The group member. The new package agent/internal/group joins the attempt's session through #762's coordinator client. The member's rank is the session's (Session.Rank).

  • Admit publishes the member's admission under admit.<rank> in the snapshot namespace and returns once it has every member's. An admission carries the member's Pod IP now, at capture its Pod UID and captured container, and at restore the ID of the capture its artifact belongs to. Members that restore different captures refuse the attempt, and so does a member whose Pod IP is not IPv4, since restore is IPv4 only. Admit waits for the others until the session's deadline plus the client's slack, so the coordinator's own DeadlineExceeded ends a late attempt, and it keeps at most two waits open at once, within the coordinator's per-member watch budget.
  • PeerIPs maps every other member's IP at capture to its IP now, from the members' IPs that the restore's artifact recorded and the admissions. Nothing in this PR uses it yet. The TCP change on top of this PR does.
  • Barrier waits for every member at a barrier.
  • Fail ends the attempt for every member, with Refused (session.ReasonRefused, shared with the coordinator) before the member calls the admitted barrier and MemberFailed once it has, since its arrival may have been recorded even if the call fails. From the attempt's deadline on, by the member's clock, Fail does not fail the attempt. It waits for the session to end, until the deadline plus the client's slack and one more second, so the coordinator's DeadlineExceeded stands even if the member's clock runs ahead. Leave records that the member is done and keeps the connection until the session ends.

Capture. A capture request takes an optional group member.

  • The member is admitted once every check that changes nothing has passed, including the multi-GPU job file and the CRIU configuration, right before the capture starts. It publishes its admission, then passes the admitted barrier, after which the attempt commits.
  • The manifest records the group as SNEP-324's Appendix D defines it, under podGroup: a version, the capture UID (the PodGroupSnapshot's UID), the member's ID, and the member table, whose index is the rank, with each member's ID, Pod UID, containers and Pod IP.
  • The member passes net-freeze after CUDA's checkpoint and before the CRIU dump, so no member's network freezes while another member still needs it.

Restore. A restore request takes an optional group member.

  • The member is admitted once the agent's checks of the placeholder pass, including the GPU context. It refuses an artifact that was captured on its own, that is another member's part, or whose member table does not match the session's members. It then publishes its new Pod IP and the capture it restores, and passes admitted.
  • Once its processes are restored and validated, the member passes release, so no member is released before every member is reconstructed.
  • SNEP-324 also puts a resume barrier before release. It orders CUDA Checkpoint's resume phase, in which libraries reconnect, after every member has rebuilt its shared memory. The agent does not run that phase yet: nsrestore restores and unlocks CUDA on its own, as for a single Pod. So a resume barrier here would pass right before release with nothing between them. It comes with the change that runs the resume phase.

Recording that the member started. Capture and restore requests take an optional RecordMemberStarted callback. The executor calls it right after the admitted barrier and before the member's first irreversible step, so the caller can record that the member started: the Started condition at capture, and RestoreStarted at restore (#934 sets it). An error fails the attempt with MemberFailed, and leaves this member as Snapshot found it. A nil RecordMemberStarted records nothing.

Timing. The timing summary of a member's capture or restore gets a group phase: the time spent at admission and at the group's barriers, mostly waiting for the other members. Without it, that wait showed as unaccounted, for example 12.6 s of a 15.8 s restore.

A failed capture or restore fails the attempt for every member, also when the executor panics. A pod group member's checkpoint restores only with its group, so a restore on its own refuses it. A restore that only failed its cleanup has released its member, so it does not. Three steps are new, "admitting the pod group", "recording that the member started" and "waiting for the pod group's other members", each with a troubleshooting entry in #930 or #972.

A Pod captured or restored on its own takes none of this and behaves exactly as today.

Build. The agent module now depends on the coordinator module, through a replace like the one for api. The agent image build gets it as a named build context, coordinator, next to api. The operator module gets the same replace, since it depends on the agent module.

Which issue(s) this PR fixes:

Part of #614. Stacked on #762. Tracking issue: #324. Design: #325 (Group checkpoint, Group restore).

How was this tested?

  • Unit tests against a real coordinator: feat(coordinator): serve coordination sessions from embedded NATS #762's coordinatortest starts one in the test process with TLS, and each member joins through feat(coordinator): serve coordination sessions from embedded NATS #762's client.
    • Three members admit at once and each sees every admission by rank. PeerIPs maps the other members' capture-time IPs to their new ones, and refuses a capture with a different member count. All three leave.
    • Two members that restore different captures both refuse admission.
    • A member that fails ends another member's barrier wait with Refused before the admitted barrier and with MemberFailed after it.
  • The executor refuses an artifact captured on its own, another member's artifact, the member's artifact at another rank, and a member table of another size.
  • Executor tests with two members in one session: a step that fails before admission ends the attempt as Refused and the peer never passes admitted. A dump failure, a mount failure after the commit, and a panic after the commit end it as MemberFailed. RecordMemberStarted runs between the admitted barrier and the first irreversible step at capture and at restore, and a RecordMemberStarted that fails stops the member there and ends the attempt as MemberFailed. An IPv6 Pod IP is refused at capture and at restore, and a group member's checkpoint restored on its own is refused.
  • Executor tests that reach the later barriers, with two members in one session. At capture, the member dumps only once a late peer arrives at net-freeze, and a peer that fails instead stops it at "waiting for the pod group's other members" with MemberFailed and no dump. At restore, the steps after release run only once a late peer arrives, and a peer that fails instead fails the member at that step with no restored process. Both tests fail if a barrier is removed or moved after the step it guards.
  • A member that fails just past the deadline, before or after the commit, while the coordinator's clock runs 500 ms behind, leaves the attempt to end as DeadlineExceeded for every member.
  • A member whose admitted wait timed out after its arrival fails the attempt as MemberFailed. Admit keeps at most two waits open, each until the deadline plus the client's slack. The manifest's podGroup section round-trips through YAML with SNEP-324's keys.
  • go build ./... in the agent and operator modules, in workspace mode and with GOWORK=off (the module mode the agent image builds in). go vet and go test of internal/executor, internal/group, internal/types and internal/controller. golangci-lint v2.14.0 on the agent module: 0 issues. go test -race of internal/executor and internal/group in a Linux container. go test -race of the whole of internal/group, internal/executor and internal/types again after the review fixes. hack/verify-troubleshooting-steps.sh passes once merged with main, which has the entries from docs(troubleshooting): document the pod group steps of capture and restore #930, and with those from docs(troubleshooting): document pod group start, step order and causes #972.
  • End to end, the whole stack (feat(coordinator): serve coordination sessions from embedded NATS #762, this PR, feat(agent): keep TCP connections between restored group members #801, feat(agent): serve the cuInterpose relay's session socket #827, feat(cuinterpose): restore FABRIC memory across the Pods of a group #824 and feat(cuinterpose): relay a Pod's coordinator through the group session #825) ran as one build. A small PoC layer stood in for the group controllers: it joins the member from Pod annotations and runs a development coordinator.
    • GB300: a two-Pod CPU group with TCP and ZeroMQ connections between the members, captured on two nodes and restored with the nodes swapped. Both members joined, exchanged admissions, passed admitted and net-freeze at capture and admitted and release at restore, and left. Each barrier took under 2 ms. The images were built from that commit.
    • Vera Rubin: the same TCP group, and a two-Pod symmetric memory group across two nodes with 4 GPUs each, which shares FABRIC unicast and multicast memory through the cuInterpose relay. Both passed in place and with the nodes swapped.
    • The runs above used this PR before its rebase onto feat(coordinator): serve coordination sessions from embedded NATS #762's current head, which changed only how the member reads its rank and how the tests start their coordinator. The group timing phase was added after the runs, to account for the wait they showed.
  • End to end on AWS GB300 with the final stack and the operator's PodGroupSnapshot and PodGroupRestore in place of the PoC layer (the DeepSeek V4.1 Flash run on GB300 described in feat(cuinterpose): relay a Pod's coordinator through the group session #825). Both members joined the session as ranks 0 and 1, passed admitted and set Started on their PodSnapshotContents in two group captures. Three group restores committed, set nvidia.com/RestoreStarted, wrote restore-complete with the PodGroupRestore's UID and released both members. The coordinator logged Session closed for every attempt. No attempt reached its deadline, so the deadline path ran only in the unit tests.
  • make check was not run locally. CI's Validate repository job runs the full make check, and it passes.
  • End to end on AWS GB300 again on December 1, with the public driver package. The nodes ran the stock 580.173.02 driver, and the workload, PageBroker, cuda-checkpoint-helper and the agent's nvidia-smi all loaded libcuda.so.620.70.06 from cuda-compat-13-5. The build was an integration of feat(agent): wire the agent into pod-group captures and restores #934, feat(operator): add the PodGroupRestore controller #858, feat(agent): join a pod group's coordination session #826 (6d43fd3), feat(agent): keep TCP connections between restored group members #801 (809e3c4), feat(agent): serve the cuInterpose relay's session socket #827 (587df98) and feat(cuinterpose): relay a Pod's coordinator through the group session #825 (9543e5d). It used feat(operator): add the PodGroupRestore controller #858 from before its November 30 API change, which feat(agent): wire the agent into pod-group captures and restores #934 does not build against yet, three fix commits for feat(agent): wire the agent into pod-group captures and restores #934 (the RecordMemberStarted rename among them), and one test-only workaround, because the cluster's shared podsnapshotcontents CRD is older and drops spec.podGroup. The two-Pod DeepSeek V4.1 Flash set was captured as a pod group twice and restored five times, three of them onto two other nodes, and four greedy answers matched byte for byte every time. Each member's restore took 16.3 to 16.9 s. Every restore remapped both Pod IPs, held 34 kept connections per member, passed the NVLink fabric check, and ran its relay over the session socket. The agent ran one nvidia-smi fabric query per node per restore, for all of the node's GPUs. Decode after restore was 191 to 234 tok/s against 230 before. A controlled follow-up confirmed the cause named above and narrowed it: with --no-numa-bind, decode speed depends on whether a Pod's two TP workers run on the same CPU socket, which a restore does not preserve (Preserve and remap per-worker CPU affinity and NUMA placement across restore #548). With each Pod's workers pinned to one socket, the source and three restores all ran at 230 to 231 tok/s, and their GPU kernel times matched within about 2%.

Special notes for your reviewer:

Does this PR introduce an API change?

NONE

Additional documentation, e.g. enhancement proposals, usage docs:

SNEP-324: docs/proposals/324-multi-pod-snapshot-restore (#325)
#930: docs/troubleshooting/checkpoints.md and restores.md, admitting the pod group and waiting for its other members (merged)
#972: docs/troubleshooting/checkpoints.md and restores.md, recording that the member started, and a member's checkpoint restored on its own (this PR also carries #930's and #972's entries, so `make check` passes without them)
#931: docs/overview/architecture-overview.md, agent/internal/group

Checklist

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor
Pre-merge checks: Passed 2

Check name Status Explanation
Breaking Api Changes Passed PR #826 (ai-dynamo/snapshot, author galletas1712, base coordinator-nats, head schwinns/agent-group-member) changes no files under api/ that this PR introduces. Evidence: - The local checkout is detach…
Rbac Least Privilege Passed The check fails only if a kubebuilder RBAC marker or Helm RBAC manifest grants wildcard verbs or resources without a justification comment. I found no such grant in the checked-out PR head (6d43fd3, t…
Full details: Breaking Api Changes

Explanation

PR #826 (ai-dynamo/snapshot, author galletas1712, base coordinator-nats, head schwinns/agent-group-member) changes no files under api/ that this PR introduces. Evidence: - The local checkout is detached at 6d43fd3. Its merge-base with main is 5f52a5e. git diff --stat main...HEAD -- api/ is empty. - The PR branch merged coordinator-nats at 96ece98. git diff --stat 96ece98^2 HEAD -- api/ is empty, and so is 96ece98^1 HEAD -- api/. So the PR's own commits add no api/ change on top of coordinator-nats. - A two-dot git diff main HEAD -- api/ shows changes. Those come from main, which has api/ commits that coordinator-nats lacks. They are not PR changes. The 96ece98^2 -&gt; main diff shows the same set. Against the check: - No existing exported field is removed, renamed, retyped, or has its json tag changed. No api/ hunk exists to inspect. - No new field is added, so the // +optional and +kubebuilder:default rule is not triggered. - No XValidation immutability marker on PodSnapshotSpec or PodSnapshotContentSpec is changed. The PR body also states "Does this PR introduce an API change? NONE", which matches the diff evidence. Limit: the coordinator-nats tip is not present locally. The conclusion rests on the merge-base and merge-parent diffs above, which show no api/ change in the PR's commit range.

Full details: Rbac Least Privilege

Explanation

The check fails only if a kubebuilder RBAC marker or Helm RBAC manifest grants wildcard verbs or resources without a justification comment. I found no such grant in the checked-out PR head (6d43fd3, the provider-reported head of PR #826). - Kubebuilder markers: every +kubebuilder:rbac marker in operator/internal/controller/ (podsnapshot_reconciler.go, snapshotcontent_reconciler.go, snapshotjob_reconciler.go) names explicit verbs and explicit resources. A search for * in kubebuilder RBAC markers returned no matches. - Helm manifests: charts/snapshot/templates/role.yaml, rolebinding.yaml, operator-rbac.yaml and openshift/rbac-privileged.yaml contain no * character. - PR scope: the PR description covers the new agent/internal/group package, executor barriers, the manifest podGroup section, a go.mod replace and a Dockerfile build context. It does not describe RBAC changes. The commits at the checked-out head touch only agent/internal/executor files (checkpoint.go, restore.go, group_test.go). Limitation: the base branch coordinator-nats is not in the local clone, so I could not produce the full PR diff against its base. The RBAC-related result does not depend on that diff, because no wildcard grant exists anywhere in the checked-out RBAC markers or manifests. Any RBAC change in the unseen part of the diff would also need a wildcard to trigger this check, and none is present at head.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@julienmancuso

Copy link
Copy Markdown
Contributor

A heads-up for the rest of #614, from the PodGroupRestore controller I'm about to start. It reads one more thing from a restore member's Pod, and the SNEP now defines it (#325, API and Appendix D).

nvidia.com/Restored keeps its public reasons, so ClassifyRestoreOutcome reads a group restore like a single one. That leaves no place for a reason of the group, so it goes on a new Pod condition, nvidia.com/GroupRestoreFailed (podcontract.GroupRestoreFailedCondition):

  • When to set it: to True when the member fails for the session's reason (MemberFailed, CoordinatorLost, DeadlineExceeded, Cancelled, Refused) or for one of the agent's group checks (PodIPChanged, GateBudgetTooShort), with that reason and a message.
  • How: in the same status update as Restored (False, RestoreFailed), and never removed.
  • When not to: a member that fails on its own leaves it unset and sets Restored alone, as a single restore does.

Restored stays the only signal that the member failed; the controller takes the reason from GroupRestoreFailed when it is set, and from Restored otherwise. The constant lands with the controller PR; nothing in this PR needs to change.

Separately, this PR is stacked on #762 at 6822d10d. #762's third round changed the client API it uses:

  • Session.Namespace(ns) became Snapshot(), CuInterpose() and Library();
  • the server's ErrInvalid and ErrNotFound aliases are gone, in favor of session.ErrInvalid and session.ErrNotFound;
  • Config gained a Clock.

So a rebase onto the current coordinator-nats will need small edits.

@julienmancuso

Copy link
Copy Markdown
Contributor

A follow-up to my note on nvidia.com/GroupRestoreFailed: the restore Pod contract changed, and one point of that note is reversed. The SNEP has the details (#325, Group restore, API and Appendix D), and #614 lists the agent's part.

A restore Pod can now serve several attempts in turn, so its binding and its reports both name an attempt by UID:

  • The owner binds a Pod by name and UID: nvidia.com/restore-group, as before, plus nvidia.com/restore-group-uid, set once the PodGroupRestore exists. The exact pair is the attempt that may act on the Pod. Serve a target only while it is bound to the attempt you serve.

  • Each report carries its attempt. Publish RestoreStarted, Restored and GroupRestoreFailed only together with nvidia.com/restore-group-report-uid: <PodGroupRestore UID>. Both go in one update of the Pod's status subresource, which also accepts annotations. The operator reads a report only when that annotation holds its own attempt's UID.

  • Switching attempts replaces the whole report. The first report for a new attempt sets Restored and removes the earlier attempt's GroupRestoreFailed in that same write. This reverses my earlier "never remove it".

  • RestoreStarted is never removed or relabelled. Never report for a new attempt on a Pod that carries it under another UID, or under none. The operator refuses such a Pod anyway.

  • Every write is fenced, RestoreStarted included.

    • Check the Pod's UID and its binding against the attempt.
    • Make the write conditional on the resourceVersion you read.
    • After a conflict, read again and check again before retrying.

    A rebinding, or a PodGroupRestore recreated under the same name, then invalidates every outstanding write of the earlier attempt.

One helper should publish every report, so no path can bypass these rules. Please test it against a real API server on Kubernetes 1.32 and the newest supported version, covering:

  • a switch of attempt over a partial earlier report;
  • conflicting writes;
  • a same-name recreation while a write is outstanding;
  • a permanent RestoreStarted;
  • the kubelet's conditions, which every write keeps.

The two annotation constants land with #811. Nothing in this PR needs to change before that.

@galletas1712
galletas1712 force-pushed the schwinns/agent-group-member branch from 8c1b613 to fc147c3 Compare November 6, 2026 20:15
julienmancuso added a commit that referenced this pull request Nov 9, 2026
The agent image now carries /usr/local/bin/snapshot-coordinator, which
the agent's Pod will run in a container of its own, with its own
command; there is no separate image.

- agent/Dockerfile builds it in a coordinator-builder stage of its own,
  from the coordinator module and its own go.mod, with the api and
  coordinator modules copied side by side from their named build
  contexts, on go-base's toolchain image. go-base is unchanged.
- The image's compliance steps cover the coordinator module's Go
  dependencies as they cover the agent's: that stage vendors them, the
  sources stage ships them at /legal/source/go/coordinator/vendor, and
  THIRD-PARTY.txt gains a section for them, which go-licenses.sh's new
  optional argument names "snapshot-coordinator". The agent's section
  and the operator's are unchanged.
- AGENT_BUILD_FLAGS passes the coordinator build context, with the line
  #826 adds, so the two changes merge cleanly.
- coordinator/.dockerignore keeps make build's bin/ out of that context.
- The root Makefile's test-integration comment named the operator only;
  the coordinator's tests run there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Julien Mancuso <jmancuso@nvidia.com>
@galletas1712
galletas1712 force-pushed the schwinns/agent-group-member branch 2 times, most recently from 83725b4 to 8bfc1d1 Compare November 11, 2026 07:40
@julienmancuso

Copy link
Copy Markdown
Contributor

A heads-up on the restore Pod contract, which changed so that one Pod template can serve every replica of a group (#325 has the details, and #614 lists the agent's part):

  • nvidia.com/restore-group is gone. A group target is marked by nvidia.com/restore-group-snapshot, and names its destination in nvidia.com/restore-container-map, which holds exactly one pair. Both are set at creation and fixed for the Pod's lifetime.
  • The NRI plugin acts on those two annotations only, with no API read: it makes the restore proxy the destination container's PID 1, and fails the creation of a marked Pod without a valid map.
  • The operator now writes the binding, nvidia.com/restore-group-uid, at admission. The plugin never reads it, since the sandbox's annotations are frozen at creation; the restore queue reads it from its Pod informer.
  • Report fencing checks the UID alone. The rest of the report identity is unchanged: restore-group-report-uid, one conditional status write, and a permanent RestoreStarted.
  • Restore only into the container the plugin prepared. A container that no longer matches the pin fails the member with PodIPChanged.

The shared parsing of the marker and the map lands in api/podcontract with #811, so the plugin and the operator use the same helper.

@julienmancuso

Copy link
Copy Markdown
Contributor

A heads-up on the restore Pod contract for group targets, which changed again (#325 has the details, and #614 lists the agent's part). The nvidia.com/restore-group-snapshot marker from the previous revision is gone.

  • Group targets arrive gated. A group restore Pod carries the scheduling gate nvidia.com/restore-group from creation, so it is never scheduled before the operator claims it.
  • The operator claims the Pod in one update. The update writes the binding, nvidia.com/restore-group-uid, and the target's single-pair nvidia.com/restore-container-map, projected from the PodGroupRestore's containerMappings, and removes the gate.
  • The NRI plugin acts on those two annotations only, with no API read. They are on the Pod before its sandbox exists. On the binding, it makes the restore proxy the mapped container's PID 1, and it fails the creation of a bound Pod without a valid single-pair map.
  • On a node without the NRI plugin, a group target follows the standalone rule: the destination's own command must be inert, and the agent restores without the proxy.
  • A claimed Pod serves one attempt only. restore-group-report-uid is gone, along with report replacement across attempts. Reports stay fenced: check the Pod UID and the binding, and make one status update conditional on the resourceVersion. RestoreStarted is still permanent.
  • Restore only into the container the plugin prepared. A container that no longer matches the pin fails the member with PodIPChanged.

The shared reader for the binding and the single-pair map lands in api/podcontract with #811, so the plugin and the operator use the same helper.

A member of a pod group runs its capture or restore as its part in the
group's, as SNEP-324 describes. The new package agent/internal/group
joins the attempt's session through the coordinator module's client,
takes the member's rank from the session, exchanges the members'
admissions, maps the other members' capture-time IPs to their current
ones, passes the group's barriers, and fails or leaves the attempt.

The executor takes an optional group member on a capture or restore
request. A capture admits the group after its own checks and before
anything changes the source, records the capture ID, the member, its
rank and every member's Pod IP in the manifest, and passes net-freeze
before the CRIU dump. A restore checks that its artifact is the member's
own part of a group capture, admits the group with its new Pod IP and
the capture it restores, and passes release once its processes are
restored. A failed capture or restore fails the attempt for every
member, with Refused before the admitted barrier and MemberFailed after.
The timing summary of a group member's capture or restore reports the
time spent in the group's admission and barriers as its own phase,
mostly waiting for the other members, so it no longer lands in
unaccounted. A Pod captured or restored on its own is unchanged.

The agent module now depends on the coordinator module, so the agent
image build gets it as a named build context, as it gets the api module.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
…ssion

A capture admitted its group before it staged and checked the CUDA job
file and configured the dump, and a restore admitted its group before it
built the GPU context for PageBroker. These steps only read the source,
the artifact or the placeholder, or write to the capture's own staging,
yet they ran after the admitted barrier. A member that failed one of
them, such as a multi-GPU capture without its job file, then failed the
attempt with MemberFailed after every other member had started, instead
of refusing it.

A capture now admits its group right before it checkpoints the GPU
state and dumps, and a restore right before it mounts into the
placeholder, so every one of these checks fails the attempt with
Refused and leaves every member as Snapshot found it. The capture
records the group's section of the manifest once admitted, and the
dump writes the manifest again with it.

Tests run a member's capture and restore against a two-member session:
a step before admission fails the attempt with Refused before the peer
passes the admitted barrier, and a step after the commit fails it with
MemberFailed.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A member counted as committed only once its own call to the admitted
barrier returned. An arrival that the coordinator recorded stays
recorded even when the call then fails, for example when its context
ends or its connection drops, and the other members may then pass the
barrier and start. Such a member then failed the attempt with Refused,
although some of its peers had already changed their workloads.

A member now counts as committed as soon as it calls the admitted
barrier, so a failure after that call always fails the attempt with
MemberFailed.

A test stops a member's wait at the admitted barrier after its arrival,
lets the peer pass the barrier, and checks that the member's failure
reaches the peer as MemberFailed.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
julienmancuso pushed a commit that referenced this pull request Nov 19, 2026
On 2026-11-17 the implementation stack (#811 to #934 with #824, #973,
#825, #826, #827 and #801) captured a two-Pod DeepSeek V4.1 Flash vLLM
group on GB300 twice and restored it in place three times, with
byte-identical greedy outputs. Each tensor-parallel worker imported 68 to
76 FABRIC handles exported by the other Pod.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
julienmancuso pushed a commit that referenced this pull request Nov 22, 2026
Match the SNEP to #826 and #827:

- An agent fails the session with Refused until its member calls the
  admitted barrier, and with MemberFailed from then on. It gives a
  relay's failure the same reason, whatever reason the relay names.
- From the deadline on, an agent fails nothing and waits for the
  session to end, so a clock ahead of the coordinator's never replaces
  DeadlineExceeded.
- At restore, a member contributes its new Pod IP, the capture ID and
  whether it runs a relay, and no Pod or container identity.
- A Pod IP that is not IPv4 refuses a capture.

Figures 5 and 8 show the reason each agent uses.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
julienmancuso pushed a commit that referenced this pull request Nov 22, 2026
On 2026-11-17 the implementation stack (#811 to #934 with #824, #973,
#825, #826, #827 and #801) captured a two-Pod DeepSeek V4.1 Flash vLLM
group on GB300 twice and restored it in place three times, with
byte-identical greedy outputs. Each tensor-parallel worker imported 68 to
76 FABRIC handles exported by the other Pod.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
g.SetLimit(2)
for rank := range admissions {
g.Go(func() error {
value, err := m.agent.Get(gctx, admitKey(rank), wait)

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.

Can each agent fetch all admission records from NATS in one batch? With 16 Pods, each agent makes 16 separate Get calls, for 256 calls total. A batch read would bring that down to 16 calls. We can keep one record per rank and the same admission checks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The session client in #762 has only a per-key Get, so a batch needs a new read there, for example a prefix read of admit.* that returns once every rank's record is present. @julienmancuso, would you be open to adding one to the session store? Once it exists, this PR switches to it with the same per-rank records and checks. Each agent's admission reads then become one call, and the limit of two reads at once goes away.

Comment thread agent/internal/group/member.go Outdated
// Barrier returns once every member has arrived at the barrier name.
func (m *Member) Barrier(ctx context.Context, name string) error {
if name == Admitted {
m.committed.Store(true)

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.

Can the coordinator classify a member failure using the order of events in NATS? If NATS records the failure before the last admitted arrival, report Refused. If it records the last arrival first, report MemberFailed, since a Pod may already have started. This can wait until after alpha unless a caller needs to act differently on the two results.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, and the coordinator is the right place, since it sees the global order. Today each member decides from its own view: Refused until it calls admitted, and MemberFailed after. So a member that called the barrier and then failed reports MemberFailed even when no other member had arrived. As you suggest, we'll leave it for after alpha, and I've added it to the follow-ups in #984.

// runs, with no CUDA process to checkpoint.
originalDump := dumpCheckpointFunc
t.Cleanup(func() { dumpCheckpointFunc = originalDump })
dumpCheckpointFunc = func(context.Context, *criurpc.CriuOpts, *types.CRIUSettings, *types.CheckpointManifest,

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.

Can we add a two-Pod end-to-end test for staggered CRIU dumps? Open a TCP connection between the Pods with keepalive enabled. Let both Pods pass net-freeze, then let A finish its real CRIU dump while B waits. Dump B, restore both Pods, and check that data flows both ways over the original connection without reconnecting. That would exercise the capture-side timeout risk in #577.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, that is the right test for #577. It needs the pod group stack on main, because the e2e suite drives a group capture through a PodGroupSnapshot, so we'll add it in a follow-up once #934 merges. The plan: two CPU Pods with a TCP connection that has keepalive on. A dumps while B is held after net-freeze, then B dumps, both restore, and data flows both ways on the original connection without reconnecting. We'll run it with B's wait inside and beyond the keepalive budget. We expect the second case to fail today, because keepalive keeps running at capture and only restore turns it off. If it does, the fix is to turn keepalive off for kept connections at net-freeze as well, and record which ones had it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test is now case 4 of #1297, which tracks the two-node pod group e2e suite. No pull request adds that suite yet, and the SNEP lists it among the alpha criteria.

// processes, and keeps it dropped after the dump ends them. A repeated
// dump needs no second barrier: every member is already past those steps.
barrierStart := time.Now()
if err := g.Barrier(ctx, group.NetFreeze); err != nil {

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.

The group has a deadline, and the CRIU dump call takes no context from the agent. If the deadline passes while CRIU is still writing the checkpoint, do we let it finish or stop it? What state should we leave the source Pod and its network in?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We let CRIU finish, and 717e89b says why at the dump call. go-criu runs criu swrk with no context, and killing it partway could leave the source frozen in its cgroup or holding CRIU's parasite code, with the Pod's network still locked.

  • After a successful dump, CRIU kills the source tree, because LeaveRunning is false. It keeps its iptables lock in the Pod's network namespace, so peers see dropped packets rather than resets, as after any capture.
  • If the dump fails, CRIU resumes the tree and unlocks the network, and the agent then ends the source because the member has started.
  • Past the deadline, the capture fails at the PageBroker commit, the first step after the dump that takes the context, and the coordinator ends the session as DeadlineExceeded.

The one gap was the staged dump, which stayed on the node until PageBroker reaped it about two hours later. A pod group member now releases it (fd203dd), and TestGroupCheckpointThatDumpsPastTheDeadlineReleasesTheDump covers that.

Comment thread agent/internal/executor/checkpoint.go Outdated
// first irreversible step, so the caller can record that the member
// started. An error fails the attempt: the barrier has passed, so with
// session.ReasonMemberFailed. Nil records nothing.
Committed func(context.Context) error

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.

I had to trace three meanings of committed. The callback records that a member started. The local flag tracks whether its artifact was committed. The member flag is set just before the Admitted call. Would RecordMemberStarted for the callback and enteredAdmitted for the member flag make this easier to follow?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 8b93aa4. The callback is now RecordMemberStarted on both requests, and the member's flag is enteredAdmitted. I kept the local committed in checkpoint, since it is set only once PageBroker has committed the artifact. When #934 merges this again it needs the new name in controller.go, podsnapshotcontent.go and podgroup_restore_test.go.

Comment thread agent/internal/executor/group_test.go Outdated
outcome.err = ctx.Err()
}
}
_ = peer.Fail(ctx)

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.

The success case checks that the local restore waits at release and then returns successfully. runLatePeer calls Fail after it passes release, so the session can still end as MemberFailed. Is that intentional test cleanup? A comment by Fail would make that clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was cleanup, not intended, and it did end the session as MemberFailed after both members succeeded. In 2d0a9e5 the peer leaves once it passes its last barrier, and the test leaves for the member after its restore succeeds, as the real caller does. The success cases now check that the session closed with every member done. A peer that fails still calls Fail.

galletas1712 added a commit that referenced this pull request Nov 30, 2026
Document what the multi-node snapshot PRs add, so their code changes can
land without docs changes:

- The cuInterpose design gains FABRIC handles: they stay real at runtime,
  the shim records each export and import, and each importer imports the
  creator's new handle during restore. It also describes how the
  coordinator validates the Pods of a group as one topology, the relay
  rounds over the group's coordination session, and the coordinator's
  group arguments. MNNVL sharing moves from unsupported to needing the
  agent to run each Pod's coordinator in a group.
- The architecture overview lists agent/internal/group.

The text is the one reviewed in #824, #825, #826 and #827.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
Comment thread agent/internal/executor/checkpoint.go Outdated
// No member's network freezes while another member still has a step
// that needs it. CRIU then drops the Pod's traffic once it freezes the
// processes, and keeps it dropped after the dump ends them. A repeated
// dump needs no second barrier: every member is already past those steps.

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.

Should group retries stay disabled until we test a failed first dump with two Pods and an open TCP connection? The failed Pod can lose its network hold before retrying, after the other Pod has already dumped.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. In 6d43fd3 a group member ignores its retry budget, and a failed dump fails the attempt. A test gives a member a budget of three and a dump that always fails, and checks that it dumps once and never records its tree to repeat. It fails without the change.

No member repeated by default before this either, since checkpoint.defaultRetryLimit is 0. But #934 passes a PodSnapshot's budget on to its group members, so a group could have opted in. The SNEP now says members do not repeat (fd28542 on #325). We can lift this once a two-Pod test with an open TCP connection shows that a repeat keeps the members consistent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #1298, so the condition for turning repeats back on does not live only in a code comment. The test is case 5 of #1297.

Comment thread agent/internal/executor/restore.go Outdated
}
// A restore that only failed its cleanup has released its member.
if retErr != nil && !errors.As(retErr, new(*RestoreCleanupError)) {
failGroup(ctx, log, req.Group)

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.

Can the agent report the failure to the group as soon as the operation fails? A CPU PageBroker abort can currently take up to 30 seconds before that call runs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in fdc28a9, on both capture and restore. The call that fails the attempt is now deferred after the cleanup, so it runs first, and the other members learn of the failure before the PageBroker abort, the unmounts and the GPU teardown. Two tests hold the first cleanup step until the peer has seen MemberFailed. The trade-off is that if the coordinator is unreachable, the up to 30 s of Fail now delays this member's own cleanup rather than its peers.

A reviewer had to trace three meanings of committed. The request callback
records that the member started, the member's flag says it called the
admitted barrier, and the capture's local flag says its artifact was
committed.

The callback on the capture and restore requests is now
RecordMemberStarted, and recordMemberStarted calls it. The member's flag
is now enteredAdmitted. The capture's local flag keeps its name, since it
is set only once PageBroker has committed the artifact. The tests that
check the record are renamed to match.

Callers that set Committed on CheckpointRequest or RestoreRequest set
RecordMemberStarted instead.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A test peer called Fail once its part was over, whether or not it had
failed. After a peer that passed release or net-freeze, that ended the
session as MemberFailed, although both members succeeded. Nothing checked
the session's end, so the tests passed either way.

A peer that passes its last barrier now leaves the attempt, as its agent
would, and so does the member once its capture or restore succeeded. The
peer's outcome is how its Leave returned, so the success cases now check
that the session closed with every member done. A peer that fails, or that
the attempt's end stopped, still calls Fail.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A reviewer asked what happens when a pod group's deadline passes while
CRIU is still dumping. go-criu runs criu swrk with no context, so nothing
stops the dump, and nothing should. CRIU freezes the cgroup, seizes every
task and injects its parasite. Killing it partway would leave the tree in
whichever of those states it had reached, with CRIU's network lock still
in the Pod's network namespace.

So CRIU finishes. A dump that succeeds kills the tree, as LeaveRunning is
false, and keeps the network lock, as after any capture. One that fails
resumes the tree and unlocks the network. Either way, the capture fails at
the commit, the first step after the dump that takes the capture's context.

The comment at the dump says this, and the troubleshooting entry for the
commit step names the deadline as a cause.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A capture keeps a completed dump when its commit fails in a way that may
clear, or cannot dial PageBroker. A pod group member whose dump outlasts
the attempt's deadline lands there: its caller bounds the capture's
context by the deadline, CRIU takes no context and finishes, and the
commit then cannot dial. The staged dump stayed on the node until
PageBroker reaped the transaction, two hours later by default.

Nothing could publish that dump. The member's failure fails the attempt,
which never runs again, and the member's artifact restores only with its
group. A pod group member's failed capture now releases its staged dump.
The abort runs on its own context, so it reaches PageBroker past the
deadline. A capture of a Pod on its own keeps the dump as before.

A test runs a member whose dump outlasts the deadline. Its capture fails
at the commit, the dump is released, and the attempt ends as
DeadlineExceeded.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A reviewer asked whether a member could report its failure to the group as
soon as its capture or restore fails. Failing the attempt was deferred
first, so it ran last, after the member's own cleanup. A PageBroker abort
alone can take 30 seconds, and the other members waited at their next
barrier for all of it.

The deferred call that fails the attempt now comes after the cleanup, so
it runs first. A capture sets up its PageBroker release before any step
that can fail, so every failure still fails the attempt. A restore that
fails only in its cleanup has passed the release barrier, and it still
does not fail the attempt, since the cleanup's errors reach the result
after the check. Nothing in the cleanup has to happen before the other
members learn of the failure. The restore-failed marker is still written
before the restore returns.

Two tests hold the member's first cleanup step until the peer has seen
the attempt end as MemberFailed, for a capture whose dump fails and for a
restore whose staging mount fails. Both fail with the old order.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
A reviewer asked whether a pod group member should repeat a failed dump
before a test covers it with two Pods and an open TCP connection. A
member spent its capture's retry budget like any other capture.

When a dump fails, CRIU unlocks the Pod's network and resumes its
processes. A peer that has already dumped stays behind its own lock.
While the member waits to repeat, keepalive or an application timeout
could close a connection on its side only, and the restore would keep
that connection on the peer's side.

A member now ignores the retry budget, and a failed dump fails the
attempt. The budget still applies to a capture outside a pod group. A
test gives a member a budget of three and a dump that always fails, and
checks that the member dumps once and never records its process tree to
repeat. It fails without the change.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
galletas1712 added a commit that referenced this pull request Nov 30, 2026
The proposal let a member repeat its dump after the commit, and said its
network stays frozen while it does. It does not: when a dump fails, CRIU
unlocks the Pod's network and resumes its processes, while a peer that has
already dumped stays behind its own lock. A connection could then close on
one side only, and the restore would keep it on the other.

A member now ignores its retry budget, and a failed dump fails the group
(#826). Repeats wait for a test with two Pods and an open TCP connection.

Signed-off-by: Schwinn Saereesitthipitak <schwinns@nvidia.com>
// dump fails the attempt.
retriesRemaining = 0
barrierStart := time.Now()
if err := g.Barrier(ctx, group.NetFreeze); err != nil {

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.

The net-freeze wait can return success after the member’s context has already ended. A loopback test hit this and the executor still called the CRIU dump function. Can we check the context just before starting the dump? A dump that already started can finish as before.

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.

Please add the regression case where NetFreeze has already recorded a successful release and the capture context expires before CRIU starts. Check that the agent never calls the dump hook. The existing test covers a dump that was already running when the deadline passed.

@dfeigin-nv dfeigin-nv left a comment

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.

Group member tests and failure reporting.

asked = "commit"
response.Result = &pagebroker.Response_CommitComplete{CommitComplete: &pagebroker.CommitComplete{}}
default:
asked = "abort"

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.

I sent PageBroker Capabilities in place of Abort, and all three cleanup tests still passed. Please make Abort an explicit case and have the fake fail the test on an unexpected request.


// A session of the coordinator cannot show how many waits a member has at
// once, so this test counts them in a Store of its own.
func TestAdmissionWaitsTwoAtATimeUntilTheSessionEnds(t *testing.T) {

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.

The fake answers each read after 10 ms and never ends the session. I’d name this test for the two checks it makes. It checks at most two admission reads in flight and the requested timeout.

// Deferred after the release of the dump, so it runs first: the other
// members learn of the failure without waiting for the PageBroker
// abort, which alone can take pageBrokerAbortTimeout.
defer func() {

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.

Capture and restore use the same deferred block to tell peers about an error or panic. I’d have both defer the same function directly, in the current order, so peers still hear about the failure before local cleanup.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants