[c10d] Update get_backend() in exception_handler (#94063)
Currently, get_backend() and get_world_size() would always return the default value if no pg group argument is passed. This fixes the issue.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/94063
Approved by: https://github.com/H-Huang
diff --git a/torch/distributed/distributed_c10d.py b/torch/distributed/distributed_c10d.py
index 22edcd0..fabf676 100644
--- a/torch/distributed/distributed_c10d.py
+++ b/torch/distributed/distributed_c10d.py
@@ -1425,8 +1425,8 @@
error_msg_dict = {
"func_name": f"{func.__name__}",
"args": f"{args}, {kwargs}",
- "backend": f"{get_backend()}",
- "world_size": f"{get_world_size()}",
+ "backend": f"{get_backend(kwargs.get('group'))}",
+ "world_size": f"{get_world_size(kwargs.get('group'))}",
"global_rank": f"{get_rank()}",
"local_rank": f"{get_rank(kwargs.get('group'))}",
"error": f"{error}",