Skip to content

Conversation

@GregoryComer
Copy link
Member

@GregoryComer GregoryComer commented Oct 31, 2025

Our current SpecPropPass doesn't properly capture the effect of guards in the shape environment due to double-tracing certain ops. The problem looks like this:

  • Every time we trace through the graph, we generate new symints.
  • That's fine, since shape_env will pick up guards during the retrace.
  • Problem is that SpecPropPass does this twice. Once to generate the spec and then once by calling super().call_operator(...) (https://github.com/.../exir/passes/spec_prop_pass.py...).
  • The tensor spec gets the symint from the first. But the graph and guards use the second.
  • Hence the tensor spec doesn't pick up on guards.

To resolve this, I've updated the SpecPropPass to re-trace the graph and then generate specs based on the meta values, not the traced ProxyValues (thanks @angelayi for the suggestion). This resolves the issue.

I originally saw this issue with the NMS torchvision op, but to avoid adding a new dep to the core EXIR tests, I've written a test with a custom op that uses an unbacked symint in the meta kernel output shape to replicate the bug in the same way.

Differential Revision: D85913581

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 31, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures

As of commit 1996324 with merge base 9981e41 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 31, 2025
@meta-codesync
Copy link

meta-codesync bot commented Oct 31, 2025

@GregoryComer has exported this pull request. If you are a Meta employee, you can view the originating Diff in D85913581.

@GregoryComer GregoryComer marked this pull request as draft October 31, 2025 00:24
@GregoryComer GregoryComer added ciflow/trunk release notes: exir Changes to any dialects and passes on these dialects, such as memory planning labels Oct 31, 2025
pytorch-bot bot pushed a commit that referenced this pull request Nov 6, 2025
Summary: Pull Request resolved: #15485

Differential Revision: D85913581
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 6, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 6, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
@GregoryComer GregoryComer requested a review from angelayi November 7, 2025 00:09
@GregoryComer
Copy link
Member Author

One additional note is that aliasing analysis feels pretty fragile as is. I fixed several subtle issues (luckily caught by CI) where my changes were accidentally planning two seperate tensors when they should alias / share one TensorSpec.

I'm wondering if we should re-write this pass again to either rely on ProxyValue reference equality or otherwise introduce some proper aliasing analysis. This is as opposed to hard coding that getitem and output, for example, always alias their argument.

This seems like it could get messy with non-functional custom ops or defunctionalization, in general. @JacobSzwejbka @angelayi what are your thoughts on this?

@GregoryComer GregoryComer changed the title Fix shape_env handling in SpecPropPass Fix double-tracing in SpecPropPass Nov 7, 2025
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 8, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 10, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 11, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
@meta-codesync
Copy link

meta-codesync bot commented Nov 11, 2025

@GregoryComer has imported this pull request. If you are a Meta employee, you can view this in D85913581.

@GregoryComer GregoryComer marked this pull request as ready for review November 11, 2025 05:10
GregoryComer added a commit to GregoryComer/executorch that referenced this pull request Nov 12, 2025
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
Summary: Pull Request resolved: pytorch#15485

Differential Revision: D85913581
@GregoryComer
Copy link
Member Author

Note that the moshi and zephyr size test failures are pre-existing.

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

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported release notes: exir Changes to any dialects and passes on these dialects, such as memory planning

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants