pyqrack-complex128 1.65.6__tar.gz → 1.74.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.

Potentially problematic release.


This version of pyqrack-complex128 might be problematic. Click here for more details.

Files changed (29) hide show
  1. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/Makefile +17 -5
  2. {pyqrack_complex128-1.65.6/pyqrack_complex128.egg-info → pyqrack_complex128-1.74.0}/PKG-INFO +2 -2
  3. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyproject.toml +1 -2
  4. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_simulator.py +108 -12
  5. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_system/qrack_system.py +19 -3
  6. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0/pyqrack_complex128.egg-info}/PKG-INFO +2 -2
  7. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/setup.py +3 -3
  8. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/LICENSE +0 -0
  9. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/MANIFEST.in +0 -0
  10. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/README.md +0 -0
  11. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/__init__.py +0 -0
  12. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/neuron_activation_fn.py +0 -0
  13. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/pauli.py +0 -0
  14. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_ace_backend.py +0 -0
  15. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_circuit.py +0 -0
  16. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_neuron.py +0 -0
  17. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  18. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_stabilizer.py +0 -0
  19. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/qrack_system/__init__.py +0 -0
  20. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/quimb_circuit_type.py +0 -0
  21. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/stats/__init__.py +0 -0
  22. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/stats/load_quantized_data.py +0 -0
  23. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack/stats/quantize_by_range.py +0 -0
  24. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack_complex128.egg-info/SOURCES.txt +0 -0
  25. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack_complex128.egg-info/dependency_links.txt +0 -0
  26. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack_complex128.egg-info/not-zip-safe +0 -0
  27. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack_complex128.egg-info/requires.txt +0 -0
  28. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/pyqrack_complex128.egg-info/top_level.txt +0 -0
  29. {pyqrack_complex128-1.65.6 → pyqrack_complex128-1.74.0}/setup.cfg +0 -0
@@ -6,6 +6,16 @@ UNAME_S := $(shell uname -s)
6
6
  UNAME_P := $(shell uname -p)
7
7
  QRACK_PRESENT := $(wildcard qrack/.)
8
8
 
9
+ ifeq ("$(wildcard /usr/local/bin/cmake)", "/usr/local/bin/cmake")
10
+ CMAKE_L := /usr/local/bin/cmake
11
+ else
12
+ ifeq ("$(wildcard /usr/bin/cmake)", "/usr/bin/cmake")
13
+ CMAKE_L := /usr/bin/cmake
14
+ else
15
+ CMAKE_L := cmake
16
+ endif
17
+ endif
18
+
9
19
  .PHONY: help
10
20
  help:
11
21
  @echo "Please use \`make <target>' where <target> is one of"
@@ -16,23 +26,25 @@ help:
16
26
 
17
27
  .PHONY: build-deps
18
28
  build-deps:
29
+ rm -rf pyqrack/qrack_system/qrack_lib
30
+ rm -rf pyqrack/qrack_system/qrack_cl_precompile
19
31
  ifneq ($(OS),Windows_NT)
20
32
  ifeq ($(QRACK_PRESENT),)
21
- git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 37d462c76f418b358876ed2d73da70fe19aacd97; cd ..
33
+ git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 909992056900c61d53ea85dfac2febb4d0c87951; cd ..
22
34
  endif
23
35
  mkdir -p qrack/build
24
36
  ifeq ($(UNAME_S),Linux)
25
37
  ifeq ($(UNAME_P),x86_64)
26
- cd qrack/build; cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DQBCAPPOW=9 -DFPPOW=6 ..; make qrack_pinvoke qrack_cl_precompile
38
+ cd qrack/build; $(CMAKE_L) -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DQBCAPPOW=8 -DFPPOW=6 ..; make qrack_pinvoke qrack_cl_precompile
27
39
  else
28
- cd qrack/build; cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=9 -DFPPOW=6 ..; make qrack_pinvoke qrack_cl_precompile
40
+ cd qrack/build; $(CMAKE_L) -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=8 -DFPPOW=6 ..; make qrack_pinvoke qrack_cl_precompile
29
41
  endif
30
42
  endif
31
43
  ifeq ($(UNAME_S),Darwin)
32
44
  ifeq ($(UNAME_P),x86_64)
33
- cd qrack/build; cmake -DQBCAPPOW=9 -DFPPOW=6 -DBoost_INCLUDE_DIR=/opt/homebrew/include -DBoost_LIBRARY_DIRS=/opt/homebrew/lib ..; make qrack_pinvoke qrack_cl_precompile
45
+ cd qrack/build; cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DQBCAPPOW=8 ..; make qrack_pinvoke qrack_cl_precompile
34
46
  else
35
- cd qrack/build; cmake -DENABLE_OPENCL=OFF -DENABLE_RDRAND=OFF -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=9 -DFPPOW=6 -DBoost_INCLUDE_DIR=/opt/homebrew/include -DBoost_LIBRARY_DIRS=/opt/homebrew/lib ..; make qrack_pinvoke qrack_cl_precompile
47
+ cd qrack/build; cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DENABLE_OPENCL=OFF -DENABLE_RDRAND=OFF -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DQBCAPPOW=8 ..; make qrack_pinvoke qrack_cl_precompile
36
48
  endif
37
49
  endif
38
50
  endif
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-complex128
3
- Version: 1.65.6
3
+ Version: 1.74.0
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -34,7 +34,7 @@ Classifier: Programming Language :: Python :: 3.9
34
34
  Classifier: Programming Language :: Python :: 3.10
35
35
  Classifier: Programming Language :: Python :: 3.11
36
36
  Classifier: Programming Language :: Python :: 3.12
37
- Classifier: Topic :: Scientific/Engineering
37
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
38
38
  Description-Content-Type: text/markdown
39
39
  License-File: LICENSE
40
40
  Provides-Extra: dev
@@ -1,7 +1,6 @@
1
1
  [build-system]
2
2
  requires = [
3
3
  "setuptools>=42",
4
- "wheel",
5
- "cmake"
4
+ "wheel"
6
5
  ]
7
6
  build-backend = "setuptools.build_meta"
@@ -49,7 +49,7 @@ class QrackSimulator:
49
49
  self,
50
50
  qubitCount=-1,
51
51
  cloneSid=-1,
52
- isTensorNetwork=True,
52
+ isTensorNetwork=False,
53
53
  isSchmidtDecomposeMulti=False,
54
54
  isSchmidtDecompose=True,
55
55
  isStabilizerHybrid=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()
@@ -2132,9 +2134,7 @@ class QrackSimulator:
2132
2134
  def decompose(self, q):
2133
2135
  """Decompose system
2134
2136
 
2135
- Decompose the given qubit out of the system.
2136
- Warning: The qubit subsystem state must be separable, or the behavior
2137
- of this method is undefined.
2137
+ Factorize a set of contiguous bits with minimal fidelity loss.
2138
2138
 
2139
2139
  Args:
2140
2140
  q: qubit id
@@ -2144,7 +2144,7 @@ class QrackSimulator:
2144
2144
  RuntimeError: QrackSimulator with isTensorNetwork=True option cannot decompose()! (Turn off just this option, in the constructor.)
2145
2145
 
2146
2146
  Returns:
2147
- State of the systems.
2147
+ Decomposed subsystem simulator.
2148
2148
  """
2149
2149
  if self.is_tensor_network:
2150
2150
  raise RuntimeError(
@@ -2161,10 +2161,8 @@ class QrackSimulator:
2161
2161
  def dispose(self, q):
2162
2162
  """Dispose qubits
2163
2163
 
2164
- Minimally decompose a set of contiguous bits from the separably
2165
- composed unit, and discard the separable bits.
2166
- Warning: The qubit subsystem state must be separable, or the behavior
2167
- of this method is undefined.
2164
+ Factorize a set of contiguous bits with minimal fidelity loss,
2165
+ and discard the separable bits.
2168
2166
 
2169
2167
  Args:
2170
2168
  q: qubit
@@ -2172,9 +2170,6 @@ class QrackSimulator:
2172
2170
  Raises:
2173
2171
  RuntimeError: QrackSimulator raised an exception.
2174
2172
  RuntimeError: QrackSimulator with isTensorNetwork=True option cannot dispose()! (Turn off just this option, in the constructor.)
2175
-
2176
- Returns:
2177
- State of the systems.
2178
2173
  """
2179
2174
  if self.is_tensor_network:
2180
2175
  raise RuntimeError(
@@ -2292,6 +2287,72 @@ class QrackSimulator:
2292
2287
  self._throw_if_error()
2293
2288
  return list(probs)
2294
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
+
2295
2356
  def prob_all(self, q):
2296
2357
  """Probabilities of all subset permutations
2297
2358
 
@@ -3261,6 +3322,41 @@ class QrackSimulator:
3261
3322
  Qrack.qrack_lib.SetNoiseParameter(self.sid, np)
3262
3323
  self._throw_if_error()
3263
3324
 
3325
+ def set_ace_max_qb(self, qb):
3326
+ """Set "automatic circuit elision" (ACE) max qubits
3327
+
3328
+ If isSchmidtDecompose=True, maximum entangled subsytem size
3329
+ of this simulator will be capped to 'qb', and entangling
3330
+ gates that would exceed that size are replaced with gate
3331
+ shadows.
3332
+
3333
+ Args:
3334
+ qb: maximum subsystem qubits
3335
+
3336
+ Raises:
3337
+ RuntimeError: QrackSimulator raised an exception.
3338
+ """
3339
+ Qrack.qrack_lib.SetAceMaxQb(self.sid, qb)
3340
+ self._throw_if_error()
3341
+
3342
+ def set_sparse_ace_max_mb(self, mb):
3343
+ """Set sparse "automatic circuit elision" (ACE) max memory
3344
+
3345
+ If isSchmidtDecompose=True, isSparse=True, and
3346
+ isOpenCL=False, maximum subsytem size memory MB of this
3347
+ simulator will be capped to 'mb', and entangling gates
3348
+ that would exceed that size are replaced with gate
3349
+ shadows.
3350
+
3351
+ Args:
3352
+ mb: maximum subsystem memory in MB
3353
+
3354
+ Raises:
3355
+ RuntimeError: QrackSimulator raised an exception.
3356
+ """
3357
+ Qrack.qrack_lib.SetSparseAceMaxMb(self.sid, mb)
3358
+ self._throw_if_error()
3359
+
3264
3360
  def normalize(self):
3265
3361
  """Normalize the state
3266
3362
 
@@ -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
@@ -155,6 +159,12 @@ class QrackSystem:
155
159
 
156
160
  # pseudo-quantum
157
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
+
158
168
  self.qrack_lib.ProbAll.restype = None
159
169
  if self.fppow == 5:
160
170
  self.qrack_lib.ProbAll.argtypes = [
@@ -1209,6 +1219,12 @@ class QrackSystem:
1209
1219
  self.qrack_lib.SetNoiseParameter.restype = None
1210
1220
  self.qrack_lib.SetNoiseParameter.argtypes = [c_ulonglong, c_double]
1211
1221
 
1222
+ self.qrack_lib.SetAceMaxQb.restype = None
1223
+ self.qrack_lib.SetAceMaxQb.argtypes = [c_ulonglong, c_ulonglong]
1224
+
1225
+ self.qrack_lib.SetSparseAceMaxMb.restype = None
1226
+ self.qrack_lib.SetSparseAceMaxMb.argtypes = [c_ulonglong, c_size_t]
1227
+
1212
1228
  self.qrack_lib.Normalize.restype = None
1213
1229
  self.qrack_lib.Normalize.argtypes = [c_ulonglong]
1214
1230
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-complex128
3
- Version: 1.65.6
3
+ Version: 1.74.0
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -34,7 +34,7 @@ Classifier: Programming Language :: Python :: 3.9
34
34
  Classifier: Programming Language :: Python :: 3.10
35
35
  Classifier: Programming Language :: Python :: 3.11
36
36
  Classifier: Programming Language :: Python :: 3.12
37
- Classifier: Topic :: Scientific/Engineering
37
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
38
38
  Description-Content-Type: text/markdown
39
39
  License-File: LICENSE
40
40
  Provides-Extra: dev
@@ -7,7 +7,7 @@ from setuptools import setup
7
7
  from setuptools.command.build_py import build_py
8
8
 
9
9
 
10
- VERSION = "1.65.6"
10
+ VERSION = "1.74.0"
11
11
 
12
12
  # Read long description from README.
13
13
  README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
@@ -64,11 +64,11 @@ setup(
64
64
  "Programming Language :: Python :: 3.10",
65
65
  "Programming Language :: Python :: 3.11",
66
66
  "Programming Language :: Python :: 3.12",
67
- "Topic :: Scientific/Engineering",
67
+ "Topic :: Scientific/Engineering :: Quantum Computing",
68
68
  ],
69
69
  keywords="pyqrack qrack simulator quantum gpu",
70
70
  install_requires=[],
71
- setup_requires=['cmake'],
71
+ setup_requires=[],
72
72
  extras_require={
73
73
  "dev": [
74
74
  "pytest>=7.3.1",