SDPLab
A library for building semidefinite and conic programs and solving them through their smoothed dual. Problem data, spectral regularizers, and the dual functional live here; every first-order optimization loop is delegated to spacecore.
Install
pip install sdplab
The JAX backend and the optax optimizer are optional:
pip install "sdplab[jax]"
The problem
$$ \begin{aligned} \min_{X \in \mathrm{dom}(\mathcal{A})}\quad & \langle C, X\rangle \ \text{s.t.}\quad & \mathcal{A}X = b, \ & X \succeq 0. \end{aligned} $$
| symbol | code | meaning |
|---|---|---|
| $\mathrm{dom}(\mathcal{A})$ | problem.dom |
space of $X$ and $C$ |
| $\mathrm{cod}(\mathcal{A})$ | problem.cod |
space of $\mathcal{A}X$, $b$, and the dual $y$ |
| $\mathcal{A}$ | problem.A |
linear constraint operator, a spacecore LinOp |
| $\mathcal{A}^\dagger y - C$ | problem.dual_slack(y) |
dual slack |
$X$ is a plain element of a spacecore Euclidean Jordan algebra space — a Hermitian matrix (classic SDP), a nonnegative vector (LP), or a tree of such blocks — and $X \succeq 0$ means a nonnegative Jordan spectrum. Solvers accept and return raw arrays and trees; there are no wrapper objects.
import numpy as np
from spacecore import Context, DenseLinOp, DenseVectorSpace, HermitianSpace, NumpyOps
from sdplab import SDPProblem
ctx = Context(NumpyOps()) # optional; see the spacecore docs
dom = HermitianSpace(n, ctx=ctx) # X and C live here
cod = DenseVectorSpace((m,), ctx=ctx) # A X, b, and the dual y live here
A = DenseLinOp(A_mats, dom, cod, ctx=ctx)
problem = SDPProblem(C, A, b, ctx=ctx)
Solve it directly with the CVXPY reference backend:
from sdplab.solvers import run_cvxpy_solver
X, y = run_cvxpy_solver(problem, solver="CLARABEL")
The smoothed dual
Penalize the primal with a superlinear convex $\varphi$ at strength $\varepsilon > 0$:
$$ \min_X\ \langle C, X\rangle + \varepsilon,\mathrm{Tr}[\varphi(X)] \quad\text{s.t.}\quad \mathcal{A}X = b,\ X \succeq 0. $$
Its dual is unconstrained and differentiable:
$$ \max_{y}\ D_\varepsilon(y) = \langle b, y\rangle - \varepsilon, \mathrm{Tr}!\left[\psi!\left(\frac{\mathcal{A}^\dagger y - C}{\varepsilon}\right)\right], $$
with $\psi$ the Legendre transform of $\varphi$. Gradient methods apply, and the primal is read back off the eigenvalues $s_i$ of the dual slack: $\lambda_i(X) = \psi'(s_i/\varepsilon)$.
This route assumes a unit-trace primal — primal_from_dual normalizes to
$\mathrm{Tr},X = 1$ — so pose the problem accordingly, hence unit_trace=True
below. On a problem whose feasible set has a different trace the recovered $X$
is not feasible for it.
from sdplab import EntropyReg, RegularizedSDPDualFunctional, run_regularized_solver
from sdplab.examples import generate_max_cut
problem = generate_max_cut(8, seed=0, unit_trace=True)
dual = RegularizedSDPDualFunctional(problem, EntropyReg(problem.dom))
result = run_regularized_solver(dual.bind(0.1), verbose=0)
X = dual.primal_from_dual(result.dual, 0.1)
problem.primal_objective(X) # -5.0859, against -5.0990 from CVXPY
$\varepsilon$ is a per-call argument, so a continuation schedule can lower it
without rebuilding anything; bind(eps) fixes it and yields a standard
single-argument spacecore.Functional.
The theoretical basis for the regularized SDP formulation — the smoothed dual, the primal recovery map, and the $\varepsilon \downarrow 0$ limit — is developed in arXiv:2602.23144.
Regularizers
| class | $\varphi(t)$ |
|---|---|
EntropyReg |
$t(\log t - 1)$ |
QuadraticReg |
$t^2/2$ |
Examples
sdplab.examples ships three instances, chosen to differ in the structure of
$\mathcal{A}$:
generate_max_cut— real, diagonal extraction.unit_trace=Truerescales the variable so $\mathrm{Tr},X = 1$.generate_random_qot— quantum optimal transport: complex, with a stacked Hermitian-block codomain, so the dual is a tuple of matrices.generate_qubit_tomography— zero cost, so pure feasibility.
Backends
Everything is written against spacecore's backend contract, so NumPy, JAX, and
torch contexts all work. run_regularized_solver picks
spacecore.minimize_optax on a JAX backend and spacecore.minimize_scipy
otherwise.
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 sdplab-0.0.1.tar.gz.
File metadata
- Download URL: sdplab-0.0.1.tar.gz
- Upload date:
- Size: 55.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27542d0ab5171e9fb7cf63be2d75b95839fd290921ecdb8374d6f04cee0acf7d
|
|
| MD5 |
82551878d8636999c420ac16f97c1676
|
|
| BLAKE2b-256 |
ecf6ba38216d31624c5d26359eea0d43a4575fada070ce60bccfa908c974a15f
|
Provenance
The following attestation bundles were made for sdplab-0.0.1.tar.gz:
Publisher:
publish.yml on Pavlo3P/SDPLab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdplab-0.0.1.tar.gz -
Subject digest:
27542d0ab5171e9fb7cf63be2d75b95839fd290921ecdb8374d6f04cee0acf7d - Sigstore transparency entry: 2498874335
- Sigstore integration time:
-
Permalink:
Pavlo3P/SDPLab@a571e0f8ef739be420e1622ffda9de8a1131b7bb -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Pavlo3P
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a571e0f8ef739be420e1622ffda9de8a1131b7bb -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file sdplab-0.0.1-py3-none-any.whl.
File metadata
- Download URL: sdplab-0.0.1-py3-none-any.whl
- Upload date:
- Size: 78.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9fd5ddc7fa13e22f63b6f31d4a973c1f534fd9c6b2e63b5ed72d5cb6f62b801
|
|
| MD5 |
9eb00773a45fa3dac5de1ad6144d3a4a
|
|
| BLAKE2b-256 |
f6a24910caebf1e3a365867d69fa5b69a6e7d9decc4312275ab53d92199fbcf1
|
Provenance
The following attestation bundles were made for sdplab-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on Pavlo3P/SDPLab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdplab-0.0.1-py3-none-any.whl -
Subject digest:
f9fd5ddc7fa13e22f63b6f31d4a973c1f534fd9c6b2e63b5ed72d5cb6f62b801 - Sigstore transparency entry: 2498874342
- Sigstore integration time:
-
Permalink:
Pavlo3P/SDPLab@a571e0f8ef739be420e1622ffda9de8a1131b7bb -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Pavlo3P
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a571e0f8ef739be420e1622ffda9de8a1131b7bb -
Trigger Event:
workflow_dispatch
-
Statement type: