Skip to content

mark metricmodule methods as experimental #2983

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions torchrec/metrics/metric_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
from torchrec.metrics.unweighted_ne import UnweightedNEMetric
from torchrec.metrics.weighted_avg import WeightedAvgMetric
from torchrec.metrics.xauc import XAUCMetric
from torchrec.utils.experimental import experimental


logger: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -394,6 +395,7 @@ def _get_metric_states(

return state_aggregated

@experimental
def get_pre_compute_states(
self, pg: Optional[Union[dist.ProcessGroup, DeviceMesh]] = None
) -> Dict[str, Dict[str, Dict[str, Union[torch.Tensor, List[torch.Tensor]]]]]:
Expand Down Expand Up @@ -442,6 +444,7 @@ def get_pre_compute_states(

return aggregated_states

@experimental
def load_pre_compute_states(
self,
source: Dict[
Expand Down
2 changes: 1 addition & 1 deletion torchrec/metrics/tests/test_metric_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def metric_module_gather_state(
metric_module.update(test_batch)

computed_value = metric_module.compute()
states = metric_module.get_pre_compute_states(pg=ctx.pg) # pyre-ignore[6]
states = metric_module.get_pre_compute_states(pg=ctx.pg)

torch.distributed.barrier(ctx.pg)
# Compare to computing metrics on metric module that loads from pre_compute_states
Expand Down
Loading