stabcert 0.1.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.
- stabcert-0.1.0/LICENSE +202 -0
- stabcert-0.1.0/PKG-INFO +138 -0
- stabcert-0.1.0/README.md +112 -0
- stabcert-0.1.0/hayden_preskill_toy/__init__.py +1 -0
- stabcert-0.1.0/hayden_preskill_toy/channels.py +137 -0
- stabcert-0.1.0/hayden_preskill_toy/dense_free_pipeline.py +128 -0
- stabcert-0.1.0/hayden_preskill_toy/experiment.py +242 -0
- stabcert-0.1.0/hayden_preskill_toy/gf2.py +244 -0
- stabcert-0.1.0/hayden_preskill_toy/layout.py +50 -0
- stabcert-0.1.0/hayden_preskill_toy/local.py +99 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_architecture_routing.py +328 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_certificate.py +380 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_channels.py +106 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_chi_correlations.py +153 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_graph_routing.py +224 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_petz.py +86 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_petz_stabilizer.py +130 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_routing.py +95 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_stabilizer.py +52 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_synthesis.py +185 -0
- stabcert-0.1.0/hayden_preskill_toy/parametric_validation.py +103 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_adversarial.py +668 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_artifact.py +163 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_cli.py +353 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_compile.py +370 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_exit_codes.py +13 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_hayden_preskill_adapter.py +94 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_problem.py +208 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_pytket.py +188 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_routing.py +230 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_run_report.py +94 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_sabre.py +206 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_serialization.py +337 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_stabilizer.py +478 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_verifier_cli.py +178 -0
- stabcert-0.1.0/hayden_preskill_toy/recovery_verify.py +484 -0
- stabcert-0.1.0/hayden_preskill_toy/simulator.py +77 -0
- stabcert-0.1.0/hayden_preskill_toy/stabilizer.py +133 -0
- stabcert-0.1.0/hayden_preskill_toy/support_code.py +279 -0
- stabcert-0.1.0/pyproject.toml +45 -0
- stabcert-0.1.0/schemas/recovery_artifact.schema.json +85 -0
- stabcert-0.1.0/schemas/recovery_problem.schema.json +111 -0
- stabcert-0.1.0/schemas/recovery_run_report.schema.json +52 -0
- stabcert-0.1.0/setup.cfg +4 -0
- stabcert-0.1.0/stabcert.egg-info/PKG-INFO +138 -0
- stabcert-0.1.0/stabcert.egg-info/SOURCES.txt +95 -0
- stabcert-0.1.0/stabcert.egg-info/dependency_links.txt +1 -0
- stabcert-0.1.0/stabcert.egg-info/entry_points.txt +2 -0
- stabcert-0.1.0/stabcert.egg-info/requires.txt +12 -0
- stabcert-0.1.0/stabcert.egg-info/top_level.txt +1 -0
- stabcert-0.1.0/tests/test_a4_collective_preflight.py +46 -0
- stabcert-0.1.0/tests/test_a5_collective_preflight.py +26 -0
- stabcert-0.1.0/tests/test_a5_structural_retry.py +23 -0
- stabcert-0.1.0/tests/test_a6_structural_preflight.py +46 -0
- stabcert-0.1.0/tests/test_a7_structural_preflight.py +54 -0
- stabcert-0.1.0/tests/test_a8_structural_preflight.py +65 -0
- stabcert-0.1.0/tests/test_a9_a12_structural_preflights.py +53 -0
- stabcert-0.1.0/tests/test_certified_import_closure.py +82 -0
- stabcert-0.1.0/tests/test_channel_certified_adversarial.py +17 -0
- stabcert-0.1.0/tests/test_channel_certified_mode.py +220 -0
- stabcert-0.1.0/tests/test_choi_symplectic_conventions.py +10 -0
- stabcert-0.1.0/tests/test_collective_two_qubit_channel.py +33 -0
- stabcert-0.1.0/tests/test_collective_two_qubit_experiment.py +32 -0
- stabcert-0.1.0/tests/test_compact_parametric_channel.py +25 -0
- stabcert-0.1.0/tests/test_dense_free_chain_regression.py +58 -0
- stabcert-0.1.0/tests/test_geometry_routing_comparison.py +51 -0
- stabcert-0.1.0/tests/test_layout_parametric_channel.py +14 -0
- stabcert-0.1.0/tests/test_layout_parametric_petz.py +28 -0
- stabcert-0.1.0/tests/test_layout_parametric_stabilizer.py +15 -0
- stabcert-0.1.0/tests/test_long_symbolic_transmission.py +36 -0
- stabcert-0.1.0/tests/test_orelia_symbolic.py +9 -0
- stabcert-0.1.0/tests/test_parametric_architecture_routing.py +48 -0
- stabcert-0.1.0/tests/test_parametric_chi_no_csv.py +14 -0
- stabcert-0.1.0/tests/test_parametric_graph_routing.py +27 -0
- stabcert-0.1.0/tests/test_parametric_operator_validation.py +13 -0
- stabcert-0.1.0/tests/test_parametric_routing_regression.py +20 -0
- stabcert-0.1.0/tests/test_parametric_routing_unit.py +16 -0
- stabcert-0.1.0/tests/test_parametric_scrambler.py +13 -0
- stabcert-0.1.0/tests/test_parametric_synthesis_in_memory.py +13 -0
- stabcert-0.1.0/tests/test_parametric_synthesis_regression.py +24 -0
- stabcert-0.1.0/tests/test_pytket_channel_certified.py +95 -0
- stabcert-0.1.0/tests/test_recovery_cli.py +91 -0
- stabcert-0.1.0/tests/test_recovery_core_fixtures.py +71 -0
- stabcert-0.1.0/tests/test_recovery_core_hermetic.py +89 -0
- stabcert-0.1.0/tests/test_recovery_core_models.py +84 -0
- stabcert-0.1.0/tests/test_routing_geometry_audit.py +82 -0
- stabcert-0.1.0/tests/test_routing_geometry_multiseed.py +71 -0
- stabcert-0.1.0/tests/test_sabre_channel_certified.py +89 -0
- stabcert-0.1.0/tests/test_signed_petz_t2_dilation.py +9 -0
- stabcert-0.1.0/tests/test_signed_support_alignment.py +8 -0
- stabcert-0.1.0/tests/test_simulator.py +101 -0
- stabcert-0.1.0/tests/test_stabilizer_state_fidelity.py +16 -0
- stabcert-0.1.0/tests/test_statefree_validation_regression_results.py +18 -0
- stabcert-0.1.0/tests/test_structural_certification.py +68 -0
- stabcert-0.1.0/tests/test_three_qubit_preflight.py +37 -0
- stabcert-0.1.0/tests/test_verifier_adversarial_validation.py +60 -0
- stabcert-0.1.0/tests/test_verifier_only_package.py +89 -0
stabcert-0.1.0/LICENSE
ADDED
|
@@ -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 2026 Frédéric Kramarczyk
|
|
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.
|
stabcert-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stabcert
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sound and complete translation validation for stabilizer channels
|
|
5
|
+
Author-email: Frédéric Kramarczyk <fkra62@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/KRAMARCZYK62750/stabcert
|
|
8
|
+
Keywords: quantum,stabilizer,verification,compilation,clifford
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.24
|
|
17
|
+
Requires-Dist: matplotlib>=3.7
|
|
18
|
+
Requires-Dist: stim>=1.13
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
21
|
+
Provides-Extra: sabre
|
|
22
|
+
Requires-Dist: qiskit<3,>=2.1; extra == "sabre"
|
|
23
|
+
Provides-Extra: pytket
|
|
24
|
+
Requires-Dist: pytket<3,>=2.18; extra == "pytket"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
# StabCert
|
|
28
|
+
|
|
29
|
+
Sound and complete translation validation for stabilizer channels.
|
|
30
|
+
|
|
31
|
+
Quantum compilers rewrite circuits to fit hardware connectivity constraints.
|
|
32
|
+
StabCert checks, exactly, that the rewritten circuit still implements the
|
|
33
|
+
intended channel — treating the compiler as an untrusted black box.
|
|
34
|
+
|
|
35
|
+
## What it does
|
|
36
|
+
|
|
37
|
+
Given a target channel and a circuit produced by any compiler, StabCert
|
|
38
|
+
decides whether they are equal on the specified input subspace.
|
|
39
|
+
|
|
40
|
+
- **Sound and complete.** No false accepts, no false rejects.
|
|
41
|
+
- **Polynomial time.** No dense matrices, no enumeration of basis states.
|
|
42
|
+
- **Compiler-agnostic.** Validated against Qiskit SABRE and pytket; the
|
|
43
|
+
compiler's internals are never inspected.
|
|
44
|
+
- **Gauge-invariant.** The verdict does not depend on the compiler's ancilla
|
|
45
|
+
or Stinespring conventions.
|
|
46
|
+
|
|
47
|
+
The decision procedure compares canonical signed code-Choi tableaus. Two
|
|
48
|
+
stabilizer channels are equal on the code subspace if and only if their
|
|
49
|
+
canonical forms coincide.
|
|
50
|
+
|
|
51
|
+
Topological conformance is checked separately: every two-qubit gate in the
|
|
52
|
+
routed circuit is verified against the coupling map.
|
|
53
|
+
|
|
54
|
+
### Verified core
|
|
55
|
+
|
|
56
|
+
The certified path — compiler, verifier, and command line — is a closed
|
|
57
|
+
import closure of eleven modules, computed by AST traversal and enforced by
|
|
58
|
+
the test suite; the verifier alone reaches eight. No module in that closure
|
|
59
|
+
enumerates basis states or constructs dense matrices.
|
|
60
|
+
|
|
61
|
+
The distribution also ships exploratory and instance-construction code
|
|
62
|
+
outside this closure — including a dense stabilizer-group enumeration —
|
|
63
|
+
which no verification path can reach. The closure test fails if that
|
|
64
|
+
changes.
|
|
65
|
+
|
|
66
|
+
## Scope
|
|
67
|
+
|
|
68
|
+
StabCert applies to **stabilizer channels**: Clifford unitaries, stabilizer
|
|
69
|
+
ancilla preparation, partial trace, and Pauli corrections that are linear
|
|
70
|
+
functions of measurement outcomes.
|
|
71
|
+
|
|
72
|
+
Out of scope by construction: noise, calibration, real-time decoding, and
|
|
73
|
+
timing or scheduling constraints. These are physical and temporal properties
|
|
74
|
+
that a stabilizer Choi state does not express.
|
|
75
|
+
|
|
76
|
+
The current release verifies coherent isometric recovery circuits, which
|
|
77
|
+
contain no mid-circuit measurement. Circuits with genuine measurement
|
|
78
|
+
feed-forward are not yet covered.
|
|
79
|
+
|
|
80
|
+
## Install
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install stabcert
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Optional compiler backends:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install 'stabcert[sabre]' # Qiskit
|
|
90
|
+
pip install 'stabcert[pytket]' # pytket
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Usage
|
|
94
|
+
|
|
95
|
+
Compile a reference recovery artifact from a problem specification:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
stabcert compile problem.json --output artifact.json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Verify an untrusted artifact against the problem — this is the part that
|
|
102
|
+
does not trust the compiler:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
stabcert verify problem.json artifact.json --policy channel-certified
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Two policies are available:
|
|
109
|
+
|
|
110
|
+
- `channel-certified` accepts any synthesis, routing, or Stinespring gauge
|
|
111
|
+
whose canonical form matches the target. Use this for circuits produced by
|
|
112
|
+
third-party compilers.
|
|
113
|
+
- `reproducible-route` additionally requires bit-for-bit equality with the
|
|
114
|
+
reference route. Use this for regression testing.
|
|
115
|
+
|
|
116
|
+
Add `--run-report report.json` to record the verdict and measured resources.
|
|
117
|
+
|
|
118
|
+
Worked examples ship with the repository as `tests/fixtures/recovery_v1/`,
|
|
119
|
+
using the `<case>.problem.json` / `<case>.artifact.json` convention:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
stabcert verify tests/fixtures/recovery_v1/a1.problem.json \
|
|
123
|
+
tests/fixtures/recovery_v1/a1.artifact.json \
|
|
124
|
+
--policy channel-certified
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Status
|
|
128
|
+
|
|
129
|
+
Early release. The verification core is covered by a test suite and an
|
|
130
|
+
adversarial campaign (1300 invalid artifacts rejected, 700 valid
|
|
131
|
+
representations accepted, no false accepts or rejects).
|
|
132
|
+
|
|
133
|
+
Resource figures reported by the tool are measured, not certified: SWAP
|
|
134
|
+
attribution does not participate in any verdict.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
stabcert-0.1.0/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# StabCert
|
|
2
|
+
|
|
3
|
+
Sound and complete translation validation for stabilizer channels.
|
|
4
|
+
|
|
5
|
+
Quantum compilers rewrite circuits to fit hardware connectivity constraints.
|
|
6
|
+
StabCert checks, exactly, that the rewritten circuit still implements the
|
|
7
|
+
intended channel — treating the compiler as an untrusted black box.
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
Given a target channel and a circuit produced by any compiler, StabCert
|
|
12
|
+
decides whether they are equal on the specified input subspace.
|
|
13
|
+
|
|
14
|
+
- **Sound and complete.** No false accepts, no false rejects.
|
|
15
|
+
- **Polynomial time.** No dense matrices, no enumeration of basis states.
|
|
16
|
+
- **Compiler-agnostic.** Validated against Qiskit SABRE and pytket; the
|
|
17
|
+
compiler's internals are never inspected.
|
|
18
|
+
- **Gauge-invariant.** The verdict does not depend on the compiler's ancilla
|
|
19
|
+
or Stinespring conventions.
|
|
20
|
+
|
|
21
|
+
The decision procedure compares canonical signed code-Choi tableaus. Two
|
|
22
|
+
stabilizer channels are equal on the code subspace if and only if their
|
|
23
|
+
canonical forms coincide.
|
|
24
|
+
|
|
25
|
+
Topological conformance is checked separately: every two-qubit gate in the
|
|
26
|
+
routed circuit is verified against the coupling map.
|
|
27
|
+
|
|
28
|
+
### Verified core
|
|
29
|
+
|
|
30
|
+
The certified path — compiler, verifier, and command line — is a closed
|
|
31
|
+
import closure of eleven modules, computed by AST traversal and enforced by
|
|
32
|
+
the test suite; the verifier alone reaches eight. No module in that closure
|
|
33
|
+
enumerates basis states or constructs dense matrices.
|
|
34
|
+
|
|
35
|
+
The distribution also ships exploratory and instance-construction code
|
|
36
|
+
outside this closure — including a dense stabilizer-group enumeration —
|
|
37
|
+
which no verification path can reach. The closure test fails if that
|
|
38
|
+
changes.
|
|
39
|
+
|
|
40
|
+
## Scope
|
|
41
|
+
|
|
42
|
+
StabCert applies to **stabilizer channels**: Clifford unitaries, stabilizer
|
|
43
|
+
ancilla preparation, partial trace, and Pauli corrections that are linear
|
|
44
|
+
functions of measurement outcomes.
|
|
45
|
+
|
|
46
|
+
Out of scope by construction: noise, calibration, real-time decoding, and
|
|
47
|
+
timing or scheduling constraints. These are physical and temporal properties
|
|
48
|
+
that a stabilizer Choi state does not express.
|
|
49
|
+
|
|
50
|
+
The current release verifies coherent isometric recovery circuits, which
|
|
51
|
+
contain no mid-circuit measurement. Circuits with genuine measurement
|
|
52
|
+
feed-forward are not yet covered.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install stabcert
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Optional compiler backends:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install 'stabcert[sabre]' # Qiskit
|
|
64
|
+
pip install 'stabcert[pytket]' # pytket
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Usage
|
|
68
|
+
|
|
69
|
+
Compile a reference recovery artifact from a problem specification:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
stabcert compile problem.json --output artifact.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Verify an untrusted artifact against the problem — this is the part that
|
|
76
|
+
does not trust the compiler:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
stabcert verify problem.json artifact.json --policy channel-certified
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Two policies are available:
|
|
83
|
+
|
|
84
|
+
- `channel-certified` accepts any synthesis, routing, or Stinespring gauge
|
|
85
|
+
whose canonical form matches the target. Use this for circuits produced by
|
|
86
|
+
third-party compilers.
|
|
87
|
+
- `reproducible-route` additionally requires bit-for-bit equality with the
|
|
88
|
+
reference route. Use this for regression testing.
|
|
89
|
+
|
|
90
|
+
Add `--run-report report.json` to record the verdict and measured resources.
|
|
91
|
+
|
|
92
|
+
Worked examples ship with the repository as `tests/fixtures/recovery_v1/`,
|
|
93
|
+
using the `<case>.problem.json` / `<case>.artifact.json` convention:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
stabcert verify tests/fixtures/recovery_v1/a1.problem.json \
|
|
97
|
+
tests/fixtures/recovery_v1/a1.artifact.json \
|
|
98
|
+
--policy channel-certified
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Status
|
|
102
|
+
|
|
103
|
+
Early release. The verification core is covered by a test suite and an
|
|
104
|
+
adversarial campaign (1300 invalid artifacts rejected, 700 valid
|
|
105
|
+
representations accepted, no false accepts or rejects).
|
|
106
|
+
|
|
107
|
+
Resource figures reported by the tool are measured, not certified: SWAP
|
|
108
|
+
attribution does not participate in any verdict.
|
|
109
|
+
|
|
110
|
+
## License
|
|
111
|
+
|
|
112
|
+
Apache License 2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Exact finite-size Clifford-channel toy model; not a black-hole simulation."""
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Exact channel, decoupling, and Petz-recovery calculations for the toy model."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from .simulator import Gate, X, apply_1q, apply_circuit, bell_pair, zero_state
|
|
8
|
+
from .experiment import A, B, E, N_QUBITS, R, SCRAMBLED
|
|
9
|
+
|
|
10
|
+
PINV_RELATIVE_CUTOFF = 1e-12
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class ChannelData:
|
|
15
|
+
kraus: tuple[np.ndarray, ...]
|
|
16
|
+
output: tuple[int, ...]
|
|
17
|
+
complement: tuple[int, ...]
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def environment_state() -> np.ndarray:
|
|
21
|
+
"""|0>_R |0>_A and the fixed pure B--E environment."""
|
|
22
|
+
state = zero_state(N_QUBITS)
|
|
23
|
+
for b, e in zip(B, E):
|
|
24
|
+
state = bell_pair(state, b, e, N_QUBITS)
|
|
25
|
+
return state
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def channel_at_time(scrambler: list[Gate], t: int) -> ChannelData:
|
|
29
|
+
"""Kraus representation of N_t: A -> E+D(t), with C(t) traced out."""
|
|
30
|
+
output = (*E, *SCRAMBLED[:t])
|
|
31
|
+
complement = SCRAMBLED[t:]
|
|
32
|
+
states = []
|
|
33
|
+
base = environment_state()
|
|
34
|
+
for bit in range(2):
|
|
35
|
+
source = base if bit == 0 else apply_1q(base, X, A, N_QUBITS)
|
|
36
|
+
states.append(apply_circuit(source, scrambler, N_QUBITS))
|
|
37
|
+
matrices = []
|
|
38
|
+
for state in states:
|
|
39
|
+
tensor = state.reshape((2,) * N_QUBITS)[0] # R is fixed to |0> for the channel.
|
|
40
|
+
axes = tuple(q - 1 for q in (*output, *complement))
|
|
41
|
+
matrices.append(np.transpose(tensor, axes).reshape(2**len(output), 2**len(complement)))
|
|
42
|
+
kraus = tuple(np.stack([mat[:, c] for mat in matrices], axis=1) for c in range(2**len(complement)))
|
|
43
|
+
return ChannelData(kraus, output, complement)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def reduced_density(state: np.ndarray, keep: tuple[int, ...], n: int = N_QUBITS) -> np.ndarray:
|
|
47
|
+
rest = tuple(q for q in range(n) if q not in keep)
|
|
48
|
+
view = np.transpose(state.reshape((2,) * n), (*keep, *rest)).reshape(2**len(keep), -1)
|
|
49
|
+
return view @ view.conj().T
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def entropy(rho: np.ndarray) -> float:
|
|
53
|
+
vals = np.linalg.eigvalsh((rho + rho.conj().T) / 2)
|
|
54
|
+
vals = vals[vals > 1e-14]
|
|
55
|
+
return float(-np.sum(vals * np.log2(vals)))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def trace_distance(rho: np.ndarray, sigma: np.ndarray) -> float:
|
|
59
|
+
vals = np.linalg.eigvalsh((rho - sigma + (rho - sigma).conj().T) / 2)
|
|
60
|
+
return float(.5 * np.sum(np.abs(vals)))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def inverse_fractional_power(rho: np.ndarray, power: float, relative_cutoff: float = PINV_RELATIVE_CUTOFF) -> np.ndarray:
|
|
64
|
+
"""Moore--Penrose rho**power on supp(rho); zero on its kernel."""
|
|
65
|
+
vals, vectors = np.linalg.eigh((rho + rho.conj().T) / 2)
|
|
66
|
+
cutoff = relative_cutoff * max(float(vals.max()), 1.0)
|
|
67
|
+
keep = vals > cutoff
|
|
68
|
+
return (vectors[:, keep] * vals[keep] ** power) @ vectors[:, keep].conj().T
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def conditional_collision_entropy(rho_rc: np.ndarray, rho_c: np.ndarray, relative_cutoff: float = PINV_RELATIVE_CUTOFF) -> float:
|
|
72
|
+
"""Sandwiched conditional collision entropy.
|
|
73
|
+
|
|
74
|
+
H_2(R|C)=-log2 Tr[(I_R⊗rho_C^-1/4 rho_RC I_R⊗rho_C^-1/4)^2].
|
|
75
|
+
The inverse is the Moore--Penrose inverse restricted to supp(rho_C).
|
|
76
|
+
"""
|
|
77
|
+
dim_c = rho_c.shape[0]; dim_r = rho_rc.shape[0] // dim_c
|
|
78
|
+
factor = np.kron(np.eye(dim_r), inverse_fractional_power(rho_c, -.25, relative_cutoff))
|
|
79
|
+
sandwiched = factor @ rho_rc @ factor
|
|
80
|
+
collision = float(np.real(np.trace(sandwiched @ sandwiched)))
|
|
81
|
+
return float(-np.log2(collision))
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def decoupling_metrics(scrambled_state: np.ndarray, t: int, include_early_radiation: bool) -> dict[str, float]:
|
|
85
|
+
"""For E+D access use C; for D-only access use E+C as the inaccessible complement."""
|
|
86
|
+
complement = SCRAMBLED[t:]
|
|
87
|
+
inaccessible = complement if include_early_radiation else (*E, *complement)
|
|
88
|
+
rho_rc = reduced_density(scrambled_state, (R, *inaccessible))
|
|
89
|
+
rho_r = reduced_density(scrambled_state, (R,))
|
|
90
|
+
rho_c = reduced_density(scrambled_state, inaccessible) if inaccessible else np.ones((1, 1), complex)
|
|
91
|
+
mutual = entropy(rho_r) + entropy(rho_c) - entropy(rho_rc)
|
|
92
|
+
product = np.kron(rho_r, rho_c)
|
|
93
|
+
h2 = conditional_collision_entropy(rho_rc, rho_c)
|
|
94
|
+
eig_rc = np.linalg.eigvalsh((rho_rc + rho_rc.conj().T) / 2); eig_c = np.linalg.eigvalsh((rho_c + rho_c.conj().T) / 2)
|
|
95
|
+
nonzero_rc = eig_rc[eig_rc > 1e-12]; nonzero_c = eig_c[eig_c > 1e-12]
|
|
96
|
+
return {"mutual_information_bits": max(0.0, mutual), "trace_distance_product": trace_distance(rho_rc, product),
|
|
97
|
+
"conditional_collision_entropy_bits": h2, "rank_rho_RC": int(len(nonzero_rc)), "rank_rho_C": int(len(nonzero_c)),
|
|
98
|
+
"spectrum_rho_RC": ";".join(f"{x:.12g}" for x in nonzero_rc), "spectrum_rho_C": ";".join(f"{x:.12g}" for x in nonzero_c)}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def channel_validation(channel: ChannelData) -> dict[str, float | bool]:
|
|
102
|
+
complete = sum((k.conj().T @ k for k in channel.kraus), start=np.zeros((2, 2), complex))
|
|
103
|
+
# Complete positivity is constructive: rho -> sum_j K_j rho K_j^dagger.
|
|
104
|
+
return {"cp_by_kraus": True, "trace_preservation_error": float(np.linalg.norm(complete - np.eye(2))),
|
|
105
|
+
"minimum_completeness_eigenvalue": float(np.linalg.eigvalsh(complete).min())}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def apply_channel(channel: ChannelData, rho: np.ndarray) -> np.ndarray:
|
|
109
|
+
return sum((k @ rho @ k.conj().T for k in channel.kraus), start=np.zeros((2**len(channel.output),) * 2, complex))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def petz_recovery(channel: ChannelData, relative_cutoff: float = PINV_RELATIVE_CUTOFF) -> tuple[tuple[np.ndarray, ...], dict[str, float]]:
|
|
113
|
+
"""Transpose/Petz channel for sigma=I/2, using only the support of N(sigma)."""
|
|
114
|
+
stacked = np.concatenate(channel.kraus, axis=1) / np.sqrt(2)
|
|
115
|
+
u, s, _ = np.linalg.svd(stacked, full_matrices=False)
|
|
116
|
+
cutoff = relative_cutoff * (s[0] if len(s) else 1.0)
|
|
117
|
+
kept = s > cutoff
|
|
118
|
+
support = u[:, kept]
|
|
119
|
+
invsqrt = (support / s[kept]) @ support.conj().T
|
|
120
|
+
recovery = tuple((k.conj().T @ invsqrt) / np.sqrt(2) for k in channel.kraus)
|
|
121
|
+
support_projector = support @ support.conj().T
|
|
122
|
+
recovered_identity = sum((r.conj().T @ r for r in recovery), start=np.zeros_like(support_projector))
|
|
123
|
+
return recovery, {"support_dimension": int(kept.sum()), "support_cutoff": float(cutoff),
|
|
124
|
+
"output_dimension": int(2**len(channel.output)), "choi_dimension": int(2 * 2**len(channel.output)),
|
|
125
|
+
"support_trace_preservation_error": float(np.linalg.norm(recovered_identity - support_projector))}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def petz_entanglement_fidelity(channel: ChannelData) -> tuple[float, dict[str, float]]:
|
|
129
|
+
recovery, info = petz_recovery(channel)
|
|
130
|
+
fidelity = 0.0
|
|
131
|
+
# (I_R \otimes R o N)(Phi): each composite Kraus is L_j K_i.
|
|
132
|
+
bell = np.array([1, 0, 0, 1], dtype=complex) / np.sqrt(2)
|
|
133
|
+
for k in channel.kraus:
|
|
134
|
+
for r in recovery:
|
|
135
|
+
op = r @ k
|
|
136
|
+
fidelity += abs(np.vdot(bell, np.kron(np.eye(2), op) @ bell)) ** 2
|
|
137
|
+
return float(np.real(fidelity)), info
|