Skip to main content

QQA4CO

CI Documentation PyPI Python

Parallel QQA replicas flowing through a sparse factor graph to verified discrete solutions

Try QQA in your browser

Launch the live QQA Studio

The hosted Streamlit studio needs no local installation. Build a problem, run QQA, inspect convergence and feasibility, and compare supported methods from a browser. For a local studio, install qqa[gui] and run qqa gui.

QQA4CO is a GPU-first primal-search and hybrid optimisation runtime. Quasi-Quantum Annealing (QQA) generates diverse candidates, structure-aware repair and local search refine them, and optional mathematical solvers certify them when requested.

The default qqa.solve(...) route is pure QQA. Exact solvers, GNNs, dashboard dependencies, and public benchmark parsers are explicit extras.

Install

Core CPU/GPU solver:

python -m pip install --upgrade pip
python -m pip install --upgrade qqa

Common optional installations:

python -m pip install --upgrade "qqa[gui]"       # Streamlit studio
python -m pip install --upgrade "qqa[benchmark]" # MIPLIB/QPLIB + SCIP
python -m pip install --upgrade "qqa[highs]"     # HiGHS LP/MIP adapter
python -m pip install --upgrade "qqa[cpsat]"     # OR-Tools CP-SAT adapter
python -m pip install --upgrade "qqa[service]"   # schema-only FastAPI job service
python -m pip install --upgrade "qqa[pignn]"     # experimental CRA/CPRA GNN
python -m pip install --upgrade "qqa[triton]"    # optional fused CUDA kernels
python -m pip install --upgrade "qqa[dev]"       # tests, lint, typing, docs

QQA4CO supports CPython 3.10--3.14. PyPy is not currently supported because the solver depends on PyTorch, whose official distributions target CPython.

PyTorch chooses CPU or CUDA according to the installed wheel. Follow the GPU setup guide when a specific CUDA build is required.

Quickstart

import networkx as nx
import qqa

graph = nx.random_regular_graph(d=3, n=100, seed=0)
problem = qqa.MaximumIndependentSet(graph, penalty=2.0)

result = qqa.solve(
    problem,
    goal="best",
    budget="30s",
    device="auto",
    seed=0,
)

print(result.status.value)
print(result.best_obj)      # original mathematical objective
print(result.feasible)
print(result.runtime)

The high-level result does not hide transformations:

print(result.objective_value)
print(result.internal_energy)
print(result.merit_value)
print(result.raw_solution)
print(result.repaired_solution)
print(result.violations.maximum_violation)
print(result.plan.explain())

Legacy research calls such as qqa.anneal, qqa.simulated_annealing, qqa.population_annealing, and qqa.discrete_langevin remain available. New integrations should prefer solve, plan, and inspect.

The one-call goal can be best, feasible, prove, diverse, or pareto. Durations accept ms, s, m, and h. prove enables an exact route but still returns a proof status only when the backend certifies the original model.

Inspect and plan before solving

inspection = qqa.inspect(problem)
print(inspection.to_dict())

doctor = qqa.doctor(problem, replicas=128)
print(doctor.explain())

plan = qqa.plan(problem, profile="quality", device="cuda")
print(plan.explain())

The planner reports domains, sparse factors, connected components, selected engine, refinements, certification route, VRAM estimate, replica count, and the reason for each choice. It does not execute the solver.

The Model Doctor additionally checks bounds, factor capabilities, scaling, curvature, presolve contradictions, decomposition, and route/proof support. Missing real or integer bounds are never silently replaced by a guessed box.

Profiles

qqa.solve(problem, profile="fast")
qqa.solve(problem, profile="balanced")
qqa.solve(problem, profile="quality")
qqa.solve(problem, profile="reproducible", seed=7)

Additional profiles:

Profile Intended use
certify QQA incumbent generation followed by an optional exact backend
diverse retain a larger candidate population
pareto multi-objective workflows

Checkpoint, events, and portable packages

Long QQA runs can be resumed without pickle payloads:

qqa.solve(
    problem,
    budget="10m",
    checkpoint_path="run.qqacp",
    checkpoint_interval=100,
)
result = qqa.solve(problem, budget="20m", resume_from="run.qqacp")

The atomic checkpoint verifies model/config fingerprints, tensor checksums, optimizer and RNG state, schedule state, incumbent, population, and historical archive. Paths stay outside result provenance. SolveResult.events uses the versioned schema-v2 stream, and qqa.runtime.export_result_package writes a checksum-protected, environment-neutral exchange bundle.

Python source and pickle inputs are trusted-local features and are denied by default. Use trusted=True in Python, --allow-unsafe-python in the CLI, or QQA_ALLOW_CUSTOM=1 for a single-user local GUI. Do not enable custom code in a shared deployment.

The Colab-ready 13_typed_primal_dual_runtime.ipynb walks through diagnosis, solve events, the cockpit, checkpoint/resume, and a verified package without credentials or environment-specific paths.

Advanced configuration is strict. Unknown or misspelled options raise an error:

config = qqa.SolverConfig.for_profile(
    "quality",
    replicas=512,
    epochs=4000,
    schedule="reheat",
    compile_core=True,
    exact_backend="none",
)
result = qqa.solve(problem, config=config)

Model inputs

The common factor-based ModelIR represents binary, spin, integer, real, categorical, and permutation blocks. Native factors include:

  • linear, sparse quadratic, and higher-order terms;
  • clauses, cardinality, all-different, assignment, Potts, and table terms;
  • indicators, SOS1/SOS2, piecewise-linear and logical relations;
  • precedence, no-overlap, cumulative resource, flow, matching, and subtour terms;
  • scenario mean/worst-case/CVaR and chance-constraint aggregation.

Supported file routes:

Format Route
MPS / LP sparse algebraic model; optional exact completion
QPLIB official parser extra, sparse linear/quadratic model
JSON ModelIR dependency-light canonical model
OPB linear pseudo-Boolean model
DIMACS CNF / WCNF native clause factors
QUBO text sparse binary quadratic model
Ising edge list sparse spin model
qqa inspect model.mps
qqa plan model.mps --profile quality --device auto
qqa solve model.mps --profile balanced --device auto

MIPLIB and QPLIB

Install the benchmark extra once:

pip install "qqa[benchmark]"

Fetch and inspect one public instance:

qqa benchmark fetch miplib --instance air05 --output benchmarks/miplib
qqa benchmark inspect benchmarks/miplib/air05.mps.gz

qqa benchmark fetch qplib --instance QPLIB_0031 --output benchmarks/qplib
qqa benchmark inspect benchmarks/qplib/QPLIB_0031.qplib

Run QQA-centred SG-CQQA or a paired baseline comparison:

qqa benchmark run INSTANCE --solver sg-cqqa --time-limit 60 --device auto

qqa benchmark compare INSTANCE \
  --solvers scip-aggressive sg-cqqa \
  --seeds 0 1 2 \
  --time-limit 60 \
  --output results.json

The campaign runner uses equal wall-clock budgets, paired seeds, checkpointing, direction-aware objectives, feasibility, bounds, gaps, time to first feasible, and primal-integral metrics. See the MIPLIB/QPLIB guide and the transparent published result summary.

Optional exact completion

Pure QQA remains the default:

result = qqa.solve(model, profile="balanced", exact_backend="none")

Certification is explicit:

result = qqa.solve(model, profile="certify", exact_backend="scip", budget=60)
print(result.best_bound, result.relative_gap, result.proven_optimal)

SCIP supports the broadest mixed nonlinear route. HiGHS is available for sparse linear LP/MIP models, and CP-SAT for bounded integral linear models with integral coefficients. Unsupported semantics fail clearly; adapters never silently round, drop, or reinterpret constraints.

Structured optimisation

problem = qqa.TSP(N=30, seed=0)  # Sinkhorn permutation relaxation
result = qqa.solve(problem, profile="quality")

print(result.raw_solution)       # untouched optimiser output
print(result.repaired_solution)  # Hungarian projection + 2-opt, when changed

Mixed-variable models use scaled constraints, per-constraint augmented Lagrangian multipliers, feasibility-first archives, and explicit repair. Sparse graph QUBOs use edge factors and incremental one-flip local search instead of an N × N matrix in the hot path.

Black-box optimisation

problem = qqa.BlackBoxProblem(
    [qqa.Real("x", -2.0, 2.0), qqa.Integer("n", 0, 8)],
    lambda point: (point["x"] - 0.4) ** 2 + (point["n"] - 3) ** 2,
)

result = problem.solve(
    budget=100,
    workers=4,
    trust_regions=3,
    evaluation_database="evaluations.sqlite",
)

The optional evaluation database caches encoded points and records pending/running/completed/failed/timed-out/cancelled states. Large campaigns can select random-Fourier-feature surrogates; discrete batch acquisition can opt into QQA with acquisition_optimizer="qqa".

Feature status

Feature Status
Sparse factor QQA and local search Stable
Device-resident telemetry and restart control Stable
Softmax/Gumbel, sparsemax/entmax and mirror-descent relaxations Experimental, opt-in
Persistent torch.export/AOTInductor sparse-model cache Experimental, opt-in
Dense QUBO compatibility view Deprecated for large models
Stable solve / plan / inspect contract Stable
Mixed-variable QQA and ModelIR presolve Beta
MPS, QPLIB, OPB, DIMACS, QUBO, Ising inputs Beta
SCIP hybrid and exact certification Beta, optional
RENS/RINS/GINS/local-branching/trust-region portfolio Beta, optional
HiGHS and CP-SAT adapters Beta, optional
Black-box trust-region solver Beta
Multi-objective and uncertainty extensions Beta
Multi-device replica islands Experimental, opt-in
CRA/CPRA graph GNN backend Experimental, opt-in
Natural-language / TeX model compilation Experimental
cuOpt bridge Experimental, version-dependent

Documentation

Development

git clone https://github.com/Yuma-Ichikawa/QQA4CO.git
cd QQA4CO
python -m pip install --upgrade pip
python -m pip install --upgrade -e ".[dev]"
ruff check src tests scripts app
ruff format --check src tests scripts app
pytest -q
mkdocs build --clean --strict

Large datasets and generated campaign trajectories are not source files. Keep only tiny smoke instances, checksums, licenses, and compact summaries in the repository; use the documented fetch commands and release/CI artifacts for full data.

Research papers and BibTeX

QQA4CO builds on three peer-reviewed continuous-relaxation methods. The default solver is pure QQA; the CRA/CPRA-inspired graph-learning route is an explicit pignn extra.

QQA / PQQA — ICLR 2025

Paper (OpenReview) · arXiv

@inproceedings{ichikawa2025optimization,
  title={Optimization by Parallel Quasi-Quantum Annealing with Gradient-Based Sampling},
  author={Ichikawa, Yuma and Arai, Yamato},
  booktitle={The Thirteenth International Conference on Learning Representations},
  year={2025},
  url={https://openreview.net/forum?id=9EfBeXaXf0}
}

CRA — NeurIPS 2024

Paper (NeurIPS Proceedings) · OpenReview · Reference implementation

@inproceedings{NEURIPS2024_54191f42,
  author={Ichikawa, Yuma},
  booktitle={Advances in Neural Information Processing Systems},
  editor={A. Globerson and L. Mackey and D. Belgrave and A. Fan and U. Paquet and J. Tomczak and C. Zhang},
  pages={47189--47216},
  publisher={Curran Associates, Inc.},
  title={Controlling Continuous Relaxation for Combinatorial Optimization},
  url={https://proceedings.neurips.cc/paper_files/paper/2024/file/54191f424e9013fc1d7b923f6e45dff4-Paper-Conference.pdf},
  volume={37},
  year={2024},
  doi={10.52202/079017-1495}
}

CPRA — TMLR 2025

Paper (OpenReview / TMLR) · Reference implementation

@article{ichikawa2025continuous,
  title={Continuous Parallel Relaxation for Finding Diverse Solutions in Combinatorial Optimization Problems},
  author={Ichikawa, Yuma and Iwashita, Hiroaki},
  journal={Transactions on Machine Learning Research},
  issn={2835-8856},
  year={2025},
  url={https://openreview.net/forum?id=ix33zd5zCw}
}

License

QQA4CO is distributed under the BSD 3-Clause License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qqa-0.9.0.tar.gz (501.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qqa-0.9.0-py3-none-any.whl (583.5 kB view details)

Uploaded Python 3

File details

Details for the file qqa-0.9.0.tar.gz.

File metadata

  • Download URL: qqa-0.9.0.tar.gz
  • Upload date:
  • Size: 501.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for qqa-0.9.0.tar.gz
Algorithm Hash digest
SHA256 d04027b2ec34fcce5eac1c4d94c3cf7fb95e380b756c48ea4e451d73fe378f43
MD5 4544ac39fe4498445dc609615f06db77
BLAKE2b-256 3db207f40ceca968dde2235eb87fc38380931ce8efee3f5974710750249a06fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for qqa-0.9.0.tar.gz:

Publisher: publish.yml on Yuma-Ichikawa/QQA4CO

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qqa-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: qqa-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 583.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for qqa-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19b1d456694020690e019b802c8082a348c2f3a5015a14a105dc9d09d1201710
MD5 d554563004c81b8278b8c8ef0695bba8
BLAKE2b-256 e2189467b77e5e6e740411718837bc3d584a372f5b71cb70c63d277d3bdfdb75

See more details on using hashes here.

Provenance

The following attestation bundles were made for qqa-0.9.0-py3-none-any.whl:

Publisher: publish.yml on Yuma-Ichikawa/QQA4CO

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.11.0

2 files

0.10.0

2 files

This release

0.9.0 This release

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 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