Get the daily emailDaily email
  1. Home
  2. Agents
  3. This story

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…

Published Read the original
TorchLens: inspect, visualize and intervene on any operation in any PyTorch network

Why it matters

Removes much of the plumbing for interpretability and model debugging work.

What happened

1 min read

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 for dynamic models such as MoE.

inscraper analysis

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.

More in Agents