debug_utils: async buffer sanity inspector + --inspect-buffers-on-shutdown#683
Draft
DLWoodruff wants to merge 2 commits into
Draft
debug_utils: async buffer sanity inspector + --inspect-buffers-on-shutdown#683DLWoodruff wants to merge 2 commits into
DLWoodruff wants to merge 2 commits into
Conversation
mpisppy/debug_utils/buffer_inspect.py is a passive content checker for SendArray / RecvArray that detects the SHUTDOWN-stomp signature plus a small set of per-Field invariants. Producers are not touched; callers pass an optional InspectContext (or an SPBase via duck-typing). _BoundSpoke.got_kill_signal gets an env-gated hook (MPISPPY_INSPECT_BUFFERS=1) that runs the inspector on each shutdown poll and prints findings only when the report is non-OK. See doc/designs/async_buffer_sanity_design.md for invariants leaned on (NaN-padding init from communicator_array, buf.id() as recv baseline), the check tables, and the wiring rationale. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the prior MPISPPY_INSPECT_BUFFERS env-var gate with a Config flag --inspect-buffers-on-shutdown (popular_args). The flag is propagated through cfg_vanilla.shared_options into opt.options and read by _BoundSpoke.got_kill_signal only when a shutdown is detected; when the report is non-OK the spoke prints rank info plus the verbose Report dump. The check fires at the moment of detection because a spurious shutdown's buffer state has not yet been overwritten by later activity. Public surface: mpisppy.debug_utils now re-exports inspect_buffer, InspectContext, and Report. Adds mpisppy/tests/test_buffer_inspect.py (34 cases covering generic checks, all per-field checkers, SPBase fallback, verbose dump, and the config-flag wiring). Wired into the unit-tests CI job. User-facing RST page (doc/src/debug_utils.rst) added under For Developers and Contributors; design doc updated to reflect the CLI-flag wiring. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #683 +/- ##
==========================================
+ Coverage 71.05% 71.26% +0.21%
==========================================
Files 154 156 +2
Lines 19252 19436 +184
==========================================
+ Hits 13679 13852 +173
- Misses 5573 5584 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new package
mpisppy.debug_utilscontaining a passive content-check utility for the MPI-RMA send and receive buffers used by the hub-and-spoke system, plus an opt-in CLI flag that runs the check at cylinder shutdown.Motivation. An xhat spoke was observed receiving a
SHUTDOWNsignal thatHub.send_terminatehad not produced — suggesting that the SHUTDOWN buffer region was being written to from somewhere unexpected. mpi-sppy had no runtime sanity check on buffer contents;_validate_recv_fieldonly checks layout at registration time. This PR adds the missing layer.What's in it
mpisppy/debug_utils/buffer_inspect.py— the inspector. Single entry pointinspect_buffer(buf, fld, ctx, *, send, verbose).InspectContextis duck-typed (accepts SPBase viagetattr); explicit fields take precedence.buf.id(); recv-side id does not regress belowbuf.id()or optionalctx.last_write_id; noinfin data; noNaNoncewrite_id >= 1; padding region (betweenlogical_lenandpadded_len) staysNaN.SHUTDOWN,NONANT,NONANT_LOWER_BOUNDS,NONANT_UPPER_BOUNDS,OBJECTIVE_INNER_BOUND,OBJECTIVE_OUTER_BOUND,BEST_XHAT. Adding a new checker is one function and one dict entry.--inspect-buffers-on-shutdownCLI flag inpopular_args, propagated throughcfg_vanilla.shared_options._BoundSpoke.got_kill_signalreads it and runs the inspector only when shutdown is detected (the diagnostic moment). Off by default; no overhead when unset.Tests (34 new)
mpisppy/tests/test_buffer_inspect.pycovers: every generic check, every per-field check, SPBase fallback for nonant length, verbose dump, severity ladder, and the config-flag wiring (default false, propagation throughshared_options). Wired into the existingunit-testsCI job so codecov picks it up.Documentation
doc/src/debug_utils.rst— user-facing page under For Developers and Contributors.doc/designs/async_buffer_sanity_design.md— internal design doc with invariants, check tables, and explicit non-goals (cross-cylinder consensus, module-level history state).Draft because
Opened as a draft so the design can be reviewed before any further hot-path integrations (e.g., wiring the inspector into
update_nonantsorsync_bounds) are added. The current scope is intentionally narrow: prove out the SHUTDOWN check, then expand.Test plan
python -m pytest mpisppy/tests/test_config.py mpisppy/tests/test_buffer_inspect.py— 112 passedruff checkclean on all touched files--inspect-buffers-on-shutdownpropagates throughshared_optionsfor hub and spoke; unset default propagates as False🤖 Generated with Claude Code