OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

L4Casadi

L4Casadi is a Python library for integrating traceable, differentiable PyTorch models into CasADi numerical optimization and learning-based optimal-control workflows.

Independent OpenViST project profile, based on linked sources.

L4Casadi — Data-driven numerical optimization with learned PyTorch models
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a PyTorch model needs to participate in CasADi numerical optimization or learning-based optimal control, and the model is traceable and differentiable.

Who it is for

  • Developers incorporating learned models into CasADi optimization problems.
  • Control and robotics practitioners building learning-based optimal-control or trajectory-planning workflows.

Documented uses

  • Use a learned PyTorch model as part of a CasADi optimization formulation.
  • Build control or planning workflows that optimize trajectories using learned models.
  • Explore Acados workflows using PyTorch-to-CasADi integration.
Before you choose

Requirements & limits

The project is a public repository with an MIT license.

  • The integrated PyTorch model must be traceable and differentiable.
  • The documented prerequisites include PyTorch 2.0 or later and a CMake-compatible C++ compiler.
  • The Naive module supports only small multilayer perceptrons and CPU inference.
  • The documentation recommends the Naive module for networks smaller than roughly three hidden layers of 64 neurons each.
  • Acados is supported, but the documented material here does not specify exact supported configurations.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install L4CasADi from PyPI for CPU use

Install the CPU-only L4CasADi package in a Python environment with PyTorch.

Before you start

  • Python environment with PyTorch 2.0 or later.
  • A CMake-compatible C++ build system; GCC 10 or later is recommended on Linux/macOS.
  • Build dependencies: setuptools 68.1 or later, scikit-build 0.17 or later, CMake 3.27 or later, and Ninja 1.11 or later.

Steps

  1. Install the PyTorch CPU version: the command below.

    Documented command
    pip install torch>=2.0 --index-url https://download.pytorch.org/whl/cpu
  2. Install the listed build dependencies in the Python environment.

  3. Install L4CasADi with the command below. The flag is required so L4CasADi can find and link against the installed PyTorch.

    Documented command
    pip install l4casadi --no-build-isolation

Expected outcome

L4CasADi is installed for CPU use in the Python environment.

Guide limitations

  • This recipe is for CPU installation; CUDA setup is a separate process.
  • On Windows, CMake and Visual C++ Build Tools are required instead of GCC, and the tools must be on PATH. Keep the build directory path within Windows' maximum character limit.
Source-based practical guide

Install L4CasADi from source for CPU use

Build and install the CPU-only package from the L4CasADi repository.

Before you start

  • Python environment with PyTorch 2.0 or later.
  • A CMake-compatible C++ build system; GCC 10 or later is recommended on Linux/macOS.
  • A working Git installation.

Steps

  1. Clone the repository with the command below.

    Documented command
    git clone https://github.com/Tim-Salzmann/l4casadi.git
  2. Install the build dependencies with the command below.

    Documented command
    pip install -r requirements_build.txt
  3. Build and install with the command below; this flag is required for L4CasADi to find and link against the installed PyTorch.

    Documented command
    pip install . --no-build-isolation

Expected outcome

L4CasADi is built and installed from the cloned source for CPU use.

Guide limitations

  • This recipe covers CPU installation only; CUDA setup is separate.
  • On Windows, install CMake and Visual C++ Build Tools, ensure they are on PATH, and use a short build-directory path.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
8 November 2026
Original website title
Tim-Salzmann/l4casadi · Official homepage title · retained in its source language