Repository navigation
A disk snapshot restore writes swarm-variable values through to PETSc (#971) - #972
Conversation
_read_swarm_from_sidecar wrote the saved values into a detached numpy view (np.asarray(var.data)), so the DMSwarm field kept the values the re-added particles were given. Anything reading the field directly, or re-reading it after a cache invalidation, saw those instead: a run restarted with stress_transport="lagrangian" lost its stress history (the cells proxy reads PETSc; the first migrate() drops the cache). Write through var.data, as Swarm.apply_snapshot_payload already does for the in-memory path (#313). Found on the viscoelastic cylinder: a Lagrangian-stress restart dropped cd by ~1.2 (the polymer contribution); with the fix a res-20 restart matches the uninterrupted run to five figures. test_0012 checks the PETSc field and a post-invalidation read after load_state(file). Underworld development team with AI support from Claude Code Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Underworld development team with AI support from Claude Code Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Underworld development team with AI support from Claude Code
A proven regression test starts at tier B. The values the test sets up and compares go through .array (three-index shapes) rather than the flat .data; the PETSc field itself is still read through unpack_raw_data_from_petsc, which is what the test is about. On development's disk_snapshot.py both tests fail; with the write-through both pass. Underworld development team with AI support from Claude Code
Adversarial review of #972Verdict: ready. Reviewed head 338e899. The merge of development into the branch is clean, and the fix works at np 1, 2 and 4, including a rank with no particles. Nothing we tried breaks it. The findings are low severity; only the missing parallel test is worth acting on in this PR. Findings
Callbacks: writing through Attacks that failed
Issues
Merge conditionsNone required. Suggested: one Could not testRestore inside Underworld development team with AI support from Claude Code |
The sidecar is read per rank, so the restore is checked on every rank: the PETSc field after load_state(file), and a re-read after the canonical cache is dropped. Hyperion's review measured the same at np 2 and 4. The snapshot file is rank 0's temporary path, broadcast to all. Underworld development team with AI support from Claude Code
…m-values Underworld development team with AI support from Claude Code
A disk snapshot restore now writes swarm-variable values through to the PETSc field (#971).
The bug
checkpoint.disk_snapshot._read_swarm_from_sidecarrestored each swarm variable into a detached view:current = np.asarray(var.data); current[...] = saved. The DMSwarm field therefore kept the values the re-added particles were given. These readers saw those values instead of the saved ones:cellsproxy of the particle Lagrangian stress history, which reads the field directly;migrate()does after advection.So a run restarted from disk with
stress_transport="lagrangian"lost its stress history. On the viscoelastic cylinder, a Lagrangian-stress restart dropped cd by about 1.2, the polymer contribution. With the fix, a resolution-20 restart matches the uninterrupted run to five figures.The change
The restore writes through
var.data[...] = saved. That fires the pack callback to PETSc, as the in-memory restore (Swarm.apply_snapshot_payload) has done since #313. This is the raw variable-to-variable copy at the persistence boundary that.datais kept for.Tests
tests/test_0020_snapshot_disk_swarm_values.py(tier B, in shard 4'stest_00[0-4]*batch):load_state(file)the PETSc field holds the saved values;_invalidate_canonical_data().Against development eddab70's
disk_snapshot.py, both tests fail; on this branch both pass. The test sets its values up through.array.The fix was written on 2026-10-06. This branch merges development (eddab70) into it rather than rebasing.
Issues
A parallel case,
tests/parallel/test_0020_snapshot_disk_swarm_values_parallel.py, checks the restore on every rank (hyperion measured it at np 2 and 4: no mismatches, and a Lagrangian restart matching an uninterrupted run to about 1e-16).Underworld development team with AI support from Claude Code