Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cirron.com/llms.txt

Use this file to discover all available pages before exploring further.

Register a model so that framework hooks can capture weight and gradient snapshots at epoch boundaries. Only needed for bare PyTorch loops (Keras and HuggingFace Trainer discover the model from their callback kwargs automatically).

Signature

def watch(model: Any) -> None

Parameters

NameTypePurpose
modelanyThe model to snapshot. Typically an nn.Module for PyTorch.

When to call

Call once, before training starts, after ci.profile():
import cirron as ci

ci.profile(snapshots="stats")
ci.watch(model)

for epoch in ci.epochs(range(20)):
    for batch in ci.batches(loader):
        loss = train_step(batch)

When not to call

Skip ci.watch when:
  • You’re using Keras: the hook reads self.model inside on_epoch_end.
  • You’re using HuggingFace Trainer: the callback receives the model via Trainer.model.
  • You’re not capturing snapshots (ci.profile(enabled=False), or you simply don’t read the snapshot records).

What it does

Stores a reference to the model on the active profiler. At each detected epoch boundary (DataLoader iterator exhaustion, ci.epochs() iteration, or callback-reported epoch end), the snapshot subsystem walks model.named_parameters() and writes per-tensor records to the spool (see Snapshot schema). In snapshots="sampled" or "full" mode, raw tensor values additionally serialize to ./.cirron/snapshots/<span_id>/weights.safetensors.

Module-level only

ci.watch is a module-level function only. There is no Cirron.watch() method. If you’re working with an explicit Cirron instance, call cirron.watch(model) from the module top-level. The registered model is held on the active profiler singleton.

Multiple models

Call ci.watch multiple times to capture snapshots from more than one model (e.g. GAN generator + discriminator). Each registered model contributes its own parameter namespace to the snapshot records.

ci.profile

The snapshots= parameter that controls what watch produces.

Snapshot schema

On-disk format for weight and gradient captures.