veriq-quantum 0.1.1__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 (62) hide show
  1. veriq_quantum-0.1.1/LICENSE +202 -0
  2. veriq_quantum-0.1.1/PKG-INFO +107 -0
  3. veriq_quantum-0.1.1/README.md +45 -0
  4. veriq_quantum-0.1.1/pyproject.toml +75 -0
  5. veriq_quantum-0.1.1/setup.cfg +4 -0
  6. veriq_quantum-0.1.1/src/veriq/__init__.py +8 -0
  7. veriq_quantum-0.1.1/src/veriq/__main__.py +5 -0
  8. veriq_quantum-0.1.1/src/veriq/_sandbox_worker.py +117 -0
  9. veriq_quantum-0.1.1/src/veriq/bench.py +522 -0
  10. veriq_quantum-0.1.1/src/veriq/certificate.py +693 -0
  11. veriq_quantum-0.1.1/src/veriq/checks.py +689 -0
  12. veriq_quantum-0.1.1/src/veriq/ci.py +654 -0
  13. veriq_quantum-0.1.1/src/veriq/cli.py +557 -0
  14. veriq_quantum-0.1.1/src/veriq/frontends/__init__.py +148 -0
  15. veriq_quantum-0.1.1/src/veriq/frontends/_exact.py +73 -0
  16. veriq_quantum-0.1.1/src/veriq/frontends/cirq_frontend.py +205 -0
  17. veriq_quantum-0.1.1/src/veriq/frontends/tket_frontend.py +189 -0
  18. veriq_quantum-0.1.1/src/veriq/loader.py +122 -0
  19. veriq_quantum-0.1.1/src/veriq/mcp_server.py +794 -0
  20. veriq_quantum-0.1.1/src/veriq/models.py +64 -0
  21. veriq_quantum-0.1.1/src/veriq/optimize.py +245 -0
  22. veriq_quantum-0.1.1/src/veriq/preflight.py +680 -0
  23. veriq_quantum-0.1.1/src/veriq/profiles/braket_superconducting_style_12q.json +18 -0
  24. veriq_quantum-0.1.1/src/veriq/profiles/ionq_style_25q.json +19 -0
  25. veriq_quantum-0.1.1/src/veriq/profiles/quantinuum_style_20q.json +19 -0
  26. veriq_quantum-0.1.1/src/veriq/pytest_plugin.py +43 -0
  27. veriq_quantum-0.1.1/src/veriq/repair.py +223 -0
  28. veriq_quantum-0.1.1/src/veriq/repair_report.py +477 -0
  29. veriq_quantum-0.1.1/src/veriq/report.py +157 -0
  30. veriq_quantum-0.1.1/src/veriq/runner.py +122 -0
  31. veriq_quantum-0.1.1/src/veriq/sandbox.py +228 -0
  32. veriq_quantum-0.1.1/src/veriq/scale.py +608 -0
  33. veriq_quantum-0.1.1/src/veriq/testing.py +134 -0
  34. veriq_quantum-0.1.1/src/veriq/tools.py +408 -0
  35. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/PKG-INFO +107 -0
  36. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/SOURCES.txt +60 -0
  37. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/dependency_links.txt +1 -0
  38. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/entry_points.txt +6 -0
  39. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/requires.txt +40 -0
  40. veriq_quantum-0.1.1/src/veriq_quantum.egg-info/top_level.txt +1 -0
  41. veriq_quantum-0.1.1/tests/test_bench.py +237 -0
  42. veriq_quantum-0.1.1/tests/test_benchmark_references.py +18 -0
  43. veriq_quantum-0.1.1/tests/test_certificate.py +359 -0
  44. veriq_quantum-0.1.1/tests/test_checks.py +81 -0
  45. veriq_quantum-0.1.1/tests/test_ci.py +332 -0
  46. veriq_quantum-0.1.1/tests/test_demo_gif.py +43 -0
  47. veriq_quantum-0.1.1/tests/test_examples.py +55 -0
  48. veriq_quantum-0.1.1/tests/test_frontends.py +216 -0
  49. veriq_quantum-0.1.1/tests/test_hard_benchmark.py +251 -0
  50. veriq_quantum-0.1.1/tests/test_loader.py +29 -0
  51. veriq_quantum-0.1.1/tests/test_mcp_server.py +293 -0
  52. veriq_quantum-0.1.1/tests/test_mcp_tools.py +137 -0
  53. veriq_quantum-0.1.1/tests/test_optimize.py +66 -0
  54. veriq_quantum-0.1.1/tests/test_preflight.py +261 -0
  55. veriq_quantum-0.1.1/tests/test_pytest_plugin.py +127 -0
  56. veriq_quantum-0.1.1/tests/test_real_bugs_tools.py +76 -0
  57. veriq_quantum-0.1.1/tests/test_repair_loop.py +111 -0
  58. veriq_quantum-0.1.1/tests/test_repair_report.py +159 -0
  59. veriq_quantum-0.1.1/tests/test_sandbox.py +118 -0
  60. veriq_quantum-0.1.1/tests/test_scale.py +159 -0
  61. veriq_quantum-0.1.1/tests/test_transpile_hazard.py +94 -0
  62. veriq_quantum-0.1.1/tests/test_week2.py +137 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://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
+ http://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,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: veriq-quantum
3
+ Version: 0.1.1
4
+ Summary: A neutral truth layer for AI-written quantum code: formal equivalence, transpile integrity and statistical checks.
5
+ Author: Yosef Noorani
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Yosefnoorani/veriq
8
+ Project-URL: Source, https://github.com/Yosefnoorani/veriq
9
+ Project-URL: Issues, https://github.com/Yosefnoorani/veriq/issues
10
+ Project-URL: Documentation, https://github.com/Yosefnoorani/veriq/tree/main/docs
11
+ Keywords: quantum,qiskit,verification,equivalence-checking,llm,ai-generated-code,pytest
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Framework :: Pytest
22
+ Classifier: Topic :: Scientific/Engineering :: Physics
23
+ Classifier: Topic :: Software Development :: Testing
24
+ Classifier: Topic :: Software Development :: Quality Assurance
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: qiskit<3,>=2.6.1
29
+ Requires-Dist: qiskit-aer>=0.18.2
30
+ Requires-Dist: mqt.qcec<4,>=3.11
31
+ Requires-Dist: qiskit-qasm3-import>=0.6
32
+ Requires-Dist: scipy>=1.11
33
+ Requires-Dist: numpy>=1.26
34
+ Requires-Dist: pyyaml>=6
35
+ Requires-Dist: cryptography>=42
36
+ Provides-Extra: mcp
37
+ Requires-Dist: mcp<3,>=2.3; extra == "mcp"
38
+ Provides-Extra: scale
39
+ Requires-Dist: matplotlib>=3.8; extra == "scale"
40
+ Requires-Dist: psutil>=5.9; extra == "scale"
41
+ Provides-Extra: preflight
42
+ Requires-Dist: qiskit-ibm-runtime==0.51.0; extra == "preflight"
43
+ Provides-Extra: cirq
44
+ Requires-Dist: cirq-core>=1.4; extra == "cirq"
45
+ Requires-Dist: ply>=3.11; extra == "cirq"
46
+ Provides-Extra: tket
47
+ Requires-Dist: pytket>=2.0; extra == "tket"
48
+ Requires-Dist: pytket-qiskit>=0.70; extra == "tket"
49
+ Provides-Extra: qasm3
50
+ Requires-Dist: qiskit-qasm3-import>=0.6; extra == "qasm3"
51
+ Provides-Extra: dev
52
+ Requires-Dist: pytest>=8; extra == "dev"
53
+ Requires-Dist: mcp<3,>=2.3; extra == "dev"
54
+ Requires-Dist: matplotlib>=3.8; extra == "dev"
55
+ Requires-Dist: psutil>=5.9; extra == "dev"
56
+ Requires-Dist: qiskit-ibm-runtime==0.51.0; extra == "dev"
57
+ Requires-Dist: cirq-core>=1.4; extra == "dev"
58
+ Requires-Dist: pytket>=2.0; extra == "dev"
59
+ Requires-Dist: pytket-qiskit>=0.70; extra == "dev"
60
+ Requires-Dist: pillow>=10; extra == "dev"
61
+ Dynamic: license-file
62
+
63
+ # Veriq — a truth layer for AI-written quantum code
64
+
65
+ ![Veriq demo: a compiled circuit passes the histogram test, Veriq proves it wrong with a counterexample and a bug region](https://raw.githubusercontent.com/Yosefnoorani/veriq/main/docs/assets/veriq_demo.gif)
66
+
67
+ **Tests and histograms say "looks right". Veriq proves whether a quantum circuit *is* right and, when it isn't, shows the input that breaks it.**
68
+
69
+ | | |
70
+ |---|---|
71
+ | **2.7% – 5.4%** | of published model solutions that **pass their benchmark's own tests are provably wrong** (7 strict, 14 counting gates wrong only on superposed inputs, of 257 passing QuanBench solutions from GPT-4.1 and GPT-4o; manually reviewed; a lower bound). [Study →](https://github.com/Yosefnoorani/veriq/blob/main/benchmark/real_bugs/README.md) |
72
+ | **34% vs 100%** | of 966 injected bugs caught by the usual Aer histogram from \|0…0⟩, vs. by Veriq's equivalence proof (0/98 false positives). [Veriq Bench →](https://github.com/Yosefnoorani/veriq/blob/main/benchmark/veriqbench/leaderboard/leaderboard.md) |
73
+ | **5 of 28** | correct LLM circuits whose *default* Qiskit compile is no longer the same unitary (the `qubits_initially_zero` hazard); only a unitary proof sees it. [Example →](https://github.com/Yosefnoorani/veriq/blob/main/examples/transpile_hazard/README.md) |
74
+
75
+ ## Install
76
+
77
+ ```bash
78
+ pip install veriq-quantum # import name and CLI: veriq (Python 3.10+)
79
+ # until the first PyPI release: pip install "git+https://github.com/Yosefnoorani/veriq"
80
+ ```
81
+
82
+ ## Quickstart
83
+
84
+ ```bash
85
+ veriq check candidate.py -r reference.py # PASS / FAIL / INCONCLUSIVE (exit 0 / 1 / 2)
86
+ veriq check compiled.py -r block.py --repair-report bug.json # FAIL -> counterexample + bug region + fix
87
+ veriq check ghz.py -r ghz_ref.py --mode state # compare states from |0...0> instead of unitaries
88
+ veriq optimize my_circuit.py -o best.qasm # fewer CX, proven equivalent
89
+ veriq mcp # let your AI assistant verify before it answers
90
+ ```
91
+
92
+ ## Features
93
+
94
+ - **Formal equivalence** (MQT QCEC, exact operator, Clifford tableaux) with a concrete counterexample input, plus transpile integrity and statistical tests: [usage](https://github.com/Yosefnoorani/veriq/blob/main/docs/usage.md)
95
+ - **pytest plugin**: the `veriq_equiv` fixture and `assert_equivalent(a, b)`: [docs/pytest.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/pytest.md)
96
+ - **CI**: a GitHub Action with a sticky PR comment, and `veriq ci`: [docs/ci.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/ci.md)
97
+ - **MCP server** for Claude Desktop, Cursor and other MCP clients (sandboxed): [docs/mcp.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/mcp.md)
98
+ - **Repair**: bug localization and a bounded verify → fix loop: [docs/repair.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/repair.md)
99
+ - **Verified optimization**: the cheapest compilation, proven equal: [docs/optimize.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/optimize.md)
100
+ - **Hardware preflight**: go / warn / no-go before you submit: [docs/preflight.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/preflight.md)
101
+ - **Large circuits** (20–50+ qubits): [docs/large-circuits.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/large-circuits.md)
102
+ - **OpenQASM 3, Cirq and TKET** front-ends: [docs/frameworks.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/frameworks.md)
103
+ - **Signed certificates** (Ed25519): [docs/certificates.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/certificates.md)
104
+ - **Benchmarks**: Veriq Bench, the hard round, real bugs: [docs/benchmarks.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/benchmarks.md)
105
+ - Limitations and roadmap: [docs/limitations.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/limitations.md). Releasing: [docs/release.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/release.md)
106
+
107
+ Apache-2.0
@@ -0,0 +1,45 @@
1
+ # Veriq — a truth layer for AI-written quantum code
2
+
3
+ ![Veriq demo: a compiled circuit passes the histogram test, Veriq proves it wrong with a counterexample and a bug region](https://raw.githubusercontent.com/Yosefnoorani/veriq/main/docs/assets/veriq_demo.gif)
4
+
5
+ **Tests and histograms say "looks right". Veriq proves whether a quantum circuit *is* right and, when it isn't, shows the input that breaks it.**
6
+
7
+ | | |
8
+ |---|---|
9
+ | **2.7% – 5.4%** | of published model solutions that **pass their benchmark's own tests are provably wrong** (7 strict, 14 counting gates wrong only on superposed inputs, of 257 passing QuanBench solutions from GPT-4.1 and GPT-4o; manually reviewed; a lower bound). [Study →](https://github.com/Yosefnoorani/veriq/blob/main/benchmark/real_bugs/README.md) |
10
+ | **34% vs 100%** | of 966 injected bugs caught by the usual Aer histogram from \|0…0⟩, vs. by Veriq's equivalence proof (0/98 false positives). [Veriq Bench →](https://github.com/Yosefnoorani/veriq/blob/main/benchmark/veriqbench/leaderboard/leaderboard.md) |
11
+ | **5 of 28** | correct LLM circuits whose *default* Qiskit compile is no longer the same unitary (the `qubits_initially_zero` hazard); only a unitary proof sees it. [Example →](https://github.com/Yosefnoorani/veriq/blob/main/examples/transpile_hazard/README.md) |
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install veriq-quantum # import name and CLI: veriq (Python 3.10+)
17
+ # until the first PyPI release: pip install "git+https://github.com/Yosefnoorani/veriq"
18
+ ```
19
+
20
+ ## Quickstart
21
+
22
+ ```bash
23
+ veriq check candidate.py -r reference.py # PASS / FAIL / INCONCLUSIVE (exit 0 / 1 / 2)
24
+ veriq check compiled.py -r block.py --repair-report bug.json # FAIL -> counterexample + bug region + fix
25
+ veriq check ghz.py -r ghz_ref.py --mode state # compare states from |0...0> instead of unitaries
26
+ veriq optimize my_circuit.py -o best.qasm # fewer CX, proven equivalent
27
+ veriq mcp # let your AI assistant verify before it answers
28
+ ```
29
+
30
+ ## Features
31
+
32
+ - **Formal equivalence** (MQT QCEC, exact operator, Clifford tableaux) with a concrete counterexample input, plus transpile integrity and statistical tests: [usage](https://github.com/Yosefnoorani/veriq/blob/main/docs/usage.md)
33
+ - **pytest plugin**: the `veriq_equiv` fixture and `assert_equivalent(a, b)`: [docs/pytest.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/pytest.md)
34
+ - **CI**: a GitHub Action with a sticky PR comment, and `veriq ci`: [docs/ci.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/ci.md)
35
+ - **MCP server** for Claude Desktop, Cursor and other MCP clients (sandboxed): [docs/mcp.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/mcp.md)
36
+ - **Repair**: bug localization and a bounded verify → fix loop: [docs/repair.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/repair.md)
37
+ - **Verified optimization**: the cheapest compilation, proven equal: [docs/optimize.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/optimize.md)
38
+ - **Hardware preflight**: go / warn / no-go before you submit: [docs/preflight.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/preflight.md)
39
+ - **Large circuits** (20–50+ qubits): [docs/large-circuits.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/large-circuits.md)
40
+ - **OpenQASM 3, Cirq and TKET** front-ends: [docs/frameworks.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/frameworks.md)
41
+ - **Signed certificates** (Ed25519): [docs/certificates.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/certificates.md)
42
+ - **Benchmarks**: Veriq Bench, the hard round, real bugs: [docs/benchmarks.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/benchmarks.md)
43
+ - Limitations and roadmap: [docs/limitations.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/limitations.md). Releasing: [docs/release.md](https://github.com/Yosefnoorani/veriq/blob/main/docs/release.md)
44
+
45
+ Apache-2.0
@@ -0,0 +1,75 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "veriq-quantum"
7
+ dynamic = ["version"]
8
+ description = "A neutral truth layer for AI-written quantum code: formal equivalence, transpile integrity and statistical checks."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Yosef Noorani" }]
14
+ keywords = ["quantum", "qiskit", "verification", "equivalence-checking", "llm", "ai-generated-code", "pytest"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Science/Research",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Framework :: Pytest",
26
+ "Topic :: Scientific/Engineering :: Physics",
27
+ "Topic :: Software Development :: Testing",
28
+ "Topic :: Software Development :: Quality Assurance",
29
+ ]
30
+ dependencies = [
31
+ "qiskit>=2.6.1,<3",
32
+ "qiskit-aer>=0.18.2",
33
+ "mqt.qcec>=3.11,<4",
34
+ "qiskit-qasm3-import>=0.6",
35
+ "scipy>=1.11",
36
+ "numpy>=1.26",
37
+ "pyyaml>=6",
38
+ "cryptography>=42",
39
+ ]
40
+
41
+ [project.optional-dependencies]
42
+ mcp = ["mcp>=2.3,<3"]
43
+ scale = ["matplotlib>=3.8", "psutil>=5.9"]
44
+ preflight = ["qiskit-ibm-runtime==0.51.0"]
45
+ cirq = ["cirq-core>=1.4", "ply>=3.11"] # ply: cirq.contrib.qasm_import
46
+ tket = ["pytket>=2.0", "pytket-qiskit>=0.70"]
47
+ qasm3 = ["qiskit-qasm3-import>=0.6"]
48
+ dev = ["pytest>=8", "mcp>=2.3,<3", "matplotlib>=3.8", "psutil>=5.9", "qiskit-ibm-runtime==0.51.0",
49
+ "cirq-core>=1.4", "pytket>=2.0", "pytket-qiskit>=0.70", "pillow>=10"] # pillow: demo/render_demo.py
50
+
51
+ [project.urls]
52
+ Homepage = "https://github.com/Yosefnoorani/veriq"
53
+ Source = "https://github.com/Yosefnoorani/veriq"
54
+ Issues = "https://github.com/Yosefnoorani/veriq/issues"
55
+ Documentation = "https://github.com/Yosefnoorani/veriq/tree/main/docs"
56
+
57
+ [project.entry-points.pytest11]
58
+ veriq = "veriq.pytest_plugin"
59
+
60
+ [project.scripts]
61
+ veriq = "veriq.cli:main"
62
+ veriq-mcp = "veriq.mcp_server:main"
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["src"]
66
+
67
+ [tool.setuptools.dynamic]
68
+ version = { attr = "veriq.__version__" }
69
+
70
+ [tool.setuptools.package-data]
71
+ veriq = ["profiles/*.json"]
72
+
73
+ [tool.pytest.ini_options]
74
+ testpaths = ["tests"]
75
+ markers = ["slow: long-running scale tests (deselect with -m 'not slow')"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,8 @@
1
+ """Veriq: a neutral truth layer for AI-written quantum code."""
2
+
3
+ from .models import CheckResult, Report, Status
4
+ from .loader import load_circuit
5
+ from .runner import run_checks
6
+
7
+ __all__ = ["CheckResult", "Report", "Status", "load_circuit", "run_checks"]
8
+ __version__ = "0.1.1"
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ sys.exit(main())
@@ -0,0 +1,117 @@
1
+ """Sandbox worker: `python -I -m veriq._sandbox_worker` reads one JSON job on stdin, prints one JSON line.
2
+
3
+ Jobs:
4
+ {"op": "build", "source": {"code"|"path", "function", "language", "framework"}, "workdir": ...}
5
+ Runs UNTRUSTED code; returns the circuit as base64 QPY (or a build/load error).
6
+ {"op": "analyze", "tool": "...", "circuits": {"candidate": qpy, "reference": qpy?}, "options": {...}}
7
+ Runs only Veriq code on deserialized circuits.
8
+ Never imported by the server process.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import base64
14
+ import io
15
+ import json
16
+ import os
17
+ import sys
18
+
19
+
20
+ def _block_network() -> None:
21
+ import socket
22
+
23
+ class _NoNet(socket.socket):
24
+ def __init__(self, *a, **k):
25
+ raise PermissionError("network access is disabled in the Veriq sandbox")
26
+
27
+ def _deny(*a, **k):
28
+ raise PermissionError("network access is disabled in the Veriq sandbox")
29
+
30
+ socket.socket = _NoNet # type: ignore[misc]
31
+ socket.create_connection = _deny # type: ignore[assignment]
32
+ socket.getaddrinfo = _deny # type: ignore[assignment]
33
+
34
+
35
+ def _qpy_dump(qc) -> str:
36
+ from qiskit import qpy
37
+
38
+ buf = io.BytesIO()
39
+ qpy.dump(qc, buf)
40
+ return base64.b64encode(buf.getvalue()).decode()
41
+
42
+
43
+ def _qpy_load(s: str):
44
+ from qiskit import qpy
45
+
46
+ return qpy.load(io.BytesIO(base64.b64decode(s)))[0]
47
+
48
+
49
+ def _build(job: dict) -> dict:
50
+ from veriq.loader import BuildError, LoadError, load_circuit
51
+
52
+ src = job["source"]
53
+ workdir = job["workdir"]
54
+ if "code" in src:
55
+ lang = src.get("language") or "auto"
56
+ code = src["code"]
57
+ if lang == "auto":
58
+ head = code.lstrip()
59
+ lang = ("qasm" if head.upper().startswith("OPENQASM") else "json" if head.startswith("{")
60
+ else "python")
61
+ fname = {"python": "candidate.py", "qasm": "candidate.qasm", "json": "candidate.json"}[lang]
62
+ path = os.path.join(workdir, src.get("filename") or fname)
63
+ with open(path, "w") as fh:
64
+ fh.write(code)
65
+ else:
66
+ path = src["path"]
67
+ captured = io.StringIO()
68
+ real_stdout = sys.stdout
69
+ sys.stdout = captured # user prints must not corrupt the protocol line
70
+ try:
71
+ qc = load_circuit(path, src.get("function"), src.get("framework"))
72
+ except BuildError as exc:
73
+ return {"status": "build_error", "error_type": exc.error_type, "exception": exc.exc_type,
74
+ "message": str(exc)[:2000], "stdout": captured.getvalue()[-2000:]}
75
+ except LoadError as exc:
76
+ return {"status": "load_error", "message": str(exc)[:2000]}
77
+ finally:
78
+ sys.stdout = real_stdout
79
+ try:
80
+ blob = _qpy_dump(qc)
81
+ except Exception as exc:
82
+ return {"status": "build_error", "error_type": "not serializable", "exception": type(exc).__name__,
83
+ "message": f"circuit cannot be serialized to QPY: {exc!r}"[:2000]}
84
+ return {"status": "ok", "qpy": blob, "name": qc.name, "num_qubits": qc.num_qubits,
85
+ "frontend": (qc.metadata or {}).get("veriq_frontend", {}).get("framework", "qiskit"),
86
+ "stdout": captured.getvalue()[-2000:]}
87
+
88
+
89
+ def _analyze(job: dict) -> dict:
90
+ from veriq import tools
91
+
92
+ circs = {k: (_qpy_load(v) if v else None) for k, v in job["circuits"].items()}
93
+ max_q = int(job.get("max_qubits", 50))
94
+ for k, qc in circs.items():
95
+ if qc is not None and qc.num_qubits > max_q:
96
+ return {"status": "limit", "message": f"{k} has {qc.num_qubits} qubits; this server allows {max_q}"}
97
+ fn = getattr(tools, job["tool"])
98
+ return {"status": "ok", "result": fn(**circs, **job.get("options", {}))}
99
+
100
+
101
+ def main() -> None:
102
+ job = json.loads(sys.stdin.read())
103
+ out_fd = os.dup(1)
104
+ os.dup2(2, 1) # anything written to fd 1 by native code or user code goes to stderr
105
+ _block_network()
106
+ if job["op"] == "build":
107
+ res = _build(job)
108
+ elif job["op"] == "analyze":
109
+ res = _analyze(job)
110
+ else:
111
+ res = {"status": "protocol", "message": f"unknown op {job['op']!r}"}
112
+ with os.fdopen(out_fd, "w") as fh:
113
+ fh.write("\n" + json.dumps(res, default=str) + "\n")
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()