KEMBAR78
[export] Deserialize args with python keyword names by angelayi · Pull Request #136036 · pytorch/pytorch · GitHub
Skip to content

Conversation

@angelayi
Copy link
Contributor

@angelayi angelayi commented Sep 13, 2024

Currently when we deserialize inputs to nodes, we deserialize arguments with default values as kwargs. So deserializing aten.uniform, which has the signature uniform(Tensor(a!) self, float from=0, float to=1, *, Generator? generator=None) -> Tensor(a!), will get become uniform(x, from=0, to=1). However, this fails when running in python because from is a python keyword. So the solution here is to not deserialize it as a kwarg.

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 13, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 35280a8 with merge base 66db61f (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot
Copy link
Contributor

@angelayi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@angelayi angelayi changed the title [export] Deserialize args with keyword names [export] Deserialize args with python keyword names Sep 13, 2024
@angelayi angelayi force-pushed the angelayi/deserialize_keyword branch from d018277 to 35280a8 Compare September 13, 2024 21:25
@facebook-github-bot
Copy link
Contributor

@angelayi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@zhxchen17
Copy link
Contributor

I mean I can accept this as a short term measure, but why this schema has a keyable argument with keyword name in this first place... Does that mean no one will ever be able to use this argument with the name in Python?

@angelayi
Copy link
Contributor Author

@zhxchen17 I think it's probably a bug that the op's schema has a kwarg with a keyword name, or it was not expected to be used this way, since it seems like the op was added into native_functions.yaml long long ago

Copy link
Contributor

@zhxchen17 zhxchen17 left a comment

Choose a reason for hiding this comment

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

ok :(

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge -f 'Landed internally'

(Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Currently when we deserialize inputs to nodes, we deserialize arguments with default values as kwargs. So deserializing `aten.uniform`, which has the signature `uniform(Tensor(a!) self, float from=0, float to=1, *, Generator? generator=None) -> Tensor(a!)`, will get become `uniform(x, from=0, to=1)`. However, this fails when running in python because `from` is a python keyword. So the solution here is to not deserialize it as a kwarg.
Pull Request resolved: pytorch#136036
Approved by: https://github.com/zhxchen17
@github-actions github-actions bot deleted the angelayi/deserialize_keyword branch October 18, 2024 02:05
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.

4 participants