qoptct 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. qoptct-0.3.0/CHANGELOG.md +63 -0
  2. qoptct-0.3.0/CITATION.cff +29 -0
  3. qoptct-0.3.0/LICENSE +202 -0
  4. qoptct-0.3.0/MANIFEST.in +8 -0
  5. qoptct-0.3.0/NOTICE +11 -0
  6. qoptct-0.3.0/PKG-INFO +282 -0
  7. qoptct-0.3.0/README.md +247 -0
  8. qoptct-0.3.0/README_RU.md +148 -0
  9. qoptct-0.3.0/bench_qc/SOURCES.md +58 -0
  10. qoptct-0.3.0/bench_qc/adder_8.qc +277 -0
  11. qoptct-0.3.0/bench_qc/barenco_tof_10.qc +74 -0
  12. qoptct-0.3.0/bench_qc/barenco_tof_3.qc +22 -0
  13. qoptct-0.3.0/bench_qc/barenco_tof_4.qc +26 -0
  14. qoptct-0.3.0/bench_qc/barenco_tof_5.qc +34 -0
  15. qoptct-0.3.0/bench_qc/csla_mux_3.qc +76 -0
  16. qoptct-0.3.0/bench_qc/csum_mux_9.qc +135 -0
  17. qoptct-0.3.0/bench_qc/gf2^4_mult.qc +46 -0
  18. qoptct-0.3.0/bench_qc/gf2^5_mult.qc +60 -0
  19. qoptct-0.3.0/bench_qc/grover_5.qc +278 -0
  20. qoptct-0.3.0/bench_qc/ham15-low.qc +172 -0
  21. qoptct-0.3.0/bench_qc/mod5_4.qc +29 -0
  22. qoptct-0.3.0/bench_qc/mod_mult_55.qc +49 -0
  23. qoptct-0.3.0/bench_qc/mod_red_21.qc +98 -0
  24. qoptct-0.3.0/bench_qc/qcla_com_7.qc +122 -0
  25. qoptct-0.3.0/bench_qc/qcla_mod_7.qc +220 -0
  26. qoptct-0.3.0/bench_qc/qft_4.qc +171 -0
  27. qoptct-0.3.0/bench_qc/rc_adder_6.qc +91 -0
  28. qoptct-0.3.0/bench_qc/tof_10.qc +58 -0
  29. qoptct-0.3.0/bench_qc/tof_3.qc +16 -0
  30. qoptct-0.3.0/bench_qc/tof_4.qc +22 -0
  31. qoptct-0.3.0/bench_qc/tof_5.qc +28 -0
  32. qoptct-0.3.0/bench_qc/vbe_adder_3.qc +47 -0
  33. qoptct-0.3.0/pyproject.toml +61 -0
  34. qoptct-0.3.0/qoptct/__init__.py +28 -0
  35. qoptct-0.3.0/qoptct/bench_real.py +212 -0
  36. qoptct-0.3.0/qoptct/block_synth.py +265 -0
  37. qoptct-0.3.0/qoptct/circuit_opt.py +127 -0
  38. qoptct-0.3.0/qoptct/contrib/__init__.py +0 -0
  39. qoptct-0.3.0/qoptct/contrib/c1/__init__.py +0 -0
  40. qoptct-0.3.0/qoptct/contrib/c1/best_clean/MANIFEST.json +13 -0
  41. qoptct-0.3.0/qoptct/contrib/c1/best_clean/csla_mux_3.qasm +156 -0
  42. qoptct-0.3.0/qoptct/contrib/c1/best_clean/gf2^4_mult.qasm +184 -0
  43. qoptct-0.3.0/qoptct/contrib/c1/best_clean/gf2^5_mult.qasm +288 -0
  44. qoptct-0.3.0/qoptct/contrib/c1/best_clean/mod5_4.qasm +23 -0
  45. qoptct-0.3.0/qoptct/contrib/c1/best_clean/mod_mult_55.qasm +71 -0
  46. qoptct-0.3.0/qoptct/contrib/c1/best_clean/mod_red_21.qasm +118 -0
  47. qoptct-0.3.0/qoptct/contrib/c1/best_clean/rc_adder_6.qasm +156 -0
  48. qoptct-0.3.0/qoptct/contrib/c1/best_clean/tof_10.qasm +122 -0
  49. qoptct-0.3.0/qoptct/contrib/c1/best_clean/tof_3.qasm +31 -0
  50. qoptct-0.3.0/qoptct/contrib/c1/best_clean/tof_4.qasm +44 -0
  51. qoptct-0.3.0/qoptct/contrib/c1/best_clean/tof_5.qasm +57 -0
  52. qoptct-0.3.0/qoptct/contrib/c1/csyn.py +265 -0
  53. qoptct-0.3.0/qoptct/contrib/c1/resyn.py +122 -0
  54. qoptct-0.3.0/qoptct/contrib/c1/resyn2.py +136 -0
  55. qoptct-0.3.0/qoptct/contrib/c1/resyn3.py +262 -0
  56. qoptct-0.3.0/qoptct/contrib/c1/resyn4.py +97 -0
  57. qoptct-0.3.0/qoptct/contrib/c1/run.py +71 -0
  58. qoptct-0.3.0/qoptct/contrib/c10/__init__.py +0 -0
  59. qoptct-0.3.0/qoptct/contrib/c10/pathsum.py +191 -0
  60. qoptct-0.3.0/qoptct/contrib/c10/verify_big.py +251 -0
  61. qoptct-0.3.0/qoptct/contrib/c12/__init__.py +0 -0
  62. qoptct-0.3.0/qoptct/contrib/c12/mcx.py +271 -0
  63. qoptct-0.3.0/qoptct/contrib/c2/__init__.py +0 -0
  64. qoptct-0.3.0/qoptct/contrib/c2/andc.py +521 -0
  65. qoptct-0.3.0/qoptct/contrib/c2/peep.py +59 -0
  66. qoptct-0.3.0/qoptct/contrib/c2/run.py +51 -0
  67. qoptct-0.3.0/qoptct/contrib/c2/sweep2.py +72 -0
  68. qoptct-0.3.0/qoptct/contrib/c8/__init__.py +0 -0
  69. qoptct-0.3.0/qoptct/contrib/c8/hyb.py +159 -0
  70. qoptct-0.3.0/qoptct/contrib/eng1/__init__.py +0 -0
  71. qoptct-0.3.0/qoptct/contrib/eng1/det.py +333 -0
  72. qoptct-0.3.0/qoptct/contrib/eng1/det2.py +386 -0
  73. qoptct-0.3.0/qoptct/contrib/eng1/equiv.py +88 -0
  74. qoptct-0.3.0/qoptct/contrib/eng1/fasttodd.py +144 -0
  75. qoptct-0.3.0/qoptct/contrib/eng1/gad.py +272 -0
  76. qoptct-0.3.0/qoptct/contrib/eng1/gad2.py +80 -0
  77. qoptct-0.3.0/qoptct/contrib/eng1/ours/adder_8.json +1 -0
  78. qoptct-0.3.0/qoptct/contrib/eng1/ours/barenco_tof_10.json +1 -0
  79. qoptct-0.3.0/qoptct/contrib/eng1/ours/barenco_tof_3.json +1 -0
  80. qoptct-0.3.0/qoptct/contrib/eng1/ours/barenco_tof_4.json +1 -0
  81. qoptct-0.3.0/qoptct/contrib/eng1/ours/barenco_tof_5.json +1 -0
  82. qoptct-0.3.0/qoptct/contrib/eng1/ours/csla_mux_3.json +1 -0
  83. qoptct-0.3.0/qoptct/contrib/eng1/ours/csum_mux_9.json +1 -0
  84. qoptct-0.3.0/qoptct/contrib/eng1/ours/gf2^4_mult.json +1 -0
  85. qoptct-0.3.0/qoptct/contrib/eng1/ours/gf2^5_mult.json +1 -0
  86. qoptct-0.3.0/qoptct/contrib/eng1/ours/grover_5.json +1 -0
  87. qoptct-0.3.0/qoptct/contrib/eng1/ours/ham15-low.json +1 -0
  88. qoptct-0.3.0/qoptct/contrib/eng1/ours/mod5_4.json +1 -0
  89. qoptct-0.3.0/qoptct/contrib/eng1/ours/mod_mult_55.json +1 -0
  90. qoptct-0.3.0/qoptct/contrib/eng1/ours/mod_red_21.json +1 -0
  91. qoptct-0.3.0/qoptct/contrib/eng1/ours/qcla_com_7.json +1 -0
  92. qoptct-0.3.0/qoptct/contrib/eng1/ours/qft_4.json +1 -0
  93. qoptct-0.3.0/qoptct/contrib/eng1/ours/rc_adder_6.json +1 -0
  94. qoptct-0.3.0/qoptct/contrib/eng1/ours/tof_10.json +1 -0
  95. qoptct-0.3.0/qoptct/contrib/eng1/ours/tof_3.json +1 -0
  96. qoptct-0.3.0/qoptct/contrib/eng1/ours/tof_4.json +1 -0
  97. qoptct-0.3.0/qoptct/contrib/eng1/ours/tof_5.json +1 -0
  98. qoptct-0.3.0/qoptct/contrib/eng1/ours/vbe_adder_3.json +1 -0
  99. qoptct-0.3.0/qoptct/contrib/eng2/__init__.py +0 -0
  100. qoptct-0.3.0/qoptct/contrib/eng2/improve.py +79 -0
  101. qoptct-0.3.0/qoptct/contrib/eng2/regions.py +69 -0
  102. qoptct-0.3.0/qoptct/contrib/eng2/synth.py +216 -0
  103. qoptct-0.3.0/qoptct/contrib/tg2/__init__.py +0 -0
  104. qoptct-0.3.0/qoptct/contrib/tg2/sel.py +293 -0
  105. qoptct-0.3.0/qoptct/contrib/tg3/__init__.py +0 -0
  106. qoptct-0.3.0/qoptct/contrib/tg3/core.py +229 -0
  107. qoptct-0.3.0/qoptct/contrib/tg3/post.py +102 -0
  108. qoptct-0.3.0/qoptct/contrib/tg3/search.py +145 -0
  109. qoptct-0.3.0/qoptct/contrib/tg3/search2.py +73 -0
  110. qoptct-0.3.0/qoptct/contrib/tg3/search_fin.py +32 -0
  111. qoptct-0.3.0/qoptct/contrib/tg3/tg3_opt.py +69 -0
  112. qoptct-0.3.0/qoptct/ei2.py +553 -0
  113. qoptct-0.3.0/qoptct/expert_iter.py +230 -0
  114. qoptct-0.3.0/qoptct/fast_gates.py +31 -0
  115. qoptct-0.3.0/qoptct/gidney.py +190 -0
  116. qoptct-0.3.0/qoptct/global_cancel.py +36 -0
  117. qoptct-0.3.0/qoptct/meas_portfolio.py +54 -0
  118. qoptct-0.3.0/qoptct/models/mx_4_4q.pt +0 -0
  119. qoptct-0.3.0/qoptct/models/rt_3_si2_3q.pt +0 -0
  120. qoptct-0.3.0/qoptct/models/u_2_best_2q.pt +0 -0
  121. qoptct-0.3.0/qoptct/models/value_u4q.pt +0 -0
  122. qoptct-0.3.0/qoptct/portfolio/__init__.py +0 -0
  123. qoptct-0.3.0/qoptct/portfolio/bench_hook.py +47 -0
  124. qoptct-0.3.0/qoptct/portfolio/evo_lib.py +373 -0
  125. qoptct-0.3.0/qoptct/portfolio/programs/__init__.py +0 -0
  126. qoptct-0.3.0/qoptct/portfolio/programs/c0001_combo2.py +10 -0
  127. qoptct-0.3.0/qoptct/portfolio/programs/c0002_vphase_push.py +198 -0
  128. qoptct-0.3.0/qoptct/portfolio/programs/c0005_phasepoly_graysynth.py +299 -0
  129. qoptct-0.3.0/qoptct/portfolio/programs/c0006_combo2_permpair.py +150 -0
  130. qoptct-0.3.0/qoptct/portfolio/programs/c0007_conj_rtof.py +203 -0
  131. qoptct-0.3.0/qoptct/portfolio/programs/c0008_cla_collapse.py +292 -0
  132. qoptct-0.3.0/qoptct/portfolio/programs/c0009_phasepoly_rtof4.py +298 -0
  133. qoptct-0.3.0/qoptct/portfolio/programs/c0010_combo2_majcarry.py +208 -0
  134. qoptct-0.3.0/qoptct/portfolio/programs/c0011_rtof3_vphase.py +248 -0
  135. qoptct-0.3.0/qoptct/portfolio/programs/c0013_unify_permpair_vphase.py +300 -0
  136. qoptct-0.3.0/qoptct/portfolio/programs/c0014_majcarry_ppresynth.py +298 -0
  137. qoptct-0.3.0/qoptct/portfolio/programs/c0015_mcx_resynth.py +151 -0
  138. qoptct-0.3.0/qoptct/portfolio/programs/c0017_rtof3_esop.py +297 -0
  139. qoptct-0.3.0/qoptct/proto2/__init__.py +0 -0
  140. qoptct-0.3.0/qoptct/proto2/phase_fold.py +67 -0
  141. qoptct-0.3.0/qoptct/proto2/rtof.py +246 -0
  142. qoptct-0.3.0/qoptct/proto2/verify.py +62 -0
  143. qoptct-0.3.0/qoptct/qenv.py +147 -0
  144. qoptct-0.3.0/qoptct/qfast.py +182 -0
  145. qoptct-0.3.0/qoptct/qgnn.py +305 -0
  146. qoptct-0.3.0/qoptct/qiskit_qopt.py +309 -0
  147. qoptct-0.3.0/qoptct/qopt_core.py +466 -0
  148. qoptct-0.3.0/qoptct/qopt_metrics.py +107 -0
  149. qoptct-0.3.0/qoptct/tpoly.py +165 -0
  150. qoptct-0.3.0/qoptct/train_agent.py +153 -0
  151. qoptct-0.3.0/qoptct/vartodd_bridge.py +73 -0
  152. qoptct-0.3.0/qoptct/verify_qasm.py +69 -0
  153. qoptct-0.3.0/qoptct.egg-info/PKG-INFO +282 -0
  154. qoptct-0.3.0/qoptct.egg-info/SOURCES.txt +161 -0
  155. qoptct-0.3.0/qoptct.egg-info/dependency_links.txt +1 -0
  156. qoptct-0.3.0/qoptct.egg-info/entry_points.txt +8 -0
  157. qoptct-0.3.0/qoptct.egg-info/requires.txt +9 -0
  158. qoptct-0.3.0/qoptct.egg-info/top_level.txt +1 -0
  159. qoptct-0.3.0/results/best/strict/tof_3.qasm +32 -0
  160. qoptct-0.3.0/setup.cfg +4 -0
  161. qoptct-0.3.0/tests/test_metrics.py +145 -0
  162. qoptct-0.3.0/tests/test_plugin.py +194 -0
  163. qoptct-0.3.0/tests/test_release.py +84 -0
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 — 2026-11-13 (first PyPI release)
4
+
5
+ ### Changed — package renamed to `qoptct`
6
+ * **The distribution, the import package and the command are now called `qoptct`** (the PyPI name `qopt`
7
+ belongs to an unrelated project with the import name `qopt`). The project itself is still called qopt.
8
+ Migration: `pip install qoptct`; `import qopt` → `import qoptct`; `from qopt.qiskit_qopt import QoptPass` →
9
+ `from qoptct.qiskit_qopt import QoptPass`; command `qopt optimize ...` → `qoptct optimize ...`.
10
+ Environment variables (`QOPT_CACHE`, `QOPT_PROG_SEC`, ...) and the cache directory `~/.cache/qopt` are unchanged.
11
+ * PyTorch is now optional: `pip install "qoptct[net]"`. Only `--net` (and `QoptPass(net=True)`) needs it and
12
+ stops with an installation hint if it is missing; the other modes no longer import torch at all.
13
+ * Python ≥ 3.11 (was 3.12); tested with 3.11, 3.12 and 3.14.
14
+
15
+ ### Added
16
+ * Qiskit transpiler stage plugins, both named `qoptct`:
17
+ `transpile(qc, optimization_method="qoptct")` (Qiskit's optimization stage of the chosen level, then
18
+ `QoptPass` restricted to the target / basis / coupling map) and `init_method="qoptct"` (`QoptPass` at the
19
+ Toffoli level, before decomposition).
20
+ * `QoptPass` now works on any circuit: it optimizes each maximal Clifford+T run separately (measurements,
21
+ barriers, rotations and other gates are kept), replaces a run only if the result is proven equal and strictly
22
+ cheaper, respects basis gates / coupling map / target, keeps the global phase (runs ≤ 10 qubits), and reports
23
+ `runs`, `replaced`, CX/T before and after in `pass.last`. Messages and documentation in English.
24
+ * `.github/workflows/tests.yml` (pytest on Ubuntu and macOS against the built wheel) and
25
+ `.github/workflows/publish.yml` (PyPI Trusted Publishing on a published GitHub release).
26
+ * `MANIFEST.in` (the sdist contains the tests and the redistributable benchmark inputs, never hwb6).
27
+
28
+ ## 0.2.0 — 2026-11-12 (first public release candidate; not yet published)
29
+
30
+ ### Added
31
+ * Measurement-based optimization modes `--mode balanced` and `--mode t` (OpenQASM 3 output with mid-circuit
32
+ measurements and classically controlled Clifford corrections):
33
+ * logical-AND compiler with measurement-based uncomputation and exact GF(2) tracking of wire values;
34
+ * clean-ancilla model `--clean` (wires not listed in `.i` start in |0>);
35
+ * CX polishing of AND circuits (re-synthesis of unconditioned pieces using |+> and measured-wire freedoms);
36
+ * hybrid compilation for circuits with genuine H gates (grover_5, qft_4);
37
+ * recognition of multi-controlled Toffolis (AND ladders, Khattar–Gidney syntheses with AND-based outer pair);
38
+ * Hadamard gadgets + TODD with deterministic corrections (`--tgad`), partial gadgetization;
39
+ * optional external VarTODD via `--vartodd` and `QOPT_VARTODD_BIN`.
40
+ * Independent checkers: `verify_qasm` (strict and clean models, no renormalization) and `verify_big`
41
+ (sum-over-paths, > 22 qubits).
42
+ * `results/`: verified best and Pareto-optimal circuits for 23 benchmarks in three models, `TABLE.md`,
43
+ `table.csv`, comparison with nine tools (`COMPARISON.md`).
44
+ * `scripts/verify_all.py`, `scripts/reproduce.sh`, `scripts/fetch_benchmarks.sh`.
45
+ * Documentation: `docs/METHOD.md`, `docs/FINDINGS.md`, `paper/preprint.md`.
46
+
47
+ ### Changed
48
+ * Installable package `qopt` with the `qopt` console command; all paths relative to the package; caches in
49
+ `$QOPT_CACHE` (default `~/.cache/qopt`).
50
+ * Cached data that is keyed by benchmark name (unitary start circuits, hand-made clean-ancilla constructions) is
51
+ used only if the SHA-256 of the input file matches the benchmark.
52
+ * CLI messages and help in English. The `bench` subcommand of 0.1 was replaced by `scripts/reproduce.sh`.
53
+
54
+ ### Removed / not included
55
+ * `hwb6` (and its optimized circuits): the benchmark file forbids redistribution; `scripts/fetch_benchmarks.sh`
56
+ downloads it for local use.
57
+
58
+ ### Fixed (found by independent verification, see docs/FINDINGS.md)
59
+ * A 51-T hwb6 circuit of an earlier gadget pipeline was wrong; it was never part of a release.
60
+
61
+ ## 0.1 — 2026-11-10 (internal)
62
+ * Unitary CX/T optimizer: portfolio of evolved rewriting programs, phase folding, neural block resynthesis,
63
+ proof of equality (unitary / PyZX / numerical) with fallback to the input.
@@ -0,0 +1,29 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software or its results, please cite it as below."
3
+ title: "qopt: a verified Clifford+T circuit optimizer for T and CNOT counts"
4
+ type: software
5
+ version: 0.3.0
6
+ date-released: "2026-11-13"
7
+ license: Apache-2.0
8
+ authors:
9
+ - given-names: Maksym
10
+ family-names: Shchehlov
11
+ keywords:
12
+ - quantum computing
13
+ - quantum circuit optimization
14
+ - Clifford+T
15
+ - T-count
16
+ - CNOT count
17
+ - logical AND
18
+ - measurement-based uncomputation
19
+ - verification
20
+ abstract: >-
21
+ qopt reduces the T count and the CNOT count of Clifford+T circuits given as Toffoli networks.
22
+ It provides a unitary mode (portfolio of evolved rewriting programs, phase folding, optional neural block
23
+ resynthesis) and measurement-based modes that place Gidney logical-AND gates with measurement-based
24
+ uncomputation automatically by tracking every wire as a polynomial over GF(2). Every reported circuit is
25
+ re-checked by an independent state-vector simulator (up to 22 qubits) or a sum-over-paths checker.
26
+ Python package: pip install qoptct (import qoptct), with a Qiskit transpiler plugin.
27
+ repository-code: "https://github.com/seglovmaksim695-creator/qopt"
28
+ url: "https://github.com/seglovmaksim695-creator/qopt"
29
+ doi: 10.5281/zenodo.24182059
qoptct-0.3.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ https://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ https://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,8 @@
1
+ # Source distribution: package, tests and the redistributable benchmark inputs the tests need.
2
+ include README.md README_RU.md CHANGELOG.md LICENSE NOTICE CITATION.cff
3
+ include bench_qc/*.qc bench_qc/SOURCES.md
4
+ include results/best/strict/tof_3.qasm
5
+ recursive-include tests *.py
6
+ prune _build
7
+ prune results/hardware
8
+ global-exclude *.pyc __pycache__ *hwb*
qoptct-0.3.0/NOTICE ADDED
@@ -0,0 +1,11 @@
1
+ qopt — verified Clifford+T circuit optimizer
2
+ Copyright 2026 Maksym Shchehlov
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Third-party material:
7
+ * bench_qc/*.qc — benchmark circuits from the Feynman toolkit repository
8
+ (https://github.com/meamy/feynman, benchmarks/qc; repository license BSD-3-Clause), originally collected by
9
+ M. Amy, D. Maslov, M. Mosca and others (see bench_qc/SOURCES.md). These files are not covered by the
10
+ Apache-2.0 license of this project; see bench_qc/SOURCES.md for provenance and checksums.
11
+ * qopt/contrib/c12/mcx.py calls multi-controlled-X syntheses from Qiskit (Apache-2.0) at run time.
qoptct-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: qoptct
3
+ Version: 0.3.0
4
+ Summary: qopt: verified Clifford+T circuit optimizer (T and CNOT counts) with a Qiskit transpiler plugin
5
+ Author: Maksym Shchehlov
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/seglovmaksim695-creator/qopt
8
+ Project-URL: Repository, https://github.com/seglovmaksim695-creator/qopt
9
+ Project-URL: Issues, https://github.com/seglovmaksim695-creator/qopt/issues
10
+ Project-URL: Changelog, https://github.com/seglovmaksim695-creator/qopt/blob/main/CHANGELOG.md
11
+ Project-URL: DOI, https://doi.org/10.5281/zenodo.24182059
12
+ Keywords: quantum computing,circuit optimization,Clifford+T,T-count,CNOT count,verification,qiskit,transpiler plugin
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Operating System :: MacOS
20
+ Classifier: Operating System :: POSIX :: Linux
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Classifier: Intended Audience :: Science/Research
23
+ Requires-Python: >=3.11
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Requires-Dist: numpy>=2.0
28
+ Requires-Dist: qiskit>=2.0
29
+ Requires-Dist: pyzx>=0.10
30
+ Provides-Extra: net
31
+ Requires-Dist: torch>=2.4; extra == "net"
32
+ Provides-Extra: test
33
+ Requires-Dist: pytest>=8; extra == "test"
34
+ Dynamic: license-file
35
+
36
+ # qopt — a verified Clifford+T circuit optimizer
37
+
38
+ [![PyPI](https://img.shields.io/pypi/v/qoptct.svg)](https://pypi.org/project/qoptct/)
39
+ [![tests](https://github.com/seglovmaksim695-creator/qopt/actions/workflows/tests.yml/badge.svg)](https://github.com/seglovmaksim695-creator/qopt/actions/workflows/tests.yml)
40
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24182059.svg)](https://doi.org/10.5281/zenodo.24182059)
41
+
42
+ > **Package name:** the project is called *qopt*, but on PyPI the name `qopt` belongs to an unrelated project.
43
+ > Since version 0.3.0 the package is therefore installed and imported as **`qoptct`**:
44
+ > `pip install qoptct`, `import qoptct`, command `qoptct`.
45
+
46
+ `qopt` reduces the **T count** and the **CNOT (CX) count** of Clifford+T circuits given as Toffoli networks
47
+ (Feynman `.qc` format). It has a unitary mode and measurement-based modes, and it **never reports a circuit that
48
+ has not been checked**: unitary outputs are proven equal to the input (or the input is returned), and every
49
+ measurement-based output is re-checked by an independent simulator before it is written.
50
+
51
+ Repository: <https://github.com/seglovmaksim695-creator/qopt> · Version 0.3.0 · License Apache-2.0 (benchmark files: see `bench_qc/SOURCES.md`) · Author: Maksym Shchehlov
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install qoptct # Python 3.11+, macOS or Linux; provides the `qoptct` command and the Qiskit plugin
57
+ pip install "qoptct[net]" # optional: + PyTorch for the neural mode --net
58
+ ```
59
+
60
+ Dependencies: numpy, qiskit ≥ 2.0, pyzx. PyTorch is needed only for `--net`; without it every other mode works
61
+ and `--net` stops with a message that says what to install.
62
+
63
+ From the repository (to run the tests, the benchmarks and the scripts):
64
+
65
+ ```bash
66
+ git clone https://github.com/seglovmaksim695-creator/qopt.git && cd qopt
67
+ python3 -m venv .venv && . .venv/bin/activate
68
+ pip install -r requirements.txt # exact versions used for the results (incl. torch)
69
+ pip install -e ".[test]"
70
+ pytest -q tests # a few minutes
71
+ ```
72
+
73
+ `requirements-lock.txt` pins the full environment used for testing. Caches are written to `$QOPT_CACHE`
74
+ (default `~/.cache/qopt`).
75
+
76
+ ## Usage
77
+
78
+ ```bash
79
+ qoptct optimize bench_qc/tof_3.qc -o tof_3_opt.qc # unitary, minimum CX (default --mode cx)
80
+ qoptct optimize bench_qc/tof_3.qc -o tof_3_opt.qc --net --post # + neural block resynthesis + CX post-pass
81
+ qoptct optimize bench_qc/tof_3.qc -o tof_3.qasm --mode balanced # fewer T, CX <= 1.5x unitary CX
82
+ qoptct optimize bench_qc/mod_red_21.qc -o m.qasm --mode t --clean # minimum T, clean-ancilla model
83
+ qoptct optimize X.qc --report report.json # JSON report (also printed to stdout)
84
+ ```
85
+
86
+ Python: `import qoptct; names, ref, best, how = qoptct.optimize("X.qc")`.
87
+
88
+ | option | meaning |
89
+ |---|---|
90
+ | `--mode cx` (default) | unitary output (`.qc`), minimum CX; proven equal to the input, otherwise the input is returned |
91
+ | `--mode balanced` | measurement-based output (OpenQASM 3) with lower T and CX ≤ `--cx-factor` (1.5) × unitary CX, if one is found and verified |
92
+ | `--mode t` | lowest T found (measurement-based), CX may grow |
93
+ | `--clean` | clean-ancilla model (see below) for the measurement-based modes |
94
+ | `--net` | neural block resynthesis (models in `qoptct/models/`; needs `pip install "qoptct[net]"`) |
95
+ | `--post` | CX post-pass on H-free regions (slow) |
96
+ | `--meas` | older Gidney transformation (clean-ancilla model), kept for compatibility |
97
+ | `--tgad`, `--vartodd` | Hadamard gadgets + TODD; `--vartodd` also tries an external VarTODD binary given by `QOPT_VARTODD_BIN` |
98
+
99
+ Measurement-based outputs are written only if they pass `verify_qasm` (≤ 22 qubits in total); otherwise the unitary
100
+ result is written. The JSON report says which candidate was used.
101
+
102
+ ## Qiskit plugin
103
+
104
+ `pip install qoptct` registers two stage plugins for the Qiskit transpiler, both named `qoptct`:
105
+
106
+ * `optimization_method="qoptct"` — Qiskit's own optimization stage of the chosen level, then `QoptPass` on the
107
+ Clifford+T parts of the (already translated and routed) circuit;
108
+ * `init_method="qoptct"` (optional, recommended for Toffoli circuits) — `QoptPass` on the circuit as written,
109
+ while the Toffolis are still Toffolis, before Qiskit's own init stage. Most of the savings come from here.
110
+
111
+ ```python
112
+ from qiskit import QuantumCircuit, transpile
113
+ from qiskit.quantum_info import Operator
114
+
115
+ qc = QuantumCircuit(5) # tof_3 from bench_qc/
116
+ qc.ccx(0, 1, 4); qc.ccx(2, 4, 3); qc.ccx(0, 1, 4)
117
+
118
+ basis = ["h", "x", "z", "s", "sdg", "t", "tdg", "cx"] # Clifford+T
119
+ plain = transpile(qc, basis_gates=basis, optimization_level=3)
120
+ ours = transpile(qc, basis_gates=basis, optimization_level=3,
121
+ init_method="qoptct", optimization_method="qoptct")
122
+ print(plain.count_ops(), ours.count_ops())
123
+ assert Operator(ours) == Operator(qc) # same operator, incl. global phase
124
+ ```
125
+
126
+ CX/T after `transpile` with a Clifford+T basis (Qiskit 2.6.2, levels 1–3 gave the same numbers):
127
+
128
+ | circuit | Qiskit level 3 | `optimization_method="qoptct"` | `+ init_method="qoptct"` |
129
+ |---|---|---|---|
130
+ | tof_3 | 18 / 19 | 16 / 15 | 12 / 15 |
131
+ | mod5_4 | 28 / 22 | 25 / 16 | 11 / 8 |
132
+ | barenco_tof_3 | 24 / 24 | 20 / 16 | 16 / 16 |
133
+
134
+ A part of the circuit is replaced only if the new version is **proven** equal, strictly cheaper (CX, then T),
135
+ and uses only gates and qubit pairs allowed by the basis / coupling map / target; everything else
136
+ (measurements, rotations, other gates) is left as it is. With a coupling map, compare with
137
+ `Operator.from_circuit(out)`. On circuits with up to 10 qubits per part the global phase is kept exactly.
138
+
139
+ The pass can also be used directly:
140
+
141
+ ```python
142
+ from qiskit.transpiler import PassManager
143
+ from qoptct.qiskit_qopt import QoptPass
144
+ p = QoptPass(); out = PassManager([p]).run(qc); print(p.last) # runs, replaced, CX/T before and after
145
+ ```
146
+
147
+ `QoptMeasPass(ancillas=[...])` is the measurement-based variant (logical AND, needs qubits known to start in |0>).
148
+
149
+ ## Cost models — read this before comparing numbers
150
+
151
+ The same benchmark has different "best" numbers in different models. All tables say which model they use.
152
+
153
+ | model | allowed in the output | input wires | ancillas | checked by |
154
+ |---|---|---|---|---|
155
+ | **unitary** | Clifford+T gates only, same wires | arbitrary state | none | full unitary / PyZX / numerical |
156
+ | **strict** (measurement-based) | + fresh ancillas in \|0>, mid-circuit measurements, classically controlled Clifford gates | **all** `.qc` wires are data in an arbitrary state, including wires the benchmark intends as ancillas | fresh ones must end in a basis state, unentangled | `verify_qasm` (strict), `verify_big` |
157
+ | **clean** (clean ancillas) | as strict | wires listed in the `.i` line are data; **the other `.qc` wires start in \|0> and must end in \|0>** (the intended use of e.g. `tof_n`, `mod_red_21`) | as strict | `verify_qasm(clean=True)` |
158
+
159
+ * *unitary* is the model of most circuit-optimization papers (Nam et al., PyZX, GUOQ, Quarl, …).
160
+ * *strict* is stronger than *clean*: a strict circuit is valid in the clean model, not vice versa.
161
+ * In both measurement-based models the logical AND costs 4 T and its uncomputation 0 T (Gidney 2018); that is
162
+ why T counts there are far below unitary ones. They must not be compared with unitary T-count records.
163
+ * Published H-gadget T-count records (TODD/FastTODD, AlphaTensor-Quantum) use yet another model (gadget ancillas,
164
+ no classical feed-forward on the output). They are listed for orientation only.
165
+
166
+ ## Results (23 benchmarks)
167
+
168
+ | circuit | qubits | Toffolis | input T/CX | unitary T/CX | strict T/CX (+extra) | clean T/CX (+extra) |
169
+ |---|---|---|---|---|---|---|
170
+ | adder_8 | 24 | 57 | 399/409 | 193/223 | — | — |
171
+ | barenco_tof_10 | 19 | 32 | 224/192 | 72/72 | 59/48 (+3) | 59/48 (+3) |
172
+ | barenco_tof_3 | 5 | 4 | 28/24 | 16/14 | 8/9 (+2) | 8/9 (+2) |
173
+ | barenco_tof_4 | 7 | 8 | 56/48 | 24/24 | 12/13 (+3) | 12/13 (+3) |
174
+ | barenco_tof_5 | 9 | 12 | 84/72 | 32/32 | 16/17 (+4) | 16/17 (+4) |
175
+ | csla_mux_3 | 15 | 10 | 70/80 | 64/64 | 40/70 (+1) | 28/84 (+3) |
176
+ | csum_mux_9 | 30 | 28 | 196/168 | 84/112 | — | — |
177
+ | gf2^4_mult | 12 | 16 | 112/99 | 68/86 | 58/115 (+0) | 36/79 (+1) |
178
+ | gf2^5_mult | 15 | 25 | 175/154 | 115/132 | 90/183 (+0) | 56/124 (+1) |
179
+ | grover_5 | 9 | 48 | 336/288 | 166/160 | 124/155 (+4) | 124/155 (+4) |
180
+ | ham15-low | 17 | 23 | 161/236 | 97/179 | — | 68/177 (+1) |
181
+ | mod5_4 | 5 | 4 | 28/28 | 7/10 | 4/11 (+1) | 4/11 (+0) |
182
+ | mod_mult_55 | 9 | 7 | 49/48 | 35/39 | 20/35 (+2) | 12/24 (+1) |
183
+ | mod_red_21 | 11 | 17 | 119/105 | 73/61 | 44/58 (+5) | 28/48 (+0) |
184
+ | qcla_com_7 | 24 | 29 | 203/186 | 95/111 | 59/565 (+37) | 59/565 (+37) |
185
+ | qcla_mod_7 | 26 | 59 | 413/382 | 237/256 | — | — |
186
+ | qft_4 | 5 | 2 | 69/46 | 67/37 | 53/265 (+42) | 53/265 (+42) |
187
+ | rc_adder_6 | 14 | 11 | 77/93 | 47/65 | 24/54 (+6) | 24/53 (+6) |
188
+ | tof_10 | 19 | 17 | 119/102 | 71/54 | 59/71 (+3) | 36/37 (+1) |
189
+ | tof_3 | 5 | 3 | 21/18 | 15/12 | 8/10 (+2) | 8/9 (+1) |
190
+ | tof_4 | 7 | 5 | 35/30 | 23/18 | 12/15 (+3) | 12/13 (+1) |
191
+ | tof_5 | 9 | 7 | 49/42 | 31/24 | 16/20 (+4) | 16/17 (+1) |
192
+ | vbe_adder_3 | 10 | 10 | 70/70 | 24/28 | 12/33 (+3) | 12/33 (+3) |
193
+
194
+ Best point per model: unitary = minimum CX; strict and clean = minimum T (then CX, then extra qubits). Other Pareto points (e.g. fewer extra qubits) are in results/TABLE.md.
195
+
196
+ Totals over the circuits that have a result in the model: unitary: 23 circuits, T 3093→1656, CX 2920→1813; strict: 19 circuits, T 1924→718, CX 1725→1747; clean: 20 circuits, T 2085→671, CX 1961→1781
197
+
198
+ Full tables with Pareto fronts and provenance: `results/TABLE.md`, machine-readable `results/table.csv`;
199
+ circuits: `results/best/<model>/<name>.qasm` and `results/pareto/<model>/`.
200
+
201
+ ## Hardware check (IBM Quantum)
202
+
203
+ On `ibm_marrakesh`, the unitary `qopt` circuits returned the correct answer more often than the input circuits on all
204
+ five benchmarks tried (+2 to +10 percentage points), while the measurement-based circuits were worse on current
205
+ hardware (mid-circuit measurement latency). Details: `results/hardware/README.md`.
206
+
207
+ ## Comparison with nine tools (summary; details in `results/COMPARISON.md`)
208
+
209
+ Tools run on the same files: Qiskit 2.6.1, PyZX 0.10.8, pytket 2.18.5, Cirq 1.7, Q# Resource Estimator 1.31,
210
+ Qualtran 0.7.0, pyLIQTR 1.0.1, Qrisp 0.9.10, PennyLane 0.45.1. All produced circuits were verified with the same
211
+ checker; estimates without circuits are marked as such.
212
+
213
+ | circuit | best tool circuit by T (as-is or MCX rewrite) | best tool circuit by CX | qopt unitary | qopt strict | qopt clean |
214
+ |---|---|---|---|---|---|
215
+ | barenco_tof_3 | 8/9 +2 (PennyLane 0.45.1, and_ladder; strict) | 8/9 +2 (PennyLane 0.45.1, and_ladder; strict) | 16/14 | 8/9 (+2) | 8/9 (+2) |
216
+ | barenco_tof_4 | 12/13 +3 (PennyLane 0.45.1, and_ladder; strict) | 12/13 +3 (PennyLane 0.45.1, and_ladder; strict) | 24/24 | 12/13 (+3) | 12/13 (+3) |
217
+ | barenco_tof_5 | 16/17 +4 (PennyLane 0.45.1, and_ladder; strict) | 16/17 +4 (PennyLane 0.45.1, and_ladder; strict) | 32/32 | 16/17 (+4) | 16/17 (+4) |
218
+ | csla_mux_3 | 62/161 +0 (PyZX 0.10.8, full_reduce; strict) | 64/72 +0 (Qiskit 2.6.1, as-is; strict) | 64/64 | 40/70 (+1) | 28/84 (+3) |
219
+ | gf2^4_mult | 68/274 +0 (PyZX 0.10.8, full_reduce; strict) | 96/99 +0 (Qiskit 2.6.1, as-is; strict) | 68/86 | 58/115 (+0) | 36/79 (+1) |
220
+ | gf2^5_mult | 115/509 +0 (pytket 2.18.5, zxperm_fpo; strict) | 155/154 +0 (Qiskit 2.6.1, as-is; strict) | 115/132 | 90/183 (+0) | 56/124 (+1) |
221
+ | grover_5 | 166/301 +0 (PyZX 0.10.8, full_reduce; strict) | 296/288 +0 (Qiskit 2.6.1, as-is; strict) | 166/160 | 124/155 (+4) | 124/155 (+4) |
222
+ | ham15-low | 97/322 +0 (PyZX 0.10.8, full_reduce; strict) | 147/236 +0 (Qiskit 2.6.1, as-is; strict) | 97/179 | — | 68/177 (+1) |
223
+ | mod5_4 | 8/20 +0 (PyZX 0.10.8, full_reduce; strict) | 8/20 +0 (PyZX 0.10.8, full_reduce; strict) | 7/10 | 4/11 (+1) | 4/11 (+0) |
224
+ | mod_mult_55 | 35/89 +0 (PyZX 0.10.8, full_reduce; strict) | 45/48 +0 (Qiskit 2.6.1, as-is; strict) | 35/39 | 20/35 (+2) | 12/24 (+1) |
225
+ | mod_red_21 | 73/149 +0 (PyZX 0.10.8, full_reduce; strict) | 107/105 +0 (Qiskit 2.6.1, as-is; strict) | 73/61 | 44/58 (+5) | 28/48 (+0) |
226
+ | qft_4 | 67/55 +0 (PyZX 0.10.8, full_reduce; strict) | 409/45 +0 (Qiskit 2.6.1, as-is; strict) | 67/37 | 53/265 (+42) | 53/265 (+42) |
227
+ | rc_adder_6 | 47/103 +0 (PyZX 0.10.8, full_reduce; strict) | 67/83 +0 (Qiskit 2.6.1, as-is; strict) | 47/65 | 24/54 (+6) | 24/53 (+6) |
228
+ | tof_10 | 36/37 +1 (PennyLane 0.45.1, and_ladder; clean) | 36/37 +1 (PennyLane 0.45.1, and_ladder; clean) | 71/54 | 59/71 (+3) | 36/37 (+1) |
229
+ | tof_3 | 8/9 +1 (PennyLane 0.45.1, and_ladder; clean) | 8/9 +1 (PennyLane 0.45.1, and_ladder; clean) | 15/12 | 8/10 (+2) | 8/9 (+1) |
230
+ | tof_4 | 12/13 +1 (PennyLane 0.45.1, and_ladder; clean) | 12/13 +1 (PennyLane 0.45.1, and_ladder; clean) | 23/18 | 12/15 (+3) | 12/13 (+1) |
231
+ | tof_5 | 16/17 +1 (PennyLane 0.45.1, and_ladder; clean) | 16/17 +1 (PennyLane 0.45.1, and_ladder; clean) | 31/24 | 16/20 (+4) | 16/17 (+1) |
232
+ | vbe_adder_3 | 24/71 +0 (PyZX 0.10.8, full_reduce; strict) | 56/58 +0 (Qiskit 2.6.1, as-is; strict) | 24/28 | 12/33 (+3) | 12/33 (+3) |
233
+
234
+ Each tool cell: T/CX extra-qubits (tool, variant; model in which the circuit passed verification).
235
+
236
+ Honest caveats:
237
+
238
+ * **Given the gate list "as is", no tool replaces Toffolis by logical ANDs with measurement-based uncomputation
239
+ automatically.** Unitary tools give ~7 T per Toffoli minus phase folding; Q#/Qualtran give only estimates
240
+ (4 T per Toffoli) without a circuit.
241
+ * **When a human rewrites the circuit as a multi-controlled X** (tof_n, barenco_tof_n), tools reach our numbers or
242
+ beat them: PennyLane's `TemporaryAND` ladder equals our clean-model tof_n points; on barenco_tof_n Qiskit's
243
+ Khattar–Gidney syntheses with one ancilla were better than our general compiler until the MCX recognition
244
+ (`contrib/c12`) was added. Our advantage is automatic discovery in arbitrary networks, not better gadgets.
245
+ * Third-party pitfalls and one wrong circuit of a tool are documented in `docs/FINDINGS.md`.
246
+
247
+ ## How to check the results yourself
248
+
249
+ ```bash
250
+ python scripts/verify_all.py --jobs 2 # re-verifies all 200 rows of results/table.csv (~40 min)
251
+ python scripts/verify_all.py --only tof_3 # one circuit
252
+ sh scripts/reproduce.sh cx out # re-run the optimizer on all benchmarks (see script header)
253
+ ```
254
+
255
+ Every qasm in `results/` is self-contained OpenQASM 3 using `h x z s sdg t tdg cx cz`, `measure`, and `if` on
256
+ classical bits; data qubits are `q[0..n-1]` in the order of the `.v` line of the `.qc` file, extra qubits follow
257
+ and start in |0>.
258
+
259
+ ## Limitations
260
+
261
+ * The checks are randomized: `verify_qasm` uses 30 random input states (10 for 20–22-qubit circuits) and sampled
262
+ measurement outcomes; `verify_big` samples basis inputs and branches. A wrong circuit could pass only if it acts
263
+ correctly on all samples. Unitary results ≤ 10 qubits are proven exactly; larger ones rely on PyZX or a
264
+ numerical check.
265
+ * Measurement-based modes handle at most 22 qubits in total (state-vector check). Larger outputs are discarded.
266
+ * The neural models were trained on random circuits of 2–4 qubits; `--net` gives small gains (≈ 1–2 % CX).
267
+ * Runtime: unitary mode takes seconds for small circuits and up to an hour for the largest benchmarks; the
268
+ measurement-based modes take minutes. Several rewriting programs have internal time limits, so results can
269
+ depend on machine speed.
270
+ * Some numbers in `results/` come from longer development searches than a single default run (column `source`
271
+ in `results/TABLE.md`); a default run may give slightly worse points.
272
+ * The hand-made clean-model constructions (`contrib/c1/best_clean`) apply only to the exact benchmark files.
273
+ * hwb6 is not included (license of the benchmark file).
274
+
275
+ ## Citation
276
+
277
+ See `CITATION.cff`. A preprint draft is in `paper/preprint.md`.
278
+
279
+ ## Acknowledgements
280
+
281
+ Benchmarks from the Feynman repository (M. Amy). Logical AND construction: C. Gidney, *Halving the cost of quantum
282
+ addition*, Quantum 2, 74 (2018). Sum-over-paths verification: M. Amy, arXiv:1805.06908.