Skip to content

remap_var_set: skip a variable on every rank or none; stop swallowing a rank-local raise (#960) - #1142

Merged
lmoresi merged 6 commits into
developmentfrom
bugfix/remap-var-set-collective-skip
Nov 13, 2026
Merged

lmoresi merged 6 commits into
developmentfrom
bugfix/remap-var-set-collective-skip

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #960 Part 1: the mesh-move field transfer no longer lets one rank's failure pair the other ranks' evaluations with the wrong variables. Size S, remesh.py only. It does not touch solver defaults, petsc_generic_snes_solvers, rotated_bc.py or the custom multigrid.

From H1 (review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)), as the probe-pass S fix for #960. Branched from development 70b240c.

The defect

remap_var_set evaluates each REMAP variable at its new DOF coordinates with global_evaluate, which is collective. It skipped a variable on the rank where something went wrong, while the other ranks went into that variable's collectives. There were two such paths:

  • the new coordinates could not be read (target is None: continue);
  • the evaluation raised (except Exception: continue).

Measured at np 2 with a forced raise on rank 1: rank 1 skipped T and went on to S, and its collectives for S were matched against rank 0's for T. The ranks thus exchanged data belonging to different variables without any error, and then hung (record on #960).

The change

  1. Unreadable coordinates. Whether a variable's new coordinates are unavailable is reduced over the ranks, with one Allreduce before any evaluation starts, and such a variable is skipped on every rank. The callers pass a list, so vars_ has the same order on every rank.
  2. Each variable's outcome is agreed before the next one. The evaluation is still caught, but a failure no longer becomes a rank-local skip.
    • The failing rank prints its own error.
    • One Allreduce right after each evaluation tells every rank. A variable that failed anywhere keeps its pre-move values on every rank, and the move and the other variables complete.
    • remesh_with_field_transfer then raises the same RuntimeError on every rank. It does so after its hooks, the stale-vector mark and the move-version count, so the mesh is left consistent.
    • remap_var_set(raise_on_failure=False) returns the failed names instead, for callers that finish their own steps first.
    • Whether REMESH_MONOTONE applies is decided before the evaluation, from the expression alone: one MeshVariable or a component of one, with "pick" only on one rank. Every rank answers alike, so nothing is caught for a retry. A ValueError from the limiter on one rank used to send that rank alone into a second global_evaluate, which hung at np 2 (H4's probe). It is now a failure like any other.
    • remesh_with_field_transfer clears the failure list at the top of its outer call, so a list left by an earlier call cannot raise on a later one.
    • The DDt on_remesh hook calls remap_var_set(..., raise_on_failure=False) and records the failed names on the mesh. The hook dispatcher does not let a hook's exception through, so a failed history transfer used to be silent. It is now raised on every rank with the rest (H4's review).
    • This also covers Remesh limiter fails on a rank with too few DOFs, and that rank alone keeps its old values #994's rank-local IndexError in the opt-in clamp. That error comes after the collectives, so the variable now fails on every rank instead of being kept stale on one.

Not fixed here, by design: a raise on one rank BEFORE global_evaluate's collectives still leaves the other ranks waiting inside it.

  • The failing rank's message now reaches the output.
  • The job then ends only by a timeout or the MPI supervisor.
  • The cure is for global_evaluate to agree on a failure before each of its collective phases. The locator rewrite carries that as a requirement.
  • A flag reduced after the evaluation cannot cure that case: the failing rank's reduction would pair with one of the others' collectives.

Test

tests/test_0791_remap_var_set_rank_local_failure.py is a serial driver. It runs its five np 2 cases in subprocesses through scripts/mpi_supervisor.py with a 40 s silence limit, so a regression fails instead of hanging CI. The fixture: a 1/16 simplex box, with T (P2, a tanh front) and S (P1, linear), moved by a smooth interior deform.

case development 70b240c this branch
T's new coordinates unreadable on rank 1 fails: the ranks hang (rank 0 in get_max_radius, rank 1 in nuke_coords_and_rebuild) and the supervisor stops the job at 40 s passes: every rank returns, T keeps its values on both ranks, and S is transferred (1.0e-5 from exact, which is the #1115 face slab)
rank 1 fails after T's evaluation (the #994 shape) fails: the job completes silently with T transferred on rank 0 and stale on rank 1 passes: every rank raises the same error after the move, the mesh is at the new coordinates on both ranks, T keeps its values on both, and S is transferred
REMESH_MONOTONE=clamp, the limiter raises on rank 1 at 79f7951: hangs, because rank 1 alone evaluates again passes: the variable fails on every rank, and every rank raises after the move
rank 1 fails inside the DDt on_remesh hook's remap (its ALE opt-out path) at 79f7951: silent; neither rank raises, because the dispatcher swallows the hook's error passes: both ranks raise after the move; the failed history keeps its values and the others transfer, the same on every rank
global_evaluate raises on rank 1 before its collectives fails: the error is swallowed, and the ranks pair T with S and hang passes: rank 1's error reaches the output, and the job does not complete

The first head of this branch (1367f3d) failed the second case: it hung, because the error propagated on rank 1 only. That is why each variable's outcome is now agreed.

Checks

set this branch development
serial remap and move set (0056, 0057, 0768, 0769, 0770, 0826, 0855, 1071, 1146, 1151, 1172, 1173) 65 passed, 2 skipped 65 passed, 2 skipped
0768 and 0769 with REMESH_MONOTONE=clamp 4 failed, 5 passed the same 4 failed (these tests assume the limiter off)
parallel set (0766, 0768, 0769, 0770, 0775, 0785, 1172, 1173), np 2 41 passed, 3 skipped the same
the same, np 4 41 passed, 3 skipped the same
  • test_0052_collective_guard_scan: 5 passed.
  • scripts/check_test_coverage.py: OK. The new file sits in the test_07* batch.

Refs #960.

Underworld development team with AI support from Claude Code

… a rank-local raise (#960)

The mesh-move field transfer evaluates each REMAP variable with the collective
global_evaluate. It skipped a variable on the rank where its new coordinates
could not be read, or where the evaluation raised, while the other ranks went
into that variable's collectives. At np 2 the ranks then evaluated different
variables against each other and hung (T skipped on rank 1, S's collectives
matched against rank 0's T).

- Whether a variable's new DOF coordinates are unavailable is now reduced over
  the ranks (one Allreduce, before any evaluation): such a variable is skipped
  on every rank.
- The broad `except Exception: continue` around the evaluation is gone. The
  monotone fallback for (ValueError, NotImplementedError) stays: it depends on
  the expression alone, so every rank takes it alike. Any other error now
  propagates instead of turning into a rank-local skip.

A rank-local raise INSIDE global_evaluate still leaves the other ranks waiting
in it. Agreeing on such a failure belongs in global_evaluate (the locator
rewrite carries it as a requirement).

tests/test_0791 runs both cases at np 2 through the MPI supervisor. On
development both fail (the ranks hang into the silence limit); with this change
the first returns on every rank with the variable skipped on both, and the
second shows the error instead of swallowing it.

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

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.

…after the move (#960, #994)

Removing the broad except made a failure AFTER global_evaluate's collectives
(a rank-local limiter, as in #994's opt-in clamp) propagate on that rank only,
so the other ranks went on to the next variable's collectives and hung. Each
variable's outcome is now reduced over the ranks right after its evaluation:
a variable that failed anywhere keeps its values on every rank, the move and
the other variables complete, and remesh_with_field_transfer then raises the
same RuntimeError on every rank (after its hooks, the stale-vector mark and the
move-version count). The failing rank prints its own error first.
remap_var_set(raise_on_failure=False) returns the failed names instead.

A raise BEFORE the collectives, on one rank, still leaves the other ranks
inside global_evaluate (its message now reaches the output).

tests/test_0791 gains the after-collectives case: on development it completes
with T transferred on one rank and not the other; at 1367f3d it hangs; here
every rank raises, T keeps its values on both ranks and S is transferred.

Underworld development team with AI support from Claude Code
… H4's review)

With REMESH_MONOTONE off (the default) the (ValueError, NotImplementedError)
fallback was an identical second call, so a ValueError on one rank re-entered
global_evaluate on that rank alone. The fallback now applies only when the
limiter is on, where the refusal it handles depends on the expression alone;
otherwise the error is a failure and is agreed across ranks like any other.

Underworld development team with AI support from Claude Code
…ailure reaches the caller (#960, H4's re-check)

- Whether REMESH_MONOTONE applies to a variable is decided before the
  evaluation, from the expression alone (one MeshVariable or a component of
  one; "pick" only on one rank), so every rank answers alike. Nothing is
  caught for a retry: with the limiter on, a ValueError from it on one rank
  used to send that rank alone into a second global_evaluate (a hang at np 2).
  Every error is now a failure, agreed across the ranks.
- The DDt on_remesh hook calls remap_var_set with raise_on_failure=False and
  records the failed names on the mesh. The hook dispatcher does not let a
  hook's exception through, so a failed history transfer used to be silent;
  remesh_with_field_transfer now raises for it on every rank, with the generic
  pass's failures, after the move is complete.

tests/test_0791 gains the limiter case (REMESH_MONOTONE=clamp, the limiter
raising on rank 1): it hangs at 79f7951 and passes here.

Underworld development team with AI support from Claude Code
…r a stale failure list (#960)

The fifth case is the second review's probe: rank 1 fails once inside the
semi-Lagrangian DDt's on_remesh remap (its ALE opt-out path), after the
evaluation's collectives. At 79f7951 neither rank raises; now both raise after
the move, the failed history keeps its values on both ranks and the others
transfer, the same on every rank.

remesh_with_field_transfer clears the failure list at the top of its outer call,
so a list left by an earlier call cannot raise on a later one.

Underworld development team with AI support from Claude Code
@lmoresi
lmoresi merged commit 14134eb 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.

2 participants