sparse-qubo
Sparse QUBO formulation for efficient embedding on hardware.
sparse-qubo is a Python library that provides sparse QUBO (Quadratic Unconstrained Binary Optimization) formulations specifically for N-hot equality and inequality constraints. Constraint QUBOs are built from switching networks: each network is a list of Switch elements (left/right variable sets and constants), and the library converts them into QUBOs optimized for embedding on quantum annealing hardware (e.g. D-Wave) or other solvers.
The method is based on the paper Sparse QUBO Formulation for Efficient Embedding via Network-Based Decomposition of Equality and Inequality Constraints (Suda, Naito, Hasegawa, 2026).
Features
- Constraint types: One-hot, equal-to, less-equal, greater-equal, clamp
- Network types: Naive (single linear equality), divide-and-conquer, bubble sort, bitonic sort, Benes, odd-even merge sort, Clos (max degree / minimum edge)
- Backends: D-Wave (
dimod.BQM) and Fixstars Amplify (amplify.Model) - Examples: Shift scheduling and TSP in
examples/with notebooks and benchmarks
Installation
pip install sparse-qubo
With uv:
uv add sparse-qubo
Quick Start
import dimod
import sparse_qubo
variables = dimod.variables.Variables(["x0", "x1", "x2", "x3"])
# One-hot constraint (divide-and-conquer network)
bqm = sparse_qubo.create_constraint_dwave(
variables,
sparse_qubo.ConstraintType.ONE_HOT,
sparse_qubo.NetworkType.DIVIDE_AND_CONQUER,
)
# Equal-to: sum = 2
bqm = sparse_qubo.create_constraint_dwave(
variables, sparse_qubo.ConstraintType.EQUAL_TO,
sparse_qubo.NetworkType.DIVIDE_AND_CONQUER,
c1=2,
)
For Fixstars Amplify, use sparse_qubo.create_constraint_amplify with a list of amplify.Variable. See the documentation for more examples and the full API.
Examples
The examples/ directory includes:
- Shift scheduling (
examples/shift_scheduling/): Demo notebook comparing NAIVE vs DIVIDE_AND_CONQUER on D-Wave, pluscreate_scheduling_problem_bqmand benchmarks - TSP (
examples/tsp/): Problem builder and benchmarks for traveling salesman formulations
Documentation
- Documentation: https://KoheiSuda.github.io/sparse-qubo/
- API reference: modules
Reference
Kohei Suda, Soshun Naito, Yoshihiko Hasegawa. Sparse QUBO Formulation for Efficient Embedding via Network-Based Decomposition of Equality and Inequality Constraints. arXiv:2601.18108, 2026. https://arxiv.org/abs/2601.18108
Contributing
Contributions are welcome. See CONTRIBUTING.md for guidelines.
License
This project is licensed under the terms in LICENSE.
Links
Metadata
Release files for sparse-qubo 0.1.0
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 | Actions |
|---|---|---|---|---|
| sparse_qubo-0.1.0.tar.gz | 186.5 kB | Without provenance | Details for sparse_qubo-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sparse_qubo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sparse_qubo-0.1.0-py3-none-any.whl |
Total release size: 212.8 kB
Release files / sparse_qubo-0.1.0.tar.gz
| Download URL | sparse_qubo-0.1.0.tar.gz |
|---|---|
| Size | 186.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0201da493f04ae2790a86d242f3e8cf27534dda19252ff85117bae053964dd78
|
|
BLAKE2b-256 checksum How to use checksums |
daccd31d62532d2579cf267cce25cf8cf0433fcc9f9eda59641c9b41864945da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sparse_qubo-0.1.0-py3-none-any.whl
| Download URL | sparse_qubo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37cc76208d304bad50e0c547134d4358fa5ae9ef11c668ee25467976fd0f7995
|
|
BLAKE2b-256 checksum How to use checksums |
b8a1e4927d20f8cc9bd138e96ba6ff34a1f8e570bcceeeb44b180af2dd3712ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sparse-qubo 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.