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

Different nccl stream within EmbeddingKey alltoall and EmbeddingValue… #2570

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion torchrec/distributed/embeddingbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def create_embedding_bag_sharding(
device: Optional[torch.device] = None,
permute_embeddings: bool = False,
qcomm_codecs_registry: Optional[Dict[str, QuantizedCommCodecs]] = None,
independent_emb_key_pg: Optional[dist.ProcessGroup] = None,
) -> EmbeddingSharding[
EmbeddingShardingContext, KeyedJaggedTensor, torch.Tensor, torch.Tensor
]:
Expand All @@ -165,6 +166,7 @@ def create_embedding_bag_sharding(
env,
device,
qcomm_codecs_registry=qcomm_codecs_registry,
independent_emb_key_pg=independent_emb_key_pg,
)
elif sharding_type == ShardingType.DATA_PARALLEL.value:
return DpPooledEmbeddingSharding(sharding_infos, env, device)
Expand Down Expand Up @@ -587,7 +589,7 @@ def __init__(
self._table_names: List[str] = []
self._pooling_type_to_rs_features: Dict[str, List[str]] = defaultdict(list)
self._table_name_to_config: Dict[str, EmbeddingBagConfig] = {}

self.independent_emb_key_pg = dist.new_group();
for config in self._embedding_bag_configs:
self._table_names.append(config.name)
self._table_name_to_config[config.name] = config
Expand Down Expand Up @@ -633,6 +635,7 @@ def __init__(
device,
permute_embeddings=True,
qcomm_codecs_registry=self.qcomm_codecs_registry,
independent_emb_key_pg=self.independent_emb_key_pg,
)
for embedding_configs in sharding_type_to_sharding_infos.values()
]
Expand Down
4 changes: 3 additions & 1 deletion torchrec/distributed/sharding/rw_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ def __init__(
need_pos: bool = False,
qcomm_codecs_registry: Optional[Dict[str, QuantizedCommCodecs]] = None,
device_type_from_sharding_infos: Optional[Union[str, Tuple[str, ...]]] = None,
independent_emb_key_pg: Optional[dist.ProcessGroup] = None,
) -> None:
super().__init__(qcomm_codecs_registry=qcomm_codecs_registry)
self._env = env
self._independent_emb_key_pg: Optional[dist.ProcessGroup] = independent_emb_key_pg if independent_emb_key_pg else self._pg
self._is_2D_parallel: bool = isinstance(env, ShardingEnv2D)
self._pg: Optional[dist.ProcessGroup] = (
self._env.sharding_pg # pyre-ignore[16]
Expand Down Expand Up @@ -538,7 +540,7 @@ def create_input_dist(
return RwSparseFeaturesDist(
# pyre-fixme[6]: For 1st param expected `ProcessGroup` but got
# `Optional[ProcessGroup]`.
pg=self._pg,
pg=self._independent_emb_key_pg,
num_features=num_features,
feature_hash_sizes=feature_hash_sizes,
device=device if device is not None else self._device,
Expand Down