pyqrack-complex128 1.78.3__py3-none-macosx_14_0_arm64.whl → 1.81.0__py3-none-macosx_14_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.
Potentially problematic release.
This version of pyqrack-complex128 might be problematic. Click here for more details.
- pyqrack/__init__.py +0 -1
- pyqrack/qrack_ace_backend.py +16 -46
- pyqrack/qrack_circuit.py +2 -6
- pyqrack/qrack_neuron.py +43 -36
- pyqrack/qrack_neuron_torch_layer.py +132 -235
- pyqrack/qrack_simulator.py +82 -98
- pyqrack/qrack_system/qrack_lib/{libqrack_pinvoke.9.34.5.dylib → libqrack_pinvoke.10.0.0.dylib} +0 -0
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib +0 -0
- pyqrack/qrack_system/qrack_system.py +68 -59
- pyqrack/stats/load_quantized_data.py +1 -3
- pyqrack/stats/quantize_by_range.py +2 -6
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.81.0.dist-info}/METADATA +3 -1
- pyqrack_complex128-1.81.0.dist-info/RECORD +23 -0
- pyqrack_complex128-1.78.3.dist-info/RECORD +0 -23
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.81.0.dist-info}/LICENSE +0 -0
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.81.0.dist-info}/WHEEL +0 -0
- {pyqrack_complex128-1.78.3.dist-info → pyqrack_complex128-1.81.0.dist-info}/top_level.txt +0 -0
pyqrack/qrack_simulator.py
CHANGED
|
@@ -57,9 +57,7 @@ class QrackSimulator:
|
|
|
57
57
|
isPaged=True,
|
|
58
58
|
isCpuGpuHybrid=True,
|
|
59
59
|
isOpenCL=True,
|
|
60
|
-
isHostPointer=(
|
|
61
|
-
True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False
|
|
62
|
-
),
|
|
60
|
+
isHostPointer=(True if os.environ.get("PYQRACK_HOST_POINTER_DEFAULT_ON") else False),
|
|
63
61
|
isSparse=False,
|
|
64
62
|
noise=0,
|
|
65
63
|
pyzxCircuit=None,
|
|
@@ -100,7 +98,7 @@ class QrackSimulator:
|
|
|
100
98
|
isCpuGpuHybrid,
|
|
101
99
|
isOpenCL,
|
|
102
100
|
isHostPointer,
|
|
103
|
-
isSparse
|
|
101
|
+
isSparse,
|
|
104
102
|
)
|
|
105
103
|
|
|
106
104
|
self._throw_if_error()
|
|
@@ -593,7 +591,11 @@ class QrackSimulator:
|
|
|
593
591
|
"2x2 matrix 'm' in QrackSimulator.mcmtrx() must contain at least 4 elements."
|
|
594
592
|
)
|
|
595
593
|
Qrack.qrack_lib.MCMtrx(
|
|
596
|
-
self.sid,
|
|
594
|
+
self.sid,
|
|
595
|
+
len(c),
|
|
596
|
+
QrackSimulator._ulonglong_byref(c),
|
|
597
|
+
QrackSimulator._complex_byref(m),
|
|
598
|
+
q,
|
|
597
599
|
)
|
|
598
600
|
self._throw_if_error()
|
|
599
601
|
|
|
@@ -771,7 +773,11 @@ class QrackSimulator:
|
|
|
771
773
|
"2x2 matrix 'm' in QrackSimulator.macmtrx() must contain at least 4 elements."
|
|
772
774
|
)
|
|
773
775
|
Qrack.qrack_lib.MACMtrx(
|
|
774
|
-
self.sid,
|
|
776
|
+
self.sid,
|
|
777
|
+
len(c),
|
|
778
|
+
QrackSimulator._ulonglong_byref(c),
|
|
779
|
+
QrackSimulator._complex_byref(m),
|
|
780
|
+
q,
|
|
775
781
|
)
|
|
776
782
|
self._throw_if_error()
|
|
777
783
|
|
|
@@ -796,7 +802,12 @@ class QrackSimulator:
|
|
|
796
802
|
"2x2 matrix 'm' in QrackSimulator.ucmtrx() must contain at least 4 elements."
|
|
797
803
|
)
|
|
798
804
|
Qrack.qrack_lib.UCMtrx(
|
|
799
|
-
self.sid,
|
|
805
|
+
self.sid,
|
|
806
|
+
len(c),
|
|
807
|
+
QrackSimulator._ulonglong_byref(c),
|
|
808
|
+
QrackSimulator._complex_byref(m),
|
|
809
|
+
q,
|
|
810
|
+
p,
|
|
800
811
|
)
|
|
801
812
|
self._throw_if_error()
|
|
802
813
|
|
|
@@ -820,7 +831,11 @@ class QrackSimulator:
|
|
|
820
831
|
"Multiplex matrix 'm' in QrackSimulator.multiplex1_mtrx() must contain at least (4 * 2 ** len(c)) elements."
|
|
821
832
|
)
|
|
822
833
|
Qrack.qrack_lib.Multiplex1Mtrx(
|
|
823
|
-
self.sid,
|
|
834
|
+
self.sid,
|
|
835
|
+
len(c),
|
|
836
|
+
QrackSimulator._ulonglong_byref(c),
|
|
837
|
+
q,
|
|
838
|
+
QrackSimulator._complex_byref(m),
|
|
824
839
|
)
|
|
825
840
|
self._throw_if_error()
|
|
826
841
|
|
|
@@ -978,9 +993,7 @@ class QrackSimulator:
|
|
|
978
993
|
Raises:
|
|
979
994
|
RuntimeError: QrackSimulator raised an exception.
|
|
980
995
|
"""
|
|
981
|
-
Qrack.qrack_lib.FSim(
|
|
982
|
-
self.sid, ctypes.c_double(th), ctypes.c_double(ph), qi1, qi2
|
|
983
|
-
)
|
|
996
|
+
Qrack.qrack_lib.FSim(self.sid, ctypes.c_double(th), ctypes.c_double(ph), qi1, qi2)
|
|
984
997
|
self._throw_if_error()
|
|
985
998
|
|
|
986
999
|
def cswap(self, c, qi1, qi2):
|
|
@@ -1831,7 +1844,10 @@ class QrackSimulator:
|
|
|
1831
1844
|
)
|
|
1832
1845
|
|
|
1833
1846
|
Qrack.qrack_lib.Hash(
|
|
1834
|
-
self.sid,
|
|
1847
|
+
self.sid,
|
|
1848
|
+
len(q),
|
|
1849
|
+
QrackSimulator._ulonglong_byref(q),
|
|
1850
|
+
QrackSimulator._to_ubyte(len(q), t),
|
|
1835
1851
|
)
|
|
1836
1852
|
self._throw_if_error()
|
|
1837
1853
|
|
|
@@ -2316,7 +2332,9 @@ class QrackSimulator:
|
|
|
2316
2332
|
amp_count = 1 << len(q)
|
|
2317
2333
|
sqr_amp_count = amp_count * amp_count
|
|
2318
2334
|
flat_rdm = QrackSimulator._qrack_complex_byref([complex(0, 0)] * sqr_amp_count)
|
|
2319
|
-
Qrack.qrack_lib.OutReducedDensityMatrix(
|
|
2335
|
+
Qrack.qrack_lib.OutReducedDensityMatrix(
|
|
2336
|
+
self.sid, len(q), QrackSimulator._ulonglong_byref(q), flat_rdm
|
|
2337
|
+
)
|
|
2320
2338
|
self._throw_if_error()
|
|
2321
2339
|
return [complex(r, i) for r, i in QrackSimulator._pairwise(flat_rdm)]
|
|
2322
2340
|
|
|
@@ -2541,7 +2559,11 @@ class QrackSimulator:
|
|
|
2541
2559
|
raise RuntimeError("factorized_expectation argument lengths do not match.")
|
|
2542
2560
|
m = max([(x.bit_length() + 63) // 64 for x in c])
|
|
2543
2561
|
result = Qrack.qrack_lib.FactorizedExpectation(
|
|
2544
|
-
self.sid,
|
|
2562
|
+
self.sid,
|
|
2563
|
+
len(q),
|
|
2564
|
+
QrackSimulator._ulonglong_byref(q),
|
|
2565
|
+
m,
|
|
2566
|
+
QrackSimulator._to_ulonglong(m, c),
|
|
2545
2567
|
)
|
|
2546
2568
|
self._throw_if_error()
|
|
2547
2569
|
return result
|
|
@@ -2566,12 +2588,15 @@ class QrackSimulator:
|
|
|
2566
2588
|
Expectation value
|
|
2567
2589
|
"""
|
|
2568
2590
|
if (len(q) << 1) != len(c):
|
|
2569
|
-
raise RuntimeError(
|
|
2570
|
-
"factorized_expectation_rdm argument lengths do not match."
|
|
2571
|
-
)
|
|
2591
|
+
raise RuntimeError("factorized_expectation_rdm argument lengths do not match.")
|
|
2572
2592
|
m = max([(x.bit_length() + 63) // 64 for x in c])
|
|
2573
2593
|
result = Qrack.qrack_lib.FactorizedExpectationRdm(
|
|
2574
|
-
self.sid,
|
|
2594
|
+
self.sid,
|
|
2595
|
+
len(q),
|
|
2596
|
+
QrackSimulator._ulonglong_byref(q),
|
|
2597
|
+
m,
|
|
2598
|
+
QrackSimulator._to_ulonglong(m, c),
|
|
2599
|
+
r,
|
|
2575
2600
|
)
|
|
2576
2601
|
self._throw_if_error()
|
|
2577
2602
|
return result
|
|
@@ -2594,9 +2619,7 @@ class QrackSimulator:
|
|
|
2594
2619
|
Expectation value
|
|
2595
2620
|
"""
|
|
2596
2621
|
if (len(q) << 1) != len(c):
|
|
2597
|
-
raise RuntimeError(
|
|
2598
|
-
"factorized_expectation_rdm argument lengths do not match."
|
|
2599
|
-
)
|
|
2622
|
+
raise RuntimeError("factorized_expectation_rdm argument lengths do not match.")
|
|
2600
2623
|
result = Qrack.qrack_lib.FactorizedExpectationFp(
|
|
2601
2624
|
self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c)
|
|
2602
2625
|
)
|
|
@@ -2623,9 +2646,7 @@ class QrackSimulator:
|
|
|
2623
2646
|
Expectation value
|
|
2624
2647
|
"""
|
|
2625
2648
|
if (len(q) << 1) != len(c):
|
|
2626
|
-
raise RuntimeError(
|
|
2627
|
-
"factorized_expectation_fp_rdm argument lengths do not match."
|
|
2628
|
-
)
|
|
2649
|
+
raise RuntimeError("factorized_expectation_fp_rdm argument lengths do not match.")
|
|
2629
2650
|
result = Qrack.qrack_lib.FactorizedExpectationFpRdm(
|
|
2630
2651
|
self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c), r
|
|
2631
2652
|
)
|
|
@@ -2836,7 +2857,11 @@ class QrackSimulator:
|
|
|
2836
2857
|
raise RuntimeError("factorized_variance argument lengths do not match.")
|
|
2837
2858
|
m = max([(x.bit_length() + 63) // 64 for x in c])
|
|
2838
2859
|
result = Qrack.qrack_lib.FactorizedVariance(
|
|
2839
|
-
self.sid,
|
|
2860
|
+
self.sid,
|
|
2861
|
+
len(q),
|
|
2862
|
+
QrackSimulator._ulonglong_byref(q),
|
|
2863
|
+
m,
|
|
2864
|
+
QrackSimulator._to_ulonglong(m, c),
|
|
2840
2865
|
)
|
|
2841
2866
|
self._throw_if_error()
|
|
2842
2867
|
return result
|
|
@@ -2864,7 +2889,12 @@ class QrackSimulator:
|
|
|
2864
2889
|
raise RuntimeError("factorized_variance_rdm argument lengths do not match.")
|
|
2865
2890
|
m = max([(x.bit_length() + 63) // 64 for x in c])
|
|
2866
2891
|
result = Qrack.qrack_lib.FactorizedVarianceRdm(
|
|
2867
|
-
self.sid,
|
|
2892
|
+
self.sid,
|
|
2893
|
+
len(q),
|
|
2894
|
+
QrackSimulator._ulonglong_byref(q),
|
|
2895
|
+
m,
|
|
2896
|
+
QrackSimulator._to_ulonglong(m, c),
|
|
2897
|
+
r,
|
|
2868
2898
|
)
|
|
2869
2899
|
self._throw_if_error()
|
|
2870
2900
|
return result
|
|
@@ -2914,9 +2944,7 @@ class QrackSimulator:
|
|
|
2914
2944
|
variance
|
|
2915
2945
|
"""
|
|
2916
2946
|
if (len(q) << 1) != len(c):
|
|
2917
|
-
raise RuntimeError(
|
|
2918
|
-
"factorized_variance_fp_rdm argument lengths do not match."
|
|
2919
|
-
)
|
|
2947
|
+
raise RuntimeError("factorized_variance_fp_rdm argument lengths do not match.")
|
|
2920
2948
|
result = Qrack.qrack_lib.FactorizedVarianceFpRdm(
|
|
2921
2949
|
self.sid, len(q), QrackSimulator._ulonglong_byref(q), QrackSimulator._real1_byref(c), r
|
|
2922
2950
|
)
|
|
@@ -3551,9 +3579,7 @@ class QrackSimulator:
|
|
|
3551
3579
|
"swap",
|
|
3552
3580
|
]
|
|
3553
3581
|
try:
|
|
3554
|
-
circ = transpile(
|
|
3555
|
-
clifford_circ, basis_gates=basis_gates, optimization_level=2
|
|
3556
|
-
)
|
|
3582
|
+
circ = transpile(clifford_circ, basis_gates=basis_gates, optimization_level=2)
|
|
3557
3583
|
except:
|
|
3558
3584
|
circ = clifford_circ
|
|
3559
3585
|
|
|
@@ -3649,9 +3675,7 @@ class QrackSimulator:
|
|
|
3649
3675
|
)
|
|
3650
3676
|
elif op.name == "h":
|
|
3651
3677
|
non_clifford = np.matmul(
|
|
3652
|
-
np.array(
|
|
3653
|
-
[[sqrt1_2, sqrt1_2], [sqrt1_2, -sqrt1_2]], np.complex128
|
|
3654
|
-
),
|
|
3678
|
+
np.array([[sqrt1_2, sqrt1_2], [sqrt1_2, -sqrt1_2]], np.complex128),
|
|
3655
3679
|
non_clifford,
|
|
3656
3680
|
)
|
|
3657
3681
|
elif op.name == "x":
|
|
@@ -3759,9 +3783,7 @@ class QrackSimulator:
|
|
|
3759
3783
|
j += 1
|
|
3760
3784
|
continue
|
|
3761
3785
|
|
|
3762
|
-
if (q1 == i) and (
|
|
3763
|
-
(op.name == "cx") or (op.name == "cy") or (op.name == "cz")
|
|
3764
|
-
):
|
|
3786
|
+
if (q1 == i) and ((op.name == "cx") or (op.name == "cy") or (op.name == "cz")):
|
|
3765
3787
|
if np.isclose(np.abs(non_clifford[0][1]), 0) and np.isclose(
|
|
3766
3788
|
np.abs(non_clifford[1][0]), 0
|
|
3767
3789
|
):
|
|
@@ -3827,9 +3849,7 @@ class QrackSimulator:
|
|
|
3827
3849
|
elif op.name == "h":
|
|
3828
3850
|
non_clifford = np.matmul(
|
|
3829
3851
|
non_clifford,
|
|
3830
|
-
np.array(
|
|
3831
|
-
[[sqrt1_2, sqrt1_2], [sqrt1_2, -sqrt1_2]], np.complex128
|
|
3832
|
-
),
|
|
3852
|
+
np.array([[sqrt1_2, sqrt1_2], [sqrt1_2, -sqrt1_2]], np.complex128),
|
|
3833
3853
|
)
|
|
3834
3854
|
elif op.name == "x":
|
|
3835
3855
|
non_clifford = np.matmul(
|
|
@@ -4019,12 +4039,8 @@ class QrackSimulator:
|
|
|
4019
4039
|
qasm = qasm3.dumps(circ)
|
|
4020
4040
|
except:
|
|
4021
4041
|
qasm = circ.qasm()
|
|
4022
|
-
qasm = qasm.replace(
|
|
4023
|
-
|
|
4024
|
-
)
|
|
4025
|
-
highest_index = max(
|
|
4026
|
-
[int(x) for x in re.findall(r"\[(.*?)\]", qasm) if x.isdigit()]
|
|
4027
|
-
)
|
|
4042
|
+
qasm = qasm.replace("qreg q[" + str(circ.width()) + "];", "qreg q[" + str(width) + "];")
|
|
4043
|
+
highest_index = max([int(x) for x in re.findall(r"\[(.*?)\]", qasm) if x.isdigit()])
|
|
4028
4044
|
if highest_index != width:
|
|
4029
4045
|
qasm = qasm.replace(
|
|
4030
4046
|
"qreg q[" + str(width) + "];", "qreg q[" + str(highest_index) + "];"
|
|
@@ -4139,17 +4155,11 @@ class QrackSimulator:
|
|
|
4139
4155
|
(-1 * float(operation.params[1])) + math.pi / 2,
|
|
4140
4156
|
)
|
|
4141
4157
|
elif name == "rx":
|
|
4142
|
-
self._sim.r(
|
|
4143
|
-
Pauli.PauliX, float(operation.params[0]), operation.qubits[0]._index
|
|
4144
|
-
)
|
|
4158
|
+
self._sim.r(Pauli.PauliX, float(operation.params[0]), operation.qubits[0]._index)
|
|
4145
4159
|
elif name == "ry":
|
|
4146
|
-
self._sim.r(
|
|
4147
|
-
Pauli.PauliY, float(operation.params[0]), operation.qubits[0]._index
|
|
4148
|
-
)
|
|
4160
|
+
self._sim.r(Pauli.PauliY, float(operation.params[0]), operation.qubits[0]._index)
|
|
4149
4161
|
elif name == "rz":
|
|
4150
|
-
self._sim.r(
|
|
4151
|
-
Pauli.PauliZ, float(operation.params[0]), operation.qubits[0]._index
|
|
4152
|
-
)
|
|
4162
|
+
self._sim.r(Pauli.PauliZ, float(operation.params[0]), operation.qubits[0]._index)
|
|
4153
4163
|
elif name == "h":
|
|
4154
4164
|
self._sim.h(operation.qubits[0]._index)
|
|
4155
4165
|
elif name == "x":
|
|
@@ -4201,21 +4211,13 @@ class QrackSimulator:
|
|
|
4201
4211
|
float(operation.params[2]),
|
|
4202
4212
|
)
|
|
4203
4213
|
elif name == "cx":
|
|
4204
|
-
self._sim.mcx(
|
|
4205
|
-
[q._index for q in operation.qubits[0:1]], operation.qubits[1]._index
|
|
4206
|
-
)
|
|
4214
|
+
self._sim.mcx([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
|
|
4207
4215
|
elif name == "cy":
|
|
4208
|
-
self._sim.mcy(
|
|
4209
|
-
[q._index for q in operation.qubits[0:1]], operation.qubits[1]._index
|
|
4210
|
-
)
|
|
4216
|
+
self._sim.mcy([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
|
|
4211
4217
|
elif name == "cz":
|
|
4212
|
-
self._sim.mcz(
|
|
4213
|
-
[q._index for q in operation.qubits[0:1]], operation.qubits[1]._index
|
|
4214
|
-
)
|
|
4218
|
+
self._sim.mcz([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
|
|
4215
4219
|
elif name == "ch":
|
|
4216
|
-
self._sim.mch(
|
|
4217
|
-
[q._index for q in operation.qubits[0:1]], operation.qubits[1]._index
|
|
4218
|
-
)
|
|
4220
|
+
self._sim.mch([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
|
|
4219
4221
|
elif name == "cp":
|
|
4220
4222
|
self._sim.mcmtrx(
|
|
4221
4223
|
[q._index for q in operation.qubits[0:1]],
|
|
@@ -4241,34 +4243,20 @@ class QrackSimulator:
|
|
|
4241
4243
|
operation.qubits[1]._index,
|
|
4242
4244
|
)
|
|
4243
4245
|
elif name == "dcx":
|
|
4244
|
-
self._sim.mcx(
|
|
4245
|
-
[q._index for q in operation.qubits[0:1]], operation.qubits[1]._index
|
|
4246
|
-
)
|
|
4246
|
+
self._sim.mcx([q._index for q in operation.qubits[0:1]], operation.qubits[1]._index)
|
|
4247
4247
|
self._sim.mcx(operation.qubits[1:2]._index, operation.qubits[0]._index)
|
|
4248
4248
|
elif name == "ccx":
|
|
4249
|
-
self._sim.mcx(
|
|
4250
|
-
[q._index for q in operation.qubits[0:2]], operation.qubits[2]._index
|
|
4251
|
-
)
|
|
4249
|
+
self._sim.mcx([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
|
|
4252
4250
|
elif name == "ccy":
|
|
4253
|
-
self._sim.mcy(
|
|
4254
|
-
[q._index for q in operation.qubits[0:2]], operation.qubits[2]._index
|
|
4255
|
-
)
|
|
4251
|
+
self._sim.mcy([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
|
|
4256
4252
|
elif name == "ccz":
|
|
4257
|
-
self._sim.mcz(
|
|
4258
|
-
[q._index for q in operation.qubits[0:2]], operation.qubits[2]._index
|
|
4259
|
-
)
|
|
4253
|
+
self._sim.mcz([q._index for q in operation.qubits[0:2]], operation.qubits[2]._index)
|
|
4260
4254
|
elif name == "mcx":
|
|
4261
|
-
self._sim.mcx(
|
|
4262
|
-
[q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index
|
|
4263
|
-
)
|
|
4255
|
+
self._sim.mcx([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
|
|
4264
4256
|
elif name == "mcy":
|
|
4265
|
-
self._sim.mcy(
|
|
4266
|
-
[q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index
|
|
4267
|
-
)
|
|
4257
|
+
self._sim.mcy([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
|
|
4268
4258
|
elif name == "mcz":
|
|
4269
|
-
self._sim.mcz(
|
|
4270
|
-
[q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index
|
|
4271
|
-
)
|
|
4259
|
+
self._sim.mcz([q._index for q in operation.qubits[0:-1]], operation.qubits[-1]._index)
|
|
4272
4260
|
elif name == "swap":
|
|
4273
4261
|
self._sim.swap(operation.qubits[0]._index, operation.qubits[1]._index)
|
|
4274
4262
|
elif name == "iswap":
|
|
@@ -4320,9 +4308,9 @@ class QrackSimulator:
|
|
|
4320
4308
|
cregbit = clbit
|
|
4321
4309
|
|
|
4322
4310
|
regbit = 1 << cregbit
|
|
4323
|
-
self._classical_register = (
|
|
4324
|
-
|
|
4325
|
-
)
|
|
4311
|
+
self._classical_register = (self._classical_register & (~regbit)) | (
|
|
4312
|
+
qubit_outcome << cregbit
|
|
4313
|
+
)
|
|
4326
4314
|
|
|
4327
4315
|
elif name == "bfunc":
|
|
4328
4316
|
mask = int(operation.mask, 16)
|
|
@@ -4437,9 +4425,7 @@ class QrackSimulator:
|
|
|
4437
4425
|
if operation.name == "id" or operation.name == "barrier":
|
|
4438
4426
|
continue
|
|
4439
4427
|
|
|
4440
|
-
if is_initializing and (
|
|
4441
|
-
(operation.name == "measure") or (operation.name == "reset")
|
|
4442
|
-
):
|
|
4428
|
+
if is_initializing and ((operation.name == "measure") or (operation.name == "reset")):
|
|
4443
4429
|
continue
|
|
4444
4430
|
|
|
4445
4431
|
is_initializing = False
|
|
@@ -4497,9 +4483,7 @@ class QrackSimulator:
|
|
|
4497
4483
|
self._sample_cregbits = []
|
|
4498
4484
|
|
|
4499
4485
|
if self._sample_measure and (len(self._sample_qubits) > 0):
|
|
4500
|
-
_data = self._add_sample_measure(
|
|
4501
|
-
self._sample_qubits, self._sample_clbits, self._shots
|
|
4502
|
-
)
|
|
4486
|
+
_data = self._add_sample_measure(self._sample_qubits, self._sample_clbits, self._shots)
|
|
4503
4487
|
|
|
4504
4488
|
del self._sim
|
|
4505
4489
|
|
pyqrack/qrack_system/qrack_lib/{libqrack_pinvoke.9.34.5.dylib → libqrack_pinvoke.10.0.0.dylib}
RENAMED
|
Binary file
|
|
Binary file
|
|
@@ -28,13 +28,9 @@ class QrackSystem:
|
|
|
28
28
|
elif _platform == "win32":
|
|
29
29
|
shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/qrack_pinvoke.dll"
|
|
30
30
|
elif _platform == "darwin":
|
|
31
|
-
shared_lib_path = (
|
|
32
|
-
os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.dylib"
|
|
33
|
-
)
|
|
31
|
+
shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.dylib"
|
|
34
32
|
else:
|
|
35
|
-
shared_lib_path = (
|
|
36
|
-
os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.so"
|
|
37
|
-
)
|
|
33
|
+
shared_lib_path = os.path.dirname(__file__) + "/qrack_lib/libqrack_pinvoke.so"
|
|
38
34
|
|
|
39
35
|
try:
|
|
40
36
|
self.qrack_lib = CDLL(shared_lib_path)
|
|
@@ -50,9 +46,7 @@ class QrackSystem:
|
|
|
50
46
|
self.qrack_lib = CDLL(shared_lib_path)
|
|
51
47
|
except Exception as e:
|
|
52
48
|
if _platform == "win32":
|
|
53
|
-
shared_lib_path = (
|
|
54
|
-
"C:/Program Files (x86)/Qrack/bin/qrack_pinvoke.dll"
|
|
55
|
-
)
|
|
49
|
+
shared_lib_path = "C:/Program Files (x86)/Qrack/bin/qrack_pinvoke.dll"
|
|
56
50
|
elif _platform == "darwin":
|
|
57
51
|
shared_lib_path = "/usr/lib/qrack/libqrack_pinvoke.dylib"
|
|
58
52
|
else:
|
|
@@ -97,12 +91,22 @@ class QrackSystem:
|
|
|
97
91
|
self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_float)]
|
|
98
92
|
self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_float)]
|
|
99
93
|
self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_float)]
|
|
100
|
-
self.qrack_lib.OutReducedDensityMatrix.argtypes = [
|
|
94
|
+
self.qrack_lib.OutReducedDensityMatrix.argtypes = [
|
|
95
|
+
c_ulonglong,
|
|
96
|
+
c_ulonglong,
|
|
97
|
+
POINTER(c_ulonglong),
|
|
98
|
+
POINTER(c_float),
|
|
99
|
+
]
|
|
101
100
|
else:
|
|
102
101
|
self.qrack_lib.InKet.argtypes = [c_ulonglong, POINTER(c_double)]
|
|
103
102
|
self.qrack_lib.OutKet.argtypes = [c_ulonglong, POINTER(c_double)]
|
|
104
103
|
self.qrack_lib.OutProbs.argtypes = [c_ulonglong, POINTER(c_double)]
|
|
105
|
-
self.qrack_lib.OutReducedDensityMatrix.argtypes = [
|
|
104
|
+
self.qrack_lib.OutReducedDensityMatrix.argtypes = [
|
|
105
|
+
c_ulonglong,
|
|
106
|
+
c_ulonglong,
|
|
107
|
+
POINTER(c_ulonglong),
|
|
108
|
+
POINTER(c_double),
|
|
109
|
+
]
|
|
106
110
|
|
|
107
111
|
self.qrack_lib.init.restype = c_ulonglong
|
|
108
112
|
self.qrack_lib.init.argtypes = []
|
|
@@ -129,7 +133,7 @@ class QrackSystem:
|
|
|
129
133
|
c_bool,
|
|
130
134
|
c_bool,
|
|
131
135
|
c_bool,
|
|
132
|
-
c_bool
|
|
136
|
+
c_bool,
|
|
133
137
|
]
|
|
134
138
|
|
|
135
139
|
self.qrack_lib.init_count_stabilizer.restype = c_ulonglong
|
|
@@ -166,14 +170,14 @@ class QrackSystem:
|
|
|
166
170
|
self.qrack_lib.HighestProbAllN.argtypes = [c_ulonglong, c_ulonglong, POINTER(c_ulonglong)]
|
|
167
171
|
|
|
168
172
|
self.qrack_lib.ProbAll.restype = None
|
|
169
|
-
if self.fppow
|
|
173
|
+
if self.fppow <= 5:
|
|
170
174
|
self.qrack_lib.ProbAll.argtypes = [
|
|
171
175
|
c_ulonglong,
|
|
172
176
|
c_ulonglong,
|
|
173
177
|
POINTER(c_ulonglong),
|
|
174
178
|
POINTER(c_float),
|
|
175
179
|
]
|
|
176
|
-
|
|
180
|
+
else:
|
|
177
181
|
self.qrack_lib.ProbAll.argtypes = [
|
|
178
182
|
c_ulonglong,
|
|
179
183
|
c_ulonglong,
|
|
@@ -238,7 +242,7 @@ class QrackSystem:
|
|
|
238
242
|
c_bool,
|
|
239
243
|
]
|
|
240
244
|
|
|
241
|
-
if self.fppow
|
|
245
|
+
if self.fppow <= 5:
|
|
242
246
|
self.qrack_lib.FactorizedExpectationFp.restype = c_double
|
|
243
247
|
self.qrack_lib.FactorizedExpectationFp.argtypes = [
|
|
244
248
|
c_ulonglong,
|
|
@@ -284,7 +288,7 @@ class QrackSystem:
|
|
|
284
288
|
POINTER(c_float),
|
|
285
289
|
POINTER(c_float),
|
|
286
290
|
]
|
|
287
|
-
|
|
291
|
+
else:
|
|
288
292
|
self.qrack_lib.FactorizedExpectationFp.restype = c_double
|
|
289
293
|
self.qrack_lib.FactorizedExpectationFp.argtypes = [
|
|
290
294
|
c_ulonglong,
|
|
@@ -373,7 +377,7 @@ class QrackSystem:
|
|
|
373
377
|
c_bool,
|
|
374
378
|
]
|
|
375
379
|
|
|
376
|
-
if self.fppow
|
|
380
|
+
if self.fppow <= 5:
|
|
377
381
|
self.qrack_lib.FactorizedVarianceFp.restype = c_double
|
|
378
382
|
self.qrack_lib.FactorizedVarianceFp.argtypes = [
|
|
379
383
|
c_ulonglong,
|
|
@@ -419,7 +423,7 @@ class QrackSystem:
|
|
|
419
423
|
POINTER(c_float),
|
|
420
424
|
POINTER(c_float),
|
|
421
425
|
]
|
|
422
|
-
|
|
426
|
+
else:
|
|
423
427
|
self.qrack_lib.FactorizedVarianceFp.restype = c_double
|
|
424
428
|
self.qrack_lib.FactorizedVarianceFp.argtypes = [
|
|
425
429
|
c_ulonglong,
|
|
@@ -1240,9 +1244,6 @@ class QrackSystem:
|
|
|
1240
1244
|
c_ulonglong,
|
|
1241
1245
|
POINTER(c_ulonglong),
|
|
1242
1246
|
c_ulonglong,
|
|
1243
|
-
c_ulonglong,
|
|
1244
|
-
c_double,
|
|
1245
|
-
c_double,
|
|
1246
1247
|
]
|
|
1247
1248
|
|
|
1248
1249
|
self.qrack_lib.clone_qneuron.restype = c_ulonglong
|
|
@@ -1251,53 +1252,61 @@ class QrackSystem:
|
|
|
1251
1252
|
self.qrack_lib.destroy_qneuron.restype = None
|
|
1252
1253
|
self.qrack_lib.destroy_qneuron.argtypes = [c_ulonglong]
|
|
1253
1254
|
|
|
1254
|
-
self.qrack_lib.
|
|
1255
|
-
self.qrack_lib.
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
c_ulonglong,
|
|
1263
|
-
POINTER(c_double),
|
|
1264
|
-
]
|
|
1265
|
-
self.qrack_lib.get_qneuron_angles.argtypes = [
|
|
1266
|
-
c_ulonglong,
|
|
1267
|
-
POINTER(c_double),
|
|
1268
|
-
]
|
|
1255
|
+
self.qrack_lib.set_qneuron_sim.restype = None
|
|
1256
|
+
self.qrack_lib.set_qneuron_sim.argtypes = [
|
|
1257
|
+
c_ulonglong,
|
|
1258
|
+
c_ulonglong,
|
|
1259
|
+
c_ulonglong,
|
|
1260
|
+
POINTER(c_ulonglong),
|
|
1261
|
+
c_ulonglong
|
|
1262
|
+
]
|
|
1269
1263
|
|
|
1270
|
-
self.
|
|
1271
|
-
|
|
1264
|
+
if self.fppow <= 5:
|
|
1265
|
+
self.qrack_lib.qneuron_predict.restype = c_double
|
|
1266
|
+
self.qrack_lib.qneuron_predict.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_bool, c_ulonglong, c_double]
|
|
1272
1267
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1268
|
+
self.qrack_lib.qneuron_unpredict.restype = c_double
|
|
1269
|
+
self.qrack_lib.qneuron_unpredict.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_ulonglong, c_double]
|
|
1275
1270
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1271
|
+
self.qrack_lib.qneuron_learn_cycle.restype = c_double
|
|
1272
|
+
self.qrack_lib.qneuron_learn_cycle.argtypes = [c_ulonglong, POINTER(c_float), c_bool, c_ulonglong, c_double]
|
|
1278
1273
|
|
|
1279
|
-
|
|
1280
|
-
|
|
1274
|
+
self.qrack_lib.qneuron_learn.restype = None
|
|
1275
|
+
self.qrack_lib.qneuron_learn.argtypes = [c_ulonglong, POINTER(c_float), c_double, c_bool, c_bool, c_ulonglong, c_double]
|
|
1281
1276
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1277
|
+
self.qrack_lib.qneuron_learn_permutation.restype = None
|
|
1278
|
+
self.qrack_lib.qneuron_learn_permutation.argtypes = [
|
|
1279
|
+
c_ulonglong,
|
|
1280
|
+
POINTER(c_float),
|
|
1281
|
+
c_double,
|
|
1282
|
+
c_bool,
|
|
1283
|
+
c_bool,
|
|
1284
|
+
c_ulonglong,
|
|
1285
|
+
c_double,
|
|
1286
|
+
]
|
|
1287
|
+
else:
|
|
1288
|
+
self.qrack_lib.qneuron_predict.restype = c_double
|
|
1289
|
+
self.qrack_lib.qneuron_predict.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_bool, c_ulonglong, c_double]
|
|
1284
1290
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1291
|
+
self.qrack_lib.qneuron_unpredict.restype = c_double
|
|
1292
|
+
self.qrack_lib.qneuron_unpredict.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_ulonglong, c_double]
|
|
1287
1293
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1294
|
+
self.qrack_lib.qneuron_learn_cycle.restype = c_double
|
|
1295
|
+
self.qrack_lib.qneuron_learn_cycle.argtypes = [c_ulonglong, POINTER(c_double), c_bool, c_ulonglong, c_double]
|
|
1290
1296
|
|
|
1291
|
-
|
|
1292
|
-
|
|
1297
|
+
self.qrack_lib.qneuron_learn.restype = None
|
|
1298
|
+
self.qrack_lib.qneuron_learn.argtypes = [c_ulonglong, POINTER(c_double), c_double, c_bool, c_bool, c_ulonglong, c_double]
|
|
1293
1299
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1300
|
+
self.qrack_lib.qneuron_learn_permutation.restype = None
|
|
1301
|
+
self.qrack_lib.qneuron_learn_permutation.argtypes = [
|
|
1302
|
+
c_ulonglong,
|
|
1303
|
+
POINTER(c_double),
|
|
1304
|
+
c_double,
|
|
1305
|
+
c_bool,
|
|
1306
|
+
c_bool,
|
|
1307
|
+
c_ulonglong,
|
|
1308
|
+
c_double,
|
|
1309
|
+
]
|
|
1301
1310
|
|
|
1302
1311
|
self.qrack_lib.init_qcircuit.restype = c_ulonglong
|
|
1303
1312
|
self.qrack_lib.init_qcircuit.argtypes = [c_bool, c_bool]
|
|
@@ -20,9 +20,7 @@ def load_data(sim, index_bits, value_bits, data):
|
|
|
20
20
|
Value error: Length of value_bits does not match data feature column count!
|
|
21
21
|
"""
|
|
22
22
|
if (len(data) > 0) and (len(value_bits) != len(data[0])):
|
|
23
|
-
raise ValueError(
|
|
24
|
-
"Length of value_bits does not match data feature column count!"
|
|
25
|
-
)
|
|
23
|
+
raise ValueError("Length of value_bits does not match data feature column count!")
|
|
26
24
|
|
|
27
25
|
for i in range(index_bits):
|
|
28
26
|
if sim.m(i):
|
|
@@ -28,9 +28,7 @@ try:
|
|
|
28
28
|
min_val, max_val = data[:, i].min(), data[:, i].max()
|
|
29
29
|
thresholds = np.linspace(min_val, max_val, n_bins + 1)[1:-1]
|
|
30
30
|
bins = np.digitize(data[:, i], bins=thresholds)
|
|
31
|
-
bin_bits = ((bins[:, None] & (1 << np.arange(bits)[::-1])) > 0).astype(
|
|
32
|
-
int
|
|
33
|
-
)
|
|
31
|
+
bin_bits = ((bins[:, None] & (1 << np.arange(bits)[::-1])) > 0).astype(int)
|
|
34
32
|
new_features.append(bin_bits)
|
|
35
33
|
else:
|
|
36
34
|
new_features.append(data[:, i][:, None]) # Keep original
|
|
@@ -51,6 +49,4 @@ except ImportError:
|
|
|
51
49
|
Returns:
|
|
52
50
|
np.ndarray: Transformed data with selected features replaced by binary bit columns.
|
|
53
51
|
"""
|
|
54
|
-
raise NotImplementedError(
|
|
55
|
-
"You must have numpy installed to use quantize_by_percentile()!"
|
|
56
|
-
)
|
|
52
|
+
raise NotImplementedError("You must have numpy installed to use quantize_by_percentile()!")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyqrack-complex128
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.81.0
|
|
4
4
|
Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
|
|
5
5
|
Home-page: https://github.com/vm6502q/pyqrack
|
|
6
6
|
Author: Daniel Strano
|
|
@@ -32,6 +32,8 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
32
32
|
Classifier: Programming Language :: Python :: 3.10
|
|
33
33
|
Classifier: Programming Language :: Python :: 3.11
|
|
34
34
|
Classifier: Programming Language :: Python :: 3.12
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
35
37
|
Classifier: Topic :: Scientific/Engineering :: Quantum Computing
|
|
36
38
|
Description-Content-Type: text/markdown
|
|
37
39
|
License-File: LICENSE
|