Fix test interaction: clean up DTensorSpec pytree registration#176128
Closed
aorenste wants to merge 1 commit intogh/aorenste/199/basefrom
Closed
Fix test interaction: clean up DTensorSpec pytree registration#176128aorenste wants to merge 1 commit intogh/aorenste/199/basefrom
aorenste wants to merge 1 commit intogh/aorenste/199/basefrom
Conversation
register_constant(DTensorSpec) in the export test helper was permanently modifying global pytree state, causing subsequent compiled DTensor tests to fail. With DTensorSpec registered as a pytree constant, dynamo no longer decomposes glu into simpler ops that have sharding strategies, so aten.glu.default gets passed through to DTensor dispatch which can't handle it. Wrap in try/finally to deregister after use. Authored with Claude. [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176128
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 a309060 with merge base b4c6054 ( 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. |
aorenste
added a commit
that referenced
this pull request
Mar 2, 2026
register_constant(DTensorSpec) in the export test helper was permanently modifying global pytree state, causing subsequent compiled DTensor tests to fail. With DTensorSpec registered as a pytree constant, dynamo no longer decomposes glu into simpler ops that have sharding strategies, so aten.glu.default gets passed through to DTensor dispatch which can't handle it. Wrap in try/finally to deregister after use. Authored with Claude. ghstack-source-id: e159e65 Pull Request resolved: #176128
SherlockNoMad
approved these changes
Mar 3, 2026
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour 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 |
RohitRathore1
added a commit
to RohitRathore1/pytorch
that referenced
this pull request
Mar 9, 2026
… export Fixes pytorch#175467. torch.export.export() with strict=False failed on tensor-parallel DTensor models because DTensorSpec is not a registered pytree type. In _emit_flat_apply_call, to_graphable() calls tree_flatten which leaves DTensorSpec as a non-graphable leaf. Globally registering DTensorSpec as a pytree constant is not viable because it changes dynamo decomposition behavior, breaking other DTensor ops like glu and rsub (see pytorch#176128). Instead, scope the registration tightly: in _emit_flat_apply_call, scan for non-graphable types not already in SUPPORTED_NODES, temporarily register them as pytree constants for the tree_flatten call, then immediately deregister them. This fixes export without polluting global pytree state.
pytorchmergebot
pushed a commit
to RohitRathore1/pytorch
that referenced
this pull request
Mar 10, 2026
… export Fixes pytorch#175467. torch.export.export() with strict=False failed on tensor-parallel DTensor models because DTensorSpec is not a registered pytree type. In _emit_flat_apply_call, to_graphable() calls tree_flatten which leaves DTensorSpec as a non-graphable leaf. Globally registering DTensorSpec as a pytree constant is not viable because it changes dynamo decomposition behavior, breaking other DTensor ops like glu and rsub (see pytorch#176128). Instead, scope the registration tightly: in _emit_flat_apply_call, scan for non-graphable types not already in SUPPORTED_NODES, temporarily register them as pytree constants for the tree_flatten call, then immediately deregister them. This fixes export without polluting global pytree state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
register_constant(DTensorSpec) in the export test helper was
permanently modifying global pytree state, causing subsequent
compiled DTensor tests to fail. With DTensorSpec registered as a
pytree constant, dynamo no longer decomposes glu into simpler ops
that have sharding strategies, so aten.glu.default gets passed
through to DTensor dispatch which can't handle it.
Wrap in try/finally to deregister after use.
Introduced in PR #163609
Authored with Claude.