#198344·pytorch

[c10d][NCCL] Uneven all_gather_into_tensor / reduce_scatter_tensor that can use NCCL symmetric memory

Author: XiaodaNVCreated Sep 23, 2026Updated Sep 28, 2026
Labelsoncall: distributedtriagedbot-triagedoncall: distributed infra

The feature, motivation and pitch

Add split-size-aware variants of all_gather_into_tensor and reduce_scatter_tensor (for example output_split_sizes / input_split_sizes), and let the NCCL backend run them on window-registered (symmetric) memory.

Motivation. In Megatron-FSDP we are adding an owner-based sharding mode (NVIDIA/Megatron-LM#7396) where each parameter is assigned whole to one rank, so the per-rank shard sizes are intentionally unequal and we do not want to pad them to the largest shard. Materialization needs an uneven Shard -> Replicate all-gather and gradient reduction needs an uneven Partial -> Shard reduce-scatter.

Today the only way to express this is the list variants dist.all_gather / dist.reduce_scatter. With unequal sizes ProcessGroupNCCL lowers them to a coalesced group of per-rank ncclBroadcast / ncclReduce calls, so they never hit the NCCL symmetric-memory kernels that all_gather_into_tensor / reduce_scatter_tensor get when the buffers come from torch.distributed._symmetric_memory with the NCCL backend. We therefore have to disable symmetric memory whenever the layout is uneven, and lose its latency benefit exactly for the sharding mode where communication is most irregular.

Why the existing symm_mem offset ops do not cover this. Both assume every rank contributes the same amount of data; their "uneven" dimension is across parameters or blocks, not across ranks.

  • symm_mem.all_gather_offset (#187642, from #187239): split_sizes[i] is the per-rank shard size of parameter i, the same list on every rank, and out.numel() must equal sum(split_sizes) * W. There is no per-rank dimension, so a parameter that is whole on one rank and absent on the others cannot be expressed.
  • symm_mem.reduce_scatter_offset (#177791): host checks require every rank to own the same number of blocks (n_owned * group_size == n_blocks) and the j-th owned block to have the same size on every rank. Owner-packed segments violate both.

Pitch.

  1. Extend all_gather_into_tensor / reduce_scatter_tensor (or add *_uneven siblings) with per-rank split sizes along dim 0.
  2. In ProcessGroupNCCL, keep the registered-window fast path for these calls instead of falling back to coalesced per-rank broadcast / reduce.

Alternatives:

  • Pad every rank's shard to the largest one and use the uniform collectives: wastes memory and bandwidth proportional to the imbalance, and forces padding into the optimizer / checkpoint layout.
  • Keep using the list variants with coalesced broadcast/reduce (what we do now): correct, but cannot use symmetric memory and issues world_size small kernels per collective.

Additional context:

  • torch 2.13.0a0 (NGC PyTorch 26.07), NCCL 2.30.7, H100.
  • Consumer: NVIDIA/Megatron-LM#7396 (TensorAtomic placement for MFSDP v2); tracking issue for uneven communication: NVIDIA/Megatron-LM#6587.
  • Related: #187239, #187642 (all_gather_offset), #177791 (reduce_scatter_offset).

Alternatives

No response

Additional context

No response

cc @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @msaroufim @dcci @aditvenk @weifengpy @kapilsh