Skip to content

Production-readiness cleanup: license, uv, CI, types, docs#3

Open
Samuelstein1224 wants to merge 18 commits into
mainfrom
cleanup/production-readiness
Open

Production-readiness cleanup: license, uv, CI, types, docs#3
Samuelstein1224 wants to merge 18 commits into
mainfrom
cleanup/production-readiness

Conversation

@Samuelstein1224
Copy link
Copy Markdown
Collaborator

@Samuelstein1224 Samuelstein1224 commented May 6, 2026

Summary

Comprehensive cleanup making FTCircuitBench reproducible and contributor-friendly for outside readers of the paper.

  • License: aligned to MIT throughout (LICENSE was MIT, but pyproject + README badge said Apache-2.0). Now consistent in pyproject.toml, README.md, CITATION.cff, and classifiers.
  • Python: standardized on 3.10–3.12 (dropped 3.9). requires-python = ">=3.10,<3.13", classifiers + black/ruff targets + CI matrix all match.
  • Install: adopted uv with committed uv.lock for reproducible installs. Pip remains a documented fallback. Added .python-version (3.11).
  • CI: replaced single-job workflow with 4 parallel jobs — test (matrix 3.10/3.11/3.12), lint (ruff/black/isort), typecheck (mypy, blocking), coverage (pytest-cov + Codecov). All install via astral-sh/setup-uv with cache.
  • Pre-commit: .pre-commit-config.yaml runs ruff/black/isort + standard hygiene hooks. Documented opt-in install in CONTRIBUTING.md.
  • Types: 149 mypy errors → 0. Two pbc_converter modules deferred via documented [[tool.mypy.overrides]] with TODO(typecheck-followup) markers; everything else is properly typed.
  • Docs: regenerated docs/api.md (22 public symbols), expanded docs/examples.md with 3 verified examples, polished docs/installation.md, refreshed docs/index.md. New README sections: "Reproducing paper results" with a verified smoke-test command, and "Troubleshooting".
  • Project archaeology: added CHANGELOG.md (Keep a Changelog format) and CITATION.cff (validates against schema 1.2.0; 13 authors transcribed from BibTeX).

Test plan

All gates pass locally on this branch:

  • uv run pytest -v → 56 passed, 2 skipped (pre-existing QASM3 skips)
  • uv run mypy ftcircuitbench → 0 errors across 27 source files
  • uv run ruff check ftcircuitbench tests → clean
  • uv run black --check ftcircuitbench tests → clean
  • uv run isort --check-only ftcircuitbench tests → clean
  • uv run pre-commit run --all-files → all 8 hooks pass
  • uv run --with cffconvert cffconvert --validate -i CITATION.cff → valid
  • Smoke-test reproduction: uv run python analyze_circuit.py qasm/qft/qft_4q.qasm --pipeline gs --gridsynth-precision 5 --skip-fidelity → produces canonical reference numbers documented in README
  • CI passes on PR (4 jobs across 3 Python versions)

Notes for reviewers

  • Source code in ftcircuitbench/ is intentionally unchanged except for type annotations driven by the mypy clean-up. No behavioral refactoring was done.
  • Generated artifact directories (circuit_outputs/, circuit_stats_output/, circuit_benchmarks/) were left committed as you requested. The README now marks circuit_outputs/ as archival (the legacy Python-Gridsynth output predates the current nwqec C++ backend, so its T-counts diverge from current runs by ~250×; a follow-up should regenerate it).
  • Two pbc_converter modules (pbc_circuit_reader, pbc_generator) have mypy ignore_errors = true overrides with documented TODOs — their type errors require API-level review and were out of scope for this cleanup.
  • Branch builds on top of an explicit format-baseline commit (bf55c47); reviewing git log --first-parent and skipping that commit makes the substantive changes much easier to read.

Samuelstein1224 and others added 18 commits May 6, 2026 07:09
- Fix MIT/Apache mismatch (LICENSE is MIT; pyproject + README now match)
- Set Python support to 3.10-3.12; drop 3.9
- Update classifiers, black target-version, add ruff target-version

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- docs/installation.md: Python 3.9+ -> 3.10+
- ci.yml: add Python 3.12 to test matrix

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
No behavioral changes; mechanical formatter output only.
Establishes a clean baseline so pre-commit hooks (Task 4)
produce zero diffs on existing code.
- Add uv.lock for reproducible installs
- Add .python-version (3.11)
- Switch README, docs/installation.md, CONTRIBUTING.md to uv-first
  install instructions; keep pip as a documented fallback
- .pre-commit-config.yaml runs ruff/black/isort + hygiene hooks
- pre-commit added to dev extras
- CONTRIBUTING.md documents opt-in install via `uv run pre-commit install`

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- mypy in dev extras with permissive settings (ignore_missing_imports,
  no disallow-untyped-defs); Task 7 will triage and tighten.
- pytest-cov in dev extras with [tool.coverage] config so the CI
  coverage job (Task 5) has config to consume.
- test: pytest matrix on Python 3.10/3.11/3.12
- lint: ruff/black/isort --check
- typecheck: mypy (continue-on-error until Task 7 cleans up errors)
- coverage: pytest-cov + Codecov upload
- Switch all installs to uv via astral-sh/setup-uv with cache

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reduce mypy error count from 149 to 0 across the package, mostly via
implicit-Optional and missing-annotation fixes:

- analyzer/clifford_t_analyzer: type stats dict and counters, mark
  union-attr ignores for the networkx-Graph union returns
- analyzer/pbc_analyzer: implicit-Optional for pbc_conversion_stats, type
  defaultdict counters
- analyzer/visualization: widen position arg to Any (matplotlib accepts
  str or tuple), type defaultdict counters
- api: type the parameters dict as Dict[str, Any], make artifacts
  Optional, accumulate parameters via mutation rather than reassignment
- benchmark_utils: implicit-Optional for column_alignments, type
  qasm_files dict, ignore Number->float conversion in fmt_float_cell
- decomposer/decomposer: annotate ops_info / rz_jobs / allowed_globals
- fidelity: widen Dict[str, Any] returns where the union grew unwieldy
- parser/qasm_parser: implicit-Optional for basis_gates
- pbc_converter/pbc_generator: implicit-Optional for max_workers and
  output_prefix
- pbc_converter/r_pauli_circ: type tracking dict
- transpilers/__init__: align signatures of cpp-fallback dummy
  functions with their real counterparts so mypy treats the conditional
  branches as compatible

Defer the deep type issues in ftcircuitbench.pbc_converter.pbc_circuit_reader
and ftcircuitbench.pbc_converter.pbc_generator via tool.mypy.overrides
ignore_errors=true with TODO comments. Those modules carry object-typed
parser returns and tableau-type mismatches that need an API/data-model
review and were out of scope for this pass.

With mypy at zero errors, remove continue-on-error from the typecheck
job in .github/workflows/ci.yml so it now blocks CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add CI status badge
- Switch quick-start commands to uv run python
- New "Reproducing paper results" section with verified smoke-test command
- New "Troubleshooting" section
- Forward-link CITATION.cff (created in Task 10)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- api.md: faithful reference for the public surface in
  ftcircuitbench/__init__.py and ftcircuitbench/api.py
- examples.md: three worked examples (CLI single, CLI batch, Python API)
  verified locally
- installation.md: final polish; uv-first with pip fallback and
  optional gridsynth binary section
- index.md: navigation TOC pointing at all of the above

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- CHANGELOG.md in Keep a Changelog format with [Unreleased]
  reflecting the production-readiness cleanup
- CITATION.cff matching the README BibTeX, validated by cffconvert
…tree

- Smoke-test paragraph no longer points readers at the legacy
  circuit_outputs/qft_4q_gs_clifford_t.qasm as a comparison target;
  the JSON snippet in the README is now the canonical reference for
  the current nwqec backend.
- Add circuit_outputs/ to the Repository structure tree, marked as
  archival/legacy.
- Set UV_PYTHON at job level so matrix value overrides .python-version
- Pass python-version to setup-uv so the right interpreter is provisioned
- Use uv run --no-sync to prevent implicit re-sync that dropped extras
  (which left pytest itself missing from .venv)
- Introduced end-to-end tests for the PBC converter to validate acceptance of the extended Clifford basis, including gates {cx, h, s, sdg, x, y, z}.
- Implemented parity tests for GS, SK, and NWQEC transpilers to ensure consistent pipeline shapes and structural parity across stages.
- Added unit tests for native Pauli/Sdg operations on the TableauForGate, covering direct conjugation, algebraic identities, and cross-checks against numpy-computed conjugation.
…ocessing fix

Remove stale MAX_QUBITS_FOR_FIDELITY SK short-circuit; SK fidelity now flows through rz_product_fidelity_sk for large circuits.
Make rz_product_fidelity_sk's per-theta helper module-level so multiprocessing.Pool can pickle it.
Add --pbc-backend {auto,cpp,python} flag, wire through PipelineConfig.use_nwqec_pbc.
argparse uses ArgumentDefaultsHelpFormatter; --sk-recursion default → 2.
Fix flaky parity test (gridsynth Python can emit X, so input-preservation is >= not ==).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants