kotlingrad  by breandan

Symbolic differentiation framework for the JVM

created 6 years ago
537 stars

Top 59.9% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
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

7 months ago

Responsiveness

1 day

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

Explore Similar Projects

Feedback? Help us improve.