caliper.metrics.v1 and v1_1¶
Service id caliper.metrics.v1 is a write-only metrics log that uses the TensorBoard vocabulary. caliper.metrics.v1_1 adds one read entry, query(), and is described below. The tables below come from the headers.
Calls¶
| Call | Signature | Description |
|---|---|---|
begin_run |
uint64_t (const char* experiment, const char* run_name) |
Open a run of experiment and return its id, or 0 on error. 0 is never a valid run. The run id scopes every scalar, histogram, image and hyperparameter that the applet logs afterward. |
end_run |
void (uint64_t run) |
Close a run. Call it on every exit path of a job, so that a run never stays open. The points logged before the end are kept. |
scalar |
void (uint64_t run, const char* tag, int64_t step, double value) |
Append one point to the series tag of a run. The tag names the series, for example "train/loss", and a slash groups tags into panes. step is the x value of the point and value is the y value. |
histogram |
void (uint64_t run, const char* tag, int64_t step, const float* values, int64_t count) |
Log a distribution of count values at step under tag. |
image |
void (uint64_t run, const char* tag, int64_t step, const CaliperTensor* hwc_u8) |
Log a picture at step under tag. The tensor must be CPU-resident, contiguous and u8 in HWC layout. The host drops and logs any other tensor. |
hparams_json |
void (uint64_t run, const char* json_utf8) |
Attach a flat JSON object of hyperparameters, for example {"lr":0.001}, to a run. |
Ids¶
| Name | Value | Description |
|---|---|---|
CALIPER_METRICS_V1 |
"caliper.metrics.v1" |
The id of this service, which get_service takes. |
Semantics¶
The vocabulary is experiment / run / tag / step, as in TensorBoard. A 0 run id means error and is never valid, so check for it and skip streaming. The step is the x-axis, and you choose the axis when you choose the step.
Use a global batch index as the step for per-batch loss. Use the same global step for accuracy that you sample every N batches, so loss and accuracy line up. A per-epoch step hides the learning transient on fast-converging datasets. The store keeps points ordered by step and returns them in that order.
Thread Callability¶
Every entry point is callable from an applet job thread, which is where training runs. Do not call it from the frame thread. The host serializes writes, so concurrent jobs are safe. The host destroys the metrics store after it joins job threads. Thus a scalar logged just before a cancel lands cannot fault, if the job honors cancel. The join gives up after 5 s (see caliper.jobs.v1).
Resource Limits¶
The metrics store (metrics.duckdb) opens with its own DuckDB thread count and memory limit. The host sizes both from the RAM and cores of the machine. Override them with CALIPER_DUCKDB_METRICS_THREADS and CALIPER_DUCKDB_METRICS_MEMORY_LIMIT, or with the all-stores CALIPER_DUCKDB_THREADS and CALIPER_DUCKDB_MEMORY_LIMIT. The defaults and the precedence are in caliper.data.v1: Resource limits.
Image Limitation¶
image() accepts only CPU-resident, contiguous, HWC u8 tensors. The host drops and logs any tensor that is non-contiguous, not on the CPU, or not u8-HWC, so it never misreads the data. Metrics images have no GPU-resident path.
Persisted Runs¶
Metrics is an optional service, so probe for it and stream only when it is present. The host persists the runs of every applet that logs a scalar, and the applet needs no storage code. The host has no run browser. Read stored runs back with caliper.metrics.v1_1.query or with SQL tools.
caliper.metrics.v1_1¶
caliper.metrics.v1 is write-only across the ABI and immutable. A consumer such as an embedding host (Embedding Caliper) cannot list runs or read scalars through it. caliper.metrics.v1_1 is the additive read revision. Its table starts with the byte-identical v1 writer prefix and appends two entries: query and last_error.
Calls¶
| Call | Signature | Description |
|---|---|---|
begin_run |
uint64_t (const char* experiment, const char* run_name) |
Open a run of experiment and return its id, or 0 on error. 0 is never a valid run. The run id scopes every scalar, histogram, image and hyperparameter that the applet logs afterward. |
end_run |
void (uint64_t run) |
Close a run. Call it on every exit path of a job, so that a run never stays open. The points logged before the end are kept. |
scalar |
void (uint64_t run, const char* tag, int64_t step, double value) |
Append one point to the series tag of a run. The tag names the series, for example "train/loss", and a slash groups tags into panes. step is the x value of the point and value is the y value. |
histogram |
void (uint64_t run, const char* tag, int64_t step, const float* values, int64_t count) |
Log a distribution of count values at step under tag. |
image |
void (uint64_t run, const char* tag, int64_t step, const CaliperTensor* hwc_u8) |
Log a picture at step under tag. The tensor must be CPU-resident, contiguous and u8 in HWC layout. The host drops and logs any other tensor. |
hparams_json |
void (uint64_t run, const char* json_utf8) |
Attach a flat JSON object of hyperparameters, for example {"lr":0.001}, to a run. |
query |
bool (const char* sql_utf8, struct ArrowArrayStream* out) |
Run one read-only SELECT against the metrics store and stream the result as Arrow. The host parses the text without running it and refuses anything that is not exactly one SELECT, so it returns false, leaves *out untouched and sets the error. A read-only introspection PRAGMA that DuckDB rewrites into a SELECT is allowed. The query sees rows that other threads logged a moment ago. |
last_error |
const char* (void) |
Return why the last query on this thread returned false. The host owns the string, which is never NULL and stays valid until the next call of this service on the same thread. |
Ids¶
| Name | Value | Description |
|---|---|---|
CALIPER_METRICS_V1_1 |
"caliper.metrics.v1_1" |
The id of this service, which get_service takes. |
Query Rules¶
- One SELECT only. The host refuses statement chaining (
SELECT 1; DROP TABLE runs) and everyINSERT,UPDATE,DELETEand DDL statement. It refuses setter pragmas. This differs fromqueryincaliper.data.v1, which runs any SQL against a separate store, because thisqueryruns on the live writer connection. - Stream ownership. This is the same rule as in
caliper.data.v1(see Arrow interchange). - Threads. Applet job threads and a host UI thread that is not the frame thread may all call
query. The host serializes every writer and reader.
Read Access via query¶
A consumer could open the metrics database file read-only with DuckDB ATTACH. That second instance sees only checkpointed state, so it misses rows that an applet logged a moment ago. query runs on the writer connection and sees fresh rows immediately. It also keeps DuckDB types on the host side of the ABI.
The header is immutable once published. A future read entry would arrive as caliper.metrics.v1_2.