-
Notifications
You must be signed in to change notification settings - Fork 8
Fix swarm cache invalidation after parallel migration #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||
| """ | ||||||
| Regression test for swarm cache invalidation after migration. | ||||||
|
|
||||||
| Verifies that SwarmVariable._canonical_data caches are properly invalidated | ||||||
| after Swarm.migrate() and after bare-bones dm.migrate() in global_evaluate. | ||||||
|
|
||||||
| Bug: SwarmVariable caches were only invalidated inside the delete_lost_points | ||||||
| branch of Swarm.migrate(), so caches became stale when particles moved between | ||||||
| ranks without deletion. This caused shape mismatches in global_evaluate. | ||||||
|
|
||||||
| See: https://github.com/underworldcode/underworld3/issues/64 | ||||||
|
|
||||||
| Run with: | ||||||
| mpirun -n 2 python -m pytest --with-mpi tests/parallel/test_0760_swarm_cache_migration.py | ||||||
| """ | ||||||
|
|
||||||
| import pytest | ||||||
| import numpy as np | ||||||
| import underworld3 as uw | ||||||
| from mpi4py import MPI | ||||||
|
||||||
| from mpi4py import MPI |
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre_count is assigned but never used. If it’s not needed for an assertion/debug message, remove it to avoid dead code in the regression test.
| pre_count = swarm.dm.getLocalSize() |
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coords_cached = swarm._particle_coordinates.data.shape[0] doesn’t currently validate cache invalidation, because _particle_coordinates.data is never accessed before swarm.migrate(). To actually regress the stale-cache bug, force creation of the coordinate cache before migration (e.g., access _particle_coordinates.data once), then assert the post-migration shape matches dm.getLocalSize().
Copilot
AI
Mar 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test claims to exercise the “DDt/SemiLagrangian” displaced-node global evaluation path, but it calls uw.function.evaluate(...) (local evaluation) rather than uw.function.global_evaluate(...). To cover the regression described in #64 (which goes through global_evaluate_nd and swarm migration), this should call global_evaluate (or update the test name/docstring if local evaluate is intentional).
| result = uw.function.evaluate(v.sym, mid_pt_coords) | |
| result = uw.function.global_evaluate(v.sym, mid_pt_coords) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test module won’t be picked up by the repo’s current parallel test runner:
scripts/test.shonly executestests/parallel/test_075*py, sotest_0760_*won’t run in CI by default. Consider either updating the parallel test glob inscripts/test.shto include this file (ortest_076*), or renaming the test file to match the existingtest_075*pattern so the regression is continuously exercised.