S-exp GPU
All pages
Docs · Observing a runMarkdown

Metrics

A run reports in two independent channels. Metrics are the time series: one event per number, sent as it happens to a file, a pipe or Metrics by 041. The status file is the single current state, rewritten in place. Consume the metrics stream; poll the status file.

Targets

SEXPGPU_METRICS, or --metrics, read once at run start:

targetwhere numbers go
unsetnowhere
jsonl:<path>one JSON object per line, appended; parent directories are created
stdoutthe same events on standard output, unbuffered, one per line
o41Metrics by 041
o41:<folder-id>the same, in that folder

o41 needs O41_METRICS_API_KEY; the folder is O41_METRICS_FOLDER_ID, and one named in the target wins. Anything else is an error at start. The run prints where its numbers go before it trains (metrics: /tmp/my-run.jsonl, or the experiment's URL), and the same string is in the summary, the status file and sweep's table. With o41 the run waits up to five seconds for the experiment id, then trains without a URL to print.

Delivery to Metrics by 041

  • Batches are delivered concurrently, so events may arrive out of order. An event the app answers busy is sent again, an annotation or done as much as a metric.
  • A run that reports faster than the app accepts fills its queue (100,000 events), then waits for space: an outage idles the GPU rather than losing metrics. After ten minutes without space the run stops with an error. A signal during the wait stops the run at the next step boundary with its checkpoint, as at any other time; the events that found no space are lost, so the run ends failed rather than interrupted.
  • At the end the process waits for acknowledgements of its queued events before it sends done, then waits for that acknowledgement too. On a resumed run, done covers the completing attempt's queue. Training series can still have gaps from earlier attempts. The drain waits while acknowledgements keep coming and prints the pending and delivered counts every ten seconds. Without an acknowledgement it stops with an error after ten minutes with no answer from the app, or after thirty minutes in all while the app keeps answering that it is busy. Meanwhile it prints metrics: the app is not answering or metrics: the app is busy every ten seconds instead of the counts. Both end with the last delivery error: the app's reply, or the request it did not answer and how long the run waited for it.
  • A run interrupted by a signal gets thirty seconds for its drain, and a second interrupt ends it. A preempted machine can be taken away before the drain ends and lose its interrupted and checkpoint annotations; the checkpoint itself is written first.
  • The queue is in memory: a process or machine lost before the drain ends loses what was queued. Metrics wait up to a minute to fill a request, but a checkpoint sends everything queued before it at once, without waiting for it to arrive. A machine lost right after a checkpoint can still lose the requests in flight, and a resume from that checkpoint does not run those steps again.
  • A run that fails sends an error event with its message. When the drain finds rejected events, its error includes the last delivery error, and a run whose training completed sends an error event with up to thirty seconds to deliver it, which an interrupt cancels. An unreachable API can still leave the experiment running.

A metric that is not a number stops the run: written as null or dropped, the stream would read as a run that went fine.

stdout is the plugin interface: sexpgpu run ... | my-forwarder sends events anywhere. Standard output then carries nothing but events, unless --json is also given: then its last line is the summary, of kind summary, which is not an event and has no ts_ms. A forwarder filters on kind. The event format is in JSONL events.

Reporting from the experiment

(metric "name" scalar :key value ...) records one scalar under a name, takes the keywords after it as metadata, and returns the value, so it wraps an expression. It works anywhere a step runs:

wherewhat it becomes
objective, prepareaveraged over a step's microbatches, emitted at that step, beside train/objective
evaluateaveraged over the batches of a pass, emitted at the step it ran, tagged with the pass, offered to the curriculum by name
the model bodyobserved in every graph the model is applied in: a training-step average and one per evaluation pass, under one name told apart by split and pass; a library model reports the same way
an optimizer bodyrefused, E-CONTRACT-011: use a diagnostic
curriculumnot read; the curriculum is a decision, not a report
(metric "probe/logit-rms" (sqrt (mean (* logits logits))) :layer "out")

:below b and :above a among the keywords bound the value, strictly, on every microbatch and batch: a guard of the metric's name stops the run at the step that crosses it.

A number about how the model is doing rather than how well, that nobody needs on every step of every run, is a diagnostic: it costs nothing until selected.

Metadata values are strings, keywords, numbers or booleans, recorded as strings; a tensor is refused, because metadata is fixed at compile time. Metadata is capped at 32 keys, 128-byte keys, 512-byte values and 4 KiB of canonical JSON, the runtime's keys and the longest stage name counted; a metric over it is refused at compile time, E-CONTRACT-012.

Offline evaluation

A pass sexpgpu evaluate runs from a checkpoint reports by default into the training run's experiment, found by the slug the checkpoint records, at the checkpoint's step, under the same names and metadata as inline: eval/loss with pass and split, then curriculum/stage, runtime/eval_seconds and, when the pass runs a generator, runtime/generate_trips. The series line up with training as if the pass had run in the loop. Before its first numbers, each evaluate process adds one annotation at that step naming its device and its choice provenance, not a guarantee of identical bits:

{"step":300,"kind":"annotation","annotation":"evaluated offline on cpu: determinism 3: chosen here, ...","metadata":{"device":"cpu","level":"3: chosen here, ...","checkpoint":"s3://my-bucket/runs/my-run/step-00000300"}}

Its metadata also carries changed, the source and knob lines a resume would print, so an evaluation of an edited file is visible in Metrics. A pass run under a knob --set moved carries set as well, so its numbers are series apart from the run's own.

It opens the experiment with an open event built from the checkpoint, so that it describes the training run as the run's own did: the setup, every pass, the run configuration, the build that trained it (release), and the device kind and count its recorded choices name (compiler and the node count, which a checkpoint does not record, are left out). It never sends start or done, so the experiment's state is the training run's. A signal stops a pass with nothing of it reported. An offline run itself reports no pass at all.

An isolated reread, requested with evaluate --metrics-slug <slug>, opens its own experiment. Its metadata describes the effective selection and evaluation device, with evaluation containing the source training slug, checkpoint URI and step. It starts and finishes only that experiment, and annotates every checkpoint it evaluates with its provenance. Ordinary evaluation keeps the training identity and lifecycle described above.

Runtime metadata

The runtime adds its own keys to every event of a series:

keyonvalue
splitevery metrictrain from the training graph and counters, eval from every pass and curriculum/stage
passevery metric of an evaluation pass, and its curriculum/stagethe defeval name, eval or probe
stageevery metric, when the training loaders have several stagesthe stage it was measured in
paramevery optimizer diagnostic and guardthe label of the update group its values folded over
setevery metric of a pass evaluate --set ran under a moved knobthe moved knobs, knob=value in knob-name order, joined by spaces
phaseevery training metric, when the file declares phasesthe selected phase's name, default when none matches

A series is its name and its metadata together, so train/loss from the easy and the hard stage are two series. An experiment that writes :split, :pass or :stage itself keeps its own value; the runtime's phase replaces an experiment's own :phase.

An optimizer group's param label is its name, such as default or the selector text. If the name exceeds 512 UTF-8 bytes, the label starts with the SHA-256 fingerprint of the full name, followed by a prefix of the name and an ellipsis. The label fits in 512 bytes, and the full selector remains visible in sexpgpu explain.

Experiment limits

Metrics by 041, used by the o41 targets, has these limits, across the whole experiment, resumes and offline evaluation included:

whatmaximum
distinct series names, meaning metric names, per experiment4096
unique metadata combinations per series name in one experiment4096

A combination is a complete metadata map, runtime keys such as split, pass, stage and param included, so each split and pass counts it again: a combination reported in training and two evaluation passes counts three times. Sampling less often does not reduce combinations; select fewer diagnostics or give them fewer metadata values.

Reporting rate

Metrics by 041 takes on the order of a thousand events a second from one experiment. A run makes one event per series per step for its metrics, runtime series and guards, and one per selected diagnostic series on each sampled step. A small model stepping a hundred times a second with forty series makes four thousand events a second, four times what the app takes: it fills its queue, then waits on it at every step, and its final drain lasts minutes. Sample diagnostics with :diagnose-every (when they compute), and make a per-layer number a diagnostic rather than a metric when it is for watching rather than for the curve. A run whose final drain prints a backlog at all is reporting too much.

Metric names

namewhat it is
whatever metric was called withan observation, averaged over a step's microbatches or a pass's batches
diagnostics/<name>a selected diagnostic, on sampled steps, folded by its reducer
guard/<name>a guard's count, summed over a step's microbatches and ranks, a pass's batches or an optimizer group's parameters, every step it is computed
train/objectivethe objective's own value, whatever its reduction and name
counter/<name>a declared counter's running total, every step
rate/<counter>what the counter grew by this step, per second of runtime/step_seconds
runtime/step_secondsthe whole step, first batch to end of update, device synchronized, evaluation excluded
runtime/data_wait_secondsthe part of runtime/step_seconds spent waiting for training batches; near the whole step, the run is waiting on its data
runtime/train_secondsthe sum of runtime/step_seconds so far in this process
runtime/eval_secondsone evaluation pass, synchronized, with its pass
runtime/peak_bytesthe device's high-water mark of live bytes, CUDA's execution cache included; absent on the CPU
runtime/generate_tripsthe mean trips a generator ran, over a step's microbatches (rank zero's) or, with its pass, a pass's batches on every rank
curriculum/stagethe stage index an evaluation ran in, with every evaluation

Every run reports the runtime series with nothing to select. The runtime knows no domain, so (counter :tokens ...) gives rate/tokens, tokens per second. On the CPU timings are wall time; under data parallel they are rank zero's. train/loss and eval/loss mean something to the runtime; see objective.

Related: JSONL events, diagnostics, the status file.