Skip to content

Set prefer_deferred_runtime_asserts_over_guards to True#165820

Closed
justinchuby wants to merge 1 commit intopytorch:mainfrom
justinchuby:justinchu/prefer-runtime-check
Closed

Set prefer_deferred_runtime_asserts_over_guards to True#165820
justinchuby wants to merge 1 commit intopytorch:mainfrom
justinchuby:justinchu/prefer-runtime-check

Conversation

@justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Oct 18, 2025

Set prefer_deferred_runtime_asserts_over_guards to True and allow a flag to control the behavior, just in case.

This option has enable the gemma3 model export with transformers==4.57. I am not sure how best to test it though.

cc @titaiwangms

Signed-off-by: Justin Chu <justinchu@microsoft.com>
@justinchuby justinchuby added the module: onnx Related to torch.onnx label Oct 18, 2025
@justinchuby justinchuby added the topic: improvements topic category label Oct 18, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 18, 2025

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit a4361c1 with merge base 9095a9d (image):

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

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

@pytorch-bot pytorch-bot bot added the release notes: onnx torch.onnx related changes that should show up in the release notes label Oct 18, 2025
@justinchuby justinchuby requested a review from xadupre October 18, 2025 04:29
@albanD albanD added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Oct 19, 2025
PREFER_DEFERRED_RUNTIME_ASSERTS_OVER_GUARDS: bool = _load_boolean_flag(
"TORCH_ONNX_PREFER_DEFERRED_RUNTIME_ASSERTS_OVER_GUARDS",
this_will="set prefer_deferred_runtime_asserts_over_guards when calling torch.export",
default=True,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@titaiwangms default is set here

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean default by torch, it's False? I am wondering if we change the default, would it cause regression?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, the default in torch is False. If the arg does what it claims to do though it is just going to not enforce the guards during export but instead make them runtime asserts (which we ignore). I think that’s a reasonable thing to do. I propose that we at least try it and run the benchmarks.

@justinchuby
Copy link
Collaborator Author

@pytorchbot merge -i

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 25, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged while ignoring the following 2 checks: pull / linux-jammy-py3.13-clang12 / test (crossref, 1, 2, linux.2xlarge), pull / linux-jammy-py3.13-clang12 / test (dynamo_wrapped, 3, 3, linux.2xlarge)

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

@justinchuby justinchuby deleted the justinchu/prefer-runtime-check branch October 25, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: improvements topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants