Skip to content
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

[dynamo] graph break on const dict KeyError #125882

Closed
wants to merge 6 commits into from

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented May 9, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 20b4ba9 with merge base 1966612 (image):
💚 Looks good so far! There are no failures yet. 💚

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

williamwen42 added a commit that referenced this pull request May 9, 2024
ghstack-source-id: 7104397e77939827b03c15592bba1a946db9c3ba
Pull Request resolved: #125882
@williamwen42 williamwen42 added the topic: not user facing topic category label May 9, 2024
[ghstack-poisoned]
williamwen42 added a commit that referenced this pull request May 10, 2024
ghstack-source-id: 8f07c5d01b78be12fa8177a432fcd6c8995084a7
Pull Request resolved: #125882
[ghstack-poisoned]
williamwen42 added a commit that referenced this pull request May 10, 2024
ghstack-source-id: 0a98e95179b0b809528ecdbb6a39235beea34978
Pull Request resolved: #125882
@williamwen42 williamwen42 added the keep-going Don't stop on first failure, keep running tests until the end label May 10, 2024
[ghstack-poisoned]
williamwen42 added a commit that referenced this pull request May 10, 2024
ghstack-source-id: 9381c55dd2bada26bdb12b5b14bfe7b493af0074
Pull Request resolved: #125882
Comment on lines +794 to +795
except Exception as exc:
unimplemented(f"constant fold exception: {repr(exc)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

What error is this catching? I worry this will be hiding bugs.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is catching an error on from a python call - fn would be a builtin function. Idea is that if we get a python error when trying to constant fold, we bubble up the error to skip the frame, then we evaluate the frame as normal, which would result in the same error. In the case of the repro, we would be catching a KeyError.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make catch case more narrow, perhaps by checking the message and warning if it is somthing else.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that any possible exception raised by a function in _constant_fold_functions would have to be caught, e.g. KeyError, ZeroDivisionError, AttributeError, ValueError, etc. We could determine a list of allowed exceptions (by going through the builtin constant fold op list and manually checking for exceptions that could be raised), but if we miss any, then tracing any code like below would crash:

def fn(x):
    try:
        y = ... # builtin constant fold op with constants that raises an exception we missed
        # e.g. we forgot ZeroDivisionError for y = 1 / 0
    except Exception:
        y = 1
    return x + y

What kind of bugs do you think would be hidden? My intent here is that if running the builtin op results in an exception, we should skip the frame, then default evaluation will also raise the exception and run any exception handlers.

Comment on lines +794 to +795
except Exception as exc:
unimplemented(f"constant fold exception: {repr(exc)}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make catch case more narrow, perhaps by checking the message and warning if it is somthing else.

[ghstack-poisoned]
williamwen42 added a commit that referenced this pull request May 13, 2024
ghstack-source-id: cbd13cd86e9e1003e1ae9cde6b2c676aa77c964f
Pull Request resolved: #125882
[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request May 15, 2024
pytorchmergebot pushed a commit that referenced this pull request May 15, 2024
Fixes #93624 but also requires jcmgray/autoray#20 to be fixed.

Pull Request resolved: #125945
Approved by: https://github.com/jansel
ghstack dependencies: #125882, #125943
ZelboK pushed a commit to ZelboK/pytorch that referenced this pull request May 19, 2024
ZelboK pushed a commit to ZelboK/pytorch that referenced this pull request May 19, 2024
ZelboK pushed a commit to ZelboK/pytorch that referenced this pull request May 19, 2024
Fixes pytorch#93624 but also requires jcmgray/autoray#20 to be fixed.

Pull Request resolved: pytorch#125945
Approved by: https://github.com/jansel
ghstack dependencies: pytorch#125882, pytorch#125943
@github-actions github-actions bot deleted the gh/williamwen42/78/head branch June 15, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/inductor keep-going Don't stop on first failure, keep running tests until the end Merged module: dynamo topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants