Generate and compute training observables without changing your training loop.#

PyTorch training observables · 0.1.0

Observable Library is a small Python package for defining, generating, and computing observables from a running PyTorch training loop. Return values directly or store them for exact id-and-step readback.

Get started · API reference

import observable_library as ol

# You choose the observables. Nothing is inferred automatically.
observables = ol.generate(model, reductions=["l2_norm"])
runtime = ol.Runtime(observables, source=ol.HookSource(model))

if step % 100 == 0:
    values = runtime.observe(step=step)
  • param_norm · illustrative

  • observed_values · illustrative

generate observables → Runtime.observe() values → optional ValueSink storage

Install#

Requires Python 3.10–3.12 and torch>=2.4.1. The package is published on PyPI under Apache-2.0.

python -m pip install observable-library

Core data flow#

You explicitly select the reductions and the steps at which computation happens. Parameter generation does not change the training loop and does not automatically create activation, gradient, or loss observables.

observables = ol.generate(model, reductions=["l2_norm"])
runtime = ol.Runtime(observables, source=ol.HookSource(model))
values = runtime.observe(step=0)

Where to go next#

Quickstart

Go from installation to the first observed and stored value with a small CPU example.

Quickstart
Concepts

Understand specs, sources, packs, runtime scheduling, storage, and stable ids.

Concepts
How-to Guides

Use online hooks, custom observables, filters, transforms, reductions, and offline files.

How-to Guides
API Reference

Browse the complete top-level 0.1.0 public API and its current behavior.

API Reference