Skip to content

[DebugMode] Support builds without distributed - #200981

Draft
pianpwk wants to merge 1 commit into
gh/pianpwk/160/basefrom
gh/pianpwk/160/head
Draft

pianpwk wants to merge 1 commit into
gh/pianpwk/160/basefrom
gh/pianpwk/160/head

Conversation

@pianpwk

@pianpwk pianpwk commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

DebugMode crashed on construction in builds with USE_DISTRIBUTED=0 (e.g.
macOS CI): init unconditionally imported torch.distributed.tensor, which
imports torch._C._distributed_c10d. torch_dispatch and the stringify/hash
helpers had the same unconditional DTensor, LocalTensor and
AsyncCollectiveTensor references.

All of these exist only to handle distributed tensor types, which cannot exist
when distributed is unavailable, so gate them on
torch.distributed.is_available(). record_nn_module still requires distributed
(ModTracker lives in torch.distributed._tools); it is opt-in and left as is.

This lets the set_output_grad_dtype DebugMode tests from the previous commit
run without distributed, so their skips are removed.

Test plan:

python -m pytest test/dynamo/test_autograd_function.py
python -m pytest test/distributed/tensor/debug/test_debug_mode.py

106 and 39 passed. To exercise the no-distributed path on a Linux build, I ran
test_autograd_function.py with a local sitecustomize that strips
torch._C's distributed init hooks (_c10d_init, _rpc_init, ...) so
torch.distributed.is_available() is False. That reproduces the macOS CI error
(ModuleNotFoundError: No module named 'torch._C._distributed_c10d' from
DebugMode.init) before this change; afterwards all non-GPU tests pass.

This PR was authored with an AI assistant (Claude Code).

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Unclassified Failure

As of commit 216b6f0 with merge base f8c63a1 (image):

NEW FAILURE - The following job has failed:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

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

@pytorch-bot

pytorch-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant