nnsight-remote-interpretability

Interpret and manipulate PyTorch model internals locally or remotely via NDIF.

5|2|Updated Aug 10, 2026
One-click install
npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill nnsight-remote-interpretability-medtilab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nnsight-remote-interpretability
Source: https://github.com/MedTiLab/Auto-meta-analysis/tree/main/skills/mechanistic-interpretability/nnsight
Command: npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill nnsight-remote-interpretability-medtilab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires nnsight, torch, and includes references (resource) components.

What problem does it solve? Running mechanistic interpretability experiments on massive models (70B+) normally requires expensive local GPU clusters, and different interpretability libraries often force you to reimplement models or work only with specific architectures. This Skill provides guidance for using nnsight to access and modify the internals of any PyTorch model, with the same code running locally on small models or remotely on huge models through NDIF. ## Core Features & Use Cases - Activation Analysis and Patching: Trace model execution, save hidden states and attention patterns from any layer, and patch activations between clean and corrupted prompts to test causal relationships. - Remote Execution on Massive Models: Toggle remote=True to run identical interpretability code on Llama-3.1-70B/405B and other models hosted on NDIF without local GPUs. - Cross-Prompt Interventions and Steering: Share activations between prompts in a single trace, add steering vectors, and perform logit lens analysis across layers. - Use Case: A researcher wants to find which layer of Llama-3.1-70B encodes factual recall. They use this Skill to run an activation patching sweep remotely via NDIF, identifying the most causally important layer without owning any GPU hardware. ## Quick Start Ask the AI to help you write an nnsight script that traces a prompt through GPT-2, saves the layer 8 activations, and patches them into a corrupted prompt to compare predictions.

Frequently Asked Questions about nnsight-remote-interpretability

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I access internal activations of a PyTorch model with nnsight?▼

Wrap the model with nnsight's LanguageModel, then use the model.trace(prompt) context manager to access any module's output as a Proxy object. Call .save() on values you need, and they become real tensors after the context exits.

How to run interpretability experiments on 70B models without a GPU?▼

Use nnsight's remote execution through NDIF. Sign up at login.ndif.us for an API key, load a large model like Llama-3.1-70B, and pass remote=True to model.trace. The same code runs on NDIF's hosted infrastructure.

nnsight vs TransformerLens for mechanistic interpretability?▼

nnsight works with any PyTorch architecture and supports remote execution via NDIF, while TransformerLens offers a consistent API but only for transformers and requires local execution. Choose nnsight for large models or non-standard architectures.

Does nnsight support gradient-based analysis?▼

Yes, nnsight supports gradient access by calling retain_grad() on saved activations and running backward() inside the trace context. However, gradients are not supported with vLLM backends or NDIF remote execution.

Why are my saved nnsight values empty or wrong after tracing?▼

This happens when you forget to call .save() on Proxy objects inside the trace context. Values accessed without .save() are not retained after the context exits, so always save every tensor you need later.

Can nnsight share activations between different prompts?▼

Yes, use tracer.invoke() to process multiple prompts within a single trace context. You can save activations from one prompt and assign them into another prompt's modules, enabling cross-prompt intervention experiments.