Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[dynamic shapes] guard individual terms in sym_and; user-code-friendly sym_and/sym_or #154737

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
Loading
from

Conversation

pianpwk
Copy link
Contributor

@pianpwk pianpwk commented May 30, 2025

Previously when processing sym_and(a, b, c), symbolic shapes wouldn't individually process a, b, and c and store their implications. This would lead us to data-dependent error on individual checks, e.g. we stored u0 >= 0 & u0 <= 10, but then couldn't figure out u0 <= 10.

This handles that, and also makes sym_and/or user-code friendly, for testing.

cc @ezyang @SherlockNoMad @EikanWang @jgong5 @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @jiayisunx @chenyang78 @kadeng @chauhang @amjames

Copy link

pytorch-bot bot commented May 30, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/154737

Note: Links to docs will display an error until the docs builds have been completed.

❌ 30 New Failures, 6 Cancelled Jobs, 7 Unrelated Failures

As of commit 3d5cb4f with merge base e895e96 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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.

return SymNodeVariable.create(
tx,
torch.fx.experimental.symbolic_shapes.sym_or(*(x.as_proxy() for x in terms)),
sym_num=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if there's a better way to do thiis

@pianpwk pianpwk changed the title [WIP][dynamic shapes] guard individual terms in sym_and; user-code-friendly sym_and/sym_or [dynamic shapes] guard individual terms in sym_and; user-code-friendly sym_and/sym_or Jun 4, 2025
@@ -7397,7 +7397,7 @@ def forward(self, xs):
):
ep.module()(torch.tensor([3, 6, 5]))
with self.assertRaisesRegex(
RuntimeError, r".* expression Eq\(u2, 5\) & \(4 <= u1\) & \(u1 <= 8\) .*"
RuntimeError, r".* expression u[\d]+ <= 5 .*"
Copy link
Contributor Author

@pianpwk pianpwk Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of how the runtime asserts pass inserts range checks for unbacked symbols:

f"Runtime assertion failed for expression {i0 <= max_val} on node '{le}'",
we now get these individual asserts before the sym_and assert.

This seems like a good thing; the ShapeEnv is now processing these bound checks. Could be a nice-to-have in the pass to recognize and deduplicate these.

if len(others) == 0:
return x
for y in others:
assert isinstance(y, (bool, SymBool))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of dynamo, is a Proxy

@pianpwk pianpwk marked this pull request as ready for review June 4, 2025 23:37
@pianpwk pianpwk requested a review from angelayi June 4, 2025 23:37
@@ -6786,12 +6782,18 @@ def _find(self, a: sympy.Symbol) -> sympy.Expr:
return self.replacements[a]

@lru_cache(256)
def _maybe_guard_rel(self, expr: sympy.Rel) -> None:
def _maybe_guard_rel(self, expr: sympy.Expr) -> None:
"""
The relational guard is guarded to be true. Use this information to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the expression?

@pianpwk
Copy link
Contributor Author

pianpwk commented Jun 6, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Successfully rebased pianpwk/sym_and_terms onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout pianpwk/sym_and_terms && git pull --rebase)

@pytorchmergebot pytorchmergebot force-pushed the pianpwk/sym_and_terms branch from c55871a to 3d5cb4f Compare June 6, 2025 04:43
@pianpwk
Copy link
Contributor Author

pianpwk commented Jun 6, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Tried to rebase and push PR #154737, but it was already up to date. Try rebasing against main by issuing:
@pytorchbot rebase -b main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.