Skip to content

Make ProcessGroup opaque - #172566

Closed
angelayi wants to merge 27 commits into
gh/angelayi/160/basefrom
gh/angelayi/160/head
Closed

angelayi wants to merge 27 commits into
gh/angelayi/160/basefrom
gh/angelayi/160/head

Conversation

@angelayi

@angelayi angelayi commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor

In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject

Stack from ghstack (oldest at bottom):

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @Lucaskabela @jataylo

@pytorch-bot

pytorch-bot Bot commented Jan 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (4 Unrelated Failures)

As of commit 02e0b16 with merge base 6335300 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but was 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.

@pytorch-bot pytorch-bot Bot added the release notes: distributed (c10d) release notes category label Jan 15, 2026
angelayi added a commit that referenced this pull request Jan 15, 2026
ghstack-source-id: 3ecd78e
Pull Request resolved: #172566
Comment thread torch/csrc/distributed/c10d/init.cpp Outdated
::c10d::ProcessGroup, ::c10d::PyProcessGroup>(
module,
"ProcessGroup",
py::metaclass(abc_meta.ptr()),

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.

What happens to the reference count of abc_meta here? Won't it get decremented?
Do you actually want?

Suggested change
py::metaclass(abc_meta.ptr()),
py::metaclass(abc_module.attr("ABCMeta")),

RIght now this creates a temporary object, increments, gives the pointer, and then decrements it.

angelayi added a commit that referenced this pull request Jan 15, 2026
ghstack-source-id: be7ed4f
Pull Request resolved: #172566
@angelayi
angelayi marked this pull request as draft January 15, 2026 19:45
angelayi added a commit that referenced this pull request Jan 15, 2026
ghstack-source-id: e1276f1
Pull Request resolved: #172566
angelayi added a commit that referenced this pull request Jan 15, 2026
ghstack-source-id: 3781f99
Pull Request resolved: #172566
@angelayi
angelayi marked this pull request as ready for review January 15, 2026 23:23
In order to register ProcessGroup as an opaque object we need to make it subclass ABC. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





[ghstack-poisoned]
angelayi added a commit that referenced this pull request Jan 16, 2026
ghstack-source-id: d2d5677
Pull Request resolved: #172566
angelayi added a commit that referenced this pull request Jan 16, 2026
ghstack-source-id: d2d5677
Pull Request resolved: #172566
In order to register ProcessGroup as an opaque object we need to make it subclass ABC. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





[ghstack-poisoned]
angelayi added a commit that referenced this pull request Jan 16, 2026
ghstack-source-id: ca622ac
Pull Request resolved: #172566
In order to register ProcessGroup as an opaque object we need to make it subclass ABC. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





[ghstack-poisoned]
angelayi added a commit that referenced this pull request Jan 16, 2026
ghstack-source-id: ea977e5
Pull Request resolved: #172566
In order to register ProcessGroup as an opaque object we need to make it subclass ABC. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





[ghstack-poisoned]
angelayi added a commit that referenced this pull request Jan 20, 2026
ghstack-source-id: c980589
Pull Request resolved: #172566
Comment thread torch/csrc/distributed/c10d/init.cpp Resolved

@zou3519 zou3519 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks fine but do you have a test?

@angelayi angelayi changed the title Make ProcessGroup metaclass ABC Make ProcessGroup metaclass OpaqueBase Jan 20, 2026
In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo

[ghstack-poisoned]
@angelayi

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
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

@atalman

atalman commented Feb 19, 2026

Copy link
Copy Markdown
Collaborator

@pytorchmergebot revert -c nosignal -m "GH job link HUD commit link"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@angelayi your PR has been successfully reverted.

In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo

[ghstack-poisoned]
@angelayi

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Command git -C /home/runner/work/pytorch/pytorch cherry-pick -x adb0e79e77ff03fd09b522f4a6875c1c68c8ca92 returned non-zero exit code 1

Auto-merging torch/_dynamo/variables/distributed.py
CONFLICT (content): Merge conflict in torch/_dynamo/variables/distributed.py
Auto-merging torch/_dynamo/variables/script_object.py
Auto-merging torch/_dynamo/variables/torch.py
Auto-merging torch/csrc/distributed/c10d/init.cpp
Auto-merging torch/distributed/device_mesh.py
Auto-merging torch/distributed/tensor/_api.py
error: could not apply adb0e79e77f... Make ProcessGroup opaque (#172566)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Details for Dev Infra team Raised by workflow job

radeksm pushed a commit to radeksm/pytorch that referenced this pull request Feb 20, 2026
In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject





cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx kadeng chauhang amjames Lucaskabela jataylo

[ghstack-poisoned]
@angelayi

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
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

norx1991 pushed a commit that referenced this pull request Feb 24, 2026
In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject

Pull Request resolved: #172566
Approved by: https://github.com/zou3519
norx1991 pushed a commit that referenced this pull request Feb 24, 2026
In order to register ProcessGroup as an opaque object we need to make it metaclass torch._opaque_base.OpaqueBaseMeta. This allows us to register FakeScriptObject as a virtual subclass of ProcessGroup, allowing us to trace through isinstance(x, ProcessGroup) correctly when x is a FakeScriptObject

Pull Request resolved: #172566
Approved by: https://github.com/zou3519
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 keep-going Don't stop on first failure, keep running tests until the end Merged module: dynamo release notes: distributed (c10d) release notes category release notes: distributed (dtensor) release notes category Reverted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants