Rate this Page
★ ★ ★ ★ ★

Functional Collectives#

Created On: Oct 25, 2026 | Last Updated On: Oct 25, 2026

Functional collectives take the group as an argument. Under torch.compile they are traced into the graph so the compiler can reorder and overlap communication.

Note

The torch.distributed.nn.functional module is deprecated in favor of this module.

import torch.distributed as dist
import torch.distributed.functional_collectives as funcol

# group can be a ProcessGroup, DeviceMesh, (DeviceMesh, dim) or group name.
out = funcol.all_reduce(tensor, "sum", group=dist.group.WORLD)
gathered = funcol.all_gather_single(tensor, gather_dim=0, group=mesh)
torch.distributed.functional_collectives.all_reduce()#
torch.distributed.functional_collectives.all_reduce_coalesced()#
torch.distributed.functional_collectives.all_gather_single()#
torch.distributed.functional_collectives.all_gather_single_coalesced()#
torch.distributed.functional_collectives.reduce_scatter_single()#
torch.distributed.functional_collectives.reduce_scatter_single_coalesced()#
torch.distributed.functional_collectives.all_to_all_single()#
torch.distributed.functional_collectives.broadcast()#
torch.distributed.functional_collectives.permute_tensor()#
torch.distributed.functional_collectives.wait_tensor()#
torch.distributed.functional_collectives.wait_tensors()#
class torch.distributed.functional_collectives.AsyncCollectiveTensor(*args, **kwargs)#