kotlingrad  by breandan

Symbolic differentiation framework for the JVM

Created 7 years ago
539 stars

Top 59.1% on SourcePulse

GitHubView on GitHub
Project Summary

Kotlin∇ is a type-safe automatic differentiation framework for the JVM, designed for users who need to express differentiable programs with higher-dimensional data structures and operators. It leverages Kotlin's type system to enforce algebraic validity at compile-time, aiming to eliminate runtime errors and provide an expressive, mathematically similar notation.

How It Works

Kotlin∇ implements automatic differentiation (AD) using a combination of operator overloading, first-class functions, and algebraic data types. Expressions are represented as directed acyclic graphs (dataflow graphs) rather than being immediately evaluated. This approach allows for symbolic manipulation, higher-order differentiation, and compile-time shape safety, particularly for up to rank-2 tensors (matrices).

Quick Start & Requirements

  • Installation: Add the dependency to your build.gradle or pom.xml. For Jupyter notebooks, use @file:DependsOn("ai.hypergraph:kotlingrad:0.4.7").
  • Requirements: Kotlin, JVM.
  • Resources: No specific hardware requirements mentioned beyond a standard JVM environment.
  • Documentation: Tutorials and examples are available.

Highlighted Details

  • Shape Safety: Enforces tensor shape compatibility at compile-time for up to rank-2 tensors.
  • Symbolic Differentiation: Supports arbitrary order derivatives and algebraic simplification.
  • Property-Based Testing: Integrates with Kotest for numerical gradient checking against analytical and finite difference methods.
  • Expression Graphing: Visualizes computation graphs for debugging.

Maintenance & Community

The project lists numerous contributors and acknowledges inspiration from many AD and differentiable programming projects. Community links (Discord/Slack) are not explicitly provided in the README.

Licensing & Compatibility

The project is distributed under the Apache License 2.0, which is permissive for commercial use and closed-source linking.

Limitations & Caveats

Shape safety is currently limited to rank-2 tensors. Higher-order derivatives for matrix functions and N-dimensional tensors beyond rank 2 are noted as future work. The "Type arithmetic" section mentions experimental features and known issues with large number computations in the type system.

Health Check
Last Commit

9 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
0 stars in the last 30 days

Explore Similar Projects

Starred by Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), Shizhe Diao Shizhe Diao(Author of LMFlow; Research Scientist at NVIDIA), and
3 more.

Math-Verify by huggingface

0.8%
933
Math evaluator for LLM outputs in mathematical tasks
Created 8 months ago
Updated 2 months ago
Starred by Bojan Tunguz Bojan Tunguz(AI Scientist; Formerly at NVIDIA), Alex Chen Alex Chen(Cofounder of Nexa AI), and
19 more.

ggml by ggml-org

0.3%
13k
Tensor library for machine learning
Created 3 years ago
Updated 2 days ago
Feedback? Help us improve.