[c10d] Start deprecating *_coalesced APIs (#85959)
- We consider that general users need not to use the `*_coalesced` APIs unless there is an extreme concern about performance.
- We are investigating using a context manager named `coalescing_manager` which wrap around multiple individual collectives to compose the coalescing hint, rather than giving each collective a *_coalesced variant.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85959
Approved by: https://github.com/XilunWu, https://github.com/H-Huang
diff --git a/torch/distributed/distributed_c10d.py b/torch/distributed/distributed_c10d.py
index 0f27a3f..ed853a5 100644
--- a/torch/distributed/distributed_c10d.py
+++ b/torch/distributed/distributed_c10d.py
@@ -1551,6 +1551,11 @@
None, if not async_op or if not part of the group.
"""
+ warnings.warn(
+ "torch.distributed.all_reduce_coalesced will be deprecated. If you must "
+ "use it, please revisit our documentation later at "
+ "https://pytorch.org/docs/master/distributed.html#collective-functions"
+ )
_check_tensor_list(tensors, "tensor")
_ensure_all_tensors_same_dtype(tensors)
if _rank_not_in_group(group):
@@ -2398,6 +2403,11 @@
performance improvements but users of this function should take extra care
to ensure that each node passes in tensors whose shapes match across nodes.
"""
+ warnings.warn(
+ "torch.distributed.all_gather_coalesced will be deprecated. If you must "
+ "use it, please revisit our documentation later at "
+ "https://pytorch.org/docs/master/distributed.html#collective-functions"
+ )
# We only check basic compatibility with C++ params here, C++ code will
# do shape and type checking.
if _rank_not_in_group(group):