Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/186129
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 1 New Failure, 2 Unrelated FailuresAs of commit 61acc31 with merge base a8eeede ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude review this pr |
|
Claude finished @anshul-si's task in 2m 31s —— View job PR Review: [dtensor] fix conv1d output placement and group scaling
SummaryThis PR fixes two real bugs in DTensor dispatch for depthwise convolution (groups == in_channels == out_channels) when channels are sharded. The fix is split cleanly across two layers — strategy enumeration and local arg adjustment — which matches DTensor's existing separation of concerns. Feedback1. Correctness of the strategy rule ( The depthwise gating condition is correct: groups > 1 and groups == input_meta.shape[1] and groups == weight_meta.shape[0]For depthwise conv, 2. Group scaling in the handler ( The formula However, two concerns:
3. Missing backward path The 4. No new tests The PR description has a test plan with a manual Minor nits
VerdictThe core logic is sound and addresses real production bugs. The main actionable items are:
|
|
@anshul-si can i get another round of review, thanks |
|
@claude please review the following issues and validate them. Provide an example the author can use as a test case for each case.
|
|
Claude finished @anshul-si's task in 12m 6s —— View job Review: validating the two reported issuesI read Issue 1 —
|
| # | Issue | Verdict | Root cause |
|---|---|---|---|
| 1 | Halo exchange on channel + padding | Valid | _requires_data_exchange only excludes batch-dim sharding; channel sharding with padding>0 wrongly enters the spatial exchange path |
| 2 | Groups rescaled for ordinary grouped conv | Valid | _scaled_local_conv_groups gate omits the depthwise invariant, so any Shard(0) weight on a groups>1 conv gets rescaled |
Both are gaps in the gating conditions rather than the core logic — the depthwise channel-sharding path itself is sound. Recommend (a) gating data exchange on the spatial dim and (b) gating the groups rescale on the depthwise invariant, plus the two regression tests above.
• branch opt
|
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Fixes DTensor dispatch for depthwise convolution (
groups == in_channels == out_channels) when channels are sharded across the mesh — e.g. under FSDP or TP where the weight isShard(0)and the input isShard(1)on the channel dim. This is the layout used by GatedDeltaNet-style depthwiseConv1din hybrid-attention models (Qwen3.5).Depthwise conv treats each channel as an independent group, so channel-sharding requires no cross-rank communication — each rank computes its own channels locally. DTensor previously couldn't express or execute this, failing in both forward and backward.
The bugs
Wrong forward output placement.
convolution_single_dim_strategyonly enumerated batch-dim sharding with a replicated weight. Channel-sharded input + out-channel-sharded weight matched no rule, so the propagator fell back to all-Replicate. The handler then ran on the still-sharded local tensors but labeled the resultReplicate— so a 64-channel local output was tagged as the full 128-channel tensor. Downstream ops (e.g.full_tensor()) trusted the label and silently returned wrong data.Crash on
groups(forward and backward).groupsis a plain int that isn't sharded. With a channel-sharded weight (128 → 64 local channels per rank), the local conv was still called withgroups=128:The backward path had the identical defect and crashed the same way; it had gone unnoticed because earlier validation only exercised the forward/inference path.
The fix
Split across the two layers that own each concern, symmetric for forward and backward:
_ops/_conv_ops.py(sharding strategies) — add a depthwise channel-sharding rule to both strategies, gated ongroups == in_channels == out_channels:[output=Shard(1), input=Shard(1), weight=Shard(0), (bias=Shard(0))][grad_input=Shard(1), grad_weight=Shard(0), grad_bias=Shard(0), grad_output=Shard(1), input=Shard(1), weight=Shard(0)]grad_weight/grad_biasareShard(0)(per out-channel, no cross-rank sum), notPartial, because the groups are independent. The propagator now returns the correctShard(1)/Shard(0)placements with no redistribution._tp_conv.py(local arg adjustment) — strategies decide placements only; the local op still needsgroupsrescaled to the local weight shard (groups * local_out_channels // global_out_channels). This is factored into a shared_scaled_local_conv_groupshelper, with a divisibility assertion guarding the even-sharding invariant, and is called from bothconvolution_handlerandconvolution_backward_handler.Only depthwise conv is handled; regular (
groups=1) and general grouped conv are untouched and fall through unchanged.Test
test/distributed/tensor/test_convolution_ops.py::test_conv1d_channel_shard— depthwiseConv1d, inputShard(1)+ weightShard(0), asserts for both forward and backward:CommDebugMode),Shard(1)output / gradient placement,full_tensor()bit-identical (max_diff 0.0) to a single-device reference.Regression tests (
test_conv1d,test_conv1d_batch_shard,test_depthwise_convolution) still pass. Validated across FSDP, TP, and FSDP+EP configs, and end-to-end on a hybrid-attention model (Qwen3.5) whose GatedDeltaNet layers use depthwiseConv1d.