Repository navigation
[aot_compile] Name guarded state that changed as a cause of the no-match report's accept line - #197300
[aot_compile] Name guarded state that changed as a cause of the no-match report's accept line#197300bobrenjc93 wants to merge 2 commits into
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/197300
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 4 Pending, 2 Unrelated FailuresAs of commit cf9ce38 with merge base 51d4378 ( UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
…tch report's accept line This commit and `[aot_compile] Say when a no-match report entry's guards accepted the call the dispatch refused` (#197150, directly below) were one commit, split for review budget: that commit gives a no-match report entry whose tree ACCEPTS the call on the report's evaluation an explanation in place of any guards, naming one cause; this one adds the second cause to that text. Below this commit the entry reads `<guards rejected this call twice and then accepted it here: a guard that does not answer consistently>`. That is one way a tree the dispatch ran twice and refused twice can accept on the third evaluation. The other needs no inconsistent guard: every guard answers consistently and the state it guards moved between the second dispatch pass and the report. Guards read live state on each evaluation (a global's dict is re-descended, a tensor's dtype and shape re-read), and `__call__` holds no lock across the dispatch, so a concurrent rebind of a guarded global, or an in-place mutation of a guarded tensor, landing in the window between the second pass's last `check()` and the report's `check_verbose` gets the same accept; the dispatch already contemplates concurrent calls (the `_binding_verdict` comment: a hint, not a lock). Naming only the first cause sends a reader whose guarded value raced off to hunt for a nondeterministic guard, so the entry now reads `<guards rejected this call twice and then accepted it here: a guard that does not answer consistently, or guarded state that changed between those evaluations>`. The branch, the `continue` after it, and the class docstring are #197150's and unchanged: the docstring quotes the entry up to `accepted it here: ...` and describes the condition, so it holds for both tails. This changes what the entry says and nothing about which calls are served. `test_no_match_message_when_guarded_state_changes_before_the_report` pins the second cause with a deterministic tree: `AOT_BRANCH_SCALE` is rebound to a wrong value before the call, so `[1]`'s tree refuses it in both passes (`check.call_count == 2` through `patch.object(manager, "check", wraps=...)`), and a wrapper around the report's `check_verbose` rebinds the right value before calling through, placing the writer in the window a concurrent one could land in; the call raises with the entry, two ` [` lines for two results, and `[0]`'s real mismatch. The entry's full text now has two readers, so it moves out of `test_no_match_message_when_a_guard_answers_inconsistently`'s inline literal into one module constant, `_ACCEPTED_IN_THE_REPORT`, beside `AOT_BRANCH_SCALE`, and both tests assert it; that test is otherwise unchanged. Both build their model through `_aot_compile_mode_branches()`, the helper their siblings on this path use. Order to review: the string in `AOTCompiledModel._no_match_report`; then `_ACCEPTED_IN_THE_REPORT` and the new test; then the first test's swap to the constant. > **FAQ: The new test plays the concurrent writer from inside the report's > own `check_verbose` rather than from a second thread. Why?** The window is > the few microseconds between the second pass's last `check()` and the > report's `check_verbose`; a thread that has to land a rebind in it would make > the test flaky or need a synchronisation hook in the dispatch, which is not > worth adding for a message test. The wrapper puts the rebind at exactly the > point such a writer could reach and leaves the tree alone: every evaluation > is the real tree against the real module dict, and the wrapped `check()` > count says both passes refused the wrong value before anything changed. > **FAQ: Why two causes and not a third, the tag-safe dict-tag fast path the > dispatch comment names?** #197150's FAQ covers it: `find_tag_safe_roots()` > runs only with `config.use_recursive_dict_tags_for_guards` (default `False`) > and its justknob on, so that exit is unreachable on defaults, and an entry > naming it would hand a reader a hypothesis their build cannot take. Both > causes the entry names now are reachable in every build without a flag. Test Plan: ``` python test/dynamo/test_aot_compile.py -k test_no_match_message_when_guarded_state_changes_before_the_report python test/dynamo/test_aot_compile.py -k test_no_match_message_when_a_guard_answers_inconsistently python test/dynamo/test_aot_compile.py ``` The whole file runs 213 tests, `OK (skipped=6)`; the parent runs one fewer. With the parent's `aot_compile.py` under this test file both tests fail on the entry's text, `' [1] <guards rejected this call twice and then accepted it here: a guard that does not answer consistently, or guarded state that changed between those evaluations>' not found in "... [1] <guards rejected this call twice and then accepted it here: a guard that does not answer consistently>\nAdd a ModelInput ..."`, the new test after its `check()`-count assertion passed: on the parent too both passes refuse, the report accepts, the call is refused, and the entry names one cause. The assertion is the entry's whole text, so the parent's tail is the mutant that cuts the new clause. Authored with the assistance of Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]> ghstack-source-id: 7617536 Pull-Request: #197300
[ghstack-poisoned]
|
Claude finished @bobrenjc93's task in 16m 35s —— View job Reviewed: the message change and the new test are correct — the only notes are a misleadingly-named test constant and two small asymmetries with the sibling test. Full reviewPR Review: #197300SummaryExtends the no-match report's "guards accepted here after two refusals" entry to name a second cause (guarded state moved between the second dispatch pass and the report) and adds a deterministic test for it. I verified the mechanics and found no correctness problems; three minor points below. I confirmed by reading the code (not by running it — no build/venv is available in this job):
Code Quality
Testing
RecommendationApprove — the behavior change is one string, the test is deterministic and correctly targeted, and the points above are cleanups rather than blockers. Process note: Dr. CI flags a missing |
|
Folded into #196823 (the no-match report now ships with the accepted-in-report line, the empty-parts line and the one-line normalisation); closing this slice. |
Stack from ghstack (oldest at bottom):
This commit and
[aot_compile] Say when a no-match report entry's guards accepted the call the dispatch refused(#197150, directly below) were onecommit, split for review budget: that commit gives a no-match report entry
whose tree ACCEPTS the call on the report's evaluation an explanation in place
of any guards, naming one cause; this one adds the second cause to that text.
Below this commit the entry reads
<guards rejected this call twice and then accepted it here: a guard that does not answer consistently>. That is oneway a tree the dispatch ran twice and refused twice can accept on the third
evaluation. The other needs no inconsistent guard: every guard answers
consistently and the state it guards moved between the second dispatch pass
and the report. Guards read live state on each evaluation (a global's dict is
re-descended, a tensor's dtype and shape re-read), and
__call__holds nolock across the dispatch, so a concurrent rebind of a guarded global, or an
in-place mutation of a guarded tensor, landing in the window between the
second pass's last
check()and the report'scheck_verbosegets the sameaccept; the dispatch already contemplates concurrent calls (the
_binding_verdictcomment: a hint, not a lock). Naming only the first causesends a reader whose guarded value raced off to hunt for a nondeterministic
guard, so the entry now reads
<guards rejected this call twice and then accepted it here: a guard that does not answer consistently, or guarded state that changed between those evaluations>. The branch, thecontinueafterit, and the class docstring are #197150's and unchanged: the docstring quotes
the entry up to
accepted it here: ...and describes the condition, so itholds for both tails.
This changes what the entry says and nothing about which calls are served.
test_no_match_message_when_guarded_state_changes_before_the_reportpins thesecond cause with a deterministic tree:
AOT_BRANCH_SCALEis rebound to awrong value before the call, so
[1]'s tree refuses it in both passes(
check.call_count == 2throughpatch.object(manager, "check", wraps=...)),and a wrapper around the report's
check_verboserebinds the right valuebefore calling through, placing the writer in the window a concurrent one
could land in; the call raises with the entry, two
[lines for tworesults, and
[0]'s real mismatch. The entry's full text now has tworeaders, so it moves out of
test_no_match_message_when_a_guard_answers_inconsistently's inline literalinto one module constant,
_ACCEPTED_IN_THE_REPORT, besideAOT_BRANCH_SCALE, and both tests assert it; that test is otherwiseunchanged. Both build their model through
_aot_compile_mode_branches(),the helper their siblings on this path use.
Order to review: the string in
AOTCompiledModel._no_match_report; then_ACCEPTED_IN_THE_REPORTand the new test; then the first test's swap to theconstant.
Test Plan:
The whole file runs 213 tests,
OK (skipped=6); the parent runs one fewer.With the parent's
aot_compile.pyunder this test file both tests fail onthe entry's text,
' [1] <guards rejected this call twice and then accepted it here: a guard that does not answer consistently, or guarded state that changed between those evaluations>' not found in "... [1] <guards rejected this call twice and then accepted it here: a guard that does not answer consistently>\nAdd a ModelInput ...", the new test after itscheck()-countassertion passed: on the parent too both passes refuse, the report accepts,
the call is refused, and the entry names one cause. The assertion is the
entry's whole text, so the parent's tail is the mutant that cuts the new
clause.
Authored with the assistance of Claude Code.
Co-Authored-By: Claude Fable 5.1 [email protected]