Skip to content

Add raw embedding streaming needed params in trec and mvai #2935

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

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 18 additions & 0 deletions torchrec/distributed/batched_embedding_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
DenseTableBatchedEmbeddingBagsCodegen,
EmbeddingLocation,
PoolingMode,
RESParams,
SparseType,
SplitTableBatchedEmbeddingBagsCodegen,
)
Expand Down Expand Up @@ -171,6 +172,23 @@ def _populate_ssd_tbe_params(config: GroupedEmbeddingConfig) -> Dict[str, Any]:
)
ssd_tbe_params["cache_sets"] = int(max_cache_sets)

# populate res_params, which is used for raw embedding streaming
# here only populates the params available in fused_params and TBE configs
res_params: RESParams = RESParams()
res_params.table_names = [table.name for table in config.embedding_tables]
res_params.table_offsets = []
for emb_tbl in config.embedding_tables:
local_metadata = emb_tbl.local_metadata
if (
local_metadata is not None
and local_metadata.shard_offsets is not None
and len(local_metadata.shard_offsets) >= 1
):
res_params.table_offsets.append(local_metadata.shard_offsets[0])
if "res_store_shards" in fused_params:
res_params.res_store_shards = fused_params.get("res_store_shards")
ssd_tbe_params["res_params"] = res_params

return ssd_tbe_params


Expand Down
8 changes: 8 additions & 0 deletions torchrec/distributed/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ class KeyValueParams:
enable_async_update: Optional[bool]: whether to enable async update for l2 cache
bulk_init_chunk_size: int: number of rows to insert into rocksdb in each chunk
lazy_bulk_init_enabled: bool: whether to enable lazy(async) bulk init for SSD TBE
enable_raw_embedding_streaming: Optional[bool]: enable raw embedding streaming for SSD TBE
res_store_shards: Optional[int] = None: the number of shards to store the raw embeddings

# Parameter Server (PS) Attributes
ps_hosts (Optional[Tuple[Tuple[str, int]]]): List of PS host ip addresses
Expand All @@ -660,6 +662,10 @@ class KeyValueParams:
enable_async_update: Optional[bool] = None # enable L2 cache async update
bulk_init_chunk_size: Optional[int] = None # number of rows
lazy_bulk_init_enabled: Optional[bool] = None # enable lazy bulk init
enable_raw_embedding_streaming: Optional[bool] = (
None # enable raw embedding streaming for SSD TBE
)
res_store_shards: Optional[int] = None # shards to store the raw embeddings

# Parameter Server (PS) Attributes
ps_hosts: Optional[Tuple[Tuple[str, int], ...]] = None
Expand All @@ -686,6 +692,8 @@ def __hash__(self) -> int:
self.enable_async_update,
self.bulk_init_chunk_size,
self.lazy_bulk_init_enabled,
self.enable_raw_embedding_streaming,
self.res_store_shards,
)
)

Expand Down
Loading