Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[nativert] Move Pytree #155136

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 1 commit into from
Closed

Conversation

yushangdi
Copy link
Contributor

@yushangdi yushangdi commented Jun 4, 2025

Summary: fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

Torch Native Runtime RFC: pytorch/rfcs#72

Test Plan:

buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:pytree_test

OSS CI

Rollback Plan:

Differential Revision: D75965059

Copy link

pytorch-bot bot commented Jun 4, 2025

🔗 Helpful Links

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

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 5a299f0 with merge base 1dd0b1d (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

@Skylion007
Copy link
Collaborator

I'm sure @XuehaiPan has some thoughts here

@Skylion007 Skylion007 self-assigned this Jun 4, 2025
@zhxchen17
Copy link
Contributor

I think we mean to move the code to nativert/ as part of the impl details. To add some context, we don't intend to expose this as part of public API. Also this pytree impl contains many optimizations we accumulated to high qps low latency model serving use cases and imo we should still recommend ppl to use optree in common cases.

@zhxchen17 zhxchen17 added the topic: not user facing topic category label Jun 4, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#155136

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:pytree_test
```

OSS CI

Rollback Plan:

Differential Revision: D75965059
@yushangdi
Copy link
Contributor Author

Also this pytree impl contains many optimizations we accumulated to high qps low latency model serving use cases and imo we should still recommend ppl to use optree in common cases.

@zhxchen17 sure, I'll move it to nativert/detail instead then.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: pytorch#155136

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:pytree_test
```

OSS CI

Differential Revision: D75965059
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 4, 2025
pytorch-bot bot pushed a commit that referenced this pull request Jun 4, 2025
Summary:
Pull Request resolved: #155136

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:pytree_test
```

OSS CI

Differential Revision: D75965059
@yushangdi yushangdi requested review from albanD and cyyever June 4, 2025 18:58
albanD
albanD previously requested changes Jun 4, 2025
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.

@zou3519 how does that align with the other c++ pytree discussion we've been having?

@yushangdi yushangdi requested a review from zou3519 June 4, 2025 19:50
@zou3519
Copy link
Contributor

zou3519 commented Jun 4, 2025

@zou3519 how does that align with the other c++ pytree discussion we've been having?

@albanD when we say C++ pytree we really mean two things:

  1. Python bindings for C++ functionality to flatten/unflatten PyObject* Python containers
  2. C++ functionality to flatten/unflatten IValues

"C++ Pytree" and optree is (1). We don't have (2) in PyTorch. This PR adds (2).
There are use cases for both, e.g. executorch has both (1) and (2).

My conclusion is that we should allow this PR and that it is unrelated to the optree story. If we're up to it then we should probably name it something else other than "pytree", because there's no Python involved

@yushangdi
Copy link
Contributor Author

yushangdi commented Jun 4, 2025

If we're up to it then we should probably name it something else other than "pytree", because there's no Python involved

I'd argue it's not completely unrelated to python, because it does register and process the string representation of python types in json, e.g. builtins.tuple, torch.fx.immutable_collections.immutable_dict...

But if we really want a name other than pytree, @zou3519 @zhxchen17 do you have any suggestion for a better name? maybe TreeSpec.h?

@yushangdi yushangdi requested a review from albanD June 4, 2025 23:00
torch/nativert/detail/Pytree.h Outdated Show resolved Hide resolved
torch/nativert/detail/Pytree.cpp Outdated Show resolved Hide resolved
@yushangdi
Copy link
Contributor Author

@XuehaiPan @zou3519 How about we just re-use the NestedStructure.h name from https://github.com/pytorch/pytorch/pull? I can change the file name from Pytree.h and Pytree.cpp to NestedStructure.h and NestedStructure.cpp.

pytorch-bot bot pushed a commit that referenced this pull request Jun 9, 2025
…cture (#155136)

Summary:
Pull Request resolved: #155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: #155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `NestedSpec`
2.  `treeSpecLoads` -> `nestedSpecLoads`
3.  `treeFlatten` -> `nestedFlatten`
4.  `treeUnflatten` -> `nestedUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zhxchen17

Differential Revision: D75965059
@yushangdi yushangdi requested a review from zou3519 June 9, 2025 21:47
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 9, 2025
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `NestedSpec`
2.  `treeSpecLoads` -> `nestedSpecLoads`
3.  `treeFlatten` -> `nestedFlatten`
4.  `treeUnflatten` -> `nestedUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zhxchen17

Differential Revision: D75965059
@yushangdi
Copy link
Contributor Author

@zou3519 updated to use ITree now :)

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 11, 2025
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `NestedSpec`
2.  `treeSpecLoads` -> `nestedSpecLoads`
3.  `treeFlatten` -> `nestedFlatten`
4.  `treeUnflatten` -> `nestedUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zou3519, zhxchen17

Differential Revision: D75965059
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 11, 2025
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `NestedSpec`
2.  `treeSpecLoads` -> `nestedSpecLoads`
3.  `treeFlatten` -> `nestedFlatten`
4.  `treeUnflatten` -> `nestedUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zou3519, zhxchen17

Differential Revision: D75965059
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 11, 2025
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `ITreeSpec`
2.  `treeSpecLoads` -> `itreeSpecLoads`
3.  `treeFlatten` -> `itreeFlatten`
4.  `treeUnflatten` -> `itreeUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zou3519, zhxchen17

Differential Revision: D75965059
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

yushangdi added a commit to yushangdi/pytorch that referenced this pull request Jun 11, 2025
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `ITreeSpec`
2.  `treeSpecLoads` -> `itreeSpecLoads`
3.  `treeFlatten` -> `itreeFlatten`
4.  `treeUnflatten` -> `itreeUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zou3519, zhxchen17

Differential Revision: D75965059
…orch#155136)

Summary:
Pull Request resolved: pytorch#155136

Torch Native Runtime RFC: pytorch/rfcs#72

As part of the effort to open source TorchNativeRuntime (or what we call Sigmoid), we are moving the Pytree implementation to torch/:

fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

We also renamed the functions, the reason behind renaming is in this discussion: pytorch#155136

The functionalities and implementation remain the same.

Rename the class and functions:

1.  `TreeSpec` -> `ITreeSpec`
2.  `treeSpecLoads` -> `itreeSpecLoads`
3.  `treeFlatten` -> `itreeFlatten`
4.  `treeUnflatten` -> `itreeUnflatten`
5.  `leafApply` -> `ivalueApply`
6.  `leafApplyFromArgs` -> `ivalueApplyFromArgs`

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:itree_test
```

OSS CI

Reviewed By: zou3519, zhxchen17

Differential Revision: D75965059
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D75965059

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@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

thatgeeman pushed a commit to thatgeeman/pytorch-docathon that referenced this pull request Jun 15, 2025
Summary: fbcode/sigmoid/core/common -> fbcode/caffe2/torch/nativert/common

Torch Native Runtime RFC: pytorch/rfcs#72

Test Plan:
```
buck run fbcode//mode/dev-nosan  //caffe2/test/cpp/nativert:pytree_test
```

OSS CI

Rollback Plan:

Differential Revision: D75965059

Pull Request resolved: pytorch#155136
Approved by: https://github.com/zhxchen17, https://github.com/XuehaiPan, https://github.com/zou3519
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 fb-exported Merged topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.