pyqrack-complex128 1.80.6__tar.gz → 1.83.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.
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/Makefile +1 -1
- {pyqrack_complex128-1.80.6/pyqrack_complex128.egg-info → pyqrack_complex128-1.83.0}/PKG-INFO +1 -1
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_neuron.py +46 -33
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_neuron_torch_layer.py +54 -34
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_simulator.py +39 -91
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_system/qrack_system.py +54 -49
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0/pyqrack_complex128.egg-info}/PKG-INFO +1 -1
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/setup.py +1 -1
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/LICENSE +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/MANIFEST.in +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/README.md +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyproject.toml +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/__init__.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/neuron_activation_fn.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/pauli.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_ace_backend.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_circuit.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_stabilizer.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_system/__init__.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/quimb_circuit_type.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/stats/__init__.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/stats/load_quantized_data.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/stats/quantize_by_range.py +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/SOURCES.txt +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/dependency_links.txt +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/not-zip-safe +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/requires.txt +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/top_level.txt +0 -0
- {pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/setup.cfg +0 -0
|
@@ -30,7 +30,7 @@ build-deps:
|
|
|
30
30
|
rm -rf pyqrack/qrack_system/qrack_cl_precompile
|
|
31
31
|
ifneq ($(OS),Windows_NT)
|
|
32
32
|
ifeq ($(QRACK_PRESENT),)
|
|
33
|
-
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout
|
|
33
|
+
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 0033dfb996eb198a05cf34bcc2cf513b52298272; cd ..
|
|
34
34
|
endif
|
|
35
35
|
mkdir -p qrack/build
|
|
36
36
|
ifeq ($(UNAME_S),Linux)
|
|
@@ -31,7 +31,9 @@ class QrackNeuron:
|
|
|
31
31
|
simulator(QrackSimulator): Simulator instance for all synaptic clefts of the neuron
|
|
32
32
|
controls(list(int)): Indices of all "control" qubits, for neuron input
|
|
33
33
|
target(int): Index of "target" qubit, for neuron output
|
|
34
|
-
|
|
34
|
+
activation_fn(NeuronActivationFn): Activation function choice
|
|
35
|
+
alpha(float): Activation function parameter, if required
|
|
36
|
+
angles(list[ctypes.c_float]): (or c_double) Memory for neuron prediction angles
|
|
35
37
|
"""
|
|
36
38
|
|
|
37
39
|
def _get_error(self):
|
|
@@ -48,15 +50,15 @@ class QrackNeuron:
|
|
|
48
50
|
target,
|
|
49
51
|
activation_fn=NeuronActivationFn.Sigmoid,
|
|
50
52
|
alpha=1.0,
|
|
51
|
-
tolerance=sys.float_info.epsilon,
|
|
52
53
|
_init=True,
|
|
54
|
+
_isTorch=False
|
|
53
55
|
):
|
|
54
56
|
self.simulator = simulator
|
|
55
57
|
self.controls = controls
|
|
56
58
|
self.target = target
|
|
57
59
|
self.activation_fn = activation_fn
|
|
58
60
|
self.alpha = alpha
|
|
59
|
-
self.
|
|
61
|
+
self.angles = None if _isTorch else QrackNeuron._real1_byref([0.0] * (1 << len(controls)))
|
|
60
62
|
|
|
61
63
|
if not _init:
|
|
62
64
|
return
|
|
@@ -66,9 +68,6 @@ class QrackNeuron:
|
|
|
66
68
|
len(controls),
|
|
67
69
|
QrackNeuron._ulonglong_byref(controls),
|
|
68
70
|
target,
|
|
69
|
-
activation_fn,
|
|
70
|
-
alpha,
|
|
71
|
-
tolerance,
|
|
72
71
|
)
|
|
73
72
|
|
|
74
73
|
self._throw_if_error()
|
|
@@ -91,11 +90,9 @@ class QrackNeuron:
|
|
|
91
90
|
self.simulator,
|
|
92
91
|
self.controls,
|
|
93
92
|
self.target,
|
|
94
|
-
self.activation_fn,
|
|
95
|
-
self.alpha,
|
|
96
|
-
self.tolerance,
|
|
97
93
|
)
|
|
98
|
-
|
|
94
|
+
result.nid = Qrack.qrack_lib.clone_qneuron(self.simulator.sid)
|
|
95
|
+
result.angles = self.angles[:]
|
|
99
96
|
self._throw_if_error()
|
|
100
97
|
return result
|
|
101
98
|
|
|
@@ -110,20 +107,50 @@ class QrackNeuron:
|
|
|
110
107
|
return (ctypes.c_float * len(a))(*a)
|
|
111
108
|
return (ctypes.c_double * len(a))(*a)
|
|
112
109
|
|
|
113
|
-
def set_simulator(self, s):
|
|
110
|
+
def set_simulator(self, s, controls=None, target=None):
|
|
114
111
|
"""Set the neuron simulator
|
|
115
112
|
|
|
116
113
|
Set the simulator used by this neuron
|
|
117
114
|
|
|
118
115
|
Args:
|
|
119
116
|
s(QrackSimulator): The simulator to use
|
|
117
|
+
controls(list[int]): The control qubit IDs to use
|
|
118
|
+
target(int): The output qubit ID to use
|
|
120
119
|
|
|
121
120
|
Raises:
|
|
122
121
|
RuntimeError: QrackSimulator raised an exception.
|
|
123
122
|
"""
|
|
124
|
-
|
|
123
|
+
if controls is None:
|
|
124
|
+
controls = self.controls
|
|
125
|
+
if target is None:
|
|
126
|
+
target = self.target
|
|
127
|
+
Qrack.qrack_lib.set_qneuron_sim(
|
|
128
|
+
self.nid,
|
|
129
|
+
s.sid,
|
|
130
|
+
len(controls),
|
|
131
|
+
QrackNeuron._ulonglong_byref(controls),
|
|
132
|
+
target,
|
|
133
|
+
)
|
|
125
134
|
self._throw_if_error()
|
|
126
135
|
self.simulator = s
|
|
136
|
+
self.controls = controls
|
|
137
|
+
self.target = target
|
|
138
|
+
|
|
139
|
+
def set_qubit_ids(self, controls, target=None):
|
|
140
|
+
"""Set the neuron qubit identifiers
|
|
141
|
+
|
|
142
|
+
Set the control and target qubits within the simulator
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
controls(list[int]): The control qubit IDs to use
|
|
146
|
+
target(int): The output qubit ID to use
|
|
147
|
+
|
|
148
|
+
Raises:
|
|
149
|
+
RuntimeError: QrackSimulator raised an exception.
|
|
150
|
+
"""
|
|
151
|
+
if target is None:
|
|
152
|
+
target = self.target
|
|
153
|
+
self.set_simulator(self.simulator, controls, target)
|
|
127
154
|
|
|
128
155
|
def set_angles(self, a):
|
|
129
156
|
"""Directly sets the neuron parameters.
|
|
@@ -142,8 +169,7 @@ class QrackNeuron:
|
|
|
142
169
|
raise ValueError(
|
|
143
170
|
"Angles 'a' in QrackNeuron.set_angles() must contain at least (2 ** len(self.controls)) elements."
|
|
144
171
|
)
|
|
145
|
-
|
|
146
|
-
self._throw_if_error()
|
|
172
|
+
self.angles = QrackNeuron._real1_byref(a)
|
|
147
173
|
|
|
148
174
|
def get_angles(self):
|
|
149
175
|
"""Directly gets the neuron parameters.
|
|
@@ -154,10 +180,7 @@ class QrackNeuron:
|
|
|
154
180
|
Raises:
|
|
155
181
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
156
182
|
"""
|
|
157
|
-
|
|
158
|
-
Qrack.qrack_lib.get_qneuron_angles(self.nid, ket)
|
|
159
|
-
self._throw_if_error()
|
|
160
|
-
return list(ket)
|
|
183
|
+
return list(self.angles)
|
|
161
184
|
|
|
162
185
|
def set_alpha(self, a):
|
|
163
186
|
"""Set the neuron 'alpha' parameter.
|
|
@@ -166,13 +189,8 @@ class QrackNeuron:
|
|
|
166
189
|
parameter that is applied as a power to its angles, before
|
|
167
190
|
learning and prediction. This makes the activation function
|
|
168
191
|
sharper (or less sharp).
|
|
169
|
-
|
|
170
|
-
Raises:
|
|
171
|
-
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
172
192
|
"""
|
|
173
193
|
self.alpha = a
|
|
174
|
-
Qrack.qrack_lib.set_qneuron_alpha(self.nid, a)
|
|
175
|
-
self._throw_if_error()
|
|
176
194
|
|
|
177
195
|
def set_activation_fn(self, f):
|
|
178
196
|
"""Sets the activation function of this QrackNeuron
|
|
@@ -180,13 +198,8 @@ class QrackNeuron:
|
|
|
180
198
|
Nonlinear activation functions can be important to neural net
|
|
181
199
|
applications, like DNN. The available activation functions are
|
|
182
200
|
enumerated in `NeuronActivationFn`.
|
|
183
|
-
|
|
184
|
-
Raises:
|
|
185
|
-
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
186
201
|
"""
|
|
187
202
|
self.activation_fn = f
|
|
188
|
-
Qrack.qrack_lib.set_qneuron_activation_fn(self.nid, f)
|
|
189
|
-
self._throw_if_error()
|
|
190
203
|
|
|
191
204
|
def predict(self, e=True, r=True):
|
|
192
205
|
"""Predict based on training
|
|
@@ -205,7 +218,7 @@ class QrackNeuron:
|
|
|
205
218
|
Raises:
|
|
206
219
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
207
220
|
"""
|
|
208
|
-
result = Qrack.qrack_lib.qneuron_predict(self.nid, e, r)
|
|
221
|
+
result = Qrack.qrack_lib.qneuron_predict(self.nid, self.angles, e, r, self.activation_fn, self.alpha)
|
|
209
222
|
self._throw_if_error()
|
|
210
223
|
return result
|
|
211
224
|
|
|
@@ -221,7 +234,7 @@ class QrackNeuron:
|
|
|
221
234
|
Raises:
|
|
222
235
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
223
236
|
"""
|
|
224
|
-
result = Qrack.qrack_lib.qneuron_unpredict(self.nid, e)
|
|
237
|
+
result = Qrack.qrack_lib.qneuron_unpredict(self.nid, self.angles, e, self.activation_fn, self.alpha)
|
|
225
238
|
self._throw_if_error()
|
|
226
239
|
return result
|
|
227
240
|
|
|
@@ -237,7 +250,7 @@ class QrackNeuron:
|
|
|
237
250
|
Raises:
|
|
238
251
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
239
252
|
"""
|
|
240
|
-
Qrack.qrack_lib.qneuron_learn_cycle(self.nid, e)
|
|
253
|
+
Qrack.qrack_lib.qneuron_learn_cycle(self.nid, self.angles, e, self.activation_fn, self.alpha)
|
|
241
254
|
self._throw_if_error()
|
|
242
255
|
|
|
243
256
|
def learn(self, eta, e=True, r=True):
|
|
@@ -256,7 +269,7 @@ class QrackNeuron:
|
|
|
256
269
|
Raises:
|
|
257
270
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
258
271
|
"""
|
|
259
|
-
Qrack.qrack_lib.qneuron_learn(self.nid, eta, e, r)
|
|
272
|
+
Qrack.qrack_lib.qneuron_learn(self.nid, self.angles, eta, e, r, self.activation_fn, self.alpha)
|
|
260
273
|
self._throw_if_error()
|
|
261
274
|
|
|
262
275
|
def learn_permutation(self, eta, e=True, r=True):
|
|
@@ -275,7 +288,7 @@ class QrackNeuron:
|
|
|
275
288
|
Raises:
|
|
276
289
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
|
277
290
|
"""
|
|
278
|
-
Qrack.qrack_lib.qneuron_learn_permutation(self.nid, eta, e, r)
|
|
291
|
+
Qrack.qrack_lib.qneuron_learn_permutation(self.nid, self.angles, eta, e, r, self.activation_fn, self.alpha)
|
|
279
292
|
self._throw_if_error()
|
|
280
293
|
|
|
281
294
|
@staticmethod
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
# Use of this source code is governed by an MIT-style license that can be
|
|
7
7
|
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
8
8
|
|
|
9
|
+
import ctypes
|
|
9
10
|
import itertools
|
|
10
11
|
import math
|
|
11
12
|
import random
|
|
@@ -16,12 +17,14 @@ try:
|
|
|
16
17
|
import torch
|
|
17
18
|
import torch.nn as nn
|
|
18
19
|
from torch.autograd import Function
|
|
20
|
+
import numpy as np
|
|
19
21
|
except ImportError:
|
|
20
22
|
_IS_TORCH_AVAILABLE = False
|
|
21
23
|
|
|
22
24
|
from .pauli import Pauli
|
|
23
25
|
from .qrack_neuron import QrackNeuron
|
|
24
26
|
from .qrack_simulator import QrackSimulator
|
|
27
|
+
from .qrack_system import Qrack
|
|
25
28
|
from .neuron_activation_fn import NeuronActivationFn
|
|
26
29
|
|
|
27
30
|
|
|
@@ -29,66 +32,66 @@ from .neuron_activation_fn import NeuronActivationFn
|
|
|
29
32
|
param_shift_eps = math.pi / 2
|
|
30
33
|
# Neuron angle initialization
|
|
31
34
|
init_phi = math.asin(0.5)
|
|
35
|
+
# Systemic floating-point type
|
|
36
|
+
fp_type = ctypes.c_float if Qrack.fppow <= 5 else ctypes.c_double
|
|
32
37
|
|
|
33
38
|
|
|
34
39
|
class QrackNeuronTorchFunction(Function if _IS_TORCH_AVAILABLE else object):
|
|
35
40
|
"""Static forward/backward/apply functions for QrackNeuronTorch"""
|
|
36
41
|
|
|
37
42
|
@staticmethod
|
|
38
|
-
def
|
|
39
|
-
ctx.neuron = neuron
|
|
40
|
-
ctx.simulator = neuron.simulator
|
|
41
|
-
ctx.save_for_backward(x)
|
|
42
|
-
|
|
43
|
+
def _apply(angles, neuron):
|
|
43
44
|
# Baseline probability BEFORE applying this neuron's unitary
|
|
44
45
|
pre_prob = neuron.simulator.prob(neuron.target)
|
|
45
46
|
|
|
46
|
-
angles =
|
|
47
|
-
neuron.set_angles(angles)
|
|
48
|
-
neuron.predict(True, False)
|
|
47
|
+
neuron.angles = angles.ctypes.data_as(ctypes.POINTER(fp_type))
|
|
49
48
|
|
|
50
49
|
# Probability AFTER applying this neuron's unitary
|
|
51
|
-
post_prob = neuron.
|
|
52
|
-
ctx.post_prob = post_prob
|
|
50
|
+
post_prob = neuron.predict(True, False)
|
|
53
51
|
|
|
52
|
+
neuron.angles = None
|
|
53
|
+
|
|
54
|
+
# Angle difference
|
|
54
55
|
delta = math.asin(post_prob) - math.asin(pre_prob)
|
|
55
|
-
ctx.delta = delta
|
|
56
56
|
|
|
57
57
|
# Return shape: (1,)
|
|
58
|
-
return
|
|
58
|
+
return delta, max(math.sqrt(max(1.0 - post_prob * post_prob, 0.0)), 1e-6)
|
|
59
59
|
|
|
60
60
|
@staticmethod
|
|
61
|
-
def
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
post_prob = ctx.post_prob
|
|
61
|
+
def forward(ctx, x, neuron):
|
|
62
|
+
ctx.neuron = neuron
|
|
63
|
+
ctx.simulator = neuron.simulator
|
|
64
|
+
ctx.save_for_backward(x)
|
|
66
65
|
|
|
67
66
|
angles = x.detach().cpu().numpy() if x.requires_grad else x.numpy()
|
|
67
|
+
delta, denom = QrackNeuronTorchFunction._apply(angles, neuron)
|
|
68
68
|
|
|
69
|
+
ctx.denom = denom
|
|
70
|
+
|
|
71
|
+
return x.new_tensor([delta])
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def _backward(angles, neuron, simulator):
|
|
69
75
|
# Restore simulator to state BEFORE this neuron's unitary
|
|
70
|
-
neuron.
|
|
76
|
+
neuron.set_simulator(simulator)
|
|
77
|
+
neuron.angles = angles.ctypes.data_as(ctypes.POINTER(fp_type))
|
|
71
78
|
neuron.unpredict()
|
|
72
79
|
pre_sim = neuron.simulator
|
|
73
80
|
|
|
74
|
-
grad_x =
|
|
81
|
+
grad_x = np.zeros(angles.shape[0], dtype=fp_type)
|
|
75
82
|
|
|
76
|
-
for i in range(
|
|
83
|
+
for i in range(angles.shape[0]):
|
|
77
84
|
angle = angles[i]
|
|
78
85
|
|
|
79
86
|
# θ + π/2
|
|
80
87
|
angles[i] = angle + param_shift_eps
|
|
81
|
-
neuron.set_angles(angles)
|
|
82
88
|
neuron.simulator = pre_sim.clone()
|
|
83
|
-
neuron.predict(True, False)
|
|
84
|
-
p_plus = neuron.simulator.prob(neuron.target)
|
|
89
|
+
p_plus = neuron.predict(True, False)
|
|
85
90
|
|
|
86
91
|
# θ − π/2
|
|
87
92
|
angles[i] = angle - param_shift_eps
|
|
88
|
-
neuron.set_angles(angles)
|
|
89
93
|
neuron.simulator = pre_sim.clone()
|
|
90
|
-
neuron.predict(True, False)
|
|
91
|
-
p_minus = neuron.simulator.prob(neuron.target)
|
|
94
|
+
p_minus = neuron.predict(True, False)
|
|
92
95
|
|
|
93
96
|
# Parameter-shift gradient
|
|
94
97
|
grad_x[i] = 0.5 * (p_plus - p_minus)
|
|
@@ -97,9 +100,24 @@ class QrackNeuronTorchFunction(Function if _IS_TORCH_AVAILABLE else object):
|
|
|
97
100
|
|
|
98
101
|
# Restore simulator
|
|
99
102
|
neuron.set_simulator(pre_sim)
|
|
103
|
+
neuron.angles = None
|
|
104
|
+
|
|
105
|
+
return grad_x
|
|
106
|
+
|
|
107
|
+
@staticmethod
|
|
108
|
+
def backward(ctx, grad_output):
|
|
109
|
+
(x,) = ctx.saved_tensors
|
|
110
|
+
neuron = ctx.neuron
|
|
111
|
+
simulator = ctx.simulator
|
|
112
|
+
denom = ctx.denom
|
|
113
|
+
|
|
114
|
+
angles = x.detach().cpu().numpy() if x.requires_grad else x.numpy()
|
|
115
|
+
|
|
116
|
+
grad_x = QrackNeuronTorchFunction._backward(angles, neuron, simulator)
|
|
117
|
+
grad_x = torch.tensor(grad_x, device=x.device, dtype=x.dtype)
|
|
100
118
|
|
|
101
119
|
# Apply chain rule and upstream gradient
|
|
102
|
-
grad_x *= grad_output[0] /
|
|
120
|
+
grad_x *= grad_output[0] / denom
|
|
103
121
|
|
|
104
122
|
return grad_x, None
|
|
105
123
|
|
|
@@ -120,6 +138,10 @@ class QrackNeuronTorch(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
|
120
138
|
return QrackNeuronTorchFunction.apply(self.weights, self.neuron)
|
|
121
139
|
|
|
122
140
|
|
|
141
|
+
def dummy_post_init_fn(simulator):
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
|
|
123
145
|
class QrackNeuronTorchLayer(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
124
146
|
"""Torch layer wrapper for QrackNeuron (with maximally expressive set of neurons between inputs and outputs)
|
|
125
147
|
|
|
@@ -143,9 +165,8 @@ class QrackNeuronTorchLayer(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
|
143
165
|
lowest_combo_count=0,
|
|
144
166
|
highest_combo_count=2,
|
|
145
167
|
activation=int(NeuronActivationFn.Generalized_Logistic),
|
|
146
|
-
dtype=torch.float if _IS_TORCH_AVAILABLE else float,
|
|
147
168
|
parameters=None,
|
|
148
|
-
post_init_fn=
|
|
169
|
+
post_init_fn=dummy_post_init_fn,
|
|
149
170
|
**kwargs
|
|
150
171
|
):
|
|
151
172
|
"""
|
|
@@ -160,7 +181,6 @@ class QrackNeuronTorchLayer(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
|
160
181
|
lowest_combo_count (int): (Optional) Lowest combination count of input qubits iterated (0 is bias)
|
|
161
182
|
highest_combo_count (int): (Optional) Highest combination count of input qubits iterated
|
|
162
183
|
activation (int): (Optional) Integer corresponding to choice of activation function from NeuronActivationFn
|
|
163
|
-
dtype (type): (Optional) dtype of tensor objects used
|
|
164
184
|
parameters (list[float]): (Optional) Flat list of initial neuron parameters, corresponding to little-endian basis states of input + hidden qubits, repeated for ascending combo count, repeated for each output index
|
|
165
185
|
post_init_fn (Callable[QrackSimulator]): (Optional) Function that is applied after forward(x) state initialization, before inference. (As the function depends on nothing but the simulator, it's differentiable.)
|
|
166
186
|
"""
|
|
@@ -175,7 +195,7 @@ class QrackNeuronTorchLayer(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
|
175
195
|
range(input_qubits + hidden_qubits, input_qubits + hidden_qubits + output_qubits)
|
|
176
196
|
)
|
|
177
197
|
self.activation = NeuronActivationFn(activation)
|
|
178
|
-
self.dtype =
|
|
198
|
+
self.dtype = torch.float if Qrack.fppow <= 5 else torch.double
|
|
179
199
|
self.apply_fn = QrackNeuronTorchFunction.apply
|
|
180
200
|
self.post_init_fn = post_init_fn
|
|
181
201
|
|
|
@@ -189,15 +209,15 @@ class QrackNeuronTorchLayer(nn.Module if _IS_TORCH_AVAILABLE else object):
|
|
|
189
209
|
angles = (
|
|
190
210
|
(
|
|
191
211
|
torch.tensor(
|
|
192
|
-
parameters[param_count : (param_count + p_count)], dtype=dtype
|
|
212
|
+
parameters[param_count : (param_count + p_count)], dtype=self.dtype
|
|
193
213
|
)
|
|
194
214
|
if parameters
|
|
195
|
-
else torch.zeros(p_count, dtype=dtype)
|
|
215
|
+
else torch.zeros(p_count, dtype=self.dtype)
|
|
196
216
|
)
|
|
197
217
|
)
|
|
198
218
|
neurons.append(
|
|
199
219
|
QrackNeuronTorch(
|
|
200
|
-
QrackNeuron(self.simulator, input_subset, output_id, activation), angles
|
|
220
|
+
QrackNeuron(self.simulator, input_subset, output_id, activation, _isTorch=True), angles
|
|
201
221
|
)
|
|
202
222
|
)
|
|
203
223
|
param_count += p_count
|
|
@@ -77,7 +77,6 @@ class QrackSimulator:
|
|
|
77
77
|
"Cannot clone a QrackSimulator and specify its qubit length at the same time, in QrackSimulator constructor!"
|
|
78
78
|
)
|
|
79
79
|
|
|
80
|
-
self.is_tensor_network = isTensorNetwork
|
|
81
80
|
self.is_pure_stabilizer = False
|
|
82
81
|
|
|
83
82
|
if cloneSid > -1:
|
|
@@ -1307,15 +1306,11 @@ class QrackSimulator:
|
|
|
1307
1306
|
|
|
1308
1307
|
Raises:
|
|
1309
1308
|
RuntimeError: QrackSimulator raised an exception.
|
|
1310
|
-
RuntimeError:
|
|
1309
|
+
RuntimeError: QrackStabilizer cannot mul()! (Create a QrackSimulator instead.)
|
|
1311
1310
|
"""
|
|
1312
|
-
if self.is_tensor_network:
|
|
1313
|
-
raise RuntimeError(
|
|
1314
|
-
"QrackSimulator with isTensorNetwork=True option cannot mul()! (Turn off just this option, in the constructor.)"
|
|
1315
|
-
)
|
|
1316
1311
|
if self.is_pure_stabilizer:
|
|
1317
1312
|
raise RuntimeError(
|
|
1318
|
-
"QrackStabilizer cannot mul()! (Create a QrackSimulator instead
|
|
1313
|
+
"QrackStabilizer cannot mul()! (Create a QrackSimulator instead.)"
|
|
1319
1314
|
)
|
|
1320
1315
|
|
|
1321
1316
|
if len(q) != len(o):
|
|
@@ -1346,15 +1341,11 @@ class QrackSimulator:
|
|
|
1346
1341
|
|
|
1347
1342
|
Raises:
|
|
1348
1343
|
RuntimeError: QrackSimulator raised an exception.
|
|
1349
|
-
RuntimeError:
|
|
1344
|
+
RuntimeError: QrackStabilizer cannot div()! (Create a QrackSimulator instead.)
|
|
1350
1345
|
"""
|
|
1351
|
-
if self.is_tensor_network:
|
|
1352
|
-
raise RuntimeError(
|
|
1353
|
-
"QrackSimulator with isTensorNetwork=True option cannot div()! (Turn off just this option, in the constructor.)"
|
|
1354
|
-
)
|
|
1355
1346
|
if self.is_pure_stabilizer:
|
|
1356
1347
|
raise RuntimeError(
|
|
1357
|
-
"QrackStabilizer cannot div()! (Create a QrackSimulator instead
|
|
1348
|
+
"QrackStabilizer cannot div()! (Create a QrackSimulator instead.)"
|
|
1358
1349
|
)
|
|
1359
1350
|
|
|
1360
1351
|
if len(q) != len(o):
|
|
@@ -1443,15 +1434,11 @@ class QrackSimulator:
|
|
|
1443
1434
|
|
|
1444
1435
|
Raises:
|
|
1445
1436
|
RuntimeError: QrackSimulator raised an exception.
|
|
1446
|
-
RuntimeError:
|
|
1437
|
+
RuntimeError: QrackStabilizer cannot pown()! (Create a QrackSimulator instead.)
|
|
1447
1438
|
"""
|
|
1448
|
-
if self.is_tensor_network:
|
|
1449
|
-
raise RuntimeError(
|
|
1450
|
-
"QrackSimulator with isTensorNetwork=True option cannot pown()! (Turn off just this option, in the constructor.)"
|
|
1451
|
-
)
|
|
1452
1439
|
if self.is_pure_stabilizer:
|
|
1453
1440
|
raise RuntimeError(
|
|
1454
|
-
"QrackStabilizer cannot pown()! (Create a QrackSimulator instead
|
|
1441
|
+
"QrackStabilizer cannot pown()! (Create a QrackSimulator instead.)"
|
|
1455
1442
|
)
|
|
1456
1443
|
|
|
1457
1444
|
if len(q) != len(o):
|
|
@@ -1536,15 +1523,11 @@ class QrackSimulator:
|
|
|
1536
1523
|
|
|
1537
1524
|
Raises:
|
|
1538
1525
|
RuntimeError: QrackSimulator raised an exception.
|
|
1539
|
-
RuntimeError:
|
|
1526
|
+
RuntimeError: QrackStabilizer cannot mcmul()! (Create a QrackSimulator instead.)
|
|
1540
1527
|
"""
|
|
1541
|
-
if self.is_tensor_network:
|
|
1542
|
-
raise RuntimeError(
|
|
1543
|
-
"QrackSimulator with isTensorNetwork=True option cannot mcmul()! (Turn off just this option, in the constructor.)"
|
|
1544
|
-
)
|
|
1545
1528
|
if self.is_pure_stabilizer:
|
|
1546
1529
|
raise RuntimeError(
|
|
1547
|
-
"QrackStabilizer cannot mcmul()! (Create a QrackSimulator instead
|
|
1530
|
+
"QrackStabilizer cannot mcmul()! (Create a QrackSimulator instead.)"
|
|
1548
1531
|
)
|
|
1549
1532
|
|
|
1550
1533
|
if len(q) != len(o):
|
|
@@ -1578,15 +1561,11 @@ class QrackSimulator:
|
|
|
1578
1561
|
|
|
1579
1562
|
Raises:
|
|
1580
1563
|
RuntimeError: QrackSimulator raised an exception.
|
|
1581
|
-
RuntimeError:
|
|
1564
|
+
RuntimeError: QrackStabilizer cannot mcdiv()! (Create a QrackSimulator instead.)
|
|
1582
1565
|
"""
|
|
1583
|
-
if self.is_tensor_network:
|
|
1584
|
-
raise RuntimeError(
|
|
1585
|
-
"QrackSimulator with isTensorNetwork=True option cannot mcdiv()! (Turn off just this option, in the constructor.)"
|
|
1586
|
-
)
|
|
1587
1566
|
if self.is_pure_stabilizer:
|
|
1588
1567
|
raise RuntimeError(
|
|
1589
|
-
"QrackStabilizer cannot mcdiv()! (Create a QrackSimulator instead
|
|
1568
|
+
"QrackStabilizer cannot mcdiv()! (Create a QrackSimulator instead.)"
|
|
1590
1569
|
)
|
|
1591
1570
|
|
|
1592
1571
|
if len(q) != len(o):
|
|
@@ -1686,15 +1665,11 @@ class QrackSimulator:
|
|
|
1686
1665
|
|
|
1687
1666
|
Raises:
|
|
1688
1667
|
RuntimeError: QrackSimulator raised an exception.
|
|
1689
|
-
RuntimeError:
|
|
1668
|
+
RuntimeError: QrackStabilizer cannot mcpown()! (Create a QrackSimulator instead.)
|
|
1690
1669
|
"""
|
|
1691
|
-
if self.is_tensor_network:
|
|
1692
|
-
raise RuntimeError(
|
|
1693
|
-
"QrackSimulator with isTensorNetwork=True option cannot mcpown()! (Turn off just this option, in the constructor.)"
|
|
1694
|
-
)
|
|
1695
1670
|
if self.is_pure_stabilizer:
|
|
1696
1671
|
raise RuntimeError(
|
|
1697
|
-
"QrackStabilizer cannot mcpown()! (Create a QrackSimulator instead
|
|
1672
|
+
"QrackStabilizer cannot mcpown()! (Create a QrackSimulator instead.)"
|
|
1698
1673
|
)
|
|
1699
1674
|
|
|
1700
1675
|
if len(q) != len(o):
|
|
@@ -1727,15 +1702,11 @@ class QrackSimulator:
|
|
|
1727
1702
|
|
|
1728
1703
|
Raises:
|
|
1729
1704
|
RuntimeError: QrackSimulator raised an exception.
|
|
1730
|
-
RuntimeError:
|
|
1705
|
+
RuntimeError: QrackStabilizer cannot lda()! (Create a QrackSimulator instead.)
|
|
1731
1706
|
"""
|
|
1732
|
-
if self.is_tensor_network:
|
|
1733
|
-
raise RuntimeError(
|
|
1734
|
-
"QrackSimulator with isTensorNetwork=True option cannot lda()! (Turn off just this option, in the constructor.)"
|
|
1735
|
-
)
|
|
1736
1707
|
if self.is_pure_stabilizer:
|
|
1737
1708
|
raise RuntimeError(
|
|
1738
|
-
"QrackStabilizer cannot lda()! (Create a QrackSimulator instead
|
|
1709
|
+
"QrackStabilizer cannot lda()! (Create a QrackSimulator instead.)"
|
|
1739
1710
|
)
|
|
1740
1711
|
|
|
1741
1712
|
Qrack.qrack_lib.LDA(
|
|
@@ -1761,15 +1732,11 @@ class QrackSimulator:
|
|
|
1761
1732
|
|
|
1762
1733
|
Raises:
|
|
1763
1734
|
RuntimeError: QrackSimulator raised an exception.
|
|
1764
|
-
RuntimeError:
|
|
1735
|
+
RuntimeError: QrackStabilizer cannot adc()! (Create a QrackSimulator instead.)
|
|
1765
1736
|
"""
|
|
1766
|
-
if self.is_tensor_network:
|
|
1767
|
-
raise RuntimeError(
|
|
1768
|
-
"QrackSimulator with isTensorNetwork=True option cannot adc()! (Turn off just this option, in the constructor.)"
|
|
1769
|
-
)
|
|
1770
1737
|
if self.is_pure_stabilizer:
|
|
1771
1738
|
raise RuntimeError(
|
|
1772
|
-
"QrackStabilizer cannot adc()! (Create a QrackSimulator instead
|
|
1739
|
+
"QrackStabilizer cannot adc()! (Create a QrackSimulator instead.)"
|
|
1773
1740
|
)
|
|
1774
1741
|
|
|
1775
1742
|
Qrack.qrack_lib.ADC(
|
|
@@ -1796,15 +1763,11 @@ class QrackSimulator:
|
|
|
1796
1763
|
|
|
1797
1764
|
Raises:
|
|
1798
1765
|
RuntimeError: QrackSimulator raised an exception.
|
|
1799
|
-
RuntimeError:
|
|
1766
|
+
RuntimeError: QrackStabilizer cannot sbc()! (Create a QrackSimulator instead.)
|
|
1800
1767
|
"""
|
|
1801
|
-
if self.is_tensor_network:
|
|
1802
|
-
raise RuntimeError(
|
|
1803
|
-
"QrackSimulator with isTensorNetwork=True option cannot sbc()! (Turn off just this option, in the constructor.)"
|
|
1804
|
-
)
|
|
1805
1768
|
if self.is_pure_stabilizer:
|
|
1806
1769
|
raise RuntimeError(
|
|
1807
|
-
"QrackStabilizer cannot sbc()! (Create a QrackSimulator instead
|
|
1770
|
+
"QrackStabilizer cannot sbc()! (Create a QrackSimulator instead.)"
|
|
1808
1771
|
)
|
|
1809
1772
|
|
|
1810
1773
|
Qrack.qrack_lib.SBC(
|
|
@@ -1832,15 +1795,11 @@ class QrackSimulator:
|
|
|
1832
1795
|
|
|
1833
1796
|
Raises:
|
|
1834
1797
|
RuntimeError: QrackSimulator raised an exception.
|
|
1835
|
-
RuntimeError:
|
|
1798
|
+
RuntimeError: QrackStabilizer cannot hash()! (Create a QrackSimulator instead.)
|
|
1836
1799
|
"""
|
|
1837
|
-
if self.is_tensor_network:
|
|
1838
|
-
raise RuntimeError(
|
|
1839
|
-
"QrackSimulator with isTensorNetwork=True option cannot hash()! (Turn off just this option, in the constructor.)"
|
|
1840
|
-
)
|
|
1841
1800
|
if self.is_pure_stabilizer:
|
|
1842
1801
|
raise RuntimeError(
|
|
1843
|
-
"QrackStabilizer cannot hash()! (Create a QrackSimulator instead
|
|
1802
|
+
"QrackStabilizer cannot hash()! (Create a QrackSimulator instead.)"
|
|
1844
1803
|
)
|
|
1845
1804
|
|
|
1846
1805
|
Qrack.qrack_lib.Hash(
|
|
@@ -2150,13 +2109,7 @@ class QrackSimulator:
|
|
|
2150
2109
|
|
|
2151
2110
|
Raises:
|
|
2152
2111
|
RuntimeError: QrackSimulator raised an exception.
|
|
2153
|
-
RuntimeError: QrackSimulator with isTensorNetwork=True option cannot compose()! (Turn off just this option, in the constructor.)
|
|
2154
2112
|
"""
|
|
2155
|
-
if self.is_tensor_network:
|
|
2156
|
-
raise RuntimeError(
|
|
2157
|
-
"QrackSimulator with isTensorNetwork=True option cannot compose()! (Turn off just this option, in the constructor.)"
|
|
2158
|
-
)
|
|
2159
|
-
|
|
2160
2113
|
Qrack.qrack_lib.Compose(self.sid, other.sid, QrackSimulator._ulonglong_byref(q))
|
|
2161
2114
|
self._throw_if_error()
|
|
2162
2115
|
|
|
@@ -2170,16 +2123,10 @@ class QrackSimulator:
|
|
|
2170
2123
|
|
|
2171
2124
|
Raises:
|
|
2172
2125
|
RuntimeError: QrackSimulator raised an exception.
|
|
2173
|
-
RuntimeError: QrackSimulator with isTensorNetwork=True option cannot decompose()! (Turn off just this option, in the constructor.)
|
|
2174
2126
|
|
|
2175
2127
|
Returns:
|
|
2176
2128
|
Decomposed subsystem simulator.
|
|
2177
2129
|
"""
|
|
2178
|
-
if self.is_tensor_network:
|
|
2179
|
-
raise RuntimeError(
|
|
2180
|
-
"QrackSimulator with isTensorNetwork=True option cannot decompose()! (Turn off just this option, in the constructor.)"
|
|
2181
|
-
)
|
|
2182
|
-
|
|
2183
2130
|
other = QrackSimulator()
|
|
2184
2131
|
Qrack.qrack_lib.destroy(other.sid)
|
|
2185
2132
|
l = len(q)
|
|
@@ -2198,13 +2145,7 @@ class QrackSimulator:
|
|
|
2198
2145
|
|
|
2199
2146
|
Raises:
|
|
2200
2147
|
RuntimeError: QrackSimulator raised an exception.
|
|
2201
|
-
RuntimeError: QrackSimulator with isTensorNetwork=True option cannot dispose()! (Turn off just this option, in the constructor.)
|
|
2202
2148
|
"""
|
|
2203
|
-
if self.is_tensor_network:
|
|
2204
|
-
raise RuntimeError(
|
|
2205
|
-
"QrackSimulator with isTensorNetwork=True option cannot dispose()! (Turn off just this option, in the constructor.)"
|
|
2206
|
-
)
|
|
2207
|
-
|
|
2208
2149
|
l = len(q)
|
|
2209
2150
|
Qrack.qrack_lib.Dispose(self.sid, l, QrackSimulator._ulonglong_byref(q))
|
|
2210
2151
|
self._throw_if_error()
|
|
@@ -3128,15 +3069,11 @@ class QrackSimulator:
|
|
|
3128
3069
|
|
|
3129
3070
|
Raises:
|
|
3130
3071
|
RuntimeError: QrackSimulator raised an exception.
|
|
3131
|
-
RuntimeError:
|
|
3072
|
+
RuntimeError: QrackStabilizer cannot phase_parity()! (Create a QrackSimulator instead.)
|
|
3132
3073
|
"""
|
|
3133
|
-
if self.is_tensor_network:
|
|
3134
|
-
raise RuntimeError(
|
|
3135
|
-
"QrackSimulator with isTensorNetwork=True option cannot phase_parity()! (Turn off just this option, in the constructor.)"
|
|
3136
|
-
)
|
|
3137
3074
|
if self.is_pure_stabilizer:
|
|
3138
3075
|
raise RuntimeError(
|
|
3139
|
-
"QrackStabilizer cannot phase_parity()! (Create a QrackSimulator instead
|
|
3076
|
+
"QrackStabilizer cannot phase_parity()! (Create a QrackSimulator instead.)"
|
|
3140
3077
|
)
|
|
3141
3078
|
|
|
3142
3079
|
Qrack.qrack_lib.PhaseParity(
|
|
@@ -3155,15 +3092,11 @@ class QrackSimulator:
|
|
|
3155
3092
|
|
|
3156
3093
|
Raises:
|
|
3157
3094
|
RuntimeError: QrackSimulator raised an exception.
|
|
3158
|
-
RuntimeError:
|
|
3095
|
+
RuntimeError: QrackStabilizer cannot phase_root_n()! (Create a QrackSimulator instead.)
|
|
3159
3096
|
"""
|
|
3160
|
-
if self.is_tensor_network:
|
|
3161
|
-
raise RuntimeError(
|
|
3162
|
-
"QrackSimulator with isTensorNetwork=True option cannot phase_root_n()! (Turn off just this option, in the constructor.)"
|
|
3163
|
-
)
|
|
3164
3097
|
if self.is_pure_stabilizer:
|
|
3165
3098
|
raise RuntimeError(
|
|
3166
|
-
"QrackStabilizer cannot phase_root_n()! (Create a QrackSimulator instead
|
|
3099
|
+
"QrackStabilizer cannot phase_root_n()! (Create a QrackSimulator instead.)"
|
|
3167
3100
|
)
|
|
3168
3101
|
|
|
3169
3102
|
Qrack.qrack_lib.PhaseRootN(self.sid, n, len(q), QrackSimulator._ulonglong_byref(q))
|
|
@@ -3348,6 +3281,21 @@ class QrackSimulator:
|
|
|
3348
3281
|
Qrack.qrack_lib.SetTInjection(self.sid, iti)
|
|
3349
3282
|
self._throw_if_error()
|
|
3350
3283
|
|
|
3284
|
+
def set_use_exact_near_clifford(self, enc):
|
|
3285
|
+
"""Set option to use exact near-Clifford simulation
|
|
3286
|
+
|
|
3287
|
+
If t-injection is available, this method turns exact near-Clifford
|
|
3288
|
+
simulation off/on. (Default is on.) Approximate methods are faster.
|
|
3289
|
+
|
|
3290
|
+
Args:
|
|
3291
|
+
enc: "on/off" for exact near-Clifford simulation
|
|
3292
|
+
|
|
3293
|
+
Raises:
|
|
3294
|
+
RuntimeError: QrackSimulator raised an exception.
|
|
3295
|
+
"""
|
|
3296
|
+
Qrack.qrack_lib.SetUseExactNearClifford(self.sid, enc)
|
|
3297
|
+
self._throw_if_error()
|
|
3298
|
+
|
|
3351
3299
|
def set_noise_parameter(self, np):
|
|
3352
3300
|
"""Set noise parameter option
|
|
3353
3301
|
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/qrack_system/qrack_system.py
RENAMED
|
@@ -170,14 +170,14 @@ class QrackSystem:
|
|
|
170
170
|
self.qrack_lib.HighestProbAllN.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
|
|
171
171
|
|
|
172
172
|
self.qrack_lib.ProbAll.restype = None
|
|
173
|
-
if self.fppow
|
|
173
|
+
if self.fppow <= 5:
|
|
174
174
|
self.qrack_lib.ProbAll.argtypes = [
|
|
175
175
|
c_ulonglong,
|
|
176
176
|
c_ulonglong,
|
|
177
177
|
POINTER(c_ulonglong),
|
|
178
178
|
POINTER(c_float),
|
|
179
179
|
]
|
|
180
|
-
|
|
180
|
+
else:
|
|
181
181
|
self.qrack_lib.ProbAll.argtypes = [
|
|
182
182
|
c_ulonglong,
|
|
183
183
|
c_ulonglong,
|
|
@@ -242,7 +242,7 @@ class QrackSystem:
|
|
|
242
242
|
c_bool,
|
|
243
243
|
]
|
|
244
244
|
|
|
245
|
-
if self.fppow
|
|
245
|
+
if self.fppow <= 5:
|
|
246
246
|
self.qrack_lib.FactorizedExpectationFp.restype = c_double
|
|
247
247
|
self.qrack_lib.FactorizedExpectationFp.argtypes = [
|
|
248
248
|
c_ulonglong,
|
|
@@ -288,7 +288,7 @@ class QrackSystem:
|
|
|
288
288
|
POINTER(c_float),
|
|
289
289
|
POINTER(c_float),
|
|
290
290
|
]
|
|
291
|
-
|
|
291
|
+
else:
|
|
292
292
|
self.qrack_lib.FactorizedExpectationFp.restype = c_double
|
|
293
293
|
self.qrack_lib.FactorizedExpectationFp.argtypes = [
|
|
294
294
|
c_ulonglong,
|
|
@@ -377,7 +377,7 @@ class QrackSystem:
|
|
|
377
377
|
c_bool,
|
|
378
378
|
]
|
|
379
379
|
|
|
380
|
-
if self.fppow
|
|
380
|
+
if self.fppow <= 5:
|
|
381
381
|
self.qrack_lib.FactorizedVarianceFp.restype = c_double
|
|
382
382
|
self.qrack_lib.FactorizedVarianceFp.argtypes = [
|
|
383
383
|
c_ulonglong,
|
|
@@ -423,7 +423,7 @@ class QrackSystem:
|
|
|
423
423
|
POINTER(c_float),
|
|
424
424
|
POINTER(c_float),
|
|
425
425
|
]
|
|
426
|
-
|
|
426
|
+
else:
|
|
427
427
|
self.qrack_lib.FactorizedVarianceFp.restype = c_double
|
|
428
428
|
self.qrack_lib.FactorizedVarianceFp.argtypes = [
|
|
429
429
|
c_ulonglong,
|
|
@@ -1220,6 +1220,9 @@ class QrackSystem:
|
|
|
1220
1220
|
self.qrack_lib.SetTInjection.restype = None
|
|
1221
1221
|
self.qrack_lib.SetTInjection.argtypes = [c_ulonglong, c_bool]
|
|
1222
1222
|
|
|
1223
|
+
self.qrack_lib.SetUseExactNearClifford.restype = None
|
|
1224
|
+
self.qrack_lib.SetUseExactNearClifford.argtypes = [c_ulonglong, c_bool]
|
|
1225
|
+
|
|
1223
1226
|
self.qrack_lib.SetNoiseParameter.restype = None
|
|
1224
1227
|
self.qrack_lib.SetNoiseParameter.argtypes = [c_ulonglong, c_double]
|
|
1225
1228
|
|
|
@@ -1244,9 +1247,6 @@ class QrackSystem:
|
|
|
1244
1247
|
c_ulonglong,
|
|
1245
1248
|
POINTER(c_ulonglong),
|
|
1246
1249
|
c_ulonglong,
|
|
1247
|
-
c_ulonglong,
|
|
1248
|
-
c_double,
|
|
1249
|
-
c_double,
|
|
1250
1250
|
]
|
|
1251
1251
|
|
|
1252
1252
|
self.qrack_lib.clone_qneuron.restype = c_ulonglong
|
|
@@ -1256,55 +1256,60 @@ class QrackSystem:
|
|
|
1256
1256
|
self.qrack_lib.destroy_qneuron.argtypes = [c_ulonglong]
|
|
1257
1257
|
|
|
1258
1258
|
self.qrack_lib.set_qneuron_sim.restype = None
|
|
1259
|
-
self.qrack_lib.set_qneuron_sim.argtypes = [
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
self.qrack_lib.get_qneuron_angles.argtypes = [c_ulonglong, POINTER(c_float)]
|
|
1267
|
-
elif self.fppow == 6:
|
|
1268
|
-
self.qrack_lib.set_qneuron_angles.argtypes = [
|
|
1269
|
-
c_ulonglong,
|
|
1270
|
-
POINTER(c_double),
|
|
1271
|
-
]
|
|
1272
|
-
self.qrack_lib.get_qneuron_angles.argtypes = [
|
|
1273
|
-
c_ulonglong,
|
|
1274
|
-
POINTER(c_double),
|
|
1275
|
-
]
|
|
1259
|
+
self.qrack_lib.set_qneuron_sim.argtypes = [
|
|
1260
|
+
c_ulonglong,
|
|
1261
|
+
c_ulonglong,
|
|
1262
|
+
c_ulonglong,
|
|
1263
|
+
POINTER(c_ulonglong),
|
|
1264
|
+
c_ulonglong
|
|
1265
|
+
]
|
|
1276
1266
|
|
|
1277
|
-
self.
|
|
1278
|
-
|
|
1267
|
+
if self.fppow <= 5:
|
|
1268
|
+
self.qrack_lib.qneuron_predict.restype = c_double
|
|
1269
|
+
self.qrack_lib.qneuron_predict.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_bool, c_ulonglong, c_double]
|
|
1279
1270
|
|
|
1280
|
-
|
|
1281
|
-
|
|
1271
|
+
self.qrack_lib.qneuron_unpredict.restype = c_double
|
|
1272
|
+
self.qrack_lib.qneuron_unpredict.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_ulonglong, c_double]
|
|
1282
1273
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1274
|
+
self.qrack_lib.qneuron_learn_cycle.restype = c_double
|
|
1275
|
+
self.qrack_lib.qneuron_learn_cycle.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_ulonglong, c_double]
|
|
1285
1276
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1277
|
+
self.qrack_lib.qneuron_learn.restype = None
|
|
1278
|
+
self.qrack_lib.qneuron_learn.argtypes = [c_ulonglong, POINTER(c_float), c_double, c_bool, c_bool, c_ulonglong, c_double]
|
|
1288
1279
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1280
|
+
self.qrack_lib.qneuron_learn_permutation.restype = None
|
|
1281
|
+
self.qrack_lib.qneuron_learn_permutation.argtypes = [
|
|
1282
|
+
c_ulonglong,
|
|
1283
|
+
POINTER(c_float),
|
|
1284
|
+
c_double,
|
|
1285
|
+
c_bool,
|
|
1286
|
+
c_bool,
|
|
1287
|
+
c_ulonglong,
|
|
1288
|
+
c_double,
|
|
1289
|
+
]
|
|
1290
|
+
else:
|
|
1291
|
+
self.qrack_lib.qneuron_predict.restype = c_double
|
|
1292
|
+
self.qrack_lib.qneuron_predict.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_bool, c_ulonglong, c_double]
|
|
1291
1293
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
+
self.qrack_lib.qneuron_unpredict.restype = c_double
|
|
1295
|
+
self.qrack_lib.qneuron_unpredict.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_ulonglong, c_double]
|
|
1294
1296
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
+
self.qrack_lib.qneuron_learn_cycle.restype = c_double
|
|
1298
|
+
self.qrack_lib.qneuron_learn_cycle.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_ulonglong, c_double]
|
|
1297
1299
|
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
+
self.qrack_lib.qneuron_learn.restype = None
|
|
1301
|
+
self.qrack_lib.qneuron_learn.argtypes = [c_ulonglong, POINTER(c_double), c_double, c_bool, c_bool, c_ulonglong, c_double]
|
|
1300
1302
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1303
|
+
self.qrack_lib.qneuron_learn_permutation.restype = None
|
|
1304
|
+
self.qrack_lib.qneuron_learn_permutation.argtypes = [
|
|
1305
|
+
c_ulonglong,
|
|
1306
|
+
POINTER(c_double),
|
|
1307
|
+
c_double,
|
|
1308
|
+
c_bool,
|
|
1309
|
+
c_bool,
|
|
1310
|
+
c_ulonglong,
|
|
1311
|
+
c_double,
|
|
1312
|
+
]
|
|
1308
1313
|
|
|
1309
1314
|
self.qrack_lib.init_qcircuit.restype = c_ulonglong
|
|
1310
1315
|
self.qrack_lib.init_qcircuit.argtypes = [c_bool, c_bool]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack/stats/load_quantized_data.py
RENAMED
|
File without changes
|
|
File without changes
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/requires.txt
RENAMED
|
File without changes
|
{pyqrack_complex128-1.80.6 → pyqrack_complex128-1.83.0}/pyqrack_complex128.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|