Metric output format
Syntax
Section titled “Syntax”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.
Numeric objectives
Section titled “Numeric objectives”Valid objective lines:
hpo.metrics.loss=0.182hpo.metrics.sample_count=250hpo.metrics.return_ratio=-0.03These 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.
Nonnumeric context
Section titled “Nonnumeric context”hpo.metrics.dataset_version="validation-v2"hpo.metrics.valid=truePrefer plain logs for detailed reports, arrays, and objects. Use numeric metrics for values you want to compare or optimize.
Python emission
Section titled “Python emission”import json
loss = 0.182print(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.
Repeated values
Section titled “Repeated values”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.