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_optimize.minimize_optax on a JAX backend and spacecore_optimize.minimize_scipy
otherwise.
Metadata
Release files for sdplab 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sdplab-0.0.2.tar.gz | 55.3 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sdplab-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 133.7 kB
Release files / sdplab-0.0.2.tar.gz
| Download URL | sdplab-0.0.2.tar.gz |
|---|---|
| Size | 55.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fac371d311f2490dab5a5708985521519da4c47f2f16c0ff5219d617f6df8587
|
|
BLAKE2b-256 checksum How to use checksums |
88f1d81e246fd71d4f8e001dfd9458ae7776d3b69fd1090389b3c6ebd4c6b7e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logRelease files / sdplab-0.0.2-py3-none-any.whl
| Download URL | sdplab-0.0.2-py3-none-any.whl |
|---|---|
| Size | 78.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
472f270b27c494f16090ae919e6ff76f09f070489cfefb169de06197c5529ef0
|
|
BLAKE2b-256 checksum How to use checksums |
84032d1dbdb00f132f4470c68d0250e2861105aa2dfa5f1741a363d31e4e475c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logSecurity for sdplab 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sdplab-0.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.