TorchLens: inspect, visualize and intervene on any operation in any PyTorch network
TorchLens is an open-source library whose tl.trace call logs every operation of a PyTorch model with no hooks or code changes. It supports selectors over activations and gradients, attention-head ablation, ATen-level capture, graph drawing, and a record mode…
Why it matters
Removes much of the plumbing for interpretability and model debugging work.
What happened
1 min readTorchLens is an open-source library whose tl.trace call logs every operation of a PyTorch model with no hooks or code changes. It supports selectors over activations and gradients, attention-head ablation, ATen-level capture, graph drawing, and a record mode for dynamic models such as MoE.
Our analysis
Unlike TransformerLens, which centers on transformers, TorchLens claims to work on any network. The first full trace is costly (2x to tens of times a plain forward pass), but faster capture modes exist. Worth trying for interpretability researchers and anyone debugging model internals.