Skip to main content

moment-sos

Certified first-order bounds for polynomial optimization, in PyTorch (with a Julia interface and a command line tool).

Write a polynomial optimization problem in a few lines. moment-sos builds its order-r moment–SOS (Lasserre) relaxation — with correlative sparsity, equality and inequality constraints, spin (Boolean) and mixed variables — and solves its dual as an eigenvalue-optimization problem with first-order methods. No SDP solver, no Schur complement: memory is O(s²) in the moment-block size s, and every iterate is a valid bound, so you can stop at any time.

import moment_sos as po

x, y = po.variables(2)
problem = po.Problem(x**2*y + x*y**2 - x - y, [x**2 + y**2 <= 1], sense="max", box=(-1, 1))
res = po.solve(problem, order=2)       # certified upper bound for a max problem (lower bound for min)
print(res)
x_hat, value = res.round()             # a feasible point: the other side of the gap

Documentation: see docs/ (Sphinx; build with sphinx-build -W docs docs/_build/html) — installation, user guide, theory summary, API reference, and a benchmarks page that states where the package does not win.

Install

pip install moment-sos          # PyPI release pending; for now: pip install -e ".[test]" from a checkout

Interfaces

Python import moment_sos as po
Command line moment-sos solve problem.json --order 2 (JSON problem format in the docs)
Julia julia/MomentSOS — DynamicPolynomials front end that calls the command line tool (Python required)

When to use it — and when not

Use it when the relaxation is too large for an interior-point solver (e.g. a dense order-2 MAX-CUT relaxation on 60 spins, a 1831×1831 moment block: 2.5 GiB here, MOSEK is killed at 40 spins) or when you need a valid bound at any moment, or an optimality proof for integer problems (all 60 generated and 5 real Biq Mac instances we tried were certified optimal).

Use an interior-point solver (TSSOS, GloptiPoly, SumOfSquares.jl) when the relaxation fits and you need high accuracy: they are faster below roughly 26 spins, TSSOS has term sparsity and more variable types, and non-certified first-order solvers (Burer–Monteiro, SCS, CGAL) are faster than this package at every size we tried. Accuracy of the smoothing solver is moderate (1e-3–1e-4); neural-network relaxations of about 40 unstable neurons were not solved to convergence.

Status

Version 0.1.0 (alpha). 18 tests; documentation examples are executed by the test suite. Not yet tested: GPU, Windows. The CI workflows in .github/workflows have not been run (they need a GitHub repository).

Citation and license

MIT license. See CITATION.cff.

Repository layout

path content
src/moment_sos/ the Python package
tests/, docs/, examples/ tests, Sphinx documentation, example scripts
julia/MomentSOS/ Julia interface
research/ manuscript, NumPy reference implementation (msos), experiments and raw results behind the benchmark numbers

Metadata

Release files for moment-sos 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moment-sos 0.1.0
File Size Uploaded Provenance Actions
moment_sos-0.1.0.tar.gz 46.4 kB With provenance Details for moment_sos-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for moment-sos 0.1.0
File Interpreter ABI Platform Actions
moment_sos-0.1.0-py3-none-any.whl Python 3 none any Details for moment_sos-0.1.0-py3-none-any.whl

Total release size: 90.7 kB

Release files / moment_sos-0.1.0.tar.gz

Download URL moment_sos-0.1.0.tar.gz
Size 46.4 kB
Tags Source
SHA-256 checksum
How to use checksums
15b3dd560651b9f0efc0cc35d9c1251d4fb9605496a06a2925291573ca9eabd6
BLAKE2b-256 checksum
How to use checksums
024e7f3098120c847a3d73e01bea84d189f1392eb604077e797f90d156a58f9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / moment_sos-0.1.0-py3-none-any.whl

Download URL moment_sos-0.1.0-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec4dc0bbfa220d1f92e69f680a892d11728edb2ccd572f3a78a45b6f8b9c58d8
BLAKE2b-256 checksum
How to use checksums
d06735d7e4a27223b269f87358c29e4f6f60b9b2babc8367ec45b389d148d87d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Security for moment-sos 0.1.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for moment_sos-0.1.0.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 Nov 10, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page