Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cache to Comm Group #4849

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
13 changes: 12 additions & 1 deletion deepspeed/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
ccl_backend = None
hccl_backend = None

# Cache of previously created comms
comms_cache = {}

# This should be set here so all rank/size information from the launcher can be propagated
from deepspeed.comm.utils import *

Expand Down Expand Up @@ -182,7 +185,15 @@ def new_group(ranks):
global cdb
assert cdb is not None and cdb.is_initialized(
), 'DeepSpeed backend not set, please initialize it using init_process_group()'
return cdb.new_group(ranks)

key = (cdb, tuple(ranks))

if key in comms_cache:
return comms_cache[key]
else:
new_group = cdb.new_group(ranks)
comms_cache[key] = new_group
return new_group


def is_available() -> bool:
Expand Down
Loading