An Environment object records the runtime facts that materially affect numeric output. It is captured once at the top of a script or notebook, fingerprinted, and embedded in every artifact produced from that point on.
Why capture an environment
The same code on the same model can produce different activations across framework upgrades, BLAS providers, and accelerators. Capturing the environment turns that variance from an invisible source of drift into a checkable field.
What is captured
·yaml
python: 3.11.7os: linux-6.5.0-generic-x86_64libc: glibc-2.38torch: 2.3.1+cu121numpy: 1.26.4blas: openblas-0.3.27cuda: 12.1.1driver: 550.90.07device: NVIDIA A100-SXM4-40GBseed: ns:global:2718281828Deliberately excluded
- Wall-clock time, hostname, and username — they do not affect numeric output.
- Installed but unused packages — the capture only records loaded modules.
- The current working directory — it is captured only when a config file references relative paths.
Seeds
Seeds live inside the environment. ns.Environment.current() reads the process seed and any framework-specific seeds, and re-applies them on every experiment start.
Pitfalls
- Upgrading PyTorch across a minor version changes the environment fingerprint even if your code is identical.
- Switching between OpenBLAS and MKL changes the environment fingerprint — matmuls are not bit-identical across BLAS backends.
- Running under
torch.compilecreates a new fingerprint every time the compile cache is invalidated.