~/projects/cudacaml

CUDACaml

> A compiler from an OCaml array DSL to fused CUDA kernels — with reverse-mode autodiff and NVRTC JIT — verified against a reference interpreter.

// compiler pipeline

OCaml array DSLmap · reduce · scan · matmul
→ typed DAG IRstable topological order
→ fusion + reverse-mode ADgraph-to-graph passes
→ CUDA C++ emissionfused kernels
→ NVRTC JITruns on the GPU
Type
Compiler / GPU
Year
2026
Fusion
5 ops → 1 kernel
Tests
230+ unit · 38 system
Platforms
2 GPU platforms
OCamlCUDANVRTCDuneAutodiffCompilers

Kernel fusion

Compiles tensor graphs (map, reduce, scan, matmul) from an OCaml array DSL down to CUDA C++ through a typed DAG IR, graph-to-graph passes, and lowering — fusing 5 chained element-wise ops into 1 kernel with no intermediate buffers.

Reverse-mode autodiff

Implements reverse-mode AD as a graph-to-graph pass, so gradients fuse and run on the GPU like any other graph — computing 4 Black–Scholes Greeks in one 25-kernel backward pass (0.7 ms on an A100, ~4.2M paths).

Deterministic codegen

Fusion, lowering, and AD are all driven from one stable DFS topological sort of the DAG, materializing only shared and barrier nodes, so the emitted code is deterministic.

Differential testing

Every GPU result is checked against a pure-OCaml reference interpreter — 230+ unit and 38 system tests passing on two GPU platforms. Exposed through a 6-command CLI (emit, run, check, dot, list, info) and a multi-GPU runtime with async streams.