Skip to content

YueWang996/quattro-transformer-ilqr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT Python Version

Quattro: Transformer-Accelerated iterative Linear Quadratic Regulator (iLQR)

Quattro is an open-source framework designed to enhance the efficiency of iterative Linear Quadratic Regulators (iLQR) through the innovative integration of Transformer models. By accelerating intermediate computations in iLQR algorithms, Quattro significantly improves real-time optimal control capabilities for nonlinear robotic systems.

Cart-pole and Quadrotor Visualization

Overview

Real-time optimal control remains challenging in robotics due to the sequential nature of traditional iLQR methods. Quattro addresses this by employing a Transformer model to concurrently predict feedback and feedforward matrices, allowing parallel computation without sacrificing control accuracy.

Architecture Overview

Key Contributions

  • Transformer-Accelerated iLQR: Parallel computation enabled by Transformer-based prediction of intermediate feedback and feedforward matrices.
  • Validated Performance: Demonstrated substantial acceleration and accuracy on cart-pole and quadrotor systems.
  • FPGA Implementation: Utilizes a customized Transformer accelerator IP on FPGA, achieving up to 27.3× performance improvements and significant power efficiency.

Performance Highlights

  • Algorithm-Level Acceleration:
Cart-Pole Simulation Result

Figure 1: Cart-Pole simulation result using Quattro. Up to 5.3× per iteration.

Quadrotor Simulation Result

Figure 2: Quadrotor simulation result using Quattro. Up to 27× per iteration.

  • Overall MPC Speedup (with Apple Silicon M4 Pro):
    • Cart-Pole: 2.8×.
    • Quadrotor: 17.8×.

Installation

We recommend use virtual environment e.g. conda. The project is based on Python 3.10 or later versions.

# Create and activate a new virtual environment
conda create --name quattro python=3.10
conda activate quattro

# Clone the repository and navigate to the project folder
git clone https://github.com/YueWang996/quattro-transformer-ilqr
cd quattro-transformer-ilqr

# Option 1 (Recommended): Install as an editable package
pip install -e .

# Option 2: Alternatively, install the dependencies manually
pip install -r requirements.txt

Usage

Running Simulations

Quattro comes with example simulations to illustrate its performance on different robotic systems.

  • Cart-Pole Simulation:
    Navigate to the examples/cartpole/ directory and run:

    python cartpole_sim.py
  • Quadrotor Simulation:
    Similarly, navigate to the examples/quadrotor/ directory and run:

    python quadrotor_sim.py

Training the Transformer Model

To train the Transformer for iLQR acceleration:

  • Data Collection:
    Use the provided data collection script located at examples/cartpole/training/training_data_collection.py to generate simulation logs. This script harnesses multi-core processing for efficiency.

  • Model Training:
    You have two options:

    • Run transformer_training.py from the same directory for script-based training. Suitable to run on a remote server.
    • Alternatively, use the Jupyter Notebook transformer_training.ipynb for an interactive guide.

Citation

Please cite this project if you find it useful:

@article{wang2025quattro,
  title={Quattro: Transformer-Accelerated Iterative Linear Quadratic Regulator Framework for Fast Trajectory Optimization},
  author={Wang, Yue and Wang, Haoyu and Li, Zhaoxing},
  journal={arXiv preprint arXiv:2504.01806},
  year={2025}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

This is a transformer-accelerated iterative linear quadratic regulator (iLQR-TF) framework.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages