MPPI-Generic: A CUDA Library for Stochastic Optimization

Bogdan I. Vlahov, Jason Gibson, Manan Gandhi, Evangelos A. TheodorouarXiv 2024 · DOI · arXiv

Stochastic trajectory optimization is a cornerstone of modern robotics, enabling systems to navigate complex and uncertain environments by simulating thousands of potential future trajectories. However, the computational intensity of these simulations often forces a compromise between model fidelity and real-time responsiveness. The MPPI-Generic library addresses this challenge by providing a high-performance, GPU-accelerated framework for Model Predictive Path Integral (MPPI) control.

The MPPI Algorithm

Model Predictive Path Integral (MPPI) control is a sampling-based method that can handle non-differentiable dynamics and complex cost functions. Unlike gradient-based methods, MPPI "imagines" thousands of possible futures to determine the optimal control sequence.

The computational pipeline of the Model Predictive Path Integral (MPPI) algorithm, showing the flow from starting state to optimal control sequence.

As shown in the figure above, the process involves generating control samples, rolling out dynamics and costs for each sample, and then performing an exponentiated transform to weight the samples. The final output is a weighted sum that represents the optimal control sequence. The bottleneck in this pipeline is the "roll out" phase, where thousands of trajectories must be simulated simultaneously.

Library Design and Flexibility

The primary contribution of MPPI-Generic is its ability to provide massive GPU parallelization without sacrificing flexibility. Historically, GPU implementations for robotics were hard-coded for specific platforms. MPPI-Generic breaks this trend by using Curiously Recurring Template Patterns (CRTP) to achieve zero-overhead polymorphism. This allows researchers to define custom components in standard C++ that are then optimized by the compiler for GPU execution.

Key modular components supported by the MPPI-Generic library, enabling customization across various robotic systems.

The library supports a wide array of modular components, including custom dynamics, cost functions, and sampling distributions. This modularity allows the same library to be used for diverse applications, from high-speed off-road racing to robust drone flight.

Technical Innovations

To maximize performance, the library implements several GPU-specific optimizations:

  • Kernel Selection: It offers both "Split" and "Combined" kernels. Split kernels run dynamics and costs separately, while Combined kernels execute them together to reduce memory bandwidth usage. An automatic benchmarking tool selects the optimal kernel for the user's specific hardware.
  • Memory Optimization: The library utilizes vectorized memory access and shared memory (on-chip cache) to minimize latency during data retrieval.

Performance Benchmarks

The authors evaluated MPPI-Generic across a spectrum of hardware, from the flagship NVIDIA RTX 4090 to the edge-focused Jetson Nano.

  • Speed: On an RTX 4090, the library processed 16,384 samples in just 0.39ms. In contrast, a standard CPU-based implementation (Nav2 MPPI) required over 60ms for the same task.
  • Efficiency: Even on the low-power Jetson Nano, the library achieved sub-10ms optimization times for over 2,000 samples, making advanced stochastic control viable for portable robots.
  • Comparison: The library matched the performance of highly specialized, hard-coded CUDA implementations while offering significantly greater ease of use and extensibility.

Conclusion

MPPI-Generic bridges the gap between flexible research-oriented code and high-performance production-ready control. By leveraging advanced C++ templates and CUDA optimizations, it enables real-time, high-fidelity stochastic optimization on both desktop and edge hardware. Future work includes the development of Python wrappers to further lower the barrier to entry for the robotics research community.

Summary updated

BibTeX
@misc{vlahov2024mppi,
  author = {Bogdan I. Vlahov and Jason Gibson and Manan Gandhi and Evangelos A. Theodorou},
  title = {{MPPI-Generic: A CUDA Library for Stochastic Optimization}},
  year = {2024},
  eprint = {2409.07563},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.07563},
}
Figure