Unraveling the iterative CHAD

📄 arXiv: 2505.15002v2 📥 PDF

作者: Fernando Lucatelli Nunes, Gordon Plotkin, Matthijs Vákár

分类: cs.PL, cs.AI, cs.LG, math.CT, math.LO

发布日期: 2025-05-21 (更新: 2025-08-13)

备注: 58 pages


💡 一句话要点

扩展CHAD至包含迭代结构的程序,实现结构保持的自动微分

🎯 匹配领域: 支柱五:交互与反应 (Interaction & Reaction)

关键词: 自动微分 反向模式 迭代结构 依赖类型 索引范畴

📋 核心要点

  1. 现有自动微分方法在处理包含迭代结构的程序时,难以保持程序语义的结构。
  2. 论文提出使用迭代外延索引范畴,将迭代结构集成到依赖类型编程语言中,实现结构保持的自动微分。
  3. 通过扩展CHAD转换,论文证明了微分程序能够计算出原始程序的正确的反向模式导数。

📝 摘要(中文)

组合同态自动微分(CHAD)最初被设计为一种语义驱动的源到源转换方法,用于对完全(终止)函数程序的反向模式自动微分。本文将CHAD扩展到包含诸如部分(可能非终止)操作、数据相关的条件(例如,实值测试)和迭代结构(即while循环)等构造的程序,同时保持CHAD结构保持语义的核心原则。一个核心贡献是引入了迭代外延索引范畴,它为迭代到依赖类型编程语言中提供了一种原则性的集成。这种集成是通过要求基本范畴中的迭代提升到索引范畴中的参数化初始代数来实现的,从而产生一个op-fibred迭代结构,该结构在总范畴中对while循环和其他迭代结构进行建模,总范畴对应于依赖类型语言的容器范畴。通过迭代外延索引范畴的思想,我们将CHAD转换扩展到循环程序,作为一种合适的意义上唯一的结构保持函子。具体来说,它是从对应于源语言的迭代Freyd范畴到从目标语言获得的容器范畴的唯一迭代Freyd范畴态射,使得每个原始操作都映射到其(转置)导数。我们通过源语言的句法范畴模型的普遍性质,建立了这种扩展转换的正确性,表明微分程序计算出其原始程序的正确的反向模式导数。

🔬 方法详解

问题定义:论文旨在解决现有自动微分方法在处理包含迭代(如while循环)的程序时,难以保持程序语义结构的问题。现有的CHAD方法主要针对完全(终止)的函数程序,无法直接应用于包含部分操作、数据依赖条件和迭代结构的程序。这些结构的引入使得自动微分过程更加复杂,容易破坏程序的原始语义。

核心思路:论文的核心思路是引入“迭代外延索引范畴”的概念,将迭代结构以一种原则性的方式集成到依赖类型编程语言中。通过将基本范畴中的迭代提升到索引范畴中的参数化初始代数,构建一个op-fibred迭代结构,从而对while循环等迭代结构进行建模。这种方法旨在保持程序语义的结构,使得自动微分过程能够正确地计算反向模式导数。

技术框架:论文的技术框架主要包括以下几个部分:1) 扩展CHAD转换以处理迭代结构;2) 引入迭代外延索引范畴的概念;3) 将迭代结构集成到依赖类型编程语言中;4) 证明扩展后的CHAD转换的正确性。整体流程是从源语言的迭代Freyd范畴到目标语言的容器范畴的唯一迭代Freyd范畴态射,确保每个原始操作都映射到其转置导数。

关键创新:论文的关键创新在于引入了“迭代外延索引范畴”这一概念,并将其应用于自动微分领域。这种方法能够以一种结构化的方式处理迭代结构,从而保持程序语义的结构。与现有方法相比,该方法能够更准确地计算包含迭代结构的程序的反向模式导数。

关键设计:论文的关键设计包括:1) 迭代外延索引范畴的定义和构造;2) CHAD转换的扩展,使其能够处理迭代结构;3) 依赖类型编程语言中迭代结构的集成方式;4) 通过句法范畴模型的普遍性质证明扩展转换的正确性。具体的参数设置、损失函数和网络结构等细节未在摘要中提及,属于未知信息。

📊 实验亮点

论文通过引入迭代外延索引范畴,成功地将CHAD自动微分方法扩展到包含迭代结构的程序。通过理论证明,扩展后的CHAD转换能够计算出原始程序的正确的反向模式导数,表明该方法在处理复杂控制流程序时具有较高的准确性和可靠性。具体的性能数据和提升幅度未在摘要中提及,属于未知信息。

🎯 应用场景

该研究成果可应用于需要对包含复杂控制流(如循环)的程序进行自动微分的领域,例如机器学习模型的训练、优化算法的设计、以及科学计算等。通过提供一种结构保持的自动微分方法,该研究有助于提高自动微分的准确性和可靠性,从而促进相关领域的发展。

📄 摘要(原文)

Combinatory Homomorphic Automatic Differentiation (CHAD) was originally formulated as a semantics-driven source-to-source transformation for reverse-mode AD of total (terminating) functional programs. In this work, we extend CHAD to encompass programs featuring constructs such as partial (potentially non-terminating) operations, data-dependent conditionals (e.g., real-valued tests), and iteration constructs (i.e. while-loops), while maintaining CHAD's core principle of structure-preserving semantics. A central contribution is the introduction of iteration-extensive indexed categories, which provide a principled integration of iteration into dependently typed programming languages. This integration is achieved by requiring that iteration in the base category lifts to parameterized initial algebras in the indexed category, yielding an op-fibred iterative structure that models while-loops and other iteration constructs in the total category, which corresponds to the category of containers of our dependently typed language. Through the idea of iteration-extensive indexed categories, we extend the CHAD transformation to looping programs as the unique structure-preserving functor in a suitable sense. Specifically, it is the unique iterative Freyd category morphism from the iterative Freyd category corresponding to the source language to the category of containers obtained from the target language, such that each primitive operation is mapped to its (transposed) derivative. We establish the correctness of this extended transformation via the universal property of the syntactic categorical model of the source language, showing that the differentiated programs compute correct reverse-mode derivatives of their originals.