# cvxpy/cvxpylayers

Differentiable convex optimization layers

Repository: https://github.com/cvxpy/cvxpylayers
Canonical: https://ross.abutalabs.com/products/cvxpylayers
Language: Python
License: Apache-2.0
License Family: permissive
Last push: 2026-05-19T19:53:38+00:00

## Health v2 (maintenance only)
Score: 87/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 83, release rhythm 84, longevity 100
- inputs: {"age_days": 2502, "days_push": 106, "days_rel": 106, "gap_med": 0, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2126, forks 193 (observed 2026-08-28T04:06:16.913363+00:00)

## What it is
CVXPYlayers is a Python library for constructing differentiable convex optimization layers in PyTorch, JAX, and MLX using CVXPY. It solves parametrized convex problems in the forward pass and computes derivatives of the solution with respect to parameters in the backward pass, with GPU acceleration via Moreau and CuClarabel backends.

## Use cases
- embed a convex optimization problem as a layer in a neural network
- backpropagate through a parametrized convex program in PyTorch or JAX
- solve convex optimization problems on the GPU inside a training loop
- learn parameters of a quadratic program or cone program end-to-end
- build model-predictive control policies that are differentiable
- train models whose forward pass includes a constrained optimization step

## When to choose
- your model includes a convex optimization step and you need gradients through it
- you want to express problems in CVXPY and use them as differentiable layers
- you need GPU-accelerated convex solving within deep learning frameworks

## When to avoid
- your optimization problem is nonconvex
- you only need to solve convex problems without gradients (plain CVXPY suffices)
- you need discrete or combinatorial optimization layers

## Facets
- artifact type: library
- maturity: active
- function: machine-learning, math, sdk
- domain: machine-learning, deep-learning, gpu-computing
- platform: python
- tags: convex-optimization, differentiable-optimization, cvxpy, pytorch, jax, mlx, optimization-layers, gpu-acceleration, algorithms, gpu

## Member repositories
- cvxpy/cvxpylayers (main) score 87

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:16.913363+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:52:30.626831+00:00, confidence not recorded.
  - readme: https://github.com/cvxpy/cvxpylayers (fetched 2026-08-28T04:06:16.913363+00:00, sha 4d55daf30f47)
  - registry_pypi: https://pypi.org/pypi/cvxpylayers/json (fetched 2026-08-29T10:32:31.966599+00:00, sha bf71613c0507)
- Data as of 2026-08-30T08:39:29.467469+00:00.
