qumat 0.0.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.
- qumat-0.0.1/LICENSE +346 -0
- qumat-0.0.1/NOTICE +41 -0
- qumat-0.0.1/PKG-INFO +77 -0
- qumat-0.0.1/README.md +56 -0
- qumat-0.0.1/pyproject.toml +27 -0
- qumat-0.0.1/qumat/__init__.py +0 -0
- qumat-0.0.1/qumat/amazon_braket_backend.py +98 -0
- qumat-0.0.1/qumat/cirq_backend.py +108 -0
- qumat-0.0.1/qumat/qiskit_backend.py +117 -0
- qumat-0.0.1/qumat/qumat.py +90 -0
qumat-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
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.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
==========================================================
|
|
206
|
+
CERN Colt Java Library
|
|
207
|
+
==========================================================
|
|
208
|
+
Copyright © 1999 CERN - European Organization for Nuclear Research.<br/><br/>
|
|
209
|
+
|
|
210
|
+
Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
|
|
211
|
+
is hereby granted without fee, provided that the above copyright notice appear in all copies and
|
|
212
|
+
that both that copyright notice and this permission notice appear in supporting documentation.
|
|
213
|
+
CERN makes no representations about the suitability of this software for any purpose.
|
|
214
|
+
It is provided "as is" without expressed or implied warranty.
|
|
215
|
+
|
|
216
|
+
[Mahout note: We have included, as source, parts of the CERN Colt Java Matrix library as a Module
|
|
217
|
+
in the Mahout source tree. The parts included are those in cern.colt* , cern.jet*, cern.clhep.
|
|
218
|
+
We have excluded the hep.aida* packages.]
|
|
219
|
+
|
|
220
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/Arrays.java
|
|
221
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/OldQRDecomposition.java
|
|
222
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/PersistentObject.java
|
|
223
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/QRDecomposition.java
|
|
224
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/SingularValueDecomposition.java
|
|
225
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/Swapper.java
|
|
226
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/collections/Arithmetic.java
|
|
227
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/collections/Constants.java
|
|
228
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/DoubleDoubleFunction.java
|
|
229
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/DoubleFunction.java
|
|
230
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/Functions.java
|
|
231
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/IntFunction.java
|
|
232
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/IntIntDoubleFunction.java
|
|
233
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/Mult.java
|
|
234
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/ObjectProcedure.java
|
|
235
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/function/PlusMult.java
|
|
236
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/math/Arithmetic.java
|
|
237
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/math/Constants.java
|
|
238
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/math/Polynomial.java
|
|
239
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/AbstractContinuousDistribution.java
|
|
240
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/AbstractDiscreteDistribution.java
|
|
241
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/AbstractDistribution.java
|
|
242
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/Exponential.java
|
|
243
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/Gamma.java
|
|
244
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/NegativeBinomial.java
|
|
245
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/Normal.java
|
|
246
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/Poisson.java
|
|
247
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/Uniform.java
|
|
248
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/engine/MersenneTwister.java
|
|
249
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/engine/RandomEngine.java
|
|
250
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/random/sampling/RandomSampler.java
|
|
251
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/stat/Gamma.java
|
|
252
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/jet/stat/Probability.java
|
|
253
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/list/AbstractList.java
|
|
254
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/list/AbstractObjectList.java
|
|
255
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/list/ObjectArrayList.java
|
|
256
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/list/SimpleLongArrayList.java
|
|
257
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/map/HashFunctions.java
|
|
258
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/map/OpenHashMap.java
|
|
259
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/map/QuickOpenIntIntHashMap.java
|
|
260
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/set/AbstractSet.java
|
|
261
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/buffer/ValueTypeBufferConsumer.java.t
|
|
262
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/function/KeyTypeObjectProcedure.java.t
|
|
263
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t
|
|
264
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t
|
|
265
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t
|
|
266
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t
|
|
267
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/list/AbstractValueTypeList.java.t
|
|
268
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/list/ValueTypeArrayList.java.t
|
|
269
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/AbstractKeyTypeObjectMap.java.t
|
|
270
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/AbstractKeyTypeValueTypeMap.java.t
|
|
271
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/AbstractObjectValueTypeMap.java.t
|
|
272
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeObjectHashMap.java.t
|
|
273
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/OpenKeyTypeValueTypeHashMap.java.t
|
|
274
|
+
apache-mahout-14.1/core/src/main/java-templates/org/apache/mahout/math/map/OpenObjectValueTypeHashMap.java.t
|
|
275
|
+
|
|
276
|
+
================================================================
|
|
277
|
+
Austin Appleby's C algorithm implemented by Yonik Seeley under public domain
|
|
278
|
+
================================================================
|
|
279
|
+
|
|
280
|
+
apache-mahout-14.1/core/src/main/java/org/apache/mahout/math/MurmurHash3.java
|
|
281
|
+
apache-mahout-14.1/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java
|
|
282
|
+
|
|
283
|
+
================================================================
|
|
284
|
+
Bootstrap
|
|
285
|
+
================================================================
|
|
286
|
+
|
|
287
|
+
Files in the directory: website/assets/vendor/bootstrap
|
|
288
|
+
Are copied from the Bootstrap (https://github.com/twbs/bootstrap) project
|
|
289
|
+
which is licensed under the MIT license
|
|
290
|
+
|
|
291
|
+
================================================================
|
|
292
|
+
JQuery
|
|
293
|
+
================================================================
|
|
294
|
+
|
|
295
|
+
Files in the directory: website/assets/vendor/jquery
|
|
296
|
+
Are copied from the JQuery (https://jquery.com/) project
|
|
297
|
+
which is licensed under the MIT license
|
|
298
|
+
|
|
299
|
+
================================================================
|
|
300
|
+
Proper
|
|
301
|
+
================================================================
|
|
302
|
+
|
|
303
|
+
Files in the directory: website/assets/vendor/propper
|
|
304
|
+
Are copied from the Propper project (https://popper.js.org/)
|
|
305
|
+
which is licensed under the MIT license.
|
|
306
|
+
|
|
307
|
+
================================================================
|
|
308
|
+
The following applies to the ViennaCL library and files in the mahout-native-viennacl module
|
|
309
|
+
================================================================
|
|
310
|
+
|
|
311
|
+
Copyright (c) 2010-2016 Institute for Microelectronics,
|
|
312
|
+
Institute for Analysis and Scientific Computing, TU Wien.
|
|
313
|
+
Portions of this software are copyright by UChicago Argonne, LLC.
|
|
314
|
+
Argonne National Laboratory, with facilities in the state of Illinois,
|
|
315
|
+
is owned by The United States Government, and operated by UChicago Argonne, LLC
|
|
316
|
+
under provision of a contract with the Department of Energy.
|
|
317
|
+
|
|
318
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
319
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
320
|
+
in the Software without restriction, including without limitation the rights
|
|
321
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
322
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
323
|
+
furnished to do so, subject to the following conditions:
|
|
324
|
+
|
|
325
|
+
The above copyright notice and this permission notice shall be included in
|
|
326
|
+
all copies or substantial portions of the Software.
|
|
327
|
+
|
|
328
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
329
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
330
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
331
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
332
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
333
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
334
|
+
THE SOFTWARE.
|
|
335
|
+
|
|
336
|
+
===============================================================================
|
|
337
|
+
The following applies to the bydeco/javacpp code and module
|
|
338
|
+
===============================================================================
|
|
339
|
+
You may use this work under the terms of either the Apache License,
|
|
340
|
+
Version 2.0, or the GNU General Public License (GPL), either version 2,
|
|
341
|
+
or any later version, with "Classpath" exception (details below).
|
|
342
|
+
|
|
343
|
+
You don't have to do anything special to choose one license or the other
|
|
344
|
+
and you don't have to notify anyone which license you are using. You are
|
|
345
|
+
free to use this work in any project (even commercial projects) as long
|
|
346
|
+
as the copyright header is left intact.
|
qumat-0.0.1/NOTICE
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
==============================================================
|
|
2
|
+
Apache Mahout
|
|
3
|
+
Copyright 2009-2020 The Apache Software Foundation
|
|
4
|
+
==============================================================
|
|
5
|
+
|
|
6
|
+
This product includes software developed by
|
|
7
|
+
The Apache Software Foundation (http://www.apache.org/).
|
|
8
|
+
|
|
9
|
+
It includes software from other Apache Software Foundation projects,
|
|
10
|
+
including, but not limited to:
|
|
11
|
+
- Apache Lucene Java
|
|
12
|
+
- Apache Solr
|
|
13
|
+
- Apache Hadoop
|
|
14
|
+
- Apache Commons
|
|
15
|
+
- Apache Spark
|
|
16
|
+
- Apache Flink
|
|
17
|
+
|
|
18
|
+
This product includes software from the SLF4J project
|
|
19
|
+
http://www.slf4j.org/
|
|
20
|
+
Copyright (c) 2004-2016 QOS.ch
|
|
21
|
+
|
|
22
|
+
This product includes software developed by the Indiana University
|
|
23
|
+
Extreme! Lab (http://www.extreme.indiana.edu/).
|
|
24
|
+
Copyright (c) 2002 Extreme! Lab, Indiana University.
|
|
25
|
+
|
|
26
|
+
This product includes a JUnit jar: http://junit.sourceforge.net/
|
|
27
|
+
License: Common Public License - v 1.0 (http://junit.sourceforge.net/cpl-v10.html)
|
|
28
|
+
Copyright (c) 2000-2006, www.hamcrest.org
|
|
29
|
+
|
|
30
|
+
This product includes code from the XStream project (http://xstream.codehaus.org/)
|
|
31
|
+
Copyright (c) 2003-2006, Joe Walnes
|
|
32
|
+
Copyright (c) 2006-2007, XStream Committers
|
|
33
|
+
|
|
34
|
+
This product includes tests written with EasyMock
|
|
35
|
+
Copyright 2001-2007 Tammo Freese (http://www.easymock.org/)
|
|
36
|
+
|
|
37
|
+
This product uses the Breast Cancer Wisconsin (Diagnostic) Dataset from the
|
|
38
|
+
UCI Machine Learning Repository
|
|
39
|
+
[http://www.ics.uci.edu/~mlearn/MLRepository.html,
|
|
40
|
+
http://archive.ics.uci.edu/ml/datasets/Breast+Cancer+Wisconsin+(Diagnostic)].
|
|
41
|
+
|
qumat-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: qumat
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A library for composing quantum machine learning.
|
|
5
|
+
License: ASFv2
|
|
6
|
+
Author: Apache Mahout
|
|
7
|
+
Requires-Python: >=3.9,<4.0
|
|
8
|
+
Classifier: License :: Other/Proprietary License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: amazon-braket-sdk (>=1.10.0,<2.0.0)
|
|
15
|
+
Requires-Dist: cirq (>=1.3.0,<2.0.0)
|
|
16
|
+
Requires-Dist: qiskit (>=0.45.1,<0.46.0)
|
|
17
|
+
Requires-Dist: qiskit-aer (>=0.13.2,<0.14.0)
|
|
18
|
+
Requires-Dist: sympy (>=1.9,<2.0)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<!--
|
|
23
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
24
|
+
contributor license agreements. See the NOTICE file distributed with
|
|
25
|
+
this work for additional information regarding copyright ownership.
|
|
26
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
27
|
+
(the "License"); you may not use this file except in compliance with
|
|
28
|
+
the License. You may obtain a copy of the License at
|
|
29
|
+
|
|
30
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
31
|
+
|
|
32
|
+
Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
See the License for the specific language governing permissions and
|
|
36
|
+
limitations under the License.
|
|
37
|
+
-->
|
|
38
|
+
|
|
39
|
+
Welcome to Apache Mahout!
|
|
40
|
+
===========
|
|
41
|
+
The goal of the Apache Mahout™ project is to build an environment for quickly creating scalable, performant machine learning applications.
|
|
42
|
+
|
|
43
|
+
For additional information about Mahout, visit the [Mahout Home Page](http://mahout.apache.org/)
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
# QuMat
|
|
48
|
+
|
|
49
|
+
QuMat is a POC of a high level Python library for intefacing with multiple quantum computing backends. It is designed to be easy to use and to abstract the particularities of each backend, so that you may 'write once, run anywhere.' Like the Java of quantum computing, but Java is the new COBOL so we're trying to distance ourselves from that comparison :P
|
|
50
|
+
|
|
51
|
+
Check out [basic gates](docs/basic_gates.md) for a quick introduction to the basic gates which are basically all that exist right now (and even those only exist for `qiskit`).
|
|
52
|
+
|
|
53
|
+
## Getting started
|
|
54
|
+
|
|
55
|
+
To install dependencies, run the following:
|
|
56
|
+
```
|
|
57
|
+
pip install -U poetry
|
|
58
|
+
poetry install
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Roadmap
|
|
62
|
+
|
|
63
|
+
### Q2
|
|
64
|
+
- [x] Transition of Classic to maintenance mode
|
|
65
|
+
|
|
66
|
+
### Q3
|
|
67
|
+
- [ ] Integration of Qumat with hardened (tests, docs, CI/CD) cirq and qiskit backends
|
|
68
|
+
- [ ] Initiation of kernel methods
|
|
69
|
+
- [x] Integration with Amazon Braket
|
|
70
|
+
- [x] [Public talk about Qumat](https://2024.fossy.us/schedule/presentation/265/)
|
|
71
|
+
|
|
72
|
+
### Q3 and beyond
|
|
73
|
+
- [ ] Development of distributed quantum solvers
|
|
74
|
+
|
|
75
|
+
#### Legal
|
|
76
|
+
Please see the `NOTICE.txt` included in this directory for more information.
|
|
77
|
+
|
qumat-0.0.1/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
<!--
|
|
3
|
+
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
contributor license agreements. See the NOTICE file distributed with
|
|
5
|
+
this work for additional information regarding copyright ownership.
|
|
6
|
+
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7
|
+
(the "License"); you may not use this file except in compliance with
|
|
8
|
+
the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
See the License for the specific language governing permissions and
|
|
16
|
+
limitations under the License.
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
Welcome to Apache Mahout!
|
|
20
|
+
===========
|
|
21
|
+
The goal of the Apache Mahout™ project is to build an environment for quickly creating scalable, performant machine learning applications.
|
|
22
|
+
|
|
23
|
+
For additional information about Mahout, visit the [Mahout Home Page](http://mahout.apache.org/)
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
# QuMat
|
|
28
|
+
|
|
29
|
+
QuMat is a POC of a high level Python library for intefacing with multiple quantum computing backends. It is designed to be easy to use and to abstract the particularities of each backend, so that you may 'write once, run anywhere.' Like the Java of quantum computing, but Java is the new COBOL so we're trying to distance ourselves from that comparison :P
|
|
30
|
+
|
|
31
|
+
Check out [basic gates](docs/basic_gates.md) for a quick introduction to the basic gates which are basically all that exist right now (and even those only exist for `qiskit`).
|
|
32
|
+
|
|
33
|
+
## Getting started
|
|
34
|
+
|
|
35
|
+
To install dependencies, run the following:
|
|
36
|
+
```
|
|
37
|
+
pip install -U poetry
|
|
38
|
+
poetry install
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Roadmap
|
|
42
|
+
|
|
43
|
+
### Q2
|
|
44
|
+
- [x] Transition of Classic to maintenance mode
|
|
45
|
+
|
|
46
|
+
### Q3
|
|
47
|
+
- [ ] Integration of Qumat with hardened (tests, docs, CI/CD) cirq and qiskit backends
|
|
48
|
+
- [ ] Initiation of kernel methods
|
|
49
|
+
- [x] Integration with Amazon Braket
|
|
50
|
+
- [x] [Public talk about Qumat](https://2024.fossy.us/schedule/presentation/265/)
|
|
51
|
+
|
|
52
|
+
### Q3 and beyond
|
|
53
|
+
- [ ] Development of distributed quantum solvers
|
|
54
|
+
|
|
55
|
+
#### Legal
|
|
56
|
+
Please see the `NOTICE.txt` included in this directory for more information.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "qumat"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "A library for composing quantum machine learning."
|
|
5
|
+
authors = ["Apache Mahout"]
|
|
6
|
+
license = "ASFv2"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
|
|
9
|
+
[[tool.poetry.source]]
|
|
10
|
+
name = "tsinghua"
|
|
11
|
+
default = true
|
|
12
|
+
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
|
13
|
+
|
|
14
|
+
[tool.poetry.dependencies]
|
|
15
|
+
python = "^3.9"
|
|
16
|
+
qiskit = "^0.45.1"
|
|
17
|
+
qiskit-aer = "^0.13.2"
|
|
18
|
+
cirq = "^1.3.0"
|
|
19
|
+
amazon-braket-sdk = "^1.10.0"
|
|
20
|
+
sympy = "^1.9"
|
|
21
|
+
|
|
22
|
+
[tool.poetry.dev-dependencies]
|
|
23
|
+
pytest = "^8.1.1"
|
|
24
|
+
|
|
25
|
+
[build-system]
|
|
26
|
+
requires = ["poetry-core"]
|
|
27
|
+
build-backend = "poetry.core.masonry.api"
|
|
File without changes
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
# this work for additional information regarding copyright ownership.
|
|
5
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
# (the "License"); you may not use this file except in compliance with
|
|
7
|
+
# the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
from braket.aws import AwsQuantumSimulator, AwsDevice
|
|
18
|
+
from braket.circuits import Circuit, FreeParameter
|
|
19
|
+
|
|
20
|
+
def initialize_backend(backend_config):
|
|
21
|
+
backend_options = backend_config['backend_options']
|
|
22
|
+
simulator_type = backend_options.get('simulator_type', 'default')
|
|
23
|
+
if simulator_type == 'default':
|
|
24
|
+
return AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
|
|
25
|
+
else:
|
|
26
|
+
print(f"Simulator type '{simulator_type}' is not supported in Amazon Braket. Using default.")
|
|
27
|
+
return AwsDevice("arn:aws:braket:::device/quantum-simulator/amazon/sv1")
|
|
28
|
+
|
|
29
|
+
def create_empty_circuit(num_qubits):
|
|
30
|
+
return Circuit()
|
|
31
|
+
|
|
32
|
+
def apply_not_gate(circuit, qubit_index):
|
|
33
|
+
circuit.x(qubit_index)
|
|
34
|
+
|
|
35
|
+
def apply_hadamard_gate(circuit, qubit_index):
|
|
36
|
+
circuit.h(qubit_index)
|
|
37
|
+
|
|
38
|
+
def apply_cnot_gate(circuit, control_qubit_index, target_qubit_index):
|
|
39
|
+
circuit.cnot(control_qubit_index, target_qubit_index)
|
|
40
|
+
|
|
41
|
+
def apply_toffoli_gate(circuit, control_qubit_index1, control_qubit_index2, target_qubit_index):
|
|
42
|
+
circuit.ccnot(control_qubit_index1, control_qubit_index2, target_qubit_index)
|
|
43
|
+
|
|
44
|
+
def apply_swap_gate(circuit, qubit_index1, qubit_index2):
|
|
45
|
+
circuit.swap(qubit_index1, qubit_index2)
|
|
46
|
+
|
|
47
|
+
def apply_pauli_x_gate(circuit, qubit_index):
|
|
48
|
+
circuit.x(qubit_index)
|
|
49
|
+
|
|
50
|
+
def apply_pauli_y_gate(circuit, qubit_index):
|
|
51
|
+
circuit.y(qubit_index)
|
|
52
|
+
|
|
53
|
+
def apply_pauli_z_gate(circuit, qubit_index):
|
|
54
|
+
circuit.z(qubit_index)
|
|
55
|
+
|
|
56
|
+
def execute_circuit(circuit, backend, backend_config):
|
|
57
|
+
shots = backend_config['backend_options'].get('shots', 1)
|
|
58
|
+
task = backend.run(circuit, shots=shots)
|
|
59
|
+
result = task.result()
|
|
60
|
+
return result.measurement_counts
|
|
61
|
+
|
|
62
|
+
# placeholder method for use in the testing suite
|
|
63
|
+
def get_final_state_vector(circuit, backend, backend_config):
|
|
64
|
+
raise NotImplementedError("Final state vector calculation is not currently supported with Amazon Braket.")
|
|
65
|
+
|
|
66
|
+
def draw_circuit(circuit):
|
|
67
|
+
# Unfortunately, Amazon Braket does not have direct support for drawing circuits in the same way
|
|
68
|
+
# as Qiskit and Cirq. You would typically visualize Amazon Braket circuits using external tools.
|
|
69
|
+
# For simplicity, we'll print the circuit object which gives some textual representation.
|
|
70
|
+
print(circuit)
|
|
71
|
+
|
|
72
|
+
def apply_rx_gate(circuit, qubit_index, angle):
|
|
73
|
+
if isinstance(angle, (int, float)):
|
|
74
|
+
circuit.rx(qubit_index, angle)
|
|
75
|
+
else:
|
|
76
|
+
param = FreeParameter(angle)
|
|
77
|
+
circuit.rx(qubit_index, param)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def apply_ry_gate(circuit, qubit_index, angle):
|
|
81
|
+
if isinstance(angle, (int, float)):
|
|
82
|
+
circuit.ry(qubit_index, angle)
|
|
83
|
+
else:
|
|
84
|
+
param = FreeParameter(angle)
|
|
85
|
+
circuit.ry(qubit_index, param)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def apply_rz_gate(circuit, qubit_index, angle):
|
|
89
|
+
if isinstance(angle, (int, float)):
|
|
90
|
+
circuit.rz(qubit_index, angle)
|
|
91
|
+
else:
|
|
92
|
+
param = FreeParameter(angle)
|
|
93
|
+
circuit.rz(qubit_index, param)
|
|
94
|
+
|
|
95
|
+
def apply_u_gate(circuit, qubit_index, theta, phi, lambd):
|
|
96
|
+
circuit.rx(qubit_index, theta)
|
|
97
|
+
circuit.ry(qubit_index, phi)
|
|
98
|
+
circuit.rz(qubit_index, lambd)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
# this work for additional information regarding copyright ownership.
|
|
5
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
# (the "License"); you may not use this file except in compliance with
|
|
7
|
+
# the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
import cirq
|
|
18
|
+
import sympy
|
|
19
|
+
|
|
20
|
+
def initialize_backend(backend_config):
|
|
21
|
+
# Assuming 'simulator_type' specifies the type of simulator in Cirq
|
|
22
|
+
simulator_type = backend_config.get('backend_options', {}).get('simulator_type', 'default')
|
|
23
|
+
if simulator_type != 'default':
|
|
24
|
+
print(f"Simulator type '{simulator_type}' is not supported in Cirq. Ignoring this argument")
|
|
25
|
+
|
|
26
|
+
return cirq.Simulator()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def create_empty_circuit(num_qubits):
|
|
30
|
+
return cirq.Circuit()
|
|
31
|
+
|
|
32
|
+
def apply_not_gate(circuit, qubit_index):
|
|
33
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
34
|
+
circuit.append(cirq.X(qubit))
|
|
35
|
+
|
|
36
|
+
def apply_hadamard_gate(circuit, qubit_index):
|
|
37
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
38
|
+
circuit.append(cirq.H(qubit))
|
|
39
|
+
|
|
40
|
+
def apply_cnot_gate(circuit, control_qubit_index, target_qubit_index):
|
|
41
|
+
control_qubit = cirq.LineQubit(control_qubit_index)
|
|
42
|
+
target_qubit = cirq.LineQubit(target_qubit_index)
|
|
43
|
+
circuit.append(cirq.CNOT(control_qubit, target_qubit))
|
|
44
|
+
|
|
45
|
+
def apply_toffoli_gate(circuit, control_qubit_index1, control_qubit_index2, target_qubit_index):
|
|
46
|
+
control_qubit1 = cirq.LineQubit(control_qubit_index1)
|
|
47
|
+
control_qubit2 = cirq.LineQubit(control_qubit_index2)
|
|
48
|
+
target_qubit = cirq.LineQubit(target_qubit_index)
|
|
49
|
+
circuit.append(cirq.CCX(control_qubit1, control_qubit2, target_qubit))
|
|
50
|
+
|
|
51
|
+
def apply_swap_gate(circuit, qubit_index1, qubit_index2):
|
|
52
|
+
qubit1 = cirq.LineQubit(qubit_index1)
|
|
53
|
+
qubit2 = cirq.LineQubit(qubit_index2)
|
|
54
|
+
circuit.append(cirq.SWAP(qubit1, qubit2))
|
|
55
|
+
|
|
56
|
+
def apply_pauli_x_gate(circuit, qubit_index):
|
|
57
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
58
|
+
circuit.append(cirq.X(qubit))
|
|
59
|
+
|
|
60
|
+
def apply_pauli_y_gate(circuit, qubit_index):
|
|
61
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
62
|
+
circuit.append(cirq.Y(qubit))
|
|
63
|
+
|
|
64
|
+
def apply_pauli_z_gate(circuit, qubit_index):
|
|
65
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
66
|
+
circuit.append(cirq.Z(qubit))
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def execute_circuit(circuit, backend, backend_config):
|
|
70
|
+
# Ensure measurement is added to capture the results
|
|
71
|
+
if not circuit.has_measurements():
|
|
72
|
+
circuit.append(cirq.measure(*circuit.all_qubits(), key='result'))
|
|
73
|
+
simulator = cirq.Simulator()
|
|
74
|
+
parameter_values = backend_config.get('parameter_values', None)
|
|
75
|
+
if parameter_values:
|
|
76
|
+
# Convert parameter_values to applicable resolvers
|
|
77
|
+
res = [cirq.ParamResolver(parameter_values)]
|
|
78
|
+
results = simulator.run_sweep(circuit, repetitions=backend_config['backend_options'].get('shots', 1), params=res)
|
|
79
|
+
return [result.histogram(key='result') for result in results]
|
|
80
|
+
else:
|
|
81
|
+
result = simulator.run(circuit, repetitions=backend_config['backend_options'].get('shots', 1))
|
|
82
|
+
return [result.histogram(key='result')]
|
|
83
|
+
|
|
84
|
+
def draw_circuit(circuit):
|
|
85
|
+
print(circuit)
|
|
86
|
+
|
|
87
|
+
def apply_rx_gate(circuit, qubit_index, angle):
|
|
88
|
+
param = sympy.Symbol(angle) if isinstance(angle, str) else angle
|
|
89
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
90
|
+
circuit.append(cirq.rx(param).on(qubit))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def apply_ry_gate(circuit, qubit_index, angle):
|
|
94
|
+
param = sympy.Symbol(angle) if isinstance(angle, str) else angle
|
|
95
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
96
|
+
circuit.append(cirq.ry(param).on(qubit))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def apply_rz_gate(circuit, qubit_index, angle):
|
|
100
|
+
param = sympy.Symbol(angle) if isinstance(angle, str) else angle
|
|
101
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
102
|
+
circuit.append(cirq.rz(param).on(qubit))
|
|
103
|
+
|
|
104
|
+
def apply_u_gate(circuit, qubit_index, theta, phi, lambd):
|
|
105
|
+
qubit = cirq.LineQubit(qubit_index)
|
|
106
|
+
circuit.append(cirq.rz(lambd).on(qubit))
|
|
107
|
+
circuit.append(cirq.ry(phi).on(qubit))
|
|
108
|
+
circuit.append(cirq.rx(theta).on(qubit))
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
# this work for additional information regarding copyright ownership.
|
|
5
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
# (the "License"); you may not use this file except in compliance with
|
|
7
|
+
# the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
import qiskit
|
|
18
|
+
|
|
19
|
+
def initialize_backend(backend_config):
|
|
20
|
+
backend_options = backend_config['backend_options']
|
|
21
|
+
simulator_type = backend_options['simulator_type']
|
|
22
|
+
shots = backend_options['shots']
|
|
23
|
+
backend = qiskit.Aer.get_backend(simulator_type)
|
|
24
|
+
backend.shots = shots
|
|
25
|
+
return backend
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def create_empty_circuit(num_qubits):
|
|
29
|
+
return qiskit.QuantumCircuit(num_qubits)
|
|
30
|
+
|
|
31
|
+
def apply_not_gate(circuit, qubit_index):
|
|
32
|
+
# Apply a NOT gate (X gate) on the specified qubit
|
|
33
|
+
circuit.x(qubit_index)
|
|
34
|
+
|
|
35
|
+
def apply_hadamard_gate(circuit, qubit_index):
|
|
36
|
+
# Apply a Hadamard gate on the specified qubit
|
|
37
|
+
circuit.h(qubit_index)
|
|
38
|
+
|
|
39
|
+
def apply_cnot_gate(circuit, control_qubit_index, target_qubit_index):
|
|
40
|
+
# Apply a CNOT gate (controlled-X gate) with the specified control and
|
|
41
|
+
# target qubits
|
|
42
|
+
circuit.cx(control_qubit_index, target_qubit_index)
|
|
43
|
+
|
|
44
|
+
def apply_toffoli_gate(circuit, control_qubit_index1,
|
|
45
|
+
control_qubit_index2,
|
|
46
|
+
target_qubit_index):
|
|
47
|
+
# Apply a Toffoli gate (controlled-controlled-X gate) with the
|
|
48
|
+
# specified control and target qubits
|
|
49
|
+
circuit.ccx(control_qubit_index1,
|
|
50
|
+
control_qubit_index2,
|
|
51
|
+
target_qubit_index)
|
|
52
|
+
|
|
53
|
+
def apply_swap_gate(circuit, qubit_index1, qubit_index2):
|
|
54
|
+
# Apply a SWAP gate to exchange the states of two qubits
|
|
55
|
+
circuit.swap(qubit_index1, qubit_index2)
|
|
56
|
+
|
|
57
|
+
def apply_pauli_x_gate(circuit, qubit_index):
|
|
58
|
+
# Apply a Pauli X gate on the specified qubit
|
|
59
|
+
circuit.x(qubit_index)
|
|
60
|
+
|
|
61
|
+
def apply_pauli_y_gate(circuit, qubit_index):
|
|
62
|
+
# Apply a Pauli Y gate on the specified qubit
|
|
63
|
+
circuit.y(qubit_index)
|
|
64
|
+
|
|
65
|
+
def apply_pauli_z_gate(circuit, qubit_index):
|
|
66
|
+
# Apply a Pauli Z gate on the specified qubit
|
|
67
|
+
circuit.z(qubit_index)
|
|
68
|
+
|
|
69
|
+
def execute_circuit(circuit, backend, backend_config):
|
|
70
|
+
# Add measurements if they are not already present
|
|
71
|
+
if not circuit.cregs:
|
|
72
|
+
circuit.measure_all()
|
|
73
|
+
|
|
74
|
+
# Ensure the circuit is parameterized properly
|
|
75
|
+
if circuit.parameters:
|
|
76
|
+
# Parse the global parameter configuration
|
|
77
|
+
parameter_bindings = {param: backend_config['parameter_values'][str(param)] for param in circuit.parameters}
|
|
78
|
+
transpiled_circuit = qiskit.transpile(circuit, backend)
|
|
79
|
+
qobj = qiskit.assemble(transpiled_circuit, parameter_binds=[parameter_bindings], shots=backend_config['backend_options']['shots'])
|
|
80
|
+
job = backend.run(qobj)
|
|
81
|
+
result = job.result()
|
|
82
|
+
return result.get_counts()
|
|
83
|
+
else:
|
|
84
|
+
transpiled_circuit = qiskit.transpile(circuit, backend)
|
|
85
|
+
job = qiskit.execute(transpiled_circuit, backend, shots=backend_config['backend_options']['shots'])
|
|
86
|
+
result = job.result()
|
|
87
|
+
return result.get_counts()
|
|
88
|
+
|
|
89
|
+
# placeholder method for use in the testing suite
|
|
90
|
+
def get_final_state_vector(circuit, backend, backend_config):
|
|
91
|
+
simulator = qiskit.Aer.get_backend('statevector_simulator')
|
|
92
|
+
|
|
93
|
+
# Simulate the circuit
|
|
94
|
+
job = qiskit.execute(circuit, simulator)
|
|
95
|
+
result = job.result()
|
|
96
|
+
|
|
97
|
+
return result.get_statevector()
|
|
98
|
+
|
|
99
|
+
def draw_circuit(circuit):
|
|
100
|
+
# Use Qiskit's built-in drawing function
|
|
101
|
+
print(circuit.draw())
|
|
102
|
+
|
|
103
|
+
def apply_rx_gate(circuit, qubit_index, angle):
|
|
104
|
+
param = qiskit.circuit.Parameter(angle) if isinstance(angle, str) else angle
|
|
105
|
+
circuit.rx(param, qubit_index)
|
|
106
|
+
|
|
107
|
+
def apply_ry_gate(circuit, qubit_index, angle):
|
|
108
|
+
param = qiskit.circuit.Parameter(angle) if isinstance(angle, str) else angle
|
|
109
|
+
circuit.ry(param, qubit_index)
|
|
110
|
+
|
|
111
|
+
def apply_rz_gate(circuit, qubit_index, angle):
|
|
112
|
+
param = qiskit.circuit.Parameter(angle) if isinstance(angle, str) else angle
|
|
113
|
+
circuit.rz(param, qubit_index)
|
|
114
|
+
|
|
115
|
+
def apply_u_gate(circuit, qubit_index, theta, phi, lambd):
|
|
116
|
+
# Apply the U gate directly with specified parameters
|
|
117
|
+
circuit.u(theta, phi, lambd, qubit_index)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
4
|
+
# this work for additional information regarding copyright ownership.
|
|
5
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
6
|
+
# (the "License"); you may not use this file except in compliance with
|
|
7
|
+
# the License. You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
from importlib import import_module
|
|
18
|
+
|
|
19
|
+
class QuMat:
|
|
20
|
+
def __init__(self, backend_config):
|
|
21
|
+
self.backend_config = backend_config
|
|
22
|
+
self.backend_name = backend_config['backend_name']
|
|
23
|
+
self.backend_module = import_module(f".{self.backend_name}_backend", package="qumat")
|
|
24
|
+
self.backend = self.backend_module.initialize_backend(backend_config)
|
|
25
|
+
self.circuit = None
|
|
26
|
+
self.parameters = {}
|
|
27
|
+
|
|
28
|
+
def create_empty_circuit(self, num_qubits):
|
|
29
|
+
self.circuit = self.backend_module.create_empty_circuit(num_qubits)
|
|
30
|
+
|
|
31
|
+
def apply_not_gate(self, qubit_index):
|
|
32
|
+
self.backend_module.apply_not_gate(self.circuit, qubit_index)
|
|
33
|
+
|
|
34
|
+
def apply_hadamard_gate(self, qubit_index):
|
|
35
|
+
self.backend_module.apply_hadamard_gate(self.circuit, qubit_index)
|
|
36
|
+
|
|
37
|
+
def apply_cnot_gate(self, control_qubit_index, target_qubit_index):
|
|
38
|
+
self.backend_module.apply_cnot_gate(self.circuit, control_qubit_index, target_qubit_index)
|
|
39
|
+
|
|
40
|
+
def apply_toffoli_gate(self, control_qubit_index1, control_qubit_index2, target_qubit_index):
|
|
41
|
+
self.backend_module.apply_toffoli_gate(self.circuit, control_qubit_index1, control_qubit_index2, target_qubit_index)
|
|
42
|
+
|
|
43
|
+
def apply_swap_gate(self, qubit_index1, qubit_index2):
|
|
44
|
+
self.backend_module.apply_swap_gate(self.circuit, qubit_index1, qubit_index2)
|
|
45
|
+
|
|
46
|
+
def apply_pauli_x_gate(self, qubit_index):
|
|
47
|
+
self.backend_module.apply_pauli_x_gate(self.circuit, qubit_index)
|
|
48
|
+
|
|
49
|
+
def apply_pauli_y_gate(self, qubit_index):
|
|
50
|
+
self.backend_module.apply_pauli_y_gate(self.circuit, qubit_index)
|
|
51
|
+
|
|
52
|
+
def apply_pauli_z_gate(self, qubit_index):
|
|
53
|
+
self.backend_module.apply_pauli_z_gate(self.circuit, qubit_index)
|
|
54
|
+
|
|
55
|
+
def execute_circuit(self, parameter_values=None):
|
|
56
|
+
if parameter_values:
|
|
57
|
+
self.bind_parameters(parameter_values)
|
|
58
|
+
self.backend_config['parameter_values'] = self.parameters # Pass parameters
|
|
59
|
+
return self.backend_module.execute_circuit(self.circuit, self.backend, self.backend_config)
|
|
60
|
+
|
|
61
|
+
def bind_parameters(self, parameter_values):
|
|
62
|
+
for param, value in parameter_values.items():
|
|
63
|
+
if param in self.parameters:
|
|
64
|
+
self.parameters[param] = value
|
|
65
|
+
|
|
66
|
+
# placeholder method for use in the testing suite
|
|
67
|
+
def get_final_state_vector(self):
|
|
68
|
+
return self.backend_module.get_final_state_vector(self.circuit, self.backend, self.backend_config)
|
|
69
|
+
|
|
70
|
+
def draw(self):
|
|
71
|
+
return self.backend_module.draw_circuit(self.circuit)
|
|
72
|
+
|
|
73
|
+
def apply_rx_gate(self, qubit_index, angle):
|
|
74
|
+
self._handle_parameter(angle)
|
|
75
|
+
self.backend_module.apply_rx_gate(self.circuit, qubit_index, angle)
|
|
76
|
+
|
|
77
|
+
def apply_ry_gate(self, qubit_index, angle):
|
|
78
|
+
self._handle_parameter(angle)
|
|
79
|
+
self.backend_module.apply_ry_gate(self.circuit, qubit_index, angle)
|
|
80
|
+
|
|
81
|
+
def apply_rz_gate(self, qubit_index, angle):
|
|
82
|
+
self._handle_parameter(angle)
|
|
83
|
+
self.backend_module.apply_rz_gate(self.circuit, qubit_index, angle)
|
|
84
|
+
|
|
85
|
+
def _handle_parameter(self, param_name):
|
|
86
|
+
if isinstance(param_name, str) and param_name not in self.parameters:
|
|
87
|
+
self.parameters[param_name] = None
|
|
88
|
+
|
|
89
|
+
def apply_u_gate(self, qubit_index, theta, phi, lambd):
|
|
90
|
+
self.backend_module.apply_u_gate(self.circuit, qubit_index, theta, phi, lambd)
|