NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ScalaGrad: A Statically Typed Automatic Differentiation Library for Safer Data Science

Benjamin Meyer, Thilo Stadelmann, Marcel LüthiSDS 2024

Abstract

While the data science ecosystem is dominated by programming languages that do not feature a strong type system, it is widely agreed that using strongly typed programming languages leads to more maintainable and less error-prone code and ultimately more trustworthy results. We believe Scala 3 would be an excellent contender for data science in a strongly typed language, but it lacks a general automatic differentiation library, e.g., for gradient-based learning. We present ScalaGrad, a general and type-safe automatic differentiation library designed for Scala. It builds on and improves a novel approach from the functional programming community using immutable duals, which is conceptually simple, asymptotically optimal and allows differentiation of higher-order code. We demonstrate the ease of use, robust performance, and versatility of ScalaGrad through its applications to deep learning, higher-order optimization, and gradient-based sampling. Specifically, we show an execution speed comparable to PyTorch for a simple deep learning use case, capabilities for higher-order differentiation, and opportunities to design more specialized libraries decoupled from ScalaGrad. As data science challenges evolve in complexity, ScalaGrad provides a pathway to harness the inherent advantages of strongly typed languages, ensuring both robustness and maintainability.
BibTeX
@inproceedings{meyer2024scalagrad,
  author = {Benjamin Meyer and Thilo Stadelmann and Marcel Lüthi},
  title = {{ScalaGrad: A Statically Typed Automatic Differentiation Library for Safer Data Science}},
  booktitle = {SDS},
  year = {2024},
  url = {https://openreview.net/forum?id=2O6BW7OGMf},
}

Loading related content...

Figure