Skip to content

Conversation

@fmassa
Copy link
Contributor

@fmassa fmassa commented Nov 21, 2025

The constant_pad_nd in PyTorch only supports a very limited set of shardings, see https://github.com/pytorch/pytorch/blob/c23a90041e451b7347d1e587b45188927ee66b89/torch/distributed/tensor/_ops/_matrix_ops.py#L470-L486

I'm temporarily expanding the support here, but we should improve it in PyTorch.

The expand rule we had also only supported ops with a single -1 in it, which this PRs fixes.
In the end, the only reason why we have the expand and view rules reimplemented here is because in PyTorch they currently raise errors for "invalid" shardings, which happens quite often when we have an arbitrary set of input shardings.

I'm also removing some rules which have already been upstreamed, or for which the default replicate strategy provides the same result.

@fmassa fmassa requested review from wconstab and zpcore November 21, 2025 14:29
@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants