Handling JAX
Accelerator-oriented languages such as JAX's jaxprs expose a first-order core without recursion or first-class functions. This leaves programmers with no principled way to express computational effects like mutable state and exceptions. JAX libraries therefore rely on ad-hoc, mutually incompatible mechanisms.
The authors define a calculus formalizing core jaxprs extended with algebraic effect handlers. They give a novel translation that statically eliminates handlers into the handler-free subset. For unbounded loops, where continuations cannot be built statically, tail-resumptive handlers are handled in place and abortive handlers by a source-level rewrite. The calculus and the type- and semantics-preservation proofs are mechanized in Lean 4, and the design is implemented as the JAX library effecax.
The translation is proven to preserve typing and semantics, and every paper result has a Lean counterpart. Case studies refactor Diffrax's ODE integration core and probabilistic programming patterns with effecax. These were evaluated for expressiveness, composition with JAX control flow, and performance on an A100 GPU.
