-
Notifications
You must be signed in to change notification settings - Fork 599
CPUOffloadedRecMetricModule: DtoHs in the update thread #3658
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
Open
jeffkbkim
wants to merge
3
commits into
meta-pytorch:main
Choose a base branch
from
jeffkbkim:export-D87800947
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
@jeffkbkim has exported this pull request. If you are a Meta employee, you can view the originating Diff in D87800947. |
jeffkbkim
added a commit
to jeffkbkim/torchrec
that referenced
this pull request
Jan 13, 2026
…#3658) Summary: Pull Request resolved: meta-pytorch#3658 CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements. Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training. Differential Revision: D87800947
59d6e9d to
050e753
Compare
jeffkbkim
added a commit
to jeffkbkim/torchrec
that referenced
this pull request
Jan 14, 2026
…#3658) Summary: Pull Request resolved: meta-pytorch#3658 CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements. Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training. Differential Revision: D87800947
050e753 to
b02ff99
Compare
b02ff99 to
d2204fc
Compare
jeffkbkim
added a commit
to jeffkbkim/torchrec
that referenced
this pull request
Jan 22, 2026
…#3658) Summary: CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements. Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training. Differential Revision: D87800947
jeffkbkim
added a commit
to jeffkbkim/torchrec
that referenced
this pull request
Jan 22, 2026
…#3658) Summary: Pull Request resolved: meta-pytorch#3658 CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements. Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training. Differential Revision: D87800947
d2204fc to
ef7c8ee
Compare
Summary: Utilities for CPUOffloadedRecMetricModule and RecMetricModule. Also raise exceptions in the main thread if any of the background threads. Added unit tests. Simplify the core metric types: - MetricsResult = Dict[str, MetricValue]: sync metrics computation - MetricsFuture = concurrent.futures.Future[MetricsResult]: for async computation - MetricsOutput = Union[MetricsResult, MetricsFuture]: Either a MetricsResult, or a MetricsFuture - The PublishableMetrics variants are to loosen the constraints to publish, so that the user can store values other than a Tensor/float. Introduce a metrics_output_util to handle the logic between futures and dicts. Users can schedule callbacks via `get_metrics_async()`. If they want to synchronously perform it, they can use `get_metrics_sync()` Introduce `device` argument to RecMetricModule constructor. It is a noop for the standard metric module, but CPUOffloadedRecMetricModule requires it to determine whether to perform GPU to CPU transfers. Differential Revision: D87110900
…ta-pytorch#3593) Summary: metric_module's get_pre_compute_states() provides an API to perform gloo all gathers instead of the default torchmetric.Metric's sync_dist (nccl). However, the mechanism calls gloo all gathers for each element in a list of tensors. This can be problematic because: - AUC's 3 state tensors hold a list of tensors, not a single tensor. - The size of the tensor list is theoretically unbounded. (In practice, it can grow to orders of 100K) - gloo all gathers are inherently much slower. Instead, this patch aims to: - apply the reduction function prior to the all gather if we're processing a tensor list - enforce that the reduction_fn does not rely on ordering Differential Revision: D88297404
…#3658) Summary: CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements. Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training. Differential Revision: D87800947
ef7c8ee to
657b7cb
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
meta-exported
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
CPUOffloadedRecMetricModule currently performs DtoH (nonblocking) from the main thread. This can start to become quite expensive when the order of magnitude of the model_out dict size is in the thousands, where each key stores a tensor with 1000+ elements.
Instead of the main thread launching the DtoHs, have the update thread be responsible. This will free the main thread to continue training.
Differential Revision: D87800947