Skip to main content

Syvain Metrics Collector

Use this Python package to send metrics and annotations from a training, evaluation, or benchmark job to Syvain Metrics. Use syvain-metrics-api-client or syvain-metrics cli (available in npm) to read stored metrics.

Install

uv add syvain-metrics-collector

Collect an experiment

from syvain_metrics_collector import Collector

collector = Collector(api_key="ak_org_...")
experiment = collector.experiment(
	slug="mamba-run-001",
	description="Baseline mamba training run",
	folder_id="00000000-0000-0000-0000-000000000000",
	meta={
		"model": "mamba",
		"dataset": "internal-v1",
		"seed": 7,
		"config": {"batch_size": 32, "learning_rate": 0.0003},
	},
)

with experiment.run():
	for step in range(1, 1_001):
	  # run actual training
		loss = 1.0 / step

		if step == 1 or step % 10 == 0:
			experiment.metric(
				"loss",
				loss,
				step=step,
				metadata={"split": "train"},
			)

	experiment.annotation(
		"Checkpoint saved",
		metadata={"path": "checkpoints/mamba-run-001/step-999.pt"},
	)

experiment.flush_or_raise()

metric() and annotation() enqueue data. The collector sends queued batches in the background. experiment.run() records the lifecycle and attempts a best-effort flush when the block exits. The final flush_or_raise() fails the job if queued data cannot be delivered or the collector previously evicted events after exceeding max_queue_items. Capacity drop counts persist for the collector's lifetime, including after a successful queue drain.

Use exactly one flush_or_raise() after the run() block. Do not call flush() or flush_or_raise() from the training loop, evaluation loop, reporting branch, or checkpoint branch.

Collect only measurements the experiment needs

Define the evidence before adding metrics. Each metric must be required to answer the experiment's question or to interpret training health. Do not emit every intermediate, tensor statistic, layer value, or runtime diagnostic.

Report training metrics at a planned cadence. Aggregate device tensors first, then convert them to Python numbers only when reporting. This avoids a device synchronization on every microbatch.

Put values in the right field

Value Field
Stable run identity and configuration Experiment meta
Numeric measurement Metric value
Training or evaluation progress Metric step
Bounded category used to group a series Metric metadata
Unique event details, paths, hashes, IDs, and text Annotation metadata

Use one stable metric name for one quantity and unit. Keep the same name across splits, datasets, stages, devices, and ranks:

experiment.metric("loss", train_loss, step=step, metadata={"split": "train"})
experiment.metric("loss", valid_loss, step=step, metadata={"split": "valid"})

Do not encode dimensions in the name:

# Wrong
experiment.metric(f"{stage}/{split}/loss", loss, step=step)

# Correct
experiment.metric(
	"loss",
	loss,
	step=step,
	metadata={"stage": stage, "split": split},
)

Keep metric metadata low-cardinality

Metric metadata is a flat str -> str mapping. Use it only for bounded categories needed to compare series, such as split, dataset, training_stage, device, rank, or optimizer parameter group.

Every distinct metadata mapping creates a separate series. The product of all dimension values, including missing-key variants, must stay at or below 4,096 series per metric in one experiment. For example, 8 stages, 3 splits, and 16 ranks produce 384 series.

Never put steps, epochs, timestamps, paths, sample or request IDs, hashes, free text, numeric measurements, or serialized objects in metric metadata. Put progress in step, stable configuration in experiment meta, and unique details in annotations.

The client accepts at most 32 metadata keys, 128 UTF-8 bytes per key, 512 UTF-8 bytes per value, and 4,096 UTF-8 bytes in the canonical JSON mapping. It validates these limits before enqueueing the metric. Metric values must be finite numbers; the client logs and drops non-finite values.

Use test collectors

Use NoopCollector when a test only needs the collector interface. Use JsonlCollector(path=...) when a local run needs inspectable JSONL output. Both collectors use the same experiment, metric, annotation, and lifecycle calls as Collector.

Release files for syvain-metrics-collector 0.0.334

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for syvain-metrics-collector 0.0.334
File Size Uploaded
syvain_metrics_collector-0.0.334.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for syvain-metrics-collector 0.0.334
File Interpreter ABI Platform
syvain_metrics_collector-0.0.334-py3-none-any.whl Python 3 none any Details

Total release size: 33.9 kB

Release files / syvain_metrics_collector-0.0.334.tar.gz

Download URL syvain_metrics_collector-0.0.334.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
44b46876f3e477055c47009f5d2b253c8b4dacf4aa8b6f19319324ef150989e3
BLAKE2b-256 checksum
How to use checksums
35d7a10a31ce329594603a2f073f05bb8e4f138c6cc3b99ba648e13949db4195
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / syvain_metrics_collector-0.0.334-py3-none-any.whl

Download URL syvain_metrics_collector-0.0.334-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea097e00798878116d1d9b82f872b95127459c8d90a6a2ed3ac7877a4256d6b7
BLAKE2b-256 checksum
How to use checksums
60981d8915cf6edc549e44786089b11501f7ac72ceb1d7eadf1faf49d0f1b154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page