Repository navigation
Invalidate caches after axiom growth - #203253
laithsakka wants to merge 8 commits into
Conversation
PR Status: Approved 🚀Please fix all CI failures and trigger merge by commenting "@pytorchbot merge". ✅ AUTOMATED REVIEW - Ready for human review:
Findings (5): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203253
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit fd72ae4 with merge base 0522dc9 ( 🟡 GREEN LIGHT - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Pull Request resolved: #203253 Include axiom growth in the existing cache-version key and advance the version when guards or derived facts add axioms. This prevents stale static-evaluation, simplification and floor-division results after learning new constraints. Add regression tests for each function that fail before the fix and pass afterward. Authored with an AI assistant. ghstack-source-id: 473242083 @exported-using-ghexport Differential Revision: [D128259287](https://our.internmc.facebook.com/intern/diff/D128259287/)
Superseded by a newer greenlight verdict.
There was a problem hiding this comment.
Automated review of fd72ae4: nothing blocking; ready for human review.
The PR adds len(self.axioms) to ShapeEnv._get_key and bumps the version after evaluate_expr records a guard and after the default-axioms FloorDivCleanDiv pass, so cached simplify, _maybe_evaluate_static, get_axioms and _simplify_floor_div results no longer go stale. Recommendation: Approve. The earlier blocking findings are fixed or answered at HEAD, and every remaining point is non-blocking.
⚪ 5 non-blocking findings
pytorch/torch/fx/experimental/symbolic_shapes.py
Line 9124 in fd72ae4
Non-blocking, low confidence: get_axioms can still miss a guard. get_axioms (:7308-7337) is built from self.guards, but the new key tracks len(self.axioms) (:4885). If a guard is recorded at :9122 and every key from its get_implications is already in self.axioms, the call at :9124 does not bump, so get_axioms() returns a tuple without that guard. This takes a new guard expression that simplifies to an existing one, for example Eq(Max(0, s0*s1), 30) after Eq(s0*s1, 30). The callers (sizevars.py:402, index_propagation.py:241) re-derive implications through the explicit-axioms path, so no wrong result was found, and before this PR it was strictly worse. Adding len(self.guards) to _get_key would make test_guard_updates_get_axioms_result's claim hold in general.
An earlier comment near this line has replies: #203253 (comment)
pytorch/torch/fx/experimental/symbolic_shapes.py
Line 7553 in fd72ae4
Non-blocking: the explicit-axioms re-simplification at :7553-7554 looks redundant. The flag describes self.axioms, not the local subst. subst comes from get_implications(self.simplify(e)) (:7551), which already uses the current divisible set, and get_implications/canonicalize_bool_expr never add FloorDiv atoms. The flag now stays set until a default-axioms call, so each explicit-axiom cache miss in between repeats this work. Either drop the call (and the assertion at test_dynamic_shapes.py:7733) or add a comment explaining when it matters.
pytorch/torch/fx/experimental/symbolic_shapes.py
Line 4885 in fd72ae4
Non-blocking, code this PR does not change: the cleanup promised in the author's reply is not in HEAD. patch_source_specialization still runs self.axioms.pop(k, None) on every key in new_axioms (symbolic_shapes.py:4452-4453), including keys that existed before entry. The bump at :4456 prevents stale caches, but facts proven before the context are lost for good. If this is meant for a later PR in the stack, a follow-up note would keep it from getting lost.
An earlier comment near this line has replies: #203253 (comment)
pytorch/test/test_dynamic_shapes.py
Line 7744 in fd72ae4
Non-blocking, still open from the last review: _check_adds_only_axioms (:7744-7763) never checks that _version_counter went up. That bump is the property under test, and neighbouring tests assert it directly (:7474-7477, :7660). Record v0 before torch._check and add assertGreater(shape_env._version_counter, v0).
pytorch/test/test_dynamic_shapes.py
Line 7733 in fd72ae4
Non-blocking: in test_explicit_axioms_preserve_pending_floor_div_resimplification (:7716-7741), the pending flag comes from ShapeEnv.__init__ (symbolic_shapes.py:4288), not from _add_divisible. Nothing before the assertTrue at :7733 clears it, so the test still passes if setting the flag when divisible grows (symbolic_shapes.py:4905-4906) breaks. Call _maybe_evaluate_static once with default axioms before _add_divisible, then assert the flag is False before and True after. Both subTest cases, () and (sympy.true,), run the same path because neither has a FloorDiv key, so one case is enough.
This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review
Withdrawn: the automated review of fd72ae4 found nothing blocking.
Pull Request resolved: #203253 Include axiom growth in the existing cache-version key and advance the version when guards or derived facts add axioms. This prevents stale static-evaluation, simplification and floor-division results after learning new constraints. Add regression tests for each function that fail before the fix and pass afterward. Authored with an AI assistant. ghstack-source-id: 473242083 @exported-using-ghexport Differential Revision: [D128259287](https://our.internmc.facebook.com/intern/diff/D128259287/)
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
Include axiom growth in the existing cache-version key and advance the version when guards or derived facts add axioms. This prevents stale static-evaluation, simplification and floor-division results after learning new constraints.
Add regression tests for each function that fail before the fix and pass afterward.
Authored with an AI assistant.
@exported-using-ghexport
Differential Revision: D128259287
Differential Revision: D128259287