Skip to content

Commit 36b14db

Browse files
committed
Refactor QQA into a pip-installable OSS toolkit (v0.3.0)
Restructure into a `qqa` package with unified `anneal()` API, a full suite of spin-glass problems (Ising, Edwards-Anderson, SK, binary perceptron, Hopfield), a `UserProblem` plug-in for custom losses, a `qqa` CLI, a Streamlit dashboard with a live parallel-search view, and an MkDocs site. Includes deep correctness tests and AppTest-driven GUI checks.
1 parent 38d4d7d commit 36b14db

70 files changed

Lines changed: 11052 additions & 2059 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint-and-test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v3
21+
with:
22+
enable-cache: true
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install package with all extras (CPU torch)
28+
env:
29+
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
30+
run: uv sync --extra plotly --extra gui --extra docs --extra dev
31+
32+
- name: Ruff lint
33+
run: uv run ruff check src tests scripts app
34+
35+
- name: Ruff format check
36+
run: uv run ruff format --check src tests scripts app
37+
38+
- name: Run tests
39+
run: uv run pytest -q

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
8+
# Distribution / packaging
9+
build/
10+
dist/
11+
*.egg-info/
12+
*.egg
13+
14+
# uv / virtualenv
15+
.venv/
16+
venv/
17+
env/
18+
19+
# Testing / coverage
20+
.pytest_cache/
21+
.ruff_cache/
22+
.coverage
23+
htmlcov/
24+
25+
# Jupyter
26+
.ipynb_checkpoints/
27+
28+
# OS
29+
.DS_Store
30+
31+
# IDE
32+
.vscode/
33+
.idea/
34+
35+
# MkDocs
36+
site/
37+
38+
# Local task planning (not versioned)
39+
tasks/
40+
41+
# Streamlit cache
42+
.streamlit/secrets.toml
43+

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-toml
9+
- id: check-added-large-files
10+
args: ["--maxkb=1024"]
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.6.9
13+
hooks:
14+
- id: ruff
15+
args: [--fix]
16+
- id: ruff-format

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented here. The format is based
4+
on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
5+
follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [0.3.0] - Unreleased
8+
9+
### Added
10+
11+
- **Spin problem family** in `qqa.problems`:
12+
- `Ising1D`, `EdwardsAnderson`, `SherringtonKirkpatrick`
13+
- `BinaryPerceptron` (teacher-student), `HopfieldMemory`
14+
- New `SpinRelaxation` that maps `[0,1]``±1` with differentiable forward.
15+
- **Visualization** (`qqa.visualization`):
16+
- Dual backend (`"matplotlib"` default, `"plotly"` optional).
17+
- `plot_best_trajectory`, `plot_schedule`, `plot_run_comparison`,
18+
`plot_parallel_coordinates`, `plot_solution_heatmap`.
19+
- **CLI** (`qqa` entry point): `qqa version`, `qqa solve`, `qqa bench`,
20+
`qqa gui`.
21+
- **Streamlit GUI** (`qqa gui` / `uv run streamlit run app/streamlit_app.py`):
22+
problem definition → live annealing → visualization → comparison.
23+
- **Example notebooks**: MIS, coloring, MaxCut, 3D Edwards–Anderson, SK,
24+
binary perceptron, Hopfield memory, parallel benchmark.
25+
- **Docs site** via MkDocs + Material with auto API reference.
26+
- **Tooling**: GitHub Actions CI, `pre-commit`, `CONTRIBUTING.md`,
27+
`CITATION.cff`.
28+
29+
### Changed
30+
31+
- `qqa.problems` is now a subpackage (`qubo.py`, `categorical.py`, `spin.py`).
32+
Public symbols (`MaximumIndependentSet`, `Coloring`, ...) are preserved via
33+
re-export, so existing code keeps working.
34+
35+
### Deprecated
36+
37+
- `qqa.legacy.*` wrappers still work and emit `DeprecationWarning`; use
38+
`qqa.anneal` instead.
39+
40+
## [0.2.0]
41+
42+
- Initial unified `qqa.anneal` API, package reorganization under `src/qqa`,
43+
`uv`/`pyproject.toml` based install, smoke tests and demo scripts.
44+
45+
## [0.1.0]
46+
47+
- Original research release accompanying the ICLR 2025 paper.

CITATION.cff

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cff-version: 1.2.0
2+
message: "If you use QQA in your research, please cite the paper below."
3+
title: "QQA: Quasi-Quantum Annealing for Combinatorial Optimization"
4+
authors:
5+
- family-names: Ichikawa
6+
given-names: Yuma
7+
- family-names: Arai
8+
given-names: Yamato
9+
repository-code: "https://github.com/Yuma-Ichikawa/QQA4CO"
10+
license: BSD-3-Clause
11+
version: 0.3.0
12+
preferred-citation:
13+
type: conference-paper
14+
title: "Continuous Tensor Relaxation for Finding Diverse Solutions in Combinatorial Optimization"
15+
authors:
16+
- family-names: Ichikawa
17+
given-names: Yuma
18+
- family-names: Arai
19+
given-names: Yamato
20+
conference:
21+
name: "International Conference on Learning Representations (ICLR)"
22+
year: 2025
23+
url: "https://openreview.net/forum?id=9EfBeXaXf0"

CONTRIBUTING.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Contributing to QQA
2+
3+
Thanks for your interest in improving QQA. This project aims to be a friendly,
4+
reproducible research tool for gradient-based annealing on discrete problems.
5+
6+
## Setup
7+
8+
We recommend [uv](https://github.com/astral-sh/uv) for dependency management.
9+
10+
```bash
11+
git clone https://github.com/Yuma-Ichikawa/QQA4CO.git
12+
cd QQA4CO
13+
uv sync --extra plotly --extra gui --extra docs --extra dev
14+
uv run pre-commit install
15+
```
16+
17+
This installs:
18+
19+
- Core runtime (PyTorch, NumPy, NetworkX, SciPy, Matplotlib, tqdm)
20+
- Optional: Plotly (interactive viz), Streamlit (GUI), MkDocs (docs)
21+
- Dev tools: pytest, ruff, pre-commit, nbval
22+
23+
## Running tests
24+
25+
```bash
26+
uv run pytest -q
27+
```
28+
29+
Tests are designed to finish in under a minute on CPU.
30+
31+
## Code style
32+
33+
- Ruff handles linting and formatting.
34+
- Target Python 3.10+.
35+
- Public functions should have a docstring (one-line summary + args/returns).
36+
37+
```bash
38+
uv run ruff check src tests scripts app
39+
uv run ruff format src tests scripts app
40+
```
41+
42+
## Adding a new problem
43+
44+
1. Add a class to the appropriate file under `src/qqa/problems/`.
45+
2. Attach a `.relaxation` (Binary / Categorical / Spin) so `qqa.anneal()` can
46+
dispatch.
47+
3. Export it from `src/qqa/problems/__init__.py` and `src/qqa/__init__.py`.
48+
4. Add a smoke test in `tests/` that solves a small instance and checks the
49+
objective.
50+
51+
## Submitting a PR
52+
53+
- Ensure `ruff check`, `ruff format --check`, and `pytest` all pass locally.
54+
- Describe what you changed and why in the PR body.
55+
- Link to any relevant issues or papers.
56+
57+
## Reporting issues
58+
59+
Please include:
60+
61+
- `qqa.__version__` and PyTorch version
62+
- A minimal reproducing snippet
63+
- Expected vs. observed behavior

0 commit comments

Comments
 (0)