Engine to compute Jacobian-vector and vector-Jacobian products for (convex) quadratic cone programs.
Project description
diffqcp: Differentiating through quadratic cone programs
diffqcp is a JAX library that enables forming the derivative of the solution map to a quadratic cone program (QCP) with respect to the QCP problem data as an abstract linear operator and computing Jacobian-vector products (JVPs) and vector-Jacobian products (VJPs) with this operator.
TODO(quill): (briefly) Discuss
- implicit differentiation approach to argmin differentiation (exploiting mathematical structure)
- DPP (relevant for batched problems)
- Automatic differentiation.
Features include:
- Hardware acclerated: JVPs and VJPs can be computed on CPUs, GPUs, and (theoretically) TPUs.
- Support for all canonical classes of convex optimization problems including
- linear programs (LPs),
- quadratic programs (QPs),
- second-order cone programs (SOCPs),
- and semidefinite programs (SDPs). TODO(quill): implement before release...should be easy
Quadratic cone programs
A quadratic cone program is given by the primal and dual problems
\begin{equation*}
\begin{array}{lll}
\text{(P)} \quad &\text{minimize} \; & (1/2)x^T P x + q^T x \\
&\text{subject to} & Ax + s = b \\
& & s \in \mathcal{K},
\end{array}
\qquad
\begin{array}{lll}
\text{(D)} \quad &\text{maximize} \; & -(1/2)x^T P x -b^T y \\
&\text{subject to} & Px + A^T y = -q \\
& & y \in \mathcal{K}^*,
\end{array}
\end{equation*}
where $x \in \mathbf{R}^n$ is the primal variable, $y \in \mathbf{R}^m$ is the dual variable, and $s \in \mathbf{R}^m$ is the primal slack variable. The problem data are $P\in \mathbf{S}_+^{n}$, $A \in \mathbf{R}^{m \times n}$, $q \in \mathbf{R}^n$, and $b \in \mathbf{R}^m$. We assume that $\mathcal K \subseteq \mathbf{R}^m$ is a nonempty, closed, convex cone with dual cone $\mathcal{K}^*$.
diffqcp currently supports QCPs whose cone is the Cartesian product of the zero cone, the positive orthant, second-order cones, and positive semidefinite cones. Support for exponential and power cones (and their dual cones) is in development (see the TODOs below).
For more information about these cones, see the appendix of our paper.
Citation
See also
Core dependencies (diffqcp makes essential use of the following libraries)
- Equinox: Neural networks and everything not already in core JAX (via callable
PyTrees). - Lineax: Linear solvers.
Related
- CVXPYlayers: Construct differentiable convex optimization layers using CVXPY. (WIP:
diffqcpis being added as a backend for CVXPYlayers.) - CuClarabel: The GPU implemenation of the second-order QCP solver, Clarabel.
- SCS: A first-order QCP solver that has an optional GPU-accelerated backend.
- diffcp: A (Python with C-bindings) library for differentiating through (linear) cone programs.
TODOs:
After failing to achieve desired performance with a torch-backed implementation (branch here), this JAX implementation of diffqcp was rapidly developed. Consequently, there is some tech debt:
Functionality
- TODO(quill)--important: Heuristic JVP and VJP computations when the solution map of a QCP is non-differentiable (
lineaxjust fails if LSMR doesn't converge, whereas our torch version anddiffcpjust return the last iterate). - Support for the exponential (and dual exponential) cone. (Just requires re-implementing the PyTorch version in JAX following best practices as found in
lineaxoroptimistix.) - Support for the power (and dual power) cone. (Same approach as for exponential cone.)
- Batched JVP and VJP computations (via
vmap--should just work since we can alreadyjit) - Batched problem computions--i.e., constructing derivatives of solution maps to a batch of DPP-compliant problems. (so yes,
diffqcpis aiming to support multi-level batching: you can batch compute JVPs and VJPs over a batch of problems.)- The cone
proj_dprojmethods already support this functionality
- The cone
- Can
HostQCPandDeviceQCPbe combined?- Only difference is the use of
BCOOarrays for the CPU "optimized" verion vs.BCSRarrays for the GPU "optimized" version - Other architecture improvements? (Be sure to add performance regression tests before making large changes.)
- Only difference is the use of
- Allow factor-solve based JVPs and VJPs
- requires
as_matrixto be implemented for all customlineax.AbstractLinearOperators. - Would need to have non-sparse returning atom functions.
- requires
- Similarly, allow for changing the tolerance of the LSMR solve.
- more explicit host and device array placement (right now have to use flag to specify whether to use single or double precision.)
- Differentiable? (i.e., what happns if we use
jax's auto-diff functionality--would this computation correspond to anything meaningful?) - Clean up the cone library so it can stand alone (i.e., it can be a JAX library for projecting onto convex cones and computing derivatives of these projections)
- so will require separate
projanddprojmethods, - plus just cleaner abstractions,
- and removal of tech debt
- so will require separate
- See if
diffqcpjust works for distributed computations out of the box
Testing
- Most of the testing exists in the torch branch, so need to port over key tests--i.e., not tests that were just initial (research) validation tests, but tests that ensure future change don't break anything.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file diffqcp-0.1.0.tar.gz.
File metadata
- Download URL: diffqcp-0.1.0.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d13dc6a697210be790e57ce32a5cfa4c3b4109e603ace1aae271d519ca05d75
|
|
| MD5 |
8788b27d9946cac3e3b96490340d2d66
|
|
| BLAKE2b-256 |
f97a3e4694d0f32b9f438bdbad15d990bd4fdb8f38c8f84dd036b9bda8b21957
|
Provenance
The following attestation bundles were made for diffqcp-0.1.0.tar.gz:
Publisher:
python-publish.yml on cvxgrp/diffqcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diffqcp-0.1.0.tar.gz -
Subject digest:
9d13dc6a697210be790e57ce32a5cfa4c3b4109e603ace1aae271d519ca05d75 - Sigstore transparency entry: 426528655
- Sigstore integration time:
-
Permalink:
cvxgrp/diffqcp@90cbc2e21700ea9457c4d6d43af9177c707f23de -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/cvxgrp
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@90cbc2e21700ea9457c4d6d43af9177c707f23de -
Trigger Event:
release
-
Statement type:
File details
Details for the file diffqcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: diffqcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae26508d24b325ebfc371ad44032263d4c3d5f6d723ea2fb25efb33e876857dd
|
|
| MD5 |
04dd47f3c0dc20d3158c6e481d0c9294
|
|
| BLAKE2b-256 |
aa10a0b3b43c5e80161dd18916115f5f7be0569c9f55cfab93b16c2d4ea2a423
|
Provenance
The following attestation bundles were made for diffqcp-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on cvxgrp/diffqcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
diffqcp-0.1.0-py3-none-any.whl -
Subject digest:
ae26508d24b325ebfc371ad44032263d4c3d5f6d723ea2fb25efb33e876857dd - Sigstore transparency entry: 426528658
- Sigstore integration time:
-
Permalink:
cvxgrp/diffqcp@90cbc2e21700ea9457c4d6d43af9177c707f23de -
Branch / Tag:
refs/tags/v0.1 - Owner: https://github.com/cvxgrp
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@90cbc2e21700ea9457c4d6d43af9177c707f23de -
Trigger Event:
release
-
Statement type: