Skip to content

[DTensor] single_dim fix symint + _create_expanded_strategy#172421

Closed
wconstab wants to merge 2 commits intogh/wconstab/498/basefrom
gh/wconstab/498/head
Closed

[DTensor] single_dim fix symint + _create_expanded_strategy#172421
wconstab wants to merge 2 commits intogh/wconstab/498/basefrom
gh/wconstab/498/head

Conversation

@wconstab
Copy link
Copy Markdown
Contributor

@wconstab wconstab commented Jan 14, 2026

Stack from ghstack (oldest at bottom):

Claude's summary

torch/distributed/tensor/_ops/single_dim_strategy.py:242-257 - Modified the caching logic to handle SymInts from dynamic shapes by:
- Renaming the cached function to _create_expanded_strategy_impl
- Creating a wrapper _create_expanded_strategy that tries the cached version first
- Catching TypeError (from unhashable SymInts) and falling back to the uncached implementation

The test confirms that the caching logic in _create_expanded_strategy gracefully falls back to uncached execution when output_tensor_meta contains unhashable SymInts.

Claude's summary

torch/distributed/tensor/_ops/single_dim_strategy.py:242-257 - Modified the caching logic to handle SymInts from dynamic shapes by:
    - Renaming the cached function to _create_expanded_strategy_impl
    - Creating a wrapper _create_expanded_strategy that tries the cached version first
    - Catching TypeError (from unhashable SymInts) and falling back to the uncached implementation

The test confirms that the caching logic in _create_expanded_strategy gracefully falls back to uncached execution when output_tensor_meta contains unhashable SymInts.

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

pytorch-bot Bot commented Jan 14, 2026

🔗 Helpful Links

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

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

✅ No Failures

As of commit 24427b0 with merge base e09f7ac (image):
💚 Looks good so far! There are no failures yet. 💚

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

Copy link
Copy Markdown
Contributor

@pianpwk pianpwk left a comment

Choose a reason for hiding this comment

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

Would it make sense to work towards a hash key for symints? maybe something like (id(ShapeEnv), ShapeEnv version, symbol name, symbol hint) could be a conservative start.

Or just have a symint-aware cache that forces cache miss when they're present - I feel like we hit this error a lot.

@weifengpy weifengpy self-requested a review January 14, 2026 07:05
Copy link
Copy Markdown
Contributor

@weifengpy weifengpy left a comment

Choose a reason for hiding this comment

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

this saved my day! it unblocks single dim strategy for matmul #172385

@weifengpy
Copy link
Copy Markdown
Contributor

would it be possible to git rebase -i and move this PR to land it first? I want to rebase on this

@wconstab
Copy link
Copy Markdown
Contributor Author

@pianpwk do you think we can make it so 1. We hash/cache successfully on symint including its size hint or its set of constraints if present, and 2. If we use the symint during shard prop we are allowed to use it via its size hint only or via its constraints, but it causes a hard error if directly accessed as int?

I guess if we do that,I'm still not sure how we handle error cases where we try to access an unbacked symint.

@wconstab
Copy link
Copy Markdown
Contributor Author

@weifengpy sure, I can land this early. I'll do it later this morning or you can just rebase underneath your work right now before I get to it.

Claude's summary

torch/distributed/tensor/_ops/single_dim_strategy.py:242-257 - Modified the caching logic to handle SymInts from dynamic shapes by:
    - Renaming the cached function to _create_expanded_strategy_impl
    - Creating a wrapper _create_expanded_strategy that tries the cached version first
    - Catching TypeError (from unhashable SymInts) and falling back to the uncached implementation

The test confirms that the caching logic in _create_expanded_strategy gracefully falls back to uncached execution when output_tensor_meta contains unhashable SymInts.

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

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jan 14, 2026
@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: 1 jobs have failed, first few of them are: trunk / before-test / target-determination

Details for Dev Infra team Raised by workflow job

@wconstab
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

mattteochen pushed a commit to mattteochen/pytorch that referenced this pull request Jan 15, 2026
…172421)

Claude's summary

torch/distributed/tensor/_ops/single_dim_strategy.py:242-257 - Modified the caching logic to handle SymInts from dynamic shapes by:
    - Renaming the cached function to _create_expanded_strategy_impl
    - Creating a wrapper _create_expanded_strategy that tries the cached version first
    - Catching TypeError (from unhashable SymInts) and falling back to the uncached implementation

The test confirms that the caching logic in _create_expanded_strategy gracefully falls back to uncached execution when output_tensor_meta contains unhashable SymInts.
Pull Request resolved: pytorch#172421
Approved by: https://github.com/pianpwk, https://github.com/weifengpy
SergeyTyshkevich pushed a commit to SergeyTyshkevich/chart2 that referenced this pull request Jan 19, 2026
Claude's summary

torch/distributed/tensor/_ops/single_dim_strategy.py:242-257 - Modified the caching logic to handle SymInts from dynamic shapes by:
    - Renaming the cached function to _create_expanded_strategy_impl
    - Creating a wrapper _create_expanded_strategy that tries the cached version first
    - Catching TypeError (from unhashable SymInts) and falling back to the uncached implementation

The test confirms that the caching logic in _create_expanded_strategy gracefully falls back to uncached execution when output_tensor_meta contains unhashable SymInts.

ghstack-source-id: d8abf38
Pull Request resolved: pytorch/pytorch#172421
@github-actions github-actions Bot deleted the gh/wconstab/498/head branch February 14, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: distributed (dtensor) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants