Rate this Page
★ ★ ★ ★ ★

Metrics#

Created On: Oct 25, 2026 | Last Updated On: Oct 25, 2026

Metric Handlers#

Below are the metric handlers that come included with torchelastic.

class torch.distributed.elastic.metrics.api.MetricHandler(*args, **kwargs)[source]#
class torch.distributed.elastic.metrics.api.ConsoleMetricHandler[source]#
class torch.distributed.elastic.metrics.api.NullMetricHandler[source]#
class torch.distributed.elastic.metrics.api.MetricData(timestamp, group_name, name, value)#

Methods#

torch.distributed.elastic.metrics.configure(handler, group=None)[source]#
torch.distributed.elastic.metrics.prof(fn=None, group='torchelastic')[source]#

@prof decorator publishes success, failure and duration.ms metrics for the function that it decorates.

The metric name defaults to the qualified name (class_name.def_name) of the function. If the function does not belong to a class, it uses the leaf module name instead.

Usage

@metrics.prof
def x():
    pass


@metrics.prof(group="agent")
def y():
    pass
torch.distributed.elastic.metrics.put_metric(metric_name, metric_value, metric_group='torchelastic')[source]#

Publish a metric data point.

Usage

put_metric("metric_name", 1)
put_metric("metric_name", 1, "metric_group_name")