Skip to content

C++-accessible Placements via pybind11#163030

Closed
swolchok wants to merge 20 commits intogh/swolchok/839/basefrom
gh/swolchok/839/head
Closed

C++-accessible Placements via pybind11#163030
swolchok wants to merge 20 commits intogh/swolchok/839/basefrom
gh/swolchok/839/head

Conversation

This makes Placement data representation available in C++ via pybind11.

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Sep 16, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 54c6509 with merge base e5c0e6b (image):
💚 Looks good so far! There are no failures yet. 💚

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

@swolchok
Copy link
Copy Markdown
Contributor Author

I was overthinking how to do this. The overhead for grabbing the object from the pybind11 object is higher than I'd like but I think using this still results in a performance win despite that (see #163031).

@swolchok swolchok marked this pull request as draft September 16, 2025 04:15
Comment thread torch/csrc/autograd/python_variable.cpp Outdated
Comment thread torch/csrc/autograd/python_variable.cpp Outdated
} // namespace torch::autograd

// XXX: Move this somewhere
static const char placement_class_docstring[] =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should also be constexpr

Comment thread torch/csrc/autograd/python_variable.cpp Outdated

class Replicate : public Placement {
public:
~Replicate() {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should be equals default, right?

Comment thread torch/csrc/autograd/python_variable.cpp Outdated
explicit Partial(std::string reduce_op_) : reduce_op(std::move(reduce_op_)) {}

~Partial() {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Likewise here

Comment thread torch/csrc/autograd/python_variable.cpp Outdated
}
};

Placement::~Placement() {}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be equals default too? Why is it out of line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why is it out of line?

It's pure virtual, but still needs an implementation. Can't do both inline.

This makes Placement data representation available in C++ via pybind11.

[ghstack-poisoned]
This makes Placement data representation available in C++ via pybind11.

[ghstack-poisoned]
@swolchok
Copy link
Copy Markdown
Contributor Author

swolchok commented Sep 17, 2025

I'm not sure why BC Lint is so unhappy with what I've done here, especially now that I've updated torch/_C/__init__.pyi.in.

@swolchok swolchok added the release notes: distributed (dtensor) release notes category label Sep 18, 2025
This makes Placement data representation available in C++ via pybind11.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Sep 18, 2025
This makes Placement data representation available in C++ via pybind11.

ghstack-source-id: 9f85bee
Pull Request resolved: #163030
@swolchok swolchok added the suppress-bc-linter Suppresses the failures of API backward-compatibility linter (Lint/bc_linter) label Sep 18, 2025
…pybind11"

This makes Placement data representation available in C++ via pybind11.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Sep 18, 2025
This makes Placement data representation available in C++ via pybind11.

ghstack-source-id: d2edadb
Pull Request resolved: #163030
…"C++-accessible Placements via pybind11"

This makes Placement data representation available in C++ via pybind11.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Sep 19, 2025
… uncertainty on "DTensor: C++ compute_global_tensor_info"

compute_global_tensor_info is on the hot path for DTensor.{from,to}_local. More incremental progress toward C++.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Sep 19, 2025
… uncertainty on "Use C++-accessible Placement in compute_global_tensor_info"

This seems to speed things up, though there is more overhead than I'd like to unwrap a Placement via pybind11. Might be time to introduce nanobind; I'm not sure that we can use it in general, but the Placement type system is (currently?) isolated. (Alternatively, I could look into whether we can cut this overhead.)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Sep 19, 2025
… uncertainty on "C++-accessible Placements via pybind11"

This makes Placement data representation available in C++ via pybind11.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta ezyang msaroufim dcci

[ghstack-poisoned]
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

@swolchok your PR has been successfully reverted.

@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Oct 2, 2025
swolchok added a commit that referenced this pull request Oct 2, 2025
This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

Differential Revision: [D83788896](https://our.internmc.facebook.com/intern/diff/D83788896/)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 2, 2025
This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

Differential Revision: [D83788896](https://our.internmc.facebook.com/intern/diff/D83788896/)

ghstack-source-id: 313745131
Pull Request resolved: #164519
swolchok added a commit that referenced this pull request Oct 3, 2025
Pull Request resolved: #164519

This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.
ghstack-source-id: 313909406
@exported-using-ghexport

Differential Revision: [D83788896](https://our.internmc.facebook.com/intern/diff/D83788896/)
swolchok added a commit that referenced this pull request Oct 3, 2025
…ind11 (#163030)""

This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

Differential Revision: [D83788896](https://our.internmc.facebook.com/intern/diff/D83788896/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames Lucaskabela

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 3, 2025
This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

Differential Revision: [D83788896](https://our.internmc.facebook.com/intern/diff/D83788896/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames Lucaskabela

[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Oct 6, 2025
This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

D83788896

Pull Request resolved: #164519
Approved by: https://github.com/Skylion007, https://github.com/ezyang
swolchok added a commit that referenced this pull request Oct 7, 2025
…Partial to placement_types to improve discoverability"

Had trouble finding this one myself in #163030.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 7, 2025
…ment_types to improve discoverability"

Had trouble finding this one myself in #163030.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 7, 2025
…rove discoverability"

Had trouble finding this one myself in #163030.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 7, 2025
…lity"

Had trouble finding this one myself in #163030.

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci

[ghstack-poisoned]
pytorchmergebot added a commit that referenced this pull request Oct 7, 2025
…164519)"

This reverts commit 8c0bc87.

Reverted #164519 on behalf of https://github.com/malfet due to Still breaks internal workflows ([comment](#164519 (comment)))
swolchok added a commit that referenced this pull request Oct 13, 2025
Was reverted due to internal signal. After internal
discussion with @fadeputr, reapplying with no further changes seems to
be the right call.

Differential Revision: [D84515401](https://our.internmc.facebook.com/intern/diff/D84515401/)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 13, 2025
Was reverted due to internal signal. After internal
discussion with fadeputr, reapplying with no further changes seems to
be the right call.

Differential Revision: [D84515401](https://our.internmc.facebook.com/intern/diff/D84515401/)

ghstack-source-id: 315835168
Pull Request resolved: #165335
swolchok added a commit that referenced this pull request Oct 13, 2025
…pybind11 (#163030)""

Was reverted due to internal signal. After internal
discussion with fadeputr, reapplying with no further changes seems to
be the right call.

Differential Revision: [D84515401](https://our.internmc.facebook.com/intern/diff/D84515401/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames Lucaskabela

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 13, 2025
…""

Was reverted due to internal signal. After internal
discussion with fadeputr, reapplying with no further changes seems to
be the right call.

Differential Revision: [D84515401](https://our.internmc.facebook.com/intern/diff/D84515401/)

cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx chenyang78 kadeng chauhang amjames Lucaskabela

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 13, 2025
Pull Request resolved: #165335

Was reverted due to internal signal. After internal
discussion with @fadeputr, reapplying with no further changes seems to
be the right call.
ghstack-source-id: 315881161
@exported-using-ghexport

Differential Revision: [D84515401](https://our.internmc.facebook.com/intern/diff/D84515401/)
swolchok added a commit that referenced this pull request Oct 17, 2025
Was reverted due to a merge conflict that crept in sometime during the "export to github -> land internally -> merge on github" process.

Differential Revision: [D84862100](https://our.internmc.facebook.com/intern/diff/D84862100/)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 17, 2025
Was reverted due to a merge conflict that crept in sometime during the "export to github -> land internally -> merge on github" process.

Differential Revision: [D84862100](https://our.internmc.facebook.com/intern/diff/D84862100/)

ghstack-source-id: 316992680
Pull Request resolved: #165764
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
This makes Placement data representation available in C++ via pybind11.

Pull Request resolved: pytorch#163030
Approved by: https://github.com/ezyang
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
…torch#164519)

This makes Placement data representation available in C++ via pybind11. Reapply with fix for internal errors.

D83788896

Pull Request resolved: pytorch#164519
Approved by: https://github.com/Skylion007, https://github.com/ezyang
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Oct 21, 2025
…)" (pytorch#164519)"

This reverts commit 8c0bc87.

Reverted pytorch#164519 on behalf of https://github.com/malfet due to Still breaks internal workflows ([comment](pytorch#164519 (comment)))
swolchok added a commit that referenced this pull request Oct 23, 2025
Was reverted (again!) due to a merge conflict that crept in sometime during the "export to github -> land internally -> merge on github" process.

Differential Revision: [D85096233](https://our.internmc.facebook.com/intern/diff/D85096233/)

[ghstack-poisoned]
swolchok added a commit that referenced this pull request Oct 23, 2025
Was reverted (again!) due to a merge conflict that crept in sometime during the "export to github -> land internally -> merge on github" process.

Differential Revision: [D85096233](https://our.internmc.facebook.com/intern/diff/D85096233/)

ghstack-source-id: 318252481
Pull Request resolved: #166132
swolchok added a commit that referenced this pull request Oct 27, 2025
Pull Request resolved: #166132

Was reverted (again!) due to a merge conflict that crept in sometime during the "export to github -> land internally -> merge on github" process.
ghstack-source-id: 318928038
@exported-using-ghexport

Differential Revision: [D85096233](https://our.internmc.facebook.com/intern/diff/D85096233/)
@github-actions
Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo oncall: distributed Add this issue/PR to distributed oncall triage queue open source release notes: distributed (dtensor) release notes category Reverted Stale suppress-bc-linter Suppresses the failures of API backward-compatibility linter (Lint/bc_linter)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants