Unifying Attention and Diffusion with Kan Extension Transformers: Structured Deep Learning with Diagrammatic Backpropagation
Sridhar Mahadevan
International Conference on Machine Learning 2026 · Tutorial
Overview
Modern foundation models, despite their staggering commercial and technical footprint, suffer from a fundamental architectural deficit: they lack reliability and internal consistency. When deployed to autonomous environments—such as the well-documented test case of Andon Market, an AI-run grocery store managed by Claude that resulted in chaotic operational failures—large language models (LLMs) prove to be exceptional token generators but poor validators. This tutorial-style ICML talk argues that the root cause of this brittleness lies in deep learning's over-reliance on 17th-century calculus rather than modern structural mathematics.

Key moments
- 0:00 Introduction to categorical deep learning and Kan extensions
- 8:00 Foundations of trustworthy foundation models and challenges
- 27:00 Generalizing deep learning: from manifolds to tangent spaces
- 40:00 Rollouts, pullbacks, and crossword puzzle analogy for Kan extensions
- 54:00 Diagrammatic backpropagation and Sudoku acceleration experiment
- 68:00 Lie algebroid skill optimization for LLM agents
Unifying Attention and Diffusion with Kan Extension Transformers: Structured Deep Learning with Diagrammatic Backpropagation
Speakers: Sridhar Mahadevan
Conference: ICML
YouTube: https://slideslive.com/39083456
Overview
Modern foundation models, despite their staggering commercial and technical footprint, suffer from a fundamental architectural deficit: they lack reliability and internal consistency. When deployed to autonomous environments—such as the well-documented test case of Andon Market, an AI-run grocery store managed by Claude that resulted in chaotic operational failures—large language models (LLMs) prove to be exceptional token generators but poor validators. This tutorial-style ICML talk argues that the root cause of this brittleness lies in deep learning's over-reliance on 17th-century calculus rather than modern structural mathematics.
To bridge this gap, Sridhar Mahadevan introduces a rigorous framework that replaces conventional vector-space operations with category theory, functors, and Kan extensions. By moving from functions to functors, machine learning problems gain canonical, universal solutions that bypass ad-hoc design. The talk outlines several novel systems—including Democritus for automated causal discovery, Prometheus for sheaf-based world modeling, and Odyssey as an overarching multi-agent foundry—demonstrating how categorical abstractions can unify attention and diffusion, accelerate training via diagrammatic backpropagation, and enforce safe compositionality in low-rank adaptation.
Background
▶ Watch: Introduction to categorical deep learning and Kan extensions (0:00)
Machine learning has spent six decades wrestling with the problem of extrapolation: taking a finite sample of experience and generalizing it to the infinite unknown. Traditional paradigms—ranging from support vector machines and regression to Bayesian inference—offer hundreds of formulations without a single canonical solution. Simultaneously, deep learning relies on parameterizing probability distributions over curved manifolds and adjusting weights via gradient descent in tangent spaces.
While this calculus-based approach powers trillion-parameter models, it creates severe limitations in systems design:
- The Trust Deficit: Unlike relational databases governed by strict integrity constraints developed over 60 years, foundation models are black boxes prone to severe hallucinations (such as fabricating academic references).
- Compositionality Failures: Standard low-rank adapters (LoRA) lack mathematical guarantees when combined, making it an art form to merge safety, helpfulness, and domain-specific adapters without catastrophic forgetting or negative interference.
- Causal Blindness: Standard next-token prediction operates strictly on conditional probabilities, struggling to distinguish correlation from causation without heavy reliance on structural causal models (SCMs) and do-calculus.
Mahadevan argues that just as Max Planck shattered Newtonian physics with discrete energy quanta, deep learning requires an abstraction leap beyond classical calculus. That leap is category theory—specifically, treating operations not as algebraic transformations on flat vectors, but as structure-preserving mappings (functors) across abstract categories.
Key Findings
▶ Watch: Generalizing deep learning: from manifolds to tangent spaces (27:00)
The central thesis is operationalized through several major discoveries and benchmarked results across architectures:
- Universal Extension via Kan Extensions: Left and right Kan extensions provide the first canonical, universal solution to the extension problem in machine learning. Attention mechanisms operate as left Kan extensions (colimits/rollouts), while diffusion models operate as right Kan extensions (limits/constraints). Unifying them forms Kan extension transformers.
- Diagrammatic Backpropagation: By incorporating explicit categorical diagrams as loss constraints during training, diagrammatic backpropagation accelerates convergence. On a 4x4 Sudoku benchmark encoding row, column, and subgrid constraints, categorical loss checks accelerate training throughput by roughly an order of magnitude (10x speedup) over standard transformer baselines.
- Lie Algebraic Skill Optimization (Lasco): Optimizing agentic markdown workflows via Microsoft Research’s SkillOpt framework traditionally requires expensive LLM validation loops for every edit. By introducing Lie algebroids and computing inexpensive Lie brackets (taking ~71 microseconds per probe on a local Mac Studio versus minutes for large models), Lasco screens out non-productive edits. This reduces costly LLM validation calls by a factor of 5 to 150 depending on model scale, yielding massive end-to-end wall-clock speedups.
- Composable Low-Rank Adaptation (ALoRA): Adding a Lie-bracket-based penalty term ($\lambda$) to standard LoRA training forces adapters to "play nice." On WikiText-2 and WikiText-103 corpora, this regularization reduces adversarial interference and improves adapter composition metrics by over two orders of magnitude (factor of 123+).
Technical Deep Dive
▶ Watch: Diagrammatic backpropagation and Sudoku acceleration experiment (54:00)
The technical architecture spans several sophisticated mathematical and systems components:
Categorical Foundations and Functors
A category consists of objects (e.g., Markov Decision Processes, metric spaces, or skill states) and arrows (morphisms) representing structure-preserving relationships. A functor maps objects and arrows from a category $\mathcal{C}$ to $\mathcal{D}$ while preserving identities and compositionality. A natural transformation defines a compatible mapping between two functors, formalizing when two distinct algorithms (such as temporal difference learning and value iteration) yield equivalent behaviors.
Kan Extension Transformers
In category theory, given a functor $K: \mathcal{A} \to \mathcal{C}$ and $F: \mathcal{A} \to \mathcal{B}$, the left Kan extension ($L_KF$) computes a colimit (generalizing attention rollouts), while the right Kan extension computes a limit (enforcing global constraints, generalizing diffusion denoising). Mahadevan’s Kan extension transformer framework encapsulates 12 distinct transformer variants, including strictly causal models, anti-causal BERT-style architectures, and "predict-detach self-conditioning" models that phase-transition from causal to joint prediction based on internal trajectory quality.
Infinitesimal Causality and Lie Algebroids
To discover latent confounders without exhaustively enumerating directed acyclic graphs (DAGs), the framework utilizes differential geometry over abstract categories (drawing on work by Cockett and Cruttwell).
- Tangent Bundles & Vector Fields: The parameter space of probability distributions forms a manifold. Gradients at any point form a tangent space; collecting them yields a tangent bundle.
- Lie Brackets: The commutator of two vector fields, $[X, Y] = XY - YX$, measures the skew-symmetry of infinitesimal movements. In Democritus (causal discovery from text) and Lasco (skill optimization), non-zero Lie brackets indicate unobserved confounders or non-commuting structural updates.
Topos Theory and Sheaf Semantics
To ensure reliability, global truth is abandoned in favor of local patches. Topos theory (featuring subobject classifiers and Cartesian closed structures) allows outputs to be tagged with contextual metadata. A sheaf glues local contexts (e.g., individual customer reviews of a Tesla Model 3 or supply chain nodes in a network economy) together. Hankel matrices—whose rows are contexts and columns are future tests—are constructed for each local sheaf to compute restriction maps. Model disagreement is quantified by checking whether overlapping sheaf sections maintain consistency.
Experimental Setup & Results
▶ Watch: Lie algebroid skill optimization for LLM agents (68:00)
The empirical evaluations span synthetic constraint tasks, financial document analysis, language corpora, and agentic workflows:
- Sudoku Constraint Acceleration: Evaluated on 4x4 Sudoku puzzles using standard transformers versus diagrammatic backpropagation. Diagrammatic constraints reduce training epochs required for convergence by a factor of 10.
- Language Modeling Corpora: Tested on WikiText-2 and WikiText-103 (100 million tokens) across 12 Kan extension transformer variants. Predict-detach self-conditioning architectures match or exceed standard bidirectional models once internal predictions stabilize.
- Skill Optimization (Lasco vs. SkillOpt): Tested on multi-anchor markdown skill documents. Evaluating 160 edits via standard LLM validation requires prolonged execution (minutes per call across models like DeepSeek or large parameter checkpoints). Lasco utilizes 72 microsecond Lie bracket probes to screen candidates, reducing expensive LLM verification steps from 111 down to 22 (a 5x reduction), with cumulative speedups scaling linearly with model size (up to 15x–150x).
- Real-World Unstructured Data Pipelines: Implemented in Democritus and Prometheus for parsing SEC 10-K filings (e.g., Apple, Adobe, Nvidia, Goldman Sachs), Washington Post health articles (e.g., dark chocolate and longevity, GLP-1 weight-loss drugs), and historical archaeological artifacts (Indus Valley script).
Practical Implications
▶ Watch: Audience Q&A on causal claims and latent confounders (138:00)
For infrastructure teams, model builders, and enterprise deployers, these findings suggest a profound shift in how foundation models should be engineered:
- Moving Beyond Blind Scaling: Throwing raw compute and massive GPU clusters at scaling laws is environmentally and economically unsustainable. Incorporating structural constraints (via category theory and diagrams) achieves exponential efficiency gains.
- Enterprise Trust & Auditing: Just as financial systems rely on relational databases with strict integrity constraints, deploying LLMs into high-stakes domains (healthcare, autonomous logistics, financial auditing) requires mathematical verification layers—such as sheaf consistency checks and subobject classifiers—rather than raw probabilistic sampling.
- Modular Adapter Ecosystems: By applying ALoRA regularization, engineering teams can safely bundle specialized domain adapters (coding, safety, tool-use) without fearing destructive interference or catastrophic forgetting.
Limitations: The primary barrier to adoption is mathematical complexity. Category theory and differential geometry over abstract categories demand a steep learning curve for practitioners trained strictly in linear algebra and calculus. Furthermore, constructing explicit categorical diagrams requires domain modeling overhead.
Key Takeaways
- The Extension Problem: Machine learning’s core challenge—extrapolating from finite experience to infinite reality—finds its first canonical, universal solution in categorical Kan extensions.
- Attention Meets Diffusion: Attention mechanisms function as left Kan extensions (colimits/rollouts), while diffusion models function as right Kan extensions (limits/constraints).
- Diagrammatic Backpropagation: Incorporating categorical constraint diagrams into training loss functions accelerates deep learning convergence by an order of magnitude.
- Efficient Agentic Optimization: Lasco uses differential geometry (Lie brackets) to screen agentic edits in microseconds, avoiding costly LLM evaluation loops and delivering massive speedups.
- Sheaf-Based Reliability: Eliminating hallucination requires abandoning monolithic global truth in favor of sheaves—patching local contexts together and enforcing consistency via overlap checks.
About the Speaker(s)
- Sridhar Mahadevan: Attended ICML since 1985 and was at Carnegie Mellon in the mid-80s where he took deep learning with Jeff Hinton. He has implemented work on a new approach to deep learning based on category theory and functors.
Reviews
→ Top-rated talks at International Conference on Machine Learning 2026
All talks from International Conference on Machine Learning 2026