-
Notifications
You must be signed in to change notification settings - Fork 24.8k
[dynamo][pytree][2/N] make CXX pytree traceable: tree_flatten
/ tree_unflatten
/ tree_structure
#137398
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
Closed
Closed
[dynamo][pytree][2/N] make CXX pytree traceable: tree_flatten
/ tree_unflatten
/ tree_structure
#137398
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
1b1d91a
Update
XuehaiPan 2ee4eb2
Update
XuehaiPan a090e3c
Update
XuehaiPan 5bbc747
Update
XuehaiPan ccf7344
Update
XuehaiPan cd1f888
Update
XuehaiPan 6a5a8a5
Update
XuehaiPan c498d86
Update
XuehaiPan 9e2f0fa
Update
XuehaiPan 91651fe
Update
XuehaiPan 82ed62c
Update
XuehaiPan ab204c7
Update
XuehaiPan d9a23dc
Update
XuehaiPan 1c045eb
Update
XuehaiPan d7dad64
Update
XuehaiPan 2065856
Update
XuehaiPan 45d3400
Update
XuehaiPan 0e41f97
Update
XuehaiPan 5315c2f
Update
XuehaiPan 42c519b
Update
XuehaiPan 2b9f79e
Update
XuehaiPan 118e901
Update
XuehaiPan 3422498
Update
XuehaiPan 732057f
Update
XuehaiPan 5e9c01c
Update
XuehaiPan 16602a5
Update
XuehaiPan 3c2bddb
Update
XuehaiPan 8164ebf
Update
XuehaiPan cac8c23
Update
XuehaiPan 8ba2581
Update
XuehaiPan 1b97c3f
Update
XuehaiPan 16a35da
Update
XuehaiPan 348dd58
Update
XuehaiPan c230fa7
Update
XuehaiPan fd704f8
Update
XuehaiPan cfce0bb
Update
XuehaiPan 0e0f86e
Update
XuehaiPan b539cb9
Update
XuehaiPan 7f6e449
Update
XuehaiPan a8a4315
Update
XuehaiPan 13c5af3
Update
XuehaiPan f0cea0b
Update
XuehaiPan 29ffbbf
Update
XuehaiPan 9ff3312
Update
XuehaiPan cb9abcc
Update
XuehaiPan 32200cf
Update
XuehaiPan 31a7f76
Update
XuehaiPan 4477993
Update
XuehaiPan 7ad1a4a
Update
XuehaiPan 5820dcd
Update
XuehaiPan 9d3affb
Update
XuehaiPan 2089924
Update
XuehaiPan c6ee2f9
Update
XuehaiPan 531cbe4
Update
XuehaiPan 28a1225
Update
XuehaiPan 4757b69
Update
XuehaiPan 473c032
Update
XuehaiPan 2c42b81
Update
XuehaiPan 75fbfed
Update
XuehaiPan 87ab4da
Update
XuehaiPan bb53b36
Update
XuehaiPan 2a6463c
Update
XuehaiPan 49cd5ce
Update
XuehaiPan 17d9823
Update
XuehaiPan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only o
2E54
ne suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@XuehaiPan, if I'm understanding this correctly, you're adding a polyfill for cxx_pytree.tree_flatten such that it will return an instance of this PyTreeSpec class. I'm not sure this works if we are trying to return a PyTreeSpec from a torch.compile'd function: does it create an instance of this "class PyTreeSpec" object, or does it create an instance of torch.utils._cxx_pytree.TreeSpec?
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.
In a compiled function, it returns
torch._dynamo.polyfills.pytree.PyTreeSpec
. This class provides the exactly same interfaces withtorch.utils._cxx_pytree.TreeSpec
.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.
Yeah this is wrong, see the following:
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.
I see. It may cause problems if we only compile part of the program.
There is an in-progress polyfill infra for C++ classes.
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.
Opened a PR to fix this:
isinstance(...)
check for polyfilled class #146921