Skip to main content

sparse-qubo

Release Build status codecov Commit activity License

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, plus create_scheduling_problem_bqm and benchmarks
  • TSP (examples/tsp/): Problem builder and benchmarks for traveling salesman formulations

Documentation

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)

Source distribution for sparse-qubo 0.1.0
File Size Uploaded
sparse_qubo-0.1.0.tar.gz 186.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sparse-qubo 0.1.0
File Interpreter ABI Platform
sparse_qubo-0.1.0-py3-none-any.whl Python 3 none any Details

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}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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