Skip to content

Commit

Permalink
Support output dtype for embeddings (#1744)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1744

As title

Reviewed By: jiaqizhai

Differential Revision:
D54337769

Privacy Context Container: L1183554

fbshipit-source-id: d4abb56fd846e3da9897f2e295485e6bebb74584
  • Loading branch information
xing-liu authored and facebook-github-bot committed Mar 2, 2024
1 parent 60b57af commit 4168f11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torchrec/distributed/batched_embedding_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ def __init__(
super().__init__(config, pg, device)

weights_precision = data_type_to_sparse_type(config.data_type)
fused_params = config.fused_params or {}
output_dtype = fused_params.get("output_dtype", SparseType.FP32)
self._emb_module: DenseTableBatchedEmbeddingBagsCodegen = (
DenseTableBatchedEmbeddingBagsCodegen(
list(zip(self._local_rows, self._local_cols)),
Expand All @@ -675,6 +677,7 @@ def __init__(
or device.type == "cpu"
or not torch.cuda.is_available(),
weights_precision=weights_precision,
output_dtype=output_dtype,
)
)
self._param_per_table: Dict[str, TableBatchedEmbeddingSlice] = dict(
Expand Down Expand Up @@ -958,6 +961,8 @@ def __init__(
super().__init__(config, pg, device)

weights_precision = data_type_to_sparse_type(config.data_type)
fused_params = config.fused_params or {}
output_dtype = fused_params.get("output_dtype", SparseType.FP32)
self._emb_module: DenseTableBatchedEmbeddingBagsCodegen = (
DenseTableBatchedEmbeddingBagsCodegen(
list(zip(self._local_rows, self._local_cols)),
Expand All @@ -967,6 +972,7 @@ def __init__(
or device.type == "cpu"
or not torch.cuda.is_available(),
weights_precision=weights_precision,
output_dtype=output_dtype,
)
)
self._param_per_table: Dict[str, TableBatchedEmbeddingSlice] = dict(
Expand Down

0 comments on commit 4168f11

Please sign in to comment.