Skip to content

Conversation

@jovianjaison
Copy link
Contributor

@jovianjaison jovianjaison commented Aug 20, 2025

Note: Adding unit test for this is tricky as having errors in the specific unit test would cause test_utils.py to crash all together.

Tested as follows:

  1. Added x = 1/0 after guarded_code = compile_inner(code, one_graph, hooks, transform) in convert_frame.py
  2. Printed exception_stack_trace and got: ['Traceback (most recent call last):\n File "/data/users/jovian/pytorch/torch/_dynamo/convert_frame.py", line 1207, in _compile\n x = 1/0\n ^\nZeroDivisionError: division by zero\n']

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

@pytorch-bot
Copy link

pytorch-bot bot commented Aug 20, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit ecea5cb with merge base 24e7f3c (image):
💚 Looks good so far! There are no failures yet. 💚

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

@jovianjaison
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Aug 20, 2025
@c00w
Copy link
Contributor

c00w commented Aug 20, 2025

For adding a unit test, I expect if you turn on suppress errors, nothing will throw, but also we can just catch the exception that gets thrown within the unit tests? (assertRaises, or just try except).

In order to generate the error, I expect unsupported exceptions should work fine -I.e. LSTMs are not supported so torch.compiling one of those should produce a log with a exception.

Copy link
Contributor

@c00w c00w left a comment

Choose a reason for hiding this comment

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

Only blocker is a test

@jovianjaison
Copy link
Contributor Author

For adding a unit test, I expect if you turn on suppress errors, nothing will throw, but also we can just catch the exception that gets thrown within the unit tests? (assertRaises, or just try except).

In order to generate the error, I expect unsupported exceptions should work fine -I.e. LSTMs are not supported so torch.compiling one of those should produce a log with a exception.

The LSTM compilation didn't throw and exception. Modeled a graph break and exception throw because of a print statement in backward.

@jovianjaison
Copy link
Contributor Author

Only blocker is a test

Added.

@jovianjaison jovianjaison requested a review from c00w August 21, 2025 17:06
print("graph break!") # This should trigger a Dynamo error
return grad_output

CustomFuncBwdPrintGraphBreak = type(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - This is all mostly redundant, I expect that you can either directly torch.compile the backward function and get an error, or worse comes to worse, make a nn module, and have it's forward direction directly call print.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@jovianjaison
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Aug 22, 2025
@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 pushed a commit to pytorch/benchmark that referenced this pull request Aug 24, 2025
Summary:
Note: Adding unit test for this is tricky as having errors in the specific unit test would cause test_utils.py to crash all together.

Tested as follows:
1. Added x = 1/0 after guarded_code = compile_inner(code, one_graph, hooks, transform) in convert_frame.py
2. Printed exception_stack_trace and got: ['Traceback (most recent call last):\n  File "/data/users/jovian/pytorch/torch/_dynamo/convert_frame.py", line 1207, in _compile\n    x = 1/0\n        ~^~\nZeroDivisionError: division by zero\n']

X-link: pytorch/pytorch#161096
Approved by: https://github.com/c00w

Reviewed By: seemethere

Differential Revision: D80776058

fbshipit-source-id: 3531dc2df17f8f18a78c13551950563ef3a46059
markc-614 pushed a commit to markc-614/pytorch that referenced this pull request Sep 17, 2025
Note: Adding unit test for this is tricky as having errors in the specific unit test would cause test_utils.py to crash all together.

Tested as follows:
1. Added x = 1/0 after guarded_code = compile_inner(code, one_graph, hooks, transform) in convert_frame.py
2. Printed exception_stack_trace and got: ['Traceback (most recent call last):\n  File "/data/users/jovian/pytorch/torch/_dynamo/convert_frame.py", line 1207, in _compile\n    x = 1/0\n        ~^~\nZeroDivisionError: division by zero\n']

Pull Request resolved: pytorch#161096
Approved by: https://github.com/c00w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants