Repository navigation
global_evaluate: refuse non-finite query points on every rank, before any collective - #1249
Conversation
On development at np 2 the file hangs (pytest's timeout fires): with a NaN row on the last rank and no points on the others, the first rank raises an IndexError and the last waits in the swarm migration's barrier. With the same NaN points on every rank the ranks raise different errors. Underworld development team with AI support from Claude Code
… any collective Each rank counts its own points with a NaN or infinite coordinate; the count is reduced over the ranks before the far-outside refusal and the swarm migration, and every rank raises the same ValueError. Only expressions that read mesh data are checked; pure sympy expressions keep returning NaN for NaN. evaluate is rank-local and unchanged. Underworld development team with AI support from Claude Code
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) 930bb74: ready to merge on green from this review. The one finding below is a rename, and it does not block. How it was run
Findings
Non-finite points: every rank must raise the same ValueError, with no hangEach case gathers what every rank raised. The 12 cases were run at np 2, at np 3, and at np 3 with the empty rank:
Results:
The new test on development and on this PR
Finite points: no regression
Pure sympy expression with a NaN point (np 2)
Cost
The difference is within noise: 0.1 to 0.7 % at np 1, and -1.3 to +0.1 % at np 3. Existing tests
Underworld development team with AI support from Claude Code |
Underworld development team with AI support from Claude Code
Underworld development team with AI support from Claude Code
uw.function.global_evaluatenow refuses query points with a NaN or infinite coordinate, with the sameValueErroron every rank, before any collective. Before this, a NaN point could hang a parallel run. This is the core evaluation path; the change is confined to that refusal, and nothing else in the evaluation is touched.The defect
Found by the parallel review desk while checking #1246 (comment 7028008624 there). A NaN coordinate passes the far-outside refusal (#786), because a comparison with NaN is false. It then reaches the swarm migration inside
global_evaluate, where the ranks part. Measured on development (9cf3509) at np 2, with a degree-2 field onUnstructuredSimplexBox(cellSize=0.2)and 41 points on a line, one row NaN:viz_ranklast arranges)IndexErrorwith a garbage index; the last waits in the migration's barrier: hangRuntimeError, and a kd-tree stencilRuntimeError)check_extrapolated=True(the far-outside refusal is off)The fix
A new
_refuse_non_finite_pointsinfunction/functions_unit_system.py, called byglobal_evaluateon every rank before the far-outside refusal and the call intoglobal_evaluate_nd.allreduceof two integers), so a rank whose own points are finite, or that holds none, raises too.ValueError: global_evaluate: k of n query points have non-finite coordinates (NaN or infinite), over all ranks. ....It applies whatever
check_extrapolatedis. As with the far-outside refusal, only expressions that read mesh data are checked: a pure sympy expression is evaluated pointwise and still returns NaN for a NaN point. A rank whose coordinates are still unit-aware tuples (converted later, inglobal_evaluate_nd) contributes nothing to the count rather than raising alone before the reduction.What a user's run does now
ValueErroron every rankglobal_evaluate, NaN point, field dataRuntimeErrorfrom the kd-tree stencilValueErroraboveglobal_evaluate, infinite point, field dataValueError(#786)ValueErroraboveuw.function.evaluate(rank-local, no migration)RuntimeErrorfor NaNevaluatedoes not reach the swarm migration, so it is left as it is.Cost
One
isfinitepass over the points and two integer reductions per call.UnstructuredSimplexBox(cellSize=0.02), degree-2 field, uniform points, slowest rank:Tests
tests/parallel/test_1249_global_evaluate_non_finite_points_parallel.py(level 1, tier B). Each case gathers what every rank raised and requires the sameValueErrorwith the right count:infand-infpoints on every rank;check_extrapolated=True;x).On development at np 2 the file hangs (pytest's timeout fires). With the fix: 9 passed on every rank at np 2 and 3, and serially.
What was run
On a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH):
test_0785,test_0786(outside domain),test_0960,test_1075,test_1076,test_0795,test_1243scripts/check_test_coverage.pyscripts/check_deprecated_patterns.pyNot run
np 4 and above for the test file; the full suite; macOS.
Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)
level_*andtier_*markers (S8)maybe_/try_/do_) and no commented-out code (S3, S4).array/mesh.X.coords— nowith ....access(...), nomesh.data(S7) — not applicable: no data access addedpixi.toml/pixi.lockor other dependency changes riding in an unrelated PRReview: the parallel review desk (H1, the session that reviews pull requests and runs the parallel tests).
Underworld development team with AI support from Claude Code