Provides an agent-generated Lean library formalizing the heterogeneous taped category framework for deep learning data flows.
Abstract
Deep learning models implement a mathematical function. Simple enough – but these functions behave in a manner not found in other fields of mathematics, complicating a mathematical analysis. Functions are broadcast over additional axes, load parameters, save values for backpropagation, and in some cases have random aspects and are hence better described as Markov processes. Components are modules, and their composition captures all these dynamics at once. Indeed, models exhibit additional atypical data transfer dynamics, reusing values and even employing LIFO tapes as in UNets. This packaged, heterogeneous, modular form of deep learning components is critical for developing a perspective which captures and optimizes processes such as backpropagation. In this work, we introduce the heterogeneous taped category to capture these dynamics formally, bringing us closer to developing a mathematically tractable form of deep learning models.
Problem
Deep learning models contain atypical data flows, such as parameter loading, saved values for backpropagation, random seeds, value reuse and LIFO tapes in UNets. A pure functional view of the model hides these flows, which makes mathematical analysis difficult.
Approach
The authors introduce heterogeneous taped categories, built on symmetric monoidal categories and hypergraph representations with grab-drop operations. Modules are modeled as packaged chains living in distinct categories (e.g., BorelStoch for randomness, PAP for the core flow), unified by functors. Broadcasting, backpropagation, reindexed attention, gated sparsity and UNets are expressed in this framework. An agent-generated Lean library accompanies the mathematics.
Figure 8: The core expression of Figure 6 can be separated into chains transferring data. 3 3 3 These chains may live in distinct mathematical spaces — such as random seeds being (inputless) Markov processes, or parameters being “swappable” independently of the other chains between initialized or loaded values. Across the chains, expressions are nonetheless packaged, and can be transformed and revFigure 14: A grab-drop expression in \mathbf{GB}(\mathcal{C}) is realized as a hypergraph where grabs become domain nodes, and drops codomain nodes.
Results
The framework captures broadcasting, backpropagation as a functor with a reverse chain, data reuse, sparsity and UNets compositionally. Congruence rules allow optimizing the data passed through backprop. A Lean library (leanncd) is released.
Figure 25: In the general case, we can express backprop as a functor by adding a reverse chain which grabs from the core flow and supplies weight updates. Morphisms remain compositionally packaged.Figure 28: In reindex attention, the chosen keys and values of an early indexing layer are reused. This can be cleanly expressed by drops and grabs in a partial hypergraph.