Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ Key test patterns:
## Dependencies

- Python >= 3.11
- CVXPY >= 1.7.4 (for native DGP→DCP reduction)
- CVXPY >= 1.9.0 (provides `quad_form_dpp_scope` for parametric quad_form, native DGP→DCP reduction)
- diffcp >= 1.1.0 (default solver backend)
- Framework: PyTorch >= 2.0, JAX >= 0.4.0, or MLX
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ separately, which can be done by following the instructions on their websites.
CVXPYlayers has the following dependencies:
* Python >= 3.11
* [NumPy](https://pypi.org/project/numpy/) >= 1.22.4
* [CVXPY](https://github.com/cvxgrp/cvxpy) >= 1.7.4
* [CVXPY](https://github.com/cvxgrp/cvxpy) >= 1.9.0
* [diffcp](https://github.com/cvxgrp/diffcp) >= 1.1.0

Additionally, install one of the following frameworks:
Expand All @@ -55,8 +55,21 @@ Additionally, install one of the following frameworks:

### GPU-accelerated pathway

For the best performance on CPU and GPU, install [Moreau](https://docs.moreau.so/).
Moreau is available by request — see the [installation guide](https://docs.moreau.so/installation.html) for access and setup.
For the best performance on CPU and GPU, install [Moreau](https://docs.moreau.so/)
via the `moreau` extra. Before installing, review the
[Moreau installation guide](https://docs.moreau.so/installation.html) for license
terms and access requirements.

```bash
pip install cvxpylayers[moreau]
```

For GPU support, install the matching Moreau CUDA wheel (see the
[Moreau installation guide](https://docs.moreau.so/installation.html) for details):

```bash
pip install "moreau[cuda12]" # or moreau[cuda13]
```

As an open-source alternative, you can use [CuClarabel](https://github.com/oxfordcontrol/Clarabel.jl/tree/CuClarabel/) for GPU acceleration. This requires installing Julia and several additional packages:

Expand Down
19 changes: 16 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,22 @@ print("Installation successful!")
:::{admonition} Moreau — Best Performance on CPU & GPU
:class: tip

[Moreau](https://docs.moreau.so/) is the recommended solver for best performance. Available by request through a private package index.
[Moreau](https://docs.moreau.so/) is the recommended solver for best performance.
:::

See the [Moreau installation guide](https://docs.moreau.so/installation.html) for access and setup instructions.
Before installing, review the [Moreau installation guide](https://docs.moreau.so/installation.html)
for license terms and access requirements.

```bash
pip install cvxpylayers[moreau]
```

For GPU acceleration, install the matching Moreau CUDA wheel
(see the [Moreau installation guide](https://docs.moreau.so/installation.html) for details):

```bash
pip install "moreau[cuda12]" # or moreau[cuda13]
```

### CuClarabel (Open-Source Alternative)

Expand Down Expand Up @@ -234,7 +246,7 @@ b_gpu = b_t.cuda()
|---------|---------|---------|
| Python | >= 3.11 | Runtime |
| NumPy | >= 1.22.4 | Array operations |
| CVXPY | >= 1.7.4 | Problem specification |
| CVXPY | >= 1.9.0 | Problem specification |
| diffcp | >= 1.1.0 | Differentiable cone programming |
:::

Expand All @@ -244,6 +256,7 @@ b_gpu = b_t.cuda()
| PyTorch | >= 2.0 |
| JAX | >= 0.4.0 |
| MLX | >= 0.27.1 |
| Moreau | >= 0.3.0 |
:::

---
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ authors = [
maintainers = [{ name = "P. Nobel", email = "parthnobel@berkeley.edu" }]
requires-python = ">=3.11"
dependencies = [
"cvxpy>=1.9",
"cvxpy>=1.9.0",
"diffcp>=1.1.0",
"numpy>=1.22.4",
"scipy>=1.13.0",
Expand Down Expand Up @@ -49,13 +49,15 @@ torch = ["torch>=2.0.0", "diffcp>=1.1.0"]
mlx = ["mlx>=0.27.1"]
metal = ["mlx-metal>=0.27.1"]
jax = ["jax>=0.4.0", "jaxlib>=0.4.0"]
moreau = ["moreau>=0.3.0"]
all = [
"torch>=2.0.0",
"diffqcp>=0.4.4",
"jax>=0.4.0",
"jaxlib>=0.4.0",
"mlx>=0.27.1",
"mlx-metal>=0.27.1",
"moreau>=0.3.0",
]

[tool.hatch.metadata]
Expand Down
2 changes: 0 additions & 2 deletions src/cvxpylayers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
__version__ = "1.1.0"

import cvxpylayers._quad_form_dpp # noqa: F401 # apply monkey-patches at import time
253 changes: 0 additions & 253 deletions src/cvxpylayers/_quad_form_dpp.py

This file was deleted.

11 changes: 8 additions & 3 deletions src/cvxpylayers/utils/parse_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
from cvxpy.utilities import scopes

import cvxpylayers.interfaces
from cvxpylayers._quad_form_dpp import SUPPORTS_QUAD_OBJ
from cvxpylayers.interfaces.base import SolverInterface

# Solvers whose cvxpylayers interface supports quadratic objectives directly.
# For these solvers, quad_form_dpp_scope is entered during canonicalization
# so that quad_form(x, P) with parametric P is accepted as DPP.
# DIFFCP decomposes quad_form to SOC and cannot handle parametric P.
SUPPORTS_QUAD_OBJ = frozenset({"MOREAU", "CUCLARABEL", "MPAX"})



if TYPE_CHECKING:
Expand Down Expand Up @@ -189,7 +194,7 @@ def _build_primal_recovery(
) -> VariableRecovery:
"""Build recovery info for a primal variable."""
start = param_prob.var_id_to_col[var_id_map.get(var.id, var.id)]
is_sym = hasattr(var, "is_symmetric") and var.is_symmetric() and len(var.shape) >= 2
is_sym = var.is_symmetric() and len(var.shape) >= 2

if is_sym:
n = var.shape[0] # type: ignore[index]
Expand Down Expand Up @@ -522,7 +527,7 @@ def parse_args(
parameters, param_prob, gp_param_to_log_param, param_id_map
)

q = getattr(param_prob, "q", getattr(param_prob, "c", None))
q = param_prob.q

# Build variable recovery info for each requested variable
constr_id_to_slice = _build_constr_id_to_slice(param_prob)
Expand Down
Loading