Repository navigation
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/174918
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (7 Unrelated Failures)As of commit 3614e21 with merge base b323a6e ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
| def test_custom_recursive_decomp(self): | ||
| """ | ||
| op1 decomps -> op2, which decomps -> matmul | ||
| op1 decomps -> op2, which decomps -> mm |
There was a problem hiding this comment.
can you explain the before/after for this- op2 used to call @, which then decomposed into ..., and now ...
There was a problem hiding this comment.
op1(x, y) := op2(x, y) * 1.0
before, op2(x, y) := x @ y, which calls aten::matmul which is CIA, so there's a weird interaction there
after, op2(x, y) := torch.mm(x, y), which calls aten::mm.
I still need to figure out the decomp/CIA interaction, but this test case is just synthetic.
| self.assertTrue(op not in sharding_prop.op_single_dim_strategy_funcs) | ||
| self.assertTrue(op not in sharding_prop.op_to_rules) | ||
|
|
||
| # binary_cross_entropy_with_logits |
There was a problem hiding this comment.
these test cases are removed because previously we accidentally supported them via CIA decomp path and now we don't support them? or, do we support them but we support them by decomposing above dtensor and redispatching to dtensors on their decomp's ops?
There was a problem hiding this comment.
these are confirmed to not be CIA, but I think they decompose to CIA (e.g. glu -> tensor_split), and there's a weird interaction there that I need to figure out.
There was a problem hiding this comment.
should these be 'xfail' instead of not tested then?
do we get a nice error saying something about CIA+Decomps when we try to do this, or is that hard?
There was a problem hiding this comment.
that is currently hard... i'll xfail with "no sharding strategy"
| ) | ||
|
|
||
| with torch.inference_mode(): # call aten::linear | ||
| out = torch.nn.functional.linear(x, w) |
There was a problem hiding this comment.
guess we didn't have a test for this path before? how did you notice the regression, out of curiousity?
There was a problem hiding this comment.
Ah yeah, I noticed in torchtitan DTensor eager inference, that linear was unnecessarily redistributing to RxR->R (another thing I need to figure out for decomps).
I think this revert should be safe-ish, we should restore old behavior for CIA ops, add correct rule support for a large number of ops, and for some ops maybe we're still comm-inefficient.
There was a problem hiding this comment.
I think this revert should be safe-ish,
in what way might it not be safe?
we should restore old behavior for CIA ops,
that's what this PR does, is that your point?
add correct rule support for a large number of ops, and for some ops maybe we're still comm-inefficient.
explain this part more?
There was a problem hiding this comment.
oh i see, using the CIA path can lead to more comms than using the decomp path? though the initial example triggering the reversion of this PR is that linear incurs more comms with decomps than with CIA wasn't it?
There was a problem hiding this comment.
in what way might it not be safe?
I think the only issue is, since the decomp work regressed aten::linear, for some previously uncovered ops it might only produce the full replicate rule, so we just get inefficient coverage..
that's what this PR does, is that your point?
yepp
explain this part more?
this is the response above; for some ops the decomp work might not help much.
I think it's likely related to views handling... i'll look into this more
| op_strategy = None | ||
| if DecompShardingStrategy.has_decomp(op_schema.op): | ||
| has_cia = torch._C._dispatch_has_kernel_for_dispatch_key( | ||
| op_schema.op.name(), |
There was a problem hiding this comment.
should comment the logic here. or above. i think at one point i added a docstring about what precedence order we dispatched things
Previously CIA ops would decompose & go through DTensor dispatch individually, now they enter the decomp flow in #171652. This caused implicit redistributes in some CIA ops with decomps (e.g. aten::linear in inference), so partially reverting this to preserve old behavior. Now we skip decomp flow if CIA decomp is present. [ghstack-poisoned]
Previously CIA ops would decompose & go through DTensor dispatch individually, now they enter the decomp flow in #171652. This caused implicit redistributes in some CIA ops with decomps (e.g. aten::linear in inference), so partially reverting this to preserve old behavior. Now we skip decomp flow if CIA decomp is present. [ghstack-poisoned]
|
@pytorchbot merge |
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 |
Merge failedReason: 1 jobs have failed, first few of them are: linux-aarch64 / linux-jammy-aarch64-py3.10 / test (openreg, 1, 1, linux.arm64.m8g.4xlarge) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
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 |
…ibutes in decomposition flow" #174918 skipped the decomposition flow for CIA ops, because we found it wasn't able to find non-replicate strategies for aten::linear. This turned out to be view handling related; the decomposition flow bans internal redistributes, but the `.needs_redistribute` semantics is too broad; for views it includes when DTensor dispatch needs to convert from global -> local tensor ops: https://github.com/pytorch/pytorch/blob/c238e6ed935df371f208b72becb206858a0cf087/torch/distributed/tensor/_sharding_prop.py#L638-L653 For example, `DTensor(shape=[8, 8], placements=[Shard(0)]).view(8, 4, 2)` on a size-4 mesh, will recalculate and run `.view(2, 4, 2)` in local compute. The decomposition flow doesn't need this handling, as it always deals with global tensors. This PR changes redistribution semantics to only be placement based, and reverts the CIA skip, allowing CIA ops to go through the decomposition flow again. [ghstack-poisoned]
…osition flow" #174918 skipped the decomposition flow for CIA ops, because we found it wasn't able to find non-replicate strategies for aten::linear. This turned out to be view handling related; the decomposition flow bans internal redistributes, but the `.needs_redistribute` semantics is too broad; for views it includes when DTensor dispatch needs to convert from global -> local tensor ops: https://github.com/pytorch/pytorch/blob/c238e6ed935df371f208b72becb206858a0cf087/torch/distributed/tensor/_sharding_prop.py#L638-L653 For example, `DTensor(shape=[8, 8], placements=[Shard(0)]).view(8, 4, 2)` on a size-4 mesh, will recalculate and run `.view(2, 4, 2)` in local compute. The decomposition flow doesn't need this handling, as it always deals with global tensors. This PR changes redistribution semantics to only be placement based, and reverts the CIA skip, allowing CIA ops to go through the decomposition flow again. [ghstack-poisoned]
#175194) #174918 skipped the decomposition flow for CIA ops, because we found it wasn't able to find non-replicate strategies for aten::linear. This turned out to be view handling related; the decomposition flow bans internal redistributes, but the `.needs_redistribute` semantics is too broad; for views it includes when DTensor dispatch needs to convert from global -> local tensor ops: https://github.com/pytorch/pytorch/blob/c238e6ed935df371f208b72becb206858a0cf087/torch/distributed/tensor/_sharding_prop.py#L638-L653 For example, `DTensor(shape=[8, 8], placements=[Shard(0)]).view(8, 4, 2)` on a size-4 mesh, will recalculate and run `.view(2, 4, 2)` in local compute. The decomposition flow doesn't need this handling, as it always deals with global tensors. This PR changes redistribution semantics to only be placement based, and reverts the CIA skip, allowing CIA ops to go through the decomposition flow again. Pull Request resolved: #175194 Approved by: https://github.com/wconstab
#175194) #174918 skipped the decomposition flow for CIA ops, because we found it wasn't able to find non-replicate strategies for aten::linear. This turned out to be view handling related; the decomposition flow bans internal redistributes, but the `.needs_redistribute` semantics is too broad; for views it includes when DTensor dispatch needs to convert from global -> local tensor ops: https://github.com/pytorch/pytorch/blob/c238e6ed935df371f208b72becb206858a0cf087/torch/distributed/tensor/_sharding_prop.py#L638-L653 For example, `DTensor(shape=[8, 8], placements=[Shard(0)]).view(8, 4, 2)` on a size-4 mesh, will recalculate and run `.view(2, 4, 2)` in local compute. The decomposition flow doesn't need this handling, as it always deals with global tensors. This PR changes redistribution semantics to only be placement based, and reverts the CIA skip, allowing CIA ops to go through the decomposition flow again. Pull Request resolved: #175194 Approved by: https://github.com/wconstab
pytorch#175194) pytorch#174918 skipped the decomposition flow for CIA ops, because we found it wasn't able to find non-replicate strategies for aten::linear. This turned out to be view handling related; the decomposition flow bans internal redistributes, but the `.needs_redistribute` semantics is too broad; for views it includes when DTensor dispatch needs to convert from global -> local tensor ops: https://github.com/pytorch/pytorch/blob/c238e6ed935df371f208b72becb206858a0cf087/torch/distributed/tensor/_sharding_prop.py#L638-L653 For example, `DTensor(shape=[8, 8], placements=[Shard(0)]).view(8, 4, 2)` on a size-4 mesh, will recalculate and run `.view(2, 4, 2)` in local compute. The decomposition flow doesn't need this handling, as it always deals with global tensors. This PR changes redistribution semantics to only be placement based, and reverts the CIA skip, allowing CIA ops to go through the decomposition flow again. Pull Request resolved: pytorch#175194 Approved by: https://github.com/wconstab
Stack from ghstack (oldest at bottom):
Previously CIA ops would decompose & go through DTensor dispatch individually, now they enter the decomp flow in #171652. This caused implicit redistributes in some CIA ops with decomps (e.g. aten::linear in inference), so partially reverting this to preserve old behavior. Now we skip decomp flow if CIA decomp is present.