Skip to content

Conversation

@ydwu4
Copy link
Contributor

@ydwu4 ydwu4 commented Jul 25, 2024

@pytorch-bot
Copy link

pytorch-bot bot commented Jul 25, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 6667fbc with merge base 6c31e02 (image):
💚 Looks good so far! There are no failures yet. 💚

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

Fixes #131189.

By specializing the sym node when used as kwargs device.



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

[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jul 25, 2024
@ydwu4 ydwu4 added the topic: not user facing topic category label Jul 25, 2024
@ezyang
Copy link
Contributor

ezyang commented Jul 26, 2024

While it is possible that this is the best possible implementation, I am meh about it because it does not work with non strict export. Are we sure it's not possible to modify the argument parser to force the spec?

Fixes #131189.

By specializing the sym node when used as kwargs device.



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

[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jul 26, 2024
@ydwu4
Copy link
Contributor Author

ydwu4 commented Jul 26, 2024

Are we sure it's not possible to modify the argument parser to force the spec?

Updated the pr. In python_arg_parser.cpp, we allow the signature check to pass when device receives a SymInt input and 2. specialize it to integer. Also add an non_strict export test.

@ydwu4 ydwu4 added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 26, 2024
Fixes #131189.

We specialize the symint in python_arg_parser when used as kwarg device.



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

[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jul 26, 2024
@anijain2305 anijain2305 removed their request for review July 26, 2024 19:12
@ydwu4 ydwu4 changed the title [dynamo] specialize sym node when used as device kwarg Specialize sym node when used as device kwarg Jul 26, 2024
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

see comment

// then cast it back to python.
auto guarded_int = py::cast<c10::SymInt>(py::handle(obj))
.guard_int(__FILE__, __LINE__);
dst[i++] = py::cast(guarded_int).ptr();
Copy link
Contributor

Choose a reason for hiding this comment

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

This sure looks like it will result in an excessive decref later (if dst is owning). Can you argue why this has the right lifetime? (cc @albanD)

Copy link
Contributor Author

@ydwu4 ydwu4 Jul 29, 2024

Choose a reason for hiding this comment

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

Yeah, the life time is wrong. I'm not very familar to pybind and digged a bit into it: dst doesn't own py::cast(guarded_int). The integer is a local variable so dst will have a dangling pointer to it after we exits the if-statement. The previous diff works probably because gc hasn't cleaned the symint up. Thanks for pointing it out!

Updated the diff to defer the specialization to when we're actually creating Device from argument.

Fixes #131189.

We specialize the symint in python_arg_parser when used as kwarg device.



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

[ghstack-poisoned]
Fixes #131189.

We specialize the symint in python_arg_parser when used as kwarg device.



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

[ghstack-poisoned]
ydwu4 added a commit that referenced this pull request Jul 29, 2024
@ydwu4 ydwu4 requested a review from ezyang July 29, 2024 21:07
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Updated code sounds good

@ydwu4
Copy link
Contributor Author

ydwu4 commented Jul 30, 2024

@pytorchbot merge

@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

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.

7 participants