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

[torchbind] fix bug of mutating FakeScriptObjects twice in aot_export #128844

Closed
wants to merge 4 commits into from

Conversation

ydwu4
Copy link
Contributor

@ydwu4 ydwu4 commented Jun 17, 2024

Stack from ghstack (oldest at bottom):

This PR does two things:

  1. it duplicates the fake script object because aot_export trace the program twice. The result of tracing in the first time would cause the tracing result of second time be wrong.
  2. Also add a new test for methods that return constant outputs. Before the PR, there's is no meta["val"] for these nodes because fx won't track these constants. We still need to preserve these constant return operators in the graph because torchbind objects are stateful and deleting it would remove the implicit state mutation inside of the object.

Copy link

pytorch-bot bot commented Jun 17, 2024

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 30af8dd with merge base 93a33bf (image):

UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:

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

ydwu4 added a commit that referenced this pull request Jun 17, 2024
ghstack-source-id: 6dc6afe2b72912e42c6e6c33ba4ab0a07ecae52c
Pull Request resolved: #128844
@ydwu4 ydwu4 requested a review from angelayi June 17, 2024 16:50
… aot_export"


This PR does two things:
1. it duplicates the fake script object because aot_export trace the program twice. The result of tracing in the first time would cause the tracing result of second time be wrong.
2. Also add a new test for methods that return constant outputs. Before the PR, there's is no meta["val"] for these nodes because fx won't track these constants. However, we need to preserve these constant return operators in the graph because torchbind objects are stateful and deleting it would remove the implicit state mutation inside of the object.



[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jun 20, 2024
ghstack-source-id: 4bd826f13a5423262d9c3364cea2395b7a729139
Pull Request resolved: #128844
Copy link
Contributor

@angelayi angelayi left a comment

Choose a reason for hiding this comment

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

I'm not sure if it's good to store the real script object inside of the fake script object.. because it's like, what's the point of having a fake one then 😂
But I can't think of a better way to duplicate a FakeScriptObject so I will stamp

… aot_export"


This PR does two things:
1. it duplicates the fake script object because aot_export trace the program twice. The result of tracing in the first time would cause the tracing result of second time be wrong.
2. Also add a new test for methods that return constant outputs. Before the PR, there's is no meta["val"] for these nodes because fx won't track these constants. We still need to preserve these constant return operators in the graph because torchbind objects are stateful and deleting it would remove the implicit state mutation inside of the object.



[ghstack-poisoned]
… aot_export"


This PR does two things:
1. it duplicates the fake script object because aot_export trace the program twice. The result of tracing in the first time would cause the tracing result of second time be wrong.
2. Also add a new test for methods that return constant outputs. Before the PR, there's is no meta["val"] for these nodes because fx won't track these constants. We still need to preserve these constant return operators in the graph because torchbind objects are stateful and deleting it would remove the implicit state mutation inside of the object.



[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jun 24, 2024
ghstack-source-id: 9c72d9d5aeacfb2cd476fb8adaa95837c00232cd
Pull Request resolved: #128844
@ydwu4
Copy link
Contributor Author

ydwu4 commented Jun 24, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 24, 2024
@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

@github-actions github-actions bot deleted the gh/ydwu4/126/head branch July 25, 2024 01:58
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.

None yet

3 participants