-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
Replace python random with torch.rand to enable dynamo.export #24434
Replace python random with torch.rand to enable dynamo.export #24434
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are touching multiple Flax model which shouldn't depend on torch, could you revert that?
Nice catch! Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! @amyeroberts could you have a quick second look here?
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this!
Changes LGTM 👍 I think technically this is slightly different as random.uniform can return 1, but for all practical purposes it doesn't change things.
@BowenBao Does this really solve the export problem. We are seeing export issues here - pytorch/pytorch#107587 If one peeks at the tensor value for the conditional, its a legit dynamic control flow. We might have to use |
@anijain2305 it does for inference export, since the actual condition is short circuited by |
What does this PR do?
Related and Fixes pytorch/pytorch#102794
TL;DR dynamo graph breaks on python
random.uniform(0, 1)
. The graph break can be prevented by replacing withtorch.randn([])
.Example repro script
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.