Moreau¶
High-performance batched differentiable convex optimization
Moreau is a GPU-accelerated conic optimization solver with full support for automatic differentiation. Solve thousands of convex problems in parallel and backpropagate through the solutions.
Frameworks¶
Just solve. Standard NumPy/SciPy interface for straightforward optimization without framework overhead.
Full autograd support with differentiable optimization. Embed optimization in your neural networks.
Compatible with jax.grad, jax.vmap, and jax.jit. Functional API for composable transformations.
Use Moreau as a CVXPY solver backend, or combine with cvxpylayers for differentiable convex optimization.
Get Started in 30 Seconds¶
import moreau
import numpy as np
from scipy import sparse
# Define a simple QP
P = sparse.diags([1.0, 1.0], format='csr')
q = np.array([2.0, 1.0])
A = sparse.csr_matrix([
[1.0, 1.0], [1.0, 0.0], [0.0, 1.0]
])
b = np.array([1.0, 0.7, 0.7])
cones = moreau.Cones(
num_zero_cones=1, num_nonneg_cones=2
)
# Solve
solver = moreau.Solver(P, q, A, b, cones=cones)
solution = solver.solve()
print(f"x = {solution.x}")
print(f"status = {solver.info.status}")
Install
Setup access, then:
pip install moreau
What’s happening?
Define a convex conic problem
Create a solver with problem data
Solve and get the optimal solution
Access solver metadata via
solver.info
Why Moreau?¶
Native CUDA implementation keeps everything on GPU. Zero host-device transfers during solving for maximum throughput.
Solve thousands of problems in parallel with shared structure. The CompiledSolver API is optimized for high-throughput workloads.
Full gradient support via implicit differentiation. Backpropagate through optimization layers in PyTorch and JAX.
Double precision numerics, robust convergence, and comprehensive error handling for reliable production deployment.
Used For¶
MPC, trajectory optimization
Portfolio optimization
Constrained learning
Motion planning
Problem Formulation¶
Moreau solves convex conic programs of the form:
minimize (1/2)x'Px + q'x
subject to Ax + s = b
s in K
Where K is a product of cones:
Zero cone: Equality constraints
Nonnegative cone: Inequality constraints
Second-order cone: Norm constraints (dim 3)
Exponential cone: Log/exp constraints
Power cone: Power function constraints