Table of Contents
Fetching ...

Cooper: A Library for Constrained Optimization in Deep Learning

Jose Gallego-Posada, Juan Ramirez, Meraj Hashemizadeh, Simon Lacoste-Julien

TL;DR

The paper addresses constrained optimization for deep learning, where a non-convex objective $f(x)$ must satisfy constraints $g(x) \le 0$ and $h(x)=0$. It introduces Cooper, a PyTorch-based library that solves these problems via Lagrangian-based first-order updates using mini-batch gradients, with a Lagrangian $\mathfrak{L}(x, \lambda, \mu) = f(x) + \lambda^T g(x) + \mu^T h(x)$ and update rules for the primal and dual variables. It supports multiple schemes (simultaneous GDA, alternating GDA, extragradient) and formulations (Augmented Lagrangian, Quadratic Penalty, proxy-Lagrangian, $\nu$PI), enabling flexible handling of large or non-differentiable constraint sets while reusing standard PyTorch optimizers. The paper details API design (CMP, Constraint, Multiplier, CMPState, CooperOptimizers), provides a concrete usage example, and discusses software aspects (MIT license, tests, documentation). It positions Cooper relative to TFCO, CVXPY, CHOP/GeoTorch, and JAXopt, and outlines future work including a JAX port.

Abstract

Cooper is an open-source package for solving constrained optimization problems involving deep learning models. Cooper implements several Lagrangian-based first-order update schemes, making it easy to combine constrained optimization algorithms with high-level features of PyTorch such as automatic differentiation, and specialized deep learning architectures and optimizers. Although Cooper is specifically designed for deep learning applications where gradients are estimated based on mini-batches, it is suitable for general non-convex continuous constrained optimization. Cooper's source code is available at https://github.com/cooper-org/cooper.

Cooper: A Library for Constrained Optimization in Deep Learning

TL;DR

The paper addresses constrained optimization for deep learning, where a non-convex objective must satisfy constraints and . It introduces Cooper, a PyTorch-based library that solves these problems via Lagrangian-based first-order updates using mini-batch gradients, with a Lagrangian and update rules for the primal and dual variables. It supports multiple schemes (simultaneous GDA, alternating GDA, extragradient) and formulations (Augmented Lagrangian, Quadratic Penalty, proxy-Lagrangian, PI), enabling flexible handling of large or non-differentiable constraint sets while reusing standard PyTorch optimizers. The paper details API design (CMP, Constraint, Multiplier, CMPState, CooperOptimizers), provides a concrete usage example, and discusses software aspects (MIT license, tests, documentation). It positions Cooper relative to TFCO, CVXPY, CHOP/GeoTorch, and JAXopt, and outlines future work including a JAX port.

Abstract

Cooper is an open-source package for solving constrained optimization problems involving deep learning models. Cooper implements several Lagrangian-based first-order update schemes, making it easy to combine constrained optimization algorithms with high-level features of PyTorch such as automatic differentiation, and specialized deep learning architectures and optimizers. Although Cooper is specifically designed for deep learning applications where gradients are estimated based on mini-batches, it is suitable for general non-convex continuous constrained optimization. Cooper's source code is available at https://github.com/cooper-org/cooper.

Paper Structure

This paper contains 5 sections, 3 equations, 1 figure.

Figures (1)

  • Figure 1: Dependency graph between the main classes in Cooper's API.