Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deepspeed/utils/comms_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def calc_bw_log(comm_op, size, duration):
if comm_op == "all_to_all_single" or comm_op == "all_to_all":
tput = (size / duration)
busbw = (size / duration) * ((n - 1) / n)
elif comm_op == "all_gather" or comm_op == "all_gather_into_tensor" or comm_op == "reduce_scatter" or comm_op == "reduce_scatter_tensor":
elif comm_op == "all_gather" or comm_op == "all_gather_object" or comm_op == "all_gather_into_tensor" or comm_op == "reduce_scatter" or comm_op == "reduce_scatter_tensor":
size *= n
tput = (size / duration)
busbw = (size / duration) * ((n - 1) / n)
elif comm_op == "all_reduce" or comm_op == "all_reduce_coalesced" or comm_op == "inference_all_reduce":
tput = (size * 2 / duration)
busbw = (size / duration) * (2 * (n - 1) / n)
elif comm_op == "send" or comm_op == "recv" or comm_op == "isend" or comm_op == "irecv" or comm_op == "batch_isend_irecv" or comm_op == "broadcast" or comm_op == "broadcast_object_list" or comm_op == "reduce" or comm_op == "gather" or comm_op == "scatter" or comm_op == "barrier":
elif comm_op == "send" or comm_op == "recv" or comm_op == "isend" or comm_op == "irecv" or comm_op == "batch_isend_irecv" or comm_op == "broadcast" or comm_op == "broadcast_object_list" or comm_op == "reduce" or comm_op == "gather" or comm_op == "scatter" or comm_op == "barrier" or comm_op == "monitored_barrier":
tput = (size / duration)
busbw = tput
else:
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/comm/test_comms_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,19 @@ def test_calc_bw_log_supports_object_and_list_collectives(monkeypatch, comm_op,
expected_busbw *= (world_size - 1) / world_size
assert tput == pytest.approx(expected_tput)
assert busbw == pytest.approx(expected_busbw)


@pytest.mark.parametrize('comm_op', ['all_gather_object', 'monitored_barrier'])
def test_calc_bw_log_supports_every_timed_op(monkeypatch, comm_op):
# all_gather_object and monitored_barrier are wrapped in timed_op but had no
# branch in calc_bw_log, which printed "wrong comm_op specified" and called
# exit(0), silently ending the training process when comms profiling was on.
import deepspeed.comm as dist
from deepspeed.utils.comms_logging import calc_bw_log

monkeypatch.setattr(dist, 'get_world_size', lambda group=None: 2)
monkeypatch.setattr(dist, 'get_rank', lambda group=None: 0)

tput, busbw = calc_bw_log(comm_op, 0, 2.0)
assert tput == 0
assert busbw == 0
Loading