Skip to content

Don't pass shard_order beside a _StridedShard when redistributing - #597

Open
schmidt-jake wants to merge 1 commit into
meta-pytorch:mainfrom
schmidt-jake:jake/strided-shard-redistribute
Open

schmidt-jake wants to merge 1 commit into
meta-pytorch:mainfrom
schmidt-jake:jake/strided-shard-redistribute

Conversation

@schmidt-jake

Copy link
Copy Markdown

Problem

ApplyShardingInterpreter.redistribute_tensor builds the current and target DTensorSpecs with an explicit shard_order. When a spec's placements contain a _StridedShard, torch 2.15's DTensorSpec refuses an explicit shard_order, because the strided placement already encodes the order. It raises ValueError. So redistributing any strided layout failed before a collective was issued. We hit it applying a solution whose expert-stack parameters came out strided-sharded.

Change

When a spec holds a _StridedShard, construct it without shard_order and let the placements carry the order. Every other spec is unchanged.

Test

tests/test_apply_sharding_strided.py redistributes a strided source spec through the interpreter on a fake process group (CPU). Without the fix it fails with that ValueError; with it, it passes. Lint passes with the repo's pinned black, isort and flake8.

🤖 Generated with Claude Code

A DTensorSpec that holds a _StridedShard encodes its shard order in its placements and
rejects an explicit shard_order (torch 2.15). ApplyShardingInterpreter.redistribute_tensor
passed the shard order it computed anyway, so redistributing any strided layout raised
ValueError before a collective was issued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@meta-cla

meta-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Hi @schmidt-jake!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant