8000 [pytree][Easy] preserve `dict` keys in insertion order in CXX pytree by XuehaiPan · Pull Request #130140 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[pytree][Easy] preserve dict keys in insertion order in CXX pytree #130140

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
wants to merge 102 commits into from

Conversation

[ghstack-poisoned]
Copy link
pytorch-bot bot commented Jul 5, 2024

🔗 Helpful Links

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

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

✅ No Failures

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

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

[ghstack-poisoned]
XuehaiPan added 12 commits July 5, 2024 16:37
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Jul 7, 2024
[ghstack-poisoned]
[ghstack-poisoned]
XuehaiPan added a commit that referenced this pull request Jul 9, 2024
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 8, 2025
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 8, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 9, 2025
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 9, 2025
@XuehaiPan XuehaiPan changed the title [pytree] preserve dict keys in insertion order in CXX pytree [pytree][Easy] preserve dict keys in insertion order in CXX pytree Jan 9, 2025
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 9, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 10, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Jan 10, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 4, 2025
[ghstack-poisoned]
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 9, 2025
XuehaiPan added a commit to XuehaiPan/pytorch that referenced this pull request Feb 9, 2025
Comment on lines +64 to +65
__TORCH_DICT_SESSION = optree.dict_insertion_ordered(True, namespace="torch")
__TORCH_DICT_SESSION.__enter__() # enable globally and permanently
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

If you're sure about this. The fun thing is if someone imports torch cxx_pytree and uses optree then they will override the optree behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It only affects optree functions that passed with namespace="torch".

@XuehaiPan
Copy link
Collaborator Author

@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

Raymo111 pushed a commit that referenced this pull request Feb 20, 2025
…130140)

`optree` and JAX pytree traversal the `dict` in sorted key ordering (see [Key Ordering for Dictionaries](https://github.com/metaopt/optree#key-ordering-for-dictionaries)). While in PyTorch Python pytree, we traversal the `dict` in insertion order. See also:

- #114392

This aligns the behavior of CXX pytree with Python pytree.

Pull Request resolved: #130140
Approved by: https://github.com/zou3519
Ryo-not-rio pushed a commit to Ryo-not-rio/pytorch that referenced this pull request Feb 24, 2025
…ytorch#130140)

`optree` and JAX pytree traversal the `dict` in sorted key ordering (see [Key Ordering for Dictionaries](https://github.com/metaopt/optree#key-ordering-for-dictionaries)). While in PyTorch Python pytree, we traversal the `dict` in insertion order. See also:

- pytorch#114392

This aligns the behavior of CXX pytree with Python pytree.

Pull Request resolved: pytorch#130140
Approved by: https://github.com/zou3519
majing921201 pushed a commit to majing921201/pytorch that referenced this pull request Mar 4, 2025
…ytorch#130140)

`optree` and JAX pytree traversal the `dict` in sorted key ordering (see [Key Ordering for Dictionaries](https://github.com/metaopt/optree#key-ordering-for-dictionaries)). While in PyTorch Python pytree, we traversal the `dict` in insertion order. See also:

- pytorch#114392

This aligns the behavior of CXX pytree with Python pytree.

Pull Request resolved: pytorch#130140
Approved by: https://github.com/zou3519
@github-actions github-actions bot deleted the gh/XuehaiPan/108/head branch March 23, 2025 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged module: pytree open source topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0