GuideStablesince v0.3.0

Your first experiment

Record a run, save the artifact, reload it in a fresh process, and confirm the recorded tensors round-trip exactly.

Audience: New usersRead: 10 minEdit on GitHub

An experiment is a recorder + inputs + probes, saved as a self-contained .nsz artifact. This walkthrough records 64 inputs against a small transformer and reloads them in a fresh interpreter.

1. Set up the recorder

first_experiment.py·
·python
import neuronscope as ns
from transformers import AutoModel

model = AutoModel.from_pretrained("distilbert-base-uncased")
ds = ns.datasets.tiny_imdb(n=64)
probes = [ns.probes.Activations("transformer.layer.*.output")]

2. Run and save

first_experiment.py·
·python
with ns.Recorder(model, probes=probes) as rec:
    rec.record(ds)
    rec.save("first.nsz")

3. Reload and inspect

shellbash
ns show first.nsz
ns show first.nsz --layer transformer.layer.0.output

4. Verify round-trip

Reload in Python and check tensor equality against a re-record on the same seed.

verify.py·
·python
import neuronscope as ns, torch
a = ns.load("first.nsz")
b = ns.load("first.nsz")  # or re-record with the same seed
for layer in a.layers():
    assert torch.equal(a[layer], b[layer])
  • Artifacts embed the environment fingerprint — a mismatch will refuse to compare.
  • Recorded tensors are stored in native dtype; reloads do not cast.
Related