Skip to content

Metric output format

hpo.metrics.<name>=<JSON value>

Print one metric per line to stdout. Use the prefix exactly as shown and no spaces around =. Normal log lines can appear between metric lines.

Part Rule Example
Prefix hpo.metrics. hpo.metrics.loss
Name Letters, numbers, dots, underscores, or hyphens; configured objective names are 1–128 characters. Names are case-sensitive. loss, validation.accuracy, duration_seconds
Objective value A finite JSON number. 0.182, 42, -1.5
Context value JSON strings or booleans can be recorded as nonnumeric context. They cannot satisfy an objective. "completed", true

Use simple, stable names and keep units consistent across every trial. For example, report duration_seconds in seconds rather than mixing seconds and milliseconds.

Valid objective lines:

hpo.metrics.loss=0.182
hpo.metrics.sample_count=250
hpo.metrics.return_ratio=-0.03

These do not provide a usable numeric objective:

Output Problem
hpo.metrics.loss="0.182" A string, not a number.
hpo.metrics.loss=NaN Not a finite JSON number.
hpo.metrics.loss=Infinity Not a finite JSON number.
hpo.metrics.loss=null No numeric value.
hpo.metrics.loss=0.182 seconds The value contains trailing text.
hpo.metrics.Loss=0.182 Does not match an objective named loss.

The collector may retain unparseable values as text. Seeing a line in logs does not mean it satisfied your objective. A successful optimization result needs a successful trial and all configured numeric objectives.

hpo.metrics.dataset_version="validation-v2"
hpo.metrics.valid=true

Prefer plain logs for detailed reports, arrays, and objects. Use numeric metrics for values you want to compare or optimize.

import json
loss = 0.182
print(f"hpo.metrics.loss={json.dumps(loss, allow_nan=False)}", flush=True)

allow_nan=False raises an error for NaN and infinity instead of emitting invalid objective values. flush=True sends the line immediately. See report metrics for a reusable numeric helper.

A trial may report the same metric more than once. For a simple final-score workload, emit each objective once after the evaluation completes. Do not assume that printing intermediate values automatically enables early stopping or Hyperband resource scheduling; see algorithm behavior.