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

Support MTIA in DenseTableBatchedEmbeddingBagsCodegen #2680

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,7 @@ def __init__(
pooling_mode: PoolingMode = PoolingMode.SUM,
use_cpu: bool = False,
output_dtype: SparseType = SparseType.FP32,
use_mtia: bool = False,
) -> None: # noqa C901 # tuple of (rows, dims,)
super(DenseTableBatchedEmbeddingBagsCodegen, self).__init__()

Expand All @@ -2468,7 +2469,10 @@ def __init__(
self.output_dtype: int = output_dtype.as_int()
table_embedding_dtype = weights_precision.as_dtype()

self.use_cpu = use_cpu
self.use_cpu: bool = use_cpu
self.use_mtia: bool = use_mtia

assert not (use_cpu and use_mtia), "Cannot use CPU and MTIA at the same time"

if self.use_cpu or self.pooling_mode == PoolingMode.NONE:
assert output_dtype in [
Expand All @@ -2479,7 +2483,13 @@ def __init__(

# pyre-fixme[8]: Attribute has type `device`; used as `Union[int, device]`.
self.current_device: torch.device = (
torch.device("cpu") if self.use_cpu else torch.cuda.current_device()
torch.device("cpu")
if self.use_cpu
else (
torch.mtia.current_device()
if self.use_mtia
else torch.cuda.current_device()
)
)

self.embedding_specs = embedding_specs
Expand Down
Loading