Add constant_pad_nd, improve expand rule and remove upstreamed rules #263
+43
−86
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.
The
constant_pad_ndin 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-L486I'm temporarily expanding the support here, but we should improve it in PyTorch.
The
expandrule we had also only supported ops with a single-1in it, which this PRs fixes.In the end, the only reason why we have the
expandandviewrules 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
replicatestrategy provides the same result.