Skip to main content
Symbolic differentiation: Python to Rust

Generate Rust crates kernels from Python

Symbolic automatic differentiation and Rust code generation.

Rust codegenEmbeddableFast + Efficient
Quick start
from gradgen import Function, SX

x = SX.sym("x", 2)
f = Function("energy", 
             [x], [x.norm2sq()], 
             input_names=["x"], 
             output_names=["cost"])

project = f.create_rust_project("./my_crates")

What it does

Using gradgen you can create symbolic variables and expressions, define functions, perform automatic differentiation, and generate embedable (#![no_std]) Rust code for your functions and their gradients, Hessians, and/or Hessian-vector products.

Gradgen workflow illustration