QuPRS 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.
- quprs-0.1.0/.github/workflows/python-publish.yml +47 -0
- quprs-0.1.0/.gitignore +33 -0
- quprs-0.1.0/LICENSE.md +10 -0
- quprs-0.1.0/MANIFEST.in +17 -0
- quprs-0.1.0/NOTICE.md +228 -0
- quprs-0.1.0/PKG-INFO +215 -0
- quprs-0.1.0/README.md +186 -0
- quprs-0.1.0/pyproject.toml +50 -0
- quprs-0.1.0/setup.cfg +4 -0
- quprs-0.1.0/src/QuPRS/__init__.py +12 -0
- quprs-0.1.0/src/QuPRS/_version.py +21 -0
- quprs-0.1.0/src/QuPRS/cache_manager/__init__.py +5 -0
- quprs-0.1.0/src/QuPRS/cache_manager/cache_decorator.py +18 -0
- quprs-0.1.0/src/QuPRS/cache_manager/global_cache_manager.py +24 -0
- quprs-0.1.0/src/QuPRS/config.py +14 -0
- quprs-0.1.0/src/QuPRS/interface/__init__.py +0 -0
- quprs-0.1.0/src/QuPRS/interface/gate_library.py +26 -0
- quprs-0.1.0/src/QuPRS/interface/load_qiskit.py +225 -0
- quprs-0.1.0/src/QuPRS/interface/ps2wmc.py +252 -0
- quprs-0.1.0/src/QuPRS/interface/qasm2qc.py +68 -0
- quprs-0.1.0/src/QuPRS/pathsum.py +664 -0
- quprs-0.1.0/src/QuPRS/utils/Qiskit_Circuit_Utils.py +471 -0
- quprs-0.1.0/src/QuPRS/utils/__init__.py +6 -0
- quprs-0.1.0/src/QuPRS/utils/gpmc +0 -0
- quprs-0.1.0/src/QuPRS/utils/reduction.py +104 -0
- quprs-0.1.0/src/QuPRS/utils/strategy.py +176 -0
- quprs-0.1.0/src/QuPRS/utils/util.py +184 -0
- quprs-0.1.0/src/QuPRS.egg-info/PKG-INFO +215 -0
- quprs-0.1.0/src/QuPRS.egg-info/SOURCES.txt +30 -0
- quprs-0.1.0/src/QuPRS.egg-info/dependency_links.txt +1 -0
- quprs-0.1.0/src/QuPRS.egg-info/requires.txt +8 -0
- quprs-0.1.0/src/QuPRS.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Publish to PyPI and Create Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*' # Only run when pushing tags like v1.0.0, v0.9.1
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build-and-publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write # Used to create GitHub Release
|
|
13
|
+
id-token: write # If you use OIDC, can be used instead of PyPI token (optional)
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check out the code
|
|
17
|
+
uses: actions/checkout@v3
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: '3.x'
|
|
23
|
+
|
|
24
|
+
- name: Install build tool
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install build
|
|
28
|
+
|
|
29
|
+
- name: Build the package
|
|
30
|
+
run: python -m build
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
34
|
+
with:
|
|
35
|
+
user: __token__
|
|
36
|
+
password: ${{ secrets.PYPI_API_TOKEN }} # Make sure PYPI_API_TOKEN is set in your repository secrets
|
|
37
|
+
|
|
38
|
+
- name: Create GitHub Release
|
|
39
|
+
uses: softprops/action-gh-release@v2
|
|
40
|
+
with:
|
|
41
|
+
tag_name: ${{ github.ref_name }}
|
|
42
|
+
name: Release ${{ github.ref_name }}
|
|
43
|
+
body: |
|
|
44
|
+
📦 Published version: `${{ github.ref_name }}`
|
|
45
|
+
✅ Auto-generated release from Git tag.
|
|
46
|
+
env:
|
|
47
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
quprs-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
*.pyd
|
|
5
|
+
|
|
6
|
+
# Build and distribution directories
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
wheels/
|
|
11
|
+
|
|
12
|
+
# Virtual environment directories
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# IDE and editor settings
|
|
18
|
+
.vscode/
|
|
19
|
+
.idea/
|
|
20
|
+
*.swp
|
|
21
|
+
*~
|
|
22
|
+
|
|
23
|
+
# OS generated files
|
|
24
|
+
.DS_Store
|
|
25
|
+
Thumbs.db
|
|
26
|
+
|
|
27
|
+
# Test and coverage reports
|
|
28
|
+
.pytest_cache/
|
|
29
|
+
.coverage
|
|
30
|
+
htmlcov/
|
|
31
|
+
|
|
32
|
+
# other
|
|
33
|
+
src/QuPRS/_version.py
|
quprs-0.1.0/LICENSE.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wei-Jia Huang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
10
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
quprs-0.1.0/MANIFEST.in
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# MANIFEST.in
|
|
2
|
+
|
|
3
|
+
prune benchmarks
|
|
4
|
+
prune Results
|
|
5
|
+
prune test
|
|
6
|
+
prune dist
|
|
7
|
+
prune *.egg-info
|
|
8
|
+
|
|
9
|
+
exclude *.ipynb
|
|
10
|
+
exclude *.cnf
|
|
11
|
+
exclude *.sh
|
|
12
|
+
exclude uv.lock
|
|
13
|
+
|
|
14
|
+
prune .git
|
|
15
|
+
global-exclude *.pyc
|
|
16
|
+
global-exclude __pycache__
|
|
17
|
+
global-exclude *.orig
|
quprs-0.1.0/NOTICE.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
This product includes software developed by third parties.
|
|
2
|
+
The following section details the licenses applicable to these components:
|
|
3
|
+
---
|
|
4
|
+
Component: `QuPRS/utils/gpmc`
|
|
5
|
+
|
|
6
|
+
Source: [https://git.trs.css.i.nagoya-u.ac.jp/k-hasimt/GPMC](https://git.trs.css.i.nagoya-u.ac.jp/k-hasimt/GPMC)
|
|
7
|
+
|
|
8
|
+
MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2020 Kenji Hashimoto
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
Component: functions (`random_circuit`, `random_clifford_T_circuit`) in (`QuPRS/utils/Qiskit_Circuit_Utils.py`)
|
|
22
|
+
|
|
23
|
+
Source: [https://github.com/Qiskit/qiskit/blob/main/qiskit/circuit/random/utils.py](https://github.com/Qiskit/qiskit/blob/main/qiskit/circuit/random/utils.py)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Copyright 2017 IBM and its contributors
|
|
27
|
+
|
|
28
|
+
Apache License
|
|
29
|
+
Version 2.0, January 2004
|
|
30
|
+
http://www.apache.org/licenses/
|
|
31
|
+
|
|
32
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
33
|
+
|
|
34
|
+
1. Definitions.
|
|
35
|
+
|
|
36
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
37
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
38
|
+
|
|
39
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
40
|
+
the copyright owner that is granting the License.
|
|
41
|
+
|
|
42
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
43
|
+
other entities that control, are controlled by, or are under common
|
|
44
|
+
control with that entity. For the purposes of this definition,
|
|
45
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
46
|
+
direction or management of such entity, whether by contract or
|
|
47
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
48
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
49
|
+
|
|
50
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
51
|
+
exercising permissions granted by this License.
|
|
52
|
+
|
|
53
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
54
|
+
including but not limited to software source code, documentation
|
|
55
|
+
source, and configuration files.
|
|
56
|
+
|
|
57
|
+
"Object" form shall mean any form resulting from mechanical
|
|
58
|
+
transformation or translation of a Source form, including but
|
|
59
|
+
not limited to compiled object code, generated documentation,
|
|
60
|
+
and conversions to other media types.
|
|
61
|
+
|
|
62
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
63
|
+
Object form, made available under the License, as indicated by a
|
|
64
|
+
copyright notice that is included in or attached to the work
|
|
65
|
+
(an example is provided in the Appendix below).
|
|
66
|
+
|
|
67
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
68
|
+
form, that is based on (or derived from) the Work and for which the
|
|
69
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
70
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
71
|
+
of this License, Derivative Works shall not include works that remain
|
|
72
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
73
|
+
the Work and Derivative Works thereof.
|
|
74
|
+
|
|
75
|
+
"Contribution" shall mean any work of authorship, including
|
|
76
|
+
the original version of the Work and any modifications or additions
|
|
77
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
78
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
79
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
80
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
81
|
+
means any form of electronic, verbal, or written communication sent
|
|
82
|
+
to the Licensor or its representatives, including but not limited to
|
|
83
|
+
communication on electronic mailing lists, source code control systems,
|
|
84
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
85
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
86
|
+
excluding communication that is conspicuously marked or otherwise
|
|
87
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
88
|
+
|
|
89
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
90
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
91
|
+
subsequently incorporated within the Work.
|
|
92
|
+
|
|
93
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
94
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
95
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
96
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
97
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
98
|
+
Work and such Derivative Works in Source or Object form.
|
|
99
|
+
|
|
100
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
101
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
102
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
103
|
+
(except as stated in this section) patent license to make, have made,
|
|
104
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
105
|
+
where such license applies only to those patent claims licensable
|
|
106
|
+
by such Contributor that are necessarily infringed by their
|
|
107
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
108
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
109
|
+
institute patent litigation against any entity (including a
|
|
110
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
111
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
112
|
+
or contributory patent infringement, then any patent licenses
|
|
113
|
+
granted to You under this License for that Work shall terminate
|
|
114
|
+
as of the date such litigation is filed.
|
|
115
|
+
|
|
116
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
117
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
118
|
+
modifications, and in Source or Object form, provided that You
|
|
119
|
+
meet the following conditions:
|
|
120
|
+
|
|
121
|
+
(a) You must give any other recipients of the Work or
|
|
122
|
+
Derivative Works a copy of this License; and
|
|
123
|
+
|
|
124
|
+
(b) You must cause any modified files to carry prominent notices
|
|
125
|
+
stating that You changed the files; and
|
|
126
|
+
|
|
127
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
128
|
+
that You distribute, all copyright, patent, trademark, and
|
|
129
|
+
attribution notices from the Source form of the Work,
|
|
130
|
+
excluding those notices that do not pertain to any part of
|
|
131
|
+
the Derivative Works; and
|
|
132
|
+
|
|
133
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
134
|
+
distribution, then any Derivative Works that You distribute must
|
|
135
|
+
include a readable copy of the attribution notices contained
|
|
136
|
+
within such NOTICE file, excluding those notices that do not
|
|
137
|
+
pertain to any part of the Derivative Works, in at least one
|
|
138
|
+
of the following places: within a NOTICE text file distributed
|
|
139
|
+
as part of the Derivative Works; within the Source form or
|
|
140
|
+
documentation, if provided along with the Derivative Works; or,
|
|
141
|
+
within a display generated by the Derivative Works, if and
|
|
142
|
+
wherever such third-party notices normally appear. The contents
|
|
143
|
+
of the NOTICE file are for informational purposes only and
|
|
144
|
+
do not modify the License. You may add Your own attribution
|
|
145
|
+
notices within Derivative Works that You distribute, alongside
|
|
146
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
147
|
+
that such additional attribution notices cannot be construed
|
|
148
|
+
as modifying the License.
|
|
149
|
+
|
|
150
|
+
You may add Your own copyright statement to Your modifications and
|
|
151
|
+
may provide additional or different license terms and conditions
|
|
152
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
153
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
154
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
155
|
+
the conditions stated in this License.
|
|
156
|
+
|
|
157
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
158
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
159
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
160
|
+
this License, without any additional terms or conditions.
|
|
161
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
162
|
+
the terms of any separate license agreement you may have executed
|
|
163
|
+
with Licensor regarding such Contributions.
|
|
164
|
+
|
|
165
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
166
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
167
|
+
except as required for reasonable and customary use in describing the
|
|
168
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
169
|
+
|
|
170
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
171
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
172
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
173
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
174
|
+
implied, including, without limitation, any warranties or conditions
|
|
175
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
176
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
177
|
+
appropriateness of using or redistributing the Work and assume any
|
|
178
|
+
risks associated with Your exercise of permissions under this License.
|
|
179
|
+
|
|
180
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
181
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
182
|
+
unless required by applicable law (such as deliberate and grossly
|
|
183
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
184
|
+
liable to You for damages, including any direct, indirect, special,
|
|
185
|
+
incidental, or consequential damages of any character arising as a
|
|
186
|
+
result of this License or out of the use or inability to use the
|
|
187
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
188
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
189
|
+
other commercial damages or losses), even if such Contributor
|
|
190
|
+
has been advised of the possibility of such damages.
|
|
191
|
+
|
|
192
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
193
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
194
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
195
|
+
or other liability obligations and/or rights consistent with this
|
|
196
|
+
License. However, in accepting such obligations, You may act only
|
|
197
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
198
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
199
|
+
defend, and hold each Contributor harmless for any liability
|
|
200
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
201
|
+
of your accepting any such warranty or additional liability.
|
|
202
|
+
|
|
203
|
+
END OF TERMS AND CONDITIONS
|
|
204
|
+
|
|
205
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
206
|
+
|
|
207
|
+
To apply the Apache License to your work, attach the following
|
|
208
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
209
|
+
replaced with your own identifying information. (Don't include
|
|
210
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
211
|
+
comment syntax for the file format. We also recommend that a
|
|
212
|
+
file or class name and description of purpose be included on the
|
|
213
|
+
same "printed page" as the copyright notice for easier
|
|
214
|
+
identification within third-party archives.
|
|
215
|
+
|
|
216
|
+
Copyright 2017 IBM and its contributors.
|
|
217
|
+
|
|
218
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
219
|
+
you may not use this file except in compliance with the License.
|
|
220
|
+
You may obtain a copy of the License at
|
|
221
|
+
|
|
222
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
223
|
+
|
|
224
|
+
Unless required by applicable law or agreed to in writing, software
|
|
225
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
226
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
227
|
+
See the License for the specific language governing permissions and
|
|
228
|
+
limitations under the License.
|
quprs-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: QuPRS
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: QuPRS: Quantum Path-sum Reduction and Solver
|
|
5
|
+
Author-email: Wei-Jia Huang <wei.jia.huang.physics@gmail.com>
|
|
6
|
+
Keywords: pathsum,weighted model counting,quantum circuit,equivalence checking
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE.md
|
|
19
|
+
License-File: NOTICE.md
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: sympy
|
|
22
|
+
Requires-Dist: symengine
|
|
23
|
+
Requires-Dist: qiskit<2.0,>=1.0.0
|
|
24
|
+
Requires-Dist: qiskit-qasm3-import>=0.5.1
|
|
25
|
+
Requires-Dist: ipykernel
|
|
26
|
+
Requires-Dist: pandas
|
|
27
|
+
Requires-Dist: tqdm
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
[](LICENSE.md)
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
# QuPRS: Quantum Path-sum Reduction and Solver
|
|
34
|
+
|
|
35
|
+
`QuPRS`("kyu-parse") is a tool for **Qu**antum Circuit tool integrate **P**ath-sum **R**eduction and **S**olver.
|
|
36
|
+
|
|
37
|
+
In quantum computing, verifying whether an optimized or compiled quantum circuit is functionally equivalent to the original circuit is a crucial task. `QuPRS` aims to solve this problem, and its features include:
|
|
38
|
+
|
|
39
|
+
- **Novel verification method**: Based on pathsum, which is a circuit representation method different from traditional matrix products.
|
|
40
|
+
- **Multiple verification strategies**:
|
|
41
|
+
1. **Hybrid mode (RR + WMC)**: Combines the efficiency of reduction rules and the completeness of weighted model counting.
|
|
42
|
+
2. **Reduction rules only (RR)**: Extremely fast, suitable for circuits that can be simplified by local rules.
|
|
43
|
+
3. **WMC only**: A powerful SAT-based method for more complex circuit structures.
|
|
44
|
+
- **Seamless integration with Qiskit ecosystem**: Circuits can be directly loaded from Qiskit `QuantumCircuit` objects or QASM files.
|
|
45
|
+
|
|
46
|
+
## Contents
|
|
47
|
+
|
|
48
|
+
- [QuPRS: Quantum Path-sum Reduction and Solver](#quprs-quantum-path-sum-reduction-and-solver)
|
|
49
|
+
- [Contents](#contents)
|
|
50
|
+
- [Installation](#installation)
|
|
51
|
+
- [Using QuPRS](#using-quprs)
|
|
52
|
+
- [Create pathsum Circuit](#create-pathsum-circuit)
|
|
53
|
+
- [Import From qasm](#import-from-qasm)
|
|
54
|
+
- [Equivalence Checking](#equivalence-checking)
|
|
55
|
+
- [Circuit Prepare](#circuit-prepare)
|
|
56
|
+
- [Run Equivalence Checking](#run-equivalence-checking)
|
|
57
|
+
- [Cite](#cite)
|
|
58
|
+
- [License Information](#license-information)
|
|
59
|
+
- [Acknowledgements](#acknowledgements)
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
It is recommended to install `QuPRS` in a virtual environment.
|
|
64
|
+
|
|
65
|
+
1. Create and activate a Conda virtual environment:
|
|
66
|
+
```bash
|
|
67
|
+
conda create --name QuPRS python=3.12 # Or your preferred Python version
|
|
68
|
+
conda activate QuPRS
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
2. Install `QuPRS` using pip:
|
|
72
|
+
```bash
|
|
73
|
+
pip install QuPRS
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Using QuPRS
|
|
77
|
+
|
|
78
|
+
This tool can build quantum circuit using path-sum formulation.
|
|
79
|
+
|
|
80
|
+
First, import the necessary components from the `QuPRS` library.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from QuPRS.pathsum import pathsum
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Create pathsum Circuit
|
|
87
|
+
|
|
88
|
+
Create a `pathsum` Circuit
|
|
89
|
+
You can create a pathsum.QuantumCircuit object directly:
|
|
90
|
+
```python
|
|
91
|
+
qubit_num = 2
|
|
92
|
+
circuit = pathsum.QuantumCircuit(qubit_num)
|
|
93
|
+
circuit = circuit.h(0) # Apply Hadamard gate to qubit 0
|
|
94
|
+
circuit = circuit.h(0) # Apply Hadamard gate to qubit 0 again (H*H = I)
|
|
95
|
+
# Add more gates as needed
|
|
96
|
+
# e.g., circuit = circuit.cx(0, 1)
|
|
97
|
+
```
|
|
98
|
+
### Import From qasm
|
|
99
|
+
|
|
100
|
+
`pathsum` supports importing circuits from QASM files or strings.
|
|
101
|
+
|
|
102
|
+
From a QASM file:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
filename = "my_circuit.qasm"
|
|
106
|
+
# Ensure my_circuit.qasm exists and contains valid QASM code
|
|
107
|
+
# Example my_circuit.qasm:
|
|
108
|
+
# OPENQASM 2.0;
|
|
109
|
+
# include "qelib1.inc";
|
|
110
|
+
# qreg q[2];
|
|
111
|
+
# h q[0];
|
|
112
|
+
# cx q[0],q[1];
|
|
113
|
+
|
|
114
|
+
circuit = pathsum.load_from_qasm_file(filename)
|
|
115
|
+
```
|
|
116
|
+
Or
|
|
117
|
+
```python
|
|
118
|
+
qasm_str = """
|
|
119
|
+
OPENQASM 2.0;
|
|
120
|
+
include "qelib1.inc";
|
|
121
|
+
qreg q[2];
|
|
122
|
+
h q[0];
|
|
123
|
+
cx q[0],q[1];
|
|
124
|
+
"""
|
|
125
|
+
circuit = pathsum.load_from_qasm_str(qasm_str)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Equivalence Checking
|
|
129
|
+
`QuPRS` provides tools for checking the equivalence of two quantum circuits, potentially imported from Qiskit or QASM files.
|
|
130
|
+
|
|
131
|
+
Importing Circuits for Equivalence Checking
|
|
132
|
+
You can load circuits from QASM files or define them directly using Qiskit for comparison.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Circuit Prepare
|
|
136
|
+
- Load from QASM files
|
|
137
|
+
```python
|
|
138
|
+
# Assuming circuit1.qasm and circuit2.qasm exist
|
|
139
|
+
from QuPRS.interface.load_qiskit import load_circuit
|
|
140
|
+
|
|
141
|
+
circuit1 = load_circuit("circuit1.qasm")
|
|
142
|
+
circuit2 = load_circuit("circuit2.qasm")
|
|
143
|
+
```
|
|
144
|
+
- Direct import from Qiskit `QuantumCircuit` objects:
|
|
145
|
+
```python
|
|
146
|
+
from qiskit import QuantumCircuit
|
|
147
|
+
|
|
148
|
+
# Define circuit1 using Qiskit
|
|
149
|
+
circuit1 = QuantumCircuit(2)
|
|
150
|
+
circuit1.h(1)
|
|
151
|
+
circuit1.cx(0, 1)
|
|
152
|
+
circuit1.h(1)
|
|
153
|
+
|
|
154
|
+
# Define circuit2 using Qiskit
|
|
155
|
+
circuit2 = QuantumCircuit(2)
|
|
156
|
+
circuit2.cz(0, 1)
|
|
157
|
+
```
|
|
158
|
+
### Run Equivalence Checking
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
- **Hybrid**: Reduction Rules (RR) and Weighted Model Counting (WMC)
|
|
162
|
+
|
|
163
|
+
This method combines RR with WMC for equivalence checking.
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
from QuPRS.interface.load_qiskit import qasm_eq_check_with_wmc
|
|
168
|
+
|
|
169
|
+
output_dict = qasm_eq_check_with_wmc(circuit1, circuit2)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- Using **Reduction Rules (RR)**
|
|
173
|
+
|
|
174
|
+
This method checks if two circuits are equivalent primarily using Reduction Rules.
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from QuPRS.interface.load_qiskit import qasm_eq_check
|
|
179
|
+
|
|
180
|
+
output_dict, circuit = qasm_eq_check(circuit1, circuit2)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
- **WMC** only (without RR)
|
|
186
|
+
|
|
187
|
+
To perform equivalence checking using only WMC, you need to disable the Reduction Rules switch.
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
from QuPRS.interface.load_qiskit import qasm_eq_check_with_wmc
|
|
191
|
+
from QuPRS.pathsum import pathsum
|
|
192
|
+
|
|
193
|
+
pathsum.set_reduction_switch(False)
|
|
194
|
+
output_dict = qasm_eq_check_with_wmc(circuit1, circuit2)
|
|
195
|
+
```
|
|
196
|
+
## Cite
|
|
197
|
+
If you use `QuPRS` in your research, please consider citing it.
|
|
198
|
+
|
|
199
|
+
This code is associated with a forthcoming publication. Please cite this repository for now, and check back for the full paper citation.
|
|
200
|
+
```
|
|
201
|
+
```
|
|
202
|
+
## License Information
|
|
203
|
+
|
|
204
|
+
- This project’s original source code is licensed under: [MIT](LICENSE.md)
|
|
205
|
+
- Kenji Hashimoto’s binary component (`QuPRS/utils/gpmc`) is licensed under the MIT License and the file (`QuPRS/utils/Qiskit_Circuit_Utils.py`) contains functions (`random_circuit`, `random_clifford_T_circuit`) that are derived from the Qiskit library. The original Qiskit code is licensed under the Apache 2.0. see: [NOTICE](NOTICE.md)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
## Acknowledgements
|
|
209
|
+
This project utilizes `gpmc`, a binary component developed by Kenji Hashimoto, for parts of its Weighted Model Counting functionality.
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|