Skip to content

Log your results

Print a line starting with KV for each result, to stdout. Any language. Other output prints as usual.

print(f"KV val_accuracy={acc:.4f} loss={loss:.4f} step={epoch}")

Lines

Line What it is for
KV <name>=<number> ... [step=<label>] Results. Several per line allowed.
KV phase <name> Start of a stage, like training or testing.
KV claim <name>=<number> [phase=<name>] A headline result you stand behind.
KV seed <value> The random seed you used.
KV model params=... arch=... precision=... Model size. Used to check the compute.
KV workload dataset_size=... epochs=... batch_size=... Work done. Used to check the compute.
KV artifact role=... path=... visibility=... A model or dataset file you vouch for.

All the details: Output lines.

Good to know

  • Names start with a letter: val_accuracy, f1.
  • Numbers can be 3, 0.94 or 1e-4.
  • step is optional. Use it for epochs or steps to get a curve.
  • A name printed more than once: the last value is the final one.
  • KV cache: 2 GB is not a result line, so it is skipped.

Any language

print(f"KV val_accuracy={acc:.4f} step={epoch}")
cat(sprintf("KV val_accuracy=%.4f step=%d\n", acc, epoch))
println("KV val_accuracy=$(acc) step=$(epoch)")
printf("KV val_accuracy=%.4f step=%d\n", acc, epoch);
fflush(stdout);
println!("KV val_accuracy={acc:.4} step={epoch}");
echo "KV val_accuracy=0.9471 step=100"

Example

import torch

torch.manual_seed(42)
print("KV seed 42")
n_params = sum(p.numel() for p in model.parameters())
print(f"KV model params={n_params} arch=resnet18 precision=fp32")

print("KV phase train")
for epoch in range(epochs):
    loss = train_one_epoch(model, train_loader)
    acc = evaluate(model, val_loader)
    print(f"KV train_loss={loss:.4f} val_accuracy={acc:.4f} step={epoch}")

print("KV phase test")
print(f"KV claim test_accuracy={evaluate(model, test_loader):.4f}")

Results saved to a file

Print them from the file in the same run, not by hand.

#!/usr/bin/env bash
python evaluate.py --out results.json
python -c 'import json; print("KV claim map=%s" % json.load(open("results.json"))["map"])'
kveritas bash run.sh

Measured for you

Every run, automatically: time, CPU time, peak memory, GPU time, GPU energy, peak GPU memory. Shown as measured in the report. Installed Python packages are recorded too.

Autolog

Off by default. Finds results in what your program already prints or saves, without KV lines.

The first time a run has no KV lines, K-Veritas asks (in a terminal):

1  Declare them
2  Autolog
3  No results

Or turn it on:

kveritas autolog on        # or: kveritas init --autolog

It can miss things, so the report labels these values as found automatically (auto:<format>). A KV line for the same name wins.

Where it looks What it understands
What your program prints Hugging Face, Keras, Lightning, XGBoost, LightGBM, JSON lines, simple name: value lines
Benchmark tools hyperfine, Google Benchmark, criterion, time
Files your run writes TensorBoard, trainer_state.json, metrics.csv, training.log, MLflow

Pick claims when you seal

kveritas seal --claim val_accuracy --claim f1

Takes the latest value of each. Shown as "claimed at seal".

Older lines

Lines starting with KVERITAS_ (like KVERITAS_METRIC) still work. See Output lines.