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 method to fetch if a feature is weighted #2727

Open
wants to merge 1 commit 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
6 changes: 6 additions & 0 deletions torchrec/distributed/embedding_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ def embedding_shard_metadata(self) -> List[Optional[ShardMetadata]]:
embedding_shard_metadata.append(table.local_metadata)
return embedding_shard_metadata

def features_weighted(self) -> List[bool]:
is_weighted = []
for table in self.embedding_tables:
is_weighted.extend([table.is_weighted] * table.num_features())
return is_weighted


F = TypeVar("F", bound=Multistreamable)
T = TypeVar("T")
Expand Down
9 changes: 9 additions & 0 deletions torchrec/distributed/sharding/tw_sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ def features_per_rank(self) -> List[int]:
features_per_rank.append(num_features)
return features_per_rank

def is_weighted_per_rank(self) -> List[List[bool]]:
is_weighted = []
for grouped_embedding_configs in self._grouped_embedding_configs_per_rank:
is_weighted_per_rank = []
for grouped_config in grouped_embedding_configs:
is_weighted_per_rank.extend(grouped_config.features_weighted())
is_weighted.append(is_weighted_per_rank)
return is_weighted


class TwSparseFeaturesDist(BaseSparseFeaturesDist[KeyedJaggedTensor]):
"""
Expand Down
Loading