KEMBAR78
switch prefer_deferred_runtime_asserts_over_guards in export by avikchaudhuri · Pull Request #160111 · pytorch/pytorch · GitHub
Skip to content

Conversation

@avikchaudhuri
Copy link
Contributor

@avikchaudhuri avikchaudhuri commented Aug 7, 2025

Summary:
In preparation for checking shape guards in export, this PR effectively switches prefer_deferred_runtime_asserts_over_guards to False, matching Dynamo.

Actually that's a lie: we switch it to allow_complex_guards_as_runtime_asserts, which is False by default but can be controlled via an internally API to be True. This makes the two flags synchronized, so we should be able to kill allow_complex_guards_as_runtime_asserts at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 7, 2025

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit 30e9d1e with merge base 4b4cdcf (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 7, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 8, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 8, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
pytorch-bot bot pushed a commit that referenced this pull request Aug 13, 2025
Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 13, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
dynamic_shapes: Optional[Union[dict[str, Any], tuple[Any, ...], list[Any]]] = None,
strict: bool = False,
preserve_module_call_signature: tuple[str, ...] = (),
prefer_deferred_runtime_asserts_over_guards: bool = False,
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be in the toplevel export API?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel you also need to propagate it to export_for_training as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@angelayi Yes, intentional: I pushed it up to the top level to act as a switch to manage risk.

@tugsbayasgalan The tests didn't need me to push this to export_for_training. Since it's on the way to deprecation, leave as is?

Copy link
Contributor

@tugsbayasgalan tugsbayasgalan Aug 14, 2025

Choose a reason for hiding this comment

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

Hmm interesting. Today torch.export.export calls into torch.export._trace._export_for_training at pre-dispatch level. So if tests are not catching it, something seems off. I still think we should add it tho because the way we are marketing the deprecation is that torch.export.export and torch.export.export_for_training are exact same APIs. Having different flags will make them look different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, _export_for_training does have this flag. Anyway, I can add it.

pytorch-bot bot pushed a commit that referenced this pull request Aug 21, 2025
Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 21, 2025
…#160111)

Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 21, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 21, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 26, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@avikchaudhuri avikchaudhuri force-pushed the export-D79734206 branch 2 times, most recently from 0b17893 to 2014a9b Compare August 26, 2025 23:48
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 26, 2025
…#160111)

Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 26, 2025
…#160111)

Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 26, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 27, 2025
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 27, 2025
…#160111)

Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
avikchaudhuri added a commit to avikchaudhuri/pytorch that referenced this pull request Aug 27, 2025
…#160111)

Summary:

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo. 

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
…#160111)

Summary:
Pull Request resolved: pytorch#160111

In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D79734206

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 27, 2025
@avikchaudhuri
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

Can't merge closed PR #160111

markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
…#160111)

Summary:
In preparation for checking shape guards in export, this PR effectively switches `prefer_deferred_runtime_asserts_over_guards` to `False`, matching Dynamo.

Actually that's a lie: we switch it to `allow_complex_guards_as_runtime_asserts`, which is `False` by default but can be controlled via an internally API to be `True`. This makes the two flags synchronized, so we should be able to kill `allow_complex_guards_as_runtime_asserts` at this point.

Test Plan:
updated tests

Rollback Plan:

Differential Revision: D79734206

Pull Request resolved: pytorch#160111
Approved by: https://github.com/tugsbayasgalan
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.

5 participants