From 3912ba3e940b9354622fa09b2ada677cd10723d8 Mon Sep 17 00:00:00 2001 From: PyTorch MergeBot Date: Mon, 6 Oct 2025 22:09:39 +0000 Subject: [PATCH] Revert "Fix refine_ranges corner case (#164075)" This reverts commit 27234792add2ee9bedd84ca02dbf34f8f244bc5c. Reverted https://github.com/pytorch/pytorch/pull/164075 on behalf of https://github.com/izaitsevfb due to fails executorch builds, see [D83938444](https://www.internalfb.com/diff/D83938444) ([comment](https://github.com/pytorch/pytorch/pull/164075#issuecomment-3374430964)) --- .ci/docker/ci_commit_pins/executorch.txt | 2 +- test/dynamo/test_misc.py | 11 +++++++---- test/test_dynamic_shapes.py | 11 ----------- test/test_proxy_tensor.py | 2 +- torch/fx/experimental/symbolic_shapes.py | 4 ++-- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.ci/docker/ci_commit_pins/executorch.txt b/.ci/docker/ci_commit_pins/executorch.txt index f2e2d655a6cf..0a30a6037a05 100644 --- a/.ci/docker/ci_commit_pins/executorch.txt +++ b/.ci/docker/ci_commit_pins/executorch.txt @@ -1 +1 @@ -deb42f2a8e48f5032b4a98ee781a15fa87a157cf +e0dda9059d082537cee36be6c5e4fe3b18c880c0 diff --git a/test/dynamo/test_misc.py b/test/dynamo/test_misc.py index 35387fb6ce8c..eced76bef625 100644 --- a/test/dynamo/test_misc.py +++ b/test/dynamo/test_misc.py @@ -6827,10 +6827,13 @@ utils_device.CURRENT_DEVICE == None""".split("\n"): self.assertTrue(guard_failure is not None) first_guard_failure = guard_failure[0].partition("\n")[0] - self.assertIn( - """tensor 'x' size mismatch at index 0. expected 2, actual 5""", - first_guard_failure, - ) + if torch._dynamo.config.assume_static_by_default: + self.assertIn( + """tensor 'x' size mismatch at index 0. expected 2, actual 5""", + first_guard_failure, + ) + else: + self.assertIn("""x.size()[0] < 3""", first_guard_failure) def test_guard_failure_fn2(self): def fn(x, y): diff --git a/test/test_dynamic_shapes.py b/test/test_dynamic_shapes.py index 526e1dd1f2ba..7b38b7fd3bd1 100644 --- a/test/test_dynamic_shapes.py +++ b/test/test_dynamic_shapes.py @@ -4040,17 +4040,6 @@ def forward(self, arg0_1: "i64[2][1]cpu", arg1_1: "Sym(u2)", arg2_1: "Sym(u3)", self.assertEqual(compiled_func2(x, zero), func2(x, zero)) self.assertEqual(cnt.frame_count, 2) - @torch._dynamo.config.patch("capture_scalar_outputs", True) - def test_unbacked_select_2(self): - class M(torch.nn.Module): - def forward(self, x): - nz = x.nonzero() - return nz[-1] - - mod = M() - x = torch.randn(4) - self.assertEqual(torch.compile(mod)(x), mod(x)) - @torch._dynamo.config.patch("capture_scalar_outputs", True) def test_unbacked_select_index_with_check(self): def func3(x, y): diff --git a/test/test_proxy_tensor.py b/test/test_proxy_tensor.py index b76895a0a91f..05cbe429b25b 100644 --- a/test/test_proxy_tensor.py +++ b/test/test_proxy_tensor.py @@ -1858,7 +1858,7 @@ L['a'].size()[1] > L['a'].size()[0] show_guards(tensor), """\ L['a'].size()[1] < L['a'].size()[0] -3 <= L['a'].size()[0] and L['a'].size()[0] <= 19 +L['a'].size()[0] <= 19 L['a'].size()[1] <= 18""") def test_sym_storage_offset(self): diff --git a/torch/fx/experimental/symbolic_shapes.py b/torch/fx/experimental/symbolic_shapes.py index 8324c5d7a71f..ddffbf6d5d64 100644 --- a/torch/fx/experimental/symbolic_shapes.py +++ b/torch/fx/experimental/symbolic_shapes.py @@ -7835,13 +7835,13 @@ class ShapeEnv: # sympy.Eq may update both lower and upper bounds. # sympy.G{t,e} may update the lower bound, only. # sympy.L{t,e} may update the upper bound, only. - if lower <= rhs_vr.lower and isinstance( + if lower < rhs_vr.lower and isinstance( r_expr, (sympy.Eq, sympy.Ge, sympy.Gt) ): # Strictly greater relations allow us to refine a bit more, since # x < y implies that the lower bound for x is: y + 1. lower = rhs_vr.lower + int(isinstance(r_expr, sympy.Gt)) - if upper >= rhs_vr.upper and isinstance( + if upper > rhs_vr.upper and isinstance( r_expr, (sympy.Eq, sympy.Le, sympy.Lt) ): upper = rhs_vr.upper - int(isinstance(r_expr, sympy.Lt))