Skip to content

A bad swarm sidecar on one rank is refused on every rank, before anything is restored (#974) - #1146

Merged
lmoresi merged 2 commits into
developmentfrom
bugfix/swarm-sidecar-collective-974
Nov 13, 2026
Merged

lmoresi merged 2 commits into
developmentfrom
bugfix/swarm-sidecar-collective-974

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #974. A reviewer from the desks with capacity, as the hub assigns.

What and why

A disk snapshot's swarm data is a per-rank sidecar. Its checks were made by each rank on its own sidecar: the rank count, the rank, the mesh name, the variable set, and each variable's shape. They also came late, after the mesh variables had been restored and after the rank had cleared its own particles.

So a sidecar damaged on one rank raised a ValueError there, while the other ranks returned from load_state as if the restore had succeeded. In the probe, one row was dropped from rank 1's sidecar at np 2: rank 0 returned and rank 1 raised.

Now the sidecars are read and checked in the same step as the restore's other checks, the step #1041 added for the meshes and variables. That happens before anything is restored, and the verdict is agreed with _agreed_problem (#1050's refuse-on-every-rank contract). Every rank raises the same error, naming the failing rank, and the model is left as it was. A variable's shape is checked against the number of particles the sidecar will re-add. The restore then applies the payloads it has already checked.

Only checkpoint/disk_snapshot.py changes. _read_swarm_from_sidecar is split into _read_swarm_sidecar_checked (read and check, rank-local) and _apply_swarm_sidecar. The new _checked_swarm_sidecars runs in the pre-check.

Tests

tests/parallel/test_0974_swarm_sidecar_refused_everywhere_parallel.py. A model with a mesh variable and a swarm variable is saved and then changed. One row is dropped from the last rank's sidecar, and load_state is called under a timeout. Every rank must raise the same error, and the mesh variable, the swarm variable and the particle count must be as they were before the call.

  • On development, one rank raises and the other returns: [None, "swarm variable 's' shape mismatch ..."].
  • On this branch, it passes at np 2, 3 and 4, with test_0020's disk swarm restore.

The serial snapshot files (every test file using save_state, load_state or disk_snapshot) give 210 passed and 1 xfailed.

Review round 1 (H6)

Medium 1. The read and check caught only OSError and KeyError, so a sidecar whose coordinates were a scalar (an IndexError), or whose variable was an HDF5 group (a TypeError), raised on its own rank before the agreement, and the job hung at np 2. Now any failure in reading or checking this rank's sidecar is reported as that rank's problem into the agreed verdict.

Medium 2. A sidecar that lacked one of the swarm's variables was accepted, and that rank's variable was left unrestored. The variable set is now checked both ways.

Low. Coordinates must have the swarm's dimension, and a variable's dtype must cast into the swarm variable's.

The test now covers four kinds of damage to the last rank's sidecar: a row dropped, scalar coordinates, a variable made a group, and a variable missing. At np 2, 3 and 4 every rank raises the same error and nothing is restored; on the previous head the new cases hang. The test's timeout uses the thread method, because a signal timeout cannot interrupt a rank blocked in a collective.

Underworld development team with AI support from Claude Code

…hing is restored (#974)

A disk snapshot's swarm sidecars are per rank, and their checks (the rank
count, the variable set, each variable's shape) were made by each rank on
its own sidecar, after the mesh variables had been restored and after the
rank had cleared its particles: a sidecar damaged on one rank raised there
while the others returned from load_state as if the restore had succeeded.
The sidecars are now read and checked with the other restore checks
(#1041's), before anything is restored, and the verdict is agreed
(_agreed_problem): every rank raises the same error, carrying the failing
rank, and the model is left as it was. A shape is checked against the
count of the particles the sidecar will re-add.

Test: one row dropped from the last rank's sidecar, np 2-4: every rank
raises the same error, and the mesh variable, the swarm variable and the
particle count are untouched. On development one rank raised and the
other returned.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 13, 2026 08:25

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

… variable set both ways

H6's review: _read_swarm_sidecar_checked caught only OSError and KeyError,
so a sidecar whose coordinates were a scalar (IndexError) or whose variable
was an HDF5 group (TypeError) raised on its rank before the agreement, and
the job hung at np 2. Reading and checking now cannot raise: any failure is
reported as that rank's problem into the agreed verdict. A sidecar lacking
one of the swarm's variables was accepted and that rank's variable left
unrestored; the variable set is now checked both ways. Coordinates must
have the swarm's dimension, and a variable's dtype must cast into the
swarm's.

Tests: four damages to the last rank's sidecar (a row dropped, scalar
coordinates, a variable made a group, a variable missing), np 2-4: every
rank raises the same error, nothing restored; d1acb3d hangs. The timeout
uses the thread method, which a blocked collective cannot stop.

Underworld development team with AI support from Claude Code
@lmoresi
lmoresi merged commit 3279cf9 into development Nov 13, 2026
10 checks passed
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