pyqrack 1.44.33__py3-none-macosx_15_0_arm64.whl → 1.70.0__py3-none-macosx_15_0_arm64.whl

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.
@@ -50,7 +50,7 @@ class QrackSimulator:
50
50
  qubitCount=-1,
51
51
  cloneSid=-1,
52
52
  isTensorNetwork=True,
53
- isSchmidtDecomposeMulti=True,
53
+ isSchmidtDecomposeMulti=False,
54
54
  isSchmidtDecompose=True,
55
55
  isStabilizerHybrid=False,
56
56
  isBinaryDecisionTree=False,
@@ -60,6 +60,7 @@ class QrackSimulator:
60
60
  isHostPointer=(
61
61
  True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False
62
62
  ),
63
+ isSparse=False,
63
64
  noise=0,
64
65
  pyzxCircuit=None,
65
66
  qiskitCircuit=None,
@@ -99,6 +100,7 @@ class QrackSimulator:
99
100
  isCpuGpuHybrid,
100
101
  isOpenCL,
101
102
  isHostPointer,
103
+ isSparse
102
104
  )
103
105
 
104
106
  self._throw_if_error()
@@ -122,6 +124,9 @@ class QrackSimulator:
122
124
  def _ulonglong_byref(self, a):
123
125
  return (ctypes.c_ulonglong * len(a))(*a)
124
126
 
127
+ def _longlong_byref(self, a):
128
+ return (ctypes.c_longlong * len(a))(*a)
129
+
125
130
  def _double_byref(self, a):
126
131
  return (ctypes.c_double * len(a))(*a)
127
132
 
@@ -181,9 +186,20 @@ class QrackSimulator:
181
186
  self._throw_if_error()
182
187
 
183
188
  def set_concurrency(self, p):
189
+ """Set the CPU parallel thread count"""
184
190
  Qrack.qrack_lib.set_concurrency(self.sid, p)
185
191
  self._throw_if_error()
186
192
 
193
+ def set_device(self, d):
194
+ """Set the GPU device ID"""
195
+ Qrack.qrack_lib.set_device(self.sid, d)
196
+ self._throw_if_error()
197
+
198
+ def set_device_list(self, d):
199
+ """Set the GPU device ID"""
200
+ Qrack.qrack_lib.set_device_list(self.sid, len(d), self._longlong_byref(d))
201
+ self._throw_if_error()
202
+
187
203
  def clone(self):
188
204
  return QrackSimulator(cloneSid=self.sid)
189
205
 
@@ -1039,9 +1055,16 @@ class QrackSimulator:
1039
1055
  Returns:
1040
1056
  Measurement result of all qubits.
1041
1057
  """
1042
- result = Qrack.qrack_lib.MAll(self.sid)
1058
+ num_q = self.num_qubits()
1059
+ num_words = (num_q + 63) // 64
1060
+ _r = (ctypes.c_ulonglong * num_words)()
1061
+ Qrack.qrack_lib.MAllLong(self.sid, _r)
1043
1062
  self._throw_if_error()
1044
- return result
1063
+ r = 0
1064
+ for w in range(num_words):
1065
+ r <<= 64
1066
+ r |= _r[w]
1067
+ return r
1045
1068
 
1046
1069
  def measure_pauli(self, b, q):
1047
1070
  """Pauli Measurement gate
@@ -2111,9 +2134,7 @@ class QrackSimulator:
2111
2134
  def decompose(self, q):
2112
2135
  """Decompose system
2113
2136
 
2114
- Decompose the given qubit out of the system.
2115
- Warning: The qubit subsystem state must be separable, or the behavior
2116
- of this method is undefined.
2137
+ Factorize a set of contiguous bits with minimal fidelity loss.
2117
2138
 
2118
2139
  Args:
2119
2140
  q: qubit id
@@ -2123,7 +2144,7 @@ class QrackSimulator:
2123
2144
  RuntimeError: QrackSimulator with isTensorNetwork=True option cannot decompose()! (Turn off just this option, in the constructor.)
2124
2145
 
2125
2146
  Returns:
2126
- State of the systems.
2147
+ Decomposed subsystem simulator.
2127
2148
  """
2128
2149
  if self.is_tensor_network:
2129
2150
  raise RuntimeError(
@@ -2140,10 +2161,8 @@ class QrackSimulator:
2140
2161
  def dispose(self, q):
2141
2162
  """Dispose qubits
2142
2163
 
2143
- Minimally decompose a set of contiguous bits from the separably
2144
- composed unit, and discard the separable bits.
2145
- Warning: The qubit subsystem state must be separable, or the behavior
2146
- of this method is undefined.
2164
+ Factorize a set of contiguous bits with minimal fidelity loss,
2165
+ and discard the separable bits.
2147
2166
 
2148
2167
  Args:
2149
2168
  q: qubit
@@ -2151,9 +2170,6 @@ class QrackSimulator:
2151
2170
  Raises:
2152
2171
  RuntimeError: QrackSimulator raised an exception.
2153
2172
  RuntimeError: QrackSimulator with isTensorNetwork=True option cannot dispose()! (Turn off just this option, in the constructor.)
2154
-
2155
- Returns:
2156
- State of the systems.
2157
2173
  """
2158
2174
  if self.is_tensor_network:
2159
2175
  raise RuntimeError(
@@ -2271,6 +2287,72 @@ class QrackSimulator:
2271
2287
  self._throw_if_error()
2272
2288
  return list(probs)
2273
2289
 
2290
+ def out_rdm(self, q):
2291
+ """Get reduced density matrix
2292
+
2293
+ Returns the raw reduced density matrix of the simulator, for the qubit list.
2294
+ Warning: State vector or is not always the internal representation leading
2295
+ to sub-optimal performance of the method.
2296
+
2297
+ Raises:
2298
+ RuntimeError: QrackSimulator raised an exception.
2299
+
2300
+ Returns:
2301
+ flat list structure representing the reduced density matrix.
2302
+ """
2303
+ amp_count = 1 << len(q)
2304
+ sqr_amp_count = amp_count * amp_count
2305
+ flat_rdm = self._qrack_complex_byref([complex(0, 0)] * sqr_amp_count)
2306
+ Qrack.qrack_lib.OutReducedDensityMatrix(self.sid, len(q), self._ulonglong_byref(q), flat_rdm)
2307
+ self._throw_if_error()
2308
+ return [complex(r, i) for r, i in self._pairwise(flat_rdm)]
2309
+
2310
+ def highest_prob_perm(self):
2311
+ """Get the permutation (bit string) with the highest probability
2312
+
2313
+ Returns the single highest-probability bit string in the Hilbert space
2314
+
2315
+ Raises:
2316
+ RuntimeError: QrackSimulator raised an exception.
2317
+
2318
+ Returns:
2319
+ Highest probability dimension index
2320
+ """
2321
+ num_q = self.num_qubits()
2322
+ num_words = (num_q + 63) // 64
2323
+ _r = (ctypes.c_ulonglong * num_words)()
2324
+ Qrack.qrack_lib.HighestProbAll(self.sid, _r)
2325
+ self._throw_if_error()
2326
+ r = 0
2327
+ for w in range(num_words):
2328
+ r <<= 64
2329
+ r |= _r[w]
2330
+ return r
2331
+
2332
+ def highest_n_prob_perm(self, n):
2333
+ """Get the top n permutations (bit strings) with the highest probability
2334
+
2335
+ Returns the top n highest-probability bit strings in the Hilbert space
2336
+
2337
+ Raises:
2338
+ RuntimeError: QrackSimulator raised an exception.
2339
+
2340
+ Returns:
2341
+ Top n highest probability dimension indices
2342
+ """
2343
+ num_q = self.num_qubits()
2344
+ num_words = (num_q + 63) // 64
2345
+ _r = (ctypes.c_ulonglong * (num_words * n))()
2346
+ Qrack.qrack_lib.HighestProbAllN(self.sid, n, _r)
2347
+ self._throw_if_error()
2348
+ r = [0] * n
2349
+ for i in range(n):
2350
+ r[i] = 0
2351
+ for w in range(num_words):
2352
+ r[i] <<= 64
2353
+ r[i] |= _r[(i * num_words) + w]
2354
+ return r
2355
+
2274
2356
  def prob_all(self, q):
2275
2357
  """Probabilities of all subset permutations
2276
2358
 
@@ -4374,3 +4456,43 @@ class QrackSimulator:
4374
4456
  del self._sim
4375
4457
 
4376
4458
  return _data
4459
+
4460
+ def get_qiskit_basis_gates():
4461
+ return [
4462
+ "id",
4463
+ "u",
4464
+ "u1",
4465
+ "u2",
4466
+ "u3",
4467
+ "r",
4468
+ "rx",
4469
+ "ry",
4470
+ "rz",
4471
+ "h",
4472
+ "x",
4473
+ "y",
4474
+ "z",
4475
+ "s",
4476
+ "sdg",
4477
+ "sx",
4478
+ "sxdg",
4479
+ "p",
4480
+ "t",
4481
+ "tdg",
4482
+ "cu",
4483
+ "cu1",
4484
+ "cu3",
4485
+ "cx",
4486
+ "cy",
4487
+ "cz",
4488
+ "ch",
4489
+ "cp",
4490
+ "csx",
4491
+ "ccx",
4492
+ "ccz",
4493
+ "swap",
4494
+ "iswap",
4495
+ "cswap",
4496
+ "reset",
4497
+ "measure",
4498
+ ]
@@ -87,19 +87,22 @@ class QrackSystem:
87
87
  CFUNCTYPE(c_ulonglong, c_double, c_double),
88
88
  ]
89
89
 
90
- # These next two methods need to have c_double pointers, if PyQrack is built with fp64.
90
+ # These next few methods need to have c_double pointers, if PyQrack is built with fp64.
91
91
  self.qrack_lib.InKet.restype = None
92
92
  self.qrack_lib.OutKet.restype = None
93
93
  self.qrack_lib.OutProbs.restype = None
94
+ self.qrack_lib.OutReducedDensityMatrix.restype = None
94
95
 
95
96
  if self.fppow < 6:
96
97
  self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_float)]
97
98
  self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_float)]
98
99
  self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_float)]
100
+ self.qrack_lib.OutReducedDensityMatrix.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong), POINTER(c_float)]
99
101
  else:
100
102
  self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_double)]
101
103
  self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_double)]
102
104
  self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_double)]
105
+ self.qrack_lib.OutReducedDensityMatrix.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong), POINTER(c_double)]
103
106
 
104
107
  self.qrack_lib.init.restype = c_ulonglong
105
108
  self.qrack_lib.init.argtypes = []
@@ -108,10 +111,10 @@ class QrackSystem:
108
111
  self.qrack_lib.get_error.argtypes = [c_ulonglong]
109
112
 
110
113
  self.qrack_lib.init_count.restype = c_ulonglong
111
- self.qrack_lib.init_count.argtypes = [c_ulonglong, c_bool]
114
+ self.qrack_lib.init_count.argtypes = [c_ulonglong, c_bool, c_bool]
112
115
 
113
116
  self.qrack_lib.init_count_pager.restype = c_ulonglong
114
- self.qrack_lib.init_count_pager.argtypes = [c_ulonglong, c_bool]
117
+ self.qrack_lib.init_count_pager.argtypes = [c_ulonglong, c_bool, c_bool]
115
118
 
116
119
  self.qrack_lib.init_count_type.restype = c_ulonglong
117
120
  self.qrack_lib.init_count_type.argtypes = [
@@ -126,6 +129,7 @@ class QrackSystem:
126
129
  c_bool,
127
130
  c_bool,
128
131
  c_bool,
132
+ c_bool
129
133
  ]
130
134
 
131
135
  self.qrack_lib.init_count_stabilizer.restype = c_ulonglong
@@ -143,8 +147,24 @@ class QrackSystem:
143
147
  self.qrack_lib.set_concurrency.restype = None
144
148
  self.qrack_lib.set_concurrency.argtypes = [c_ulonglong, c_ulonglong]
145
149
 
150
+ self.qrack_lib.set_device.restype = None
151
+ self.qrack_lib.set_device.argtypes = [c_ulonglong, c_longlong]
152
+
153
+ self.qrack_lib.set_device_list.restype = None
154
+ self.qrack_lib.set_device_list.argtypes = [
155
+ c_ulonglong,
156
+ c_ulonglong,
157
+ POINTER(c_longlong),
158
+ ]
159
+
146
160
  # pseudo-quantum
147
161
 
162
+ self.qrack_lib.HighestProbAll.restype = None
163
+ self.qrack_lib.HighestProbAll.argtypes = [c_ulonglong, POINTER(c_ulonglong)]
164
+
165
+ self.qrack_lib.HighestProbAllN.restype = None
166
+ self.qrack_lib.HighestProbAllN.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
167
+
148
168
  self.qrack_lib.ProbAll.restype = None
149
169
  if self.fppow == 5:
150
170
  self.qrack_lib.ProbAll.argtypes = [
@@ -780,6 +800,9 @@ class QrackSystem:
780
800
  self.qrack_lib.MAll.restype = c_ulonglong
781
801
  self.qrack_lib.MAll.argtypes = [c_ulonglong]
782
802
 
803
+ self.qrack_lib.MAllLong.restype = None
804
+ self.qrack_lib.MAllLong.argtypes = [c_ulonglong, POINTER(c_ulonglong)]
805
+
783
806
  self.qrack_lib.Measure.restype = c_ulonglong
784
807
  self.qrack_lib.Measure.argtypes = [
785
808
  c_ulonglong,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyqrack
3
- Version: 1.44.33
3
+ Version: 1.70.0
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -47,7 +47,7 @@ Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator
47
47
 
48
48
  (**PyQrack** is just pure Qrack.)
49
49
 
50
- **Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **You must also install OpenCL.**
50
+ **Note: You must also install OpenCL to use this version of Qrack.** (There are also CPU-only and CUDA version.)
51
51
 
52
52
  **If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
53
53
 
@@ -79,4 +79,4 @@ For custom Qrack build floating-point precision, where options are `half`, `floa
79
79
 
80
80
  Please feel welcome to open an issue, if you'd like help. 😃
81
81
 
82
- **Special thanks go to Zeeshan Ahmed, for bug fixes and design suggestions, Ashish Panigrahi, for documentation and design suggestions, WingCode, for documentation, and to the broader community of Qrack contributors, for years of happy Qracking! You rock!**
82
+ **Special thanks go to Zeeshan Ahmed, for bug fixes and design suggestions, Ashish Panigrahi, for documentation and design suggestions, WingCode, for documentation, Or Golan, for CI build pipeline tooling, and to the broader community of Qrack contributors, for years of happy Qracking! You rock!**
@@ -1,22 +1,23 @@
1
1
  pyqrack/__init__.py,sha256=3tBwfCCD-zQjQ2g1EUZdggKdn-3b2uSFTbT7LS0YLaU,785
2
2
  pyqrack/neuron_activation_fn.py,sha256=fQTTFfsvwcot_43Vopacot47IV2Rxk8pelUyuzwpXPs,593
3
3
  pyqrack/pauli.py,sha256=wg500wDOwdIU4lEVJoMmjtbAdmtakZYzLPjdzC2rwUQ,654
4
- pyqrack/qrack_ace_backend.py,sha256=re4vovUF12Uj1YbhaejStmKWOXQ2dqK5CVdLnZTbp5Q,27629
4
+ pyqrack/qrack_ace_backend.py,sha256=Prw1NhVVt0csbHiJeW8MJI9rl1P1YS63sXM5quoNPrI,49392
5
5
  pyqrack/qrack_circuit.py,sha256=vDCKGbcEHJDFUKprjCpWgit8lXFnMrPimKHURD2_Hj4,19538
6
6
  pyqrack/qrack_neuron.py,sha256=UiJdjAGB6usjAGHWSosSFCUUeIkhh3MtZbsaxfsIsNw,9043
7
7
  pyqrack/qrack_neuron_torch_layer.py,sha256=Bs5BLC2GFevfSpo_jSJ2AZl-hfDRJmzlGN9pFw1CtoQ,6160
8
- pyqrack/qrack_simulator.py,sha256=ddn0Bz0FNwu5Ft5pl8C1mXtXDMid58gBWGPEPrlbXAY,142593
8
+ pyqrack/qrack_simulator.py,sha256=PSrcEIlzCt33WXjoEo5dZdmzx9zR90QI_Dw9LTphjMg,146030
9
9
  pyqrack/qrack_stabilizer.py,sha256=O-7VJ9Vw4h25PK_kesSjIqHXGSo8lLrQLIyGgmzG7Co,2124
10
10
  pyqrack/quimb_circuit_type.py,sha256=Sk-Tmn38kUYmAkJJ75btWuhYZyTXOOezmowFhfdiGDc,621
11
11
  pyqrack/qrack_system/__init__.py,sha256=-oZ9dsb1hixsnrkUJRY_C5DzQ_l6MtifF_Z465BgqV4,334
12
- pyqrack/qrack_system/qrack_system.py,sha256=OG1D1PgUqYAYlyDH7QfgfcM_4NH4tpFgig3xe3RlE_0,42622
13
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.9.19.6.dylib,sha256=maFaiJ-zAfcdANen0tdgcV5Cv7bdCHnEdHiCnaybZ9s,2764272
14
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib,sha256=maFaiJ-zAfcdANen0tdgcV5Cv7bdCHnEdHiCnaybZ9s,2764272
12
+ pyqrack/qrack_system/qrack_system.py,sha256=ToxxggEEJmEJjWwvnBDe5ZYbN-iks5OmWlWXYE5Oiw8,43719
13
+ pyqrack/qrack_system/qrack_cl_precompile/qrack_cl_precompile,sha256=WQ9ogDtySxTbg9Fv6wBClCanD5AWqZthx-wz0oulE2g,36224
14
+ pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.9.29.0.dylib,sha256=mdxhgT-jZ0WfKd1dNWL-xw-l9aAvq7PgN2hERkQu6c8,3549776
15
+ pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib,sha256=mdxhgT-jZ0WfKd1dNWL-xw-l9aAvq7PgN2hERkQu6c8,3549776
15
16
  pyqrack/stats/__init__.py,sha256=Hla85my2fY_roR9lIjGBVpEG7ySOTMwjWa8D6-kgCnY,276
16
17
  pyqrack/stats/load_quantized_data.py,sha256=z12u9F7Nt3P-i44nY1xxvso_klS6WIHS3iqq7R2_lqE,1184
17
18
  pyqrack/stats/quantize_by_range.py,sha256=UM0_7jJDdQ7g30cR3UQAxkbzkqrmsy1oUfqg0h11FUY,2270
18
- pyqrack-1.44.33.dist-info/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
19
- pyqrack-1.44.33.dist-info/METADATA,sha256=hZ0cCukn4208wneNikigKFsHYI51iYjsawFDkTiZbto,6035
20
- pyqrack-1.44.33.dist-info/WHEEL,sha256=uKwoxROtjcnx4Gbh9Fbsan8Fm8wY5xdQpS0Bc4agBqM,106
21
- pyqrack-1.44.33.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
22
- pyqrack-1.44.33.dist-info/RECORD,,
19
+ pyqrack-1.70.0.dist-info/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
20
+ pyqrack-1.70.0.dist-info/METADATA,sha256=_nsxdb0SMXlE7M3GAJa7Z_-cxeg2gm_O8kjJoKqa-fY,5892
21
+ pyqrack-1.70.0.dist-info/WHEEL,sha256=uKwoxROtjcnx4Gbh9Fbsan8Fm8wY5xdQpS0Bc4agBqM,106
22
+ pyqrack-1.70.0.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
23
+ pyqrack-1.70.0.dist-info/RECORD,,