Skip to content

Commit

Permalink
Move ITEP iter to CPU explicitly
Browse files Browse the repository at this point in the history
Summary: Move ITEP iter to CPU explicitly to prevent D2H sync

Reviewed By: aporialiao

Differential Revision: D66804959
  • Loading branch information
sryap authored and facebook-github-bot committed Dec 8, 2024
1 parent f450c59 commit 7b36097
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torchrec/modules/itep_embedding_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def forward(
The iteration counter is incremented after each forward pass to keep track of the number of iterations.
"""

# We need to explicitly move iter to CPU since it might be moved to GPU
# after __init__. This should be done once.
self._iter = self._iter.cpu()

features = self._itep_module(features, self._iter.item())
pooled_embeddings = self._embedding_bag_collection(features)
self._iter += 1
Expand Down

0 comments on commit 7b36097

Please sign in to comment.