Python bindings for the vor profiler.
Instrument a training or inference loop, write per-step metrics (and
optional flame frames) to a .vor file, and read it back in Python with
vor.Reader. The GUI replay panel stays in the Rust tools.
uv add vor-profile # or: pip install vor-profileThe distribution is vor-profile (the name vor is taken on PyPI); the
import is vor.
import vor
vor.enable()
vor.record_metric_unit("throughput", "tok/s") # optional, once
@vor.profile
def train_step(batch):
...
for batch in loader:
loss = train_step(batch)
vor.record_metric("loss", loss)
vor.frame_mark()
vor.flush()Set VOR_RECORD to capture; leave it unset and nothing is written:
VOR_RECORD=/scratch/run.vor python train.pyVOR_RECORD_FLAME=1 also records flame frames (VOR_RECORD_EVERY=N
samples 1 step in N). See examples/train.py.
enable()- turn collection on; arm capture whenVOR_RECORDis set.frame_mark()- end a step; writes one record.record_metric(name, value)- a named scalar for this step.record_metric_unit(name, unit)- label a metric's row, once.flush()- write buffered records before exit.@profile- flame scope per call, namedmodule.qualname.profile_scope(name)- flame scope for awithblock.Reader(path)- iterate a capture; eachFramehas.system(aligned toreader.columns),.user(dict of named scalars), and.flame(raw puffin bytes orNone).
import vor
reader = vor.Reader("/scratch/run.vor")
for frame in reader:
step_ms = frame.system[0] # columns are reader.columns
loss = frame.user.get("loss")Into a DataFrame for plotting (no pandas dependency in this package):
import pandas as pd
reader = vor.Reader("/scratch/run.vor")
cols = [name for name, _unit in reader.columns]
df = pd.DataFrame(
{**dict(zip(cols, f.system)), **f.user} for f in reader
)
df["loss"].rolling(50).mean().plot()The GUI replay panel stays in the Rust crate:
cargo run --example replay --features viz,mac -- /scratch/run.vorNeeds maturin. The base build is portable (metrics only); add a platform feature for GPU rows:
maturin develop # metrics
maturin develop --features mac # + Apple Silicon GPU (IOKit)
maturin build --release --features cuda # + NVIDIA GPU (NVML)