For sixty years, deep neural networks were treated as inscrutable, empirical “black boxes”: billions of floating-point numbers optimized by gradient descent that somehow produce intelligent outputs. Mechanistic Interpretability treats deep networks not as mystical oracles, but as complex electronic circuits that can be reverse-engineered down to their individual logic gates, attention routing circuits, and residual stream communications.
1. The Residual Stream as a Linear Communication Bus
Elhage et al. (2021) formulated the foundational framework for Transformer circuit analysis. In a modern Transformer, the Residual Stream acts as a shared, high-dimensional linear communication bus $mathbf{x} in mathbb{R}^d$ running from input embeddings to the unembedding layer:
Individual attention heads and MLP layers do not overwrite the stream; they read specific linear subspaces from the bus via projection matrices and write independent additive updates back onto it. Attention heads serve as information routers (moving data across sequence positions), while MLPs serve as key-value associative memories that store factual associations.
2. Dissecting Attention Circuits: $QK$ vs $OV$ Decomposition
The mathematical operation of an attention head $h$ in layer $l$ factors cleanly into two distinct linear circuits:
The $QK$ Circuit ($W_{QK} = W_Q W_K^T in mathbb{R}^{d times d}$): Determines where information is routed. Computes the bilinear form $mathbf{x}_i^T W_{QK} mathbf{x}_j$ to dictate which source token position $j$ the current target token $i$ attends to.
The $OV$ Circuit ($W_{OV} = W_V W_O in mathbb{R}^{d times d}$): Determines what information is routed. Reads from source token representation $mathbf{x}_j$, applies linear map $W_{OV}$, and adds the result into target position $i$’s residual stream.
3. Causal Mediation Analysis: Activation Patching
How do interpretability researchers prove that a specific neural circuit actually causes a model behavior rather than merely correlating with it? The gold standard is Activation Patching (Causal Tracing):
Run a “clean” prompt through the model: “The Eiffel Tower is located in the city of [Paris].” Record all internal activations.
Run a “corrupted” counterfactual prompt: “The Colosseum is located in the city of [Rome].”
Surgically intervene: overwrite the internal hidden state of a single specific attention head or MLP layer during the corrupted run with the activation recorded during the clean run.
Measure how much the corrupted run’s output probability shifts back toward “Paris”.
Activation patching has localized factual recall to mid-layer MLP modules and in-context copy algorithms to two-layer induction circuits, proving that neural networks compile into interpretable, compositional algorithms.
Share:
Shakil Mahmud Shazal
Senior Software Engineer based in Dhaka, Bangladesh. Building scalable web architectures and writing at the intersection of computer science, physical systems, history, and ideas.
Editorial Dispatch
Curiosity & Articles Delivered to Your Inbox
Receive thoughtful articles on software architecture, physical sciences, history, and systems. No algorithms, no sponsors, no noise.
Connected Intellectual Pathways Frontier AI: Autonomous Agents, Alignment & The Road to AGI→Large Language Models & Generative AI
Deepen Your Exploration: Connected Series
Transition from passive next-token completion to autonomous agentic deliberation, test-time compute, and reinforcement planning.
From subword tokenization, scaling laws, and distributed Megatron/ZeRO clusters to FlashAttention, LoRA, RLHF, DPO, diffusion ODEs, and multimodal foundation systems.
Contemplate the future horizons of our lineage: contemporary polygenic selection detected by GWAS, demographic aging, CRISPR-Cas9 germline gene editing, and the emergence...
Examine the rigorous population genetics of human diversity: Richard Lewontin's 1972 FST variance partition, geographic clines, isolation-by-distance serial bottlenecks, and the deconstruction...
Investigate natural selection in the Anthropocene: how the Neolithic Agricultural Revolution drove powerful selective sweeps for adult lactase persistence, Vitamin D depigmentation,...
•4 min read
Editorial Academy
Learner Portal & Sync
Open to everyone worldwide—researchers, engineers, students, and independent scholars. Sign in with Google or your email to securely track reading progress across devices, take faculty examinations, and earn verified diplomas.
or continue with email
🎓
Enrolled Academic Curricula (43 Disciplines)
The Great Equations (MATH-101)20 Parts • Mathematical Physics & Epistemology
The Story of Physics (PHYS-101)20 Parts • Classical & Modern Theoretical Physics
The Universal Chronicle (COSM-101)20 Parts • Astrophysics & Big History Cosmology
The Evolutionary Odyssey (BIOL-101)20 Parts • Paleobiology, Genetics & Macroevolution
The Story of Consciousness (PHIL-101)20 Parts • Cognitive Neuroscience & Philosophy of Mind
The History of Computing and AI (COMP-101)20 Parts • Computer Architecture & Machine Intelligence
The History of Bengal (HIST-101)20 Parts • Regional Historiography & Geopolitical Economy
The Epic of Human Civilization (CIV-101)20 Parts • World History & Civilizational Anthropology
The Evolution of Money & Markets (ECON-101)20 Parts • Monetary History, Central Banking & Macroeconomics
The Story of Chemistry (CHEM-101)20 Parts • Molecular Sciences, Quantum Bonding & Nanotechnology
The Story of Genetics (GEN-101)20 Parts • Molecular Biology, Genomics & Synthetic Life
The History of Philosophy (PHIL-101)20 Parts • Epistemology, Classical Metaphysics & Continental Thought
Game Theory & Mechanism Design (GAME-101)20 Parts • Strategic Interaction, Mechanism Design & Algorithmic Economics
Nuclear Physics, Fusion Energy & Advanced Reactors (ENERGY-201)20 Parts • Nuclear Physics, Thermonuclear Plasmas & Reactor Engineering
Autonomous Robotics, Kinematics & Spatial Intelligence (ROBOT-201)20 Parts • Robotic Kinematics, Dynamics, SLAM & Embodied AI
Modern Cryptography, Zero-Knowledge & Post-Quantum Security (CRYPTO-301)20 Parts • Mathematical Cryptography, Complexity Theory & Zero-Knowledge Systems