Sleipnir
A linearity-exploiting reverse mode autodiff library and nonlinear program solver DSL.
Loading...
Searching...
No Matches
Contributing

Building Sleipnir

Dependencies

  • C++23 compiler
    • On Windows 11 or greater, install Visual Studio Community 2022 and select the C++ programming language during installation
    • On Ubuntu 24.04 or greater, install GCC 14 via sudo apt install g++-14
    • On macOS 14.5 or greater, install the Xcode 16.2 command-line build tools via xcode-select --install
  • CMake 3.21 or greater
    • On Windows, install from the link above
    • On Linux, install via sudo apt install cmake
    • On macOS, install via brew install cmake
  • Python 3.12 or greater
    • On Windows, install from the link above
    • On Linux, install via sudo apt install python
    • On macOS, install via brew install python
  • Eigen
  • small_vector
  • nanobind (build only)
  • Catch2 (tests only)

Library dependencies which aren't installed locally will be automatically downloaded and built by CMake.

The benchmark executables require CasADi to be installed locally.

C++ library

On Windows, open a Developer PowerShell. On Linux or macOS, open a Bash shell.

# Clone the repository
git clone git@github.com:SleipnirGroup/Sleipnir
cd Sleipnir
# Configure; automatically downloads library dependencies
cmake -B build -S .
# Build
cmake --build build
# Test
ctest --test-dir build --output-on-failure
# Install
cmake --install build --prefix pkgdir

The following build types can be specified via -DCMAKE_BUILD_TYPE during CMake configure:

  • Debug
    • Optimizations off
    • Debug symbols on
  • Release
    • Optimizations on
    • Debug symbols off
  • RelWithDebInfo (default)
    • Release build type, but with debug info
  • MinSizeRel
    • Minimum size release build
  • Asan
    • Enables address sanitizer
  • Tsan
    • Enables thread sanitizer
  • Ubsan
    • Enables undefined behavior sanitizer
  • Perf
    • RelWithDebInfo build type, but with frame pointer so perf utility can use it

Python library

On Windows, open a Developer PowerShell. On Linux or macOS, open a Bash shell.

# Clone the repository
git clone git@github.com:SleipnirGroup/Sleipnir
cd Sleipnir
# Setup
pip install --user build
# Build
python -m build --wheel
# Install
pip install --user dist/sleipnirgroup_jormungandr-*.whl
# Test
pytest

Educational resources

Autodiff

Here's an introductory video on autodiff.

‍Ari Seff. What is Automatic Differentation?. 2020. https://www.youtube.com/watch?v=wG_nF1awSSY

Linear algebra

3Blue1Brown's Essence of Linear Algebra video series provides geometric intuition for linear algebra.

‍3Blue1Brown. Essence of Linear Algebra, 2016. https://www.3blue1brown.com/topics/linear-algebra

Convex optimization

Visually Explained's Convex Optimization video series provides geometric intuition for convex optimization and the interior-point method.

‍Visually Explained. Convex Optimization, 2021. https://www.youtube.com/playlist?list=PLqwozWPBo-FuPu4d9pFOobsCF1vDGdY_I

Sleipnir's authors learned numerical optimization from the following book and relied heavily upon it to implement Sleipnir.

‍Nocedal, J. and Wright, S. Numerical Optimization, 2nd. ed., Springer, 2006. https://www.math.uci.edu/~qnie/Publications/NumericalOptimization.pdf

See this page for derivations of Newton's method (unconstrained optimization), sequential quadratic programming (optimization with equality constraints), and interior-point method (optimization with equality and inequality constraints). The bottom of that page lists works cited by Sleipnir's internals.

Branding

Logo

SVG, PNG (1000px), PNG (55px)
Font: Centaur

Color palette

Purple Yellow
6D3D94 FDB813