pyqrack-cpu-complex128 1.58.9__py3-none-manylinux_2_39_x86_64.whl → 1.70.2__py3-none-manylinux_2_39_x86_64.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.
- pyqrack/qrack_ace_backend.py +123 -76
- pyqrack/qrack_simulator.py +81 -13
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so +0 -0
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so.9.29.2 +0 -0
- pyqrack/qrack_system/qrack_system.py +16 -3
- {pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/METADATA +3 -3
- {pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/RECORD +10 -10
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so.9.21.0 +0 -0
- {pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/WHEEL +0 -0
- {pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/licenses/LICENSE +0 -0
- {pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/top_level.txt +0 -0
pyqrack/qrack_ace_backend.py
CHANGED
|
@@ -139,6 +139,12 @@ class LHVQubit:
|
|
|
139
139
|
new_y = 2 * (rho_prime[0][1].imag - rho_prime[1][0].imag)
|
|
140
140
|
new_z = 2 * rho_prime[0][0].real - 1 # since Tr(ρ') = 1
|
|
141
141
|
|
|
142
|
+
p = math.sqrt(new_x**2 + new_y**2 + new_z**2)
|
|
143
|
+
|
|
144
|
+
new_x /= p
|
|
145
|
+
new_y /= p
|
|
146
|
+
new_z /= p
|
|
147
|
+
|
|
142
148
|
self.bloch = [new_x, new_y, new_z]
|
|
143
149
|
|
|
144
150
|
def prob(self, basis=Pauli.PauliZ):
|
|
@@ -207,8 +213,8 @@ class QrackAceBackend:
|
|
|
207
213
|
def __init__(
|
|
208
214
|
self,
|
|
209
215
|
qubit_count=1,
|
|
210
|
-
long_range_columns=
|
|
211
|
-
long_range_rows=
|
|
216
|
+
long_range_columns=4,
|
|
217
|
+
long_range_rows=4,
|
|
212
218
|
is_transpose=False,
|
|
213
219
|
isTensorNetwork=False,
|
|
214
220
|
isSchmidtDecomposeMulti=False,
|
|
@@ -272,12 +278,8 @@ class QrackAceBackend:
|
|
|
272
278
|
if long_range_rows < self._col_length:
|
|
273
279
|
self._is_row_long_range[-1] = False
|
|
274
280
|
sim_count = col_patch_count * row_patch_count
|
|
275
|
-
self._row_offset = 0
|
|
276
|
-
for r in range(self._col_length):
|
|
277
|
-
for c in self._is_col_long_range:
|
|
278
|
-
self._row_offset += 1 if c else 3
|
|
279
281
|
|
|
280
|
-
self.
|
|
282
|
+
self._qubits = []
|
|
281
283
|
sim_counts = [0] * sim_count
|
|
282
284
|
sim_id = 0
|
|
283
285
|
tot_qubits = 0
|
|
@@ -294,7 +296,7 @@ class QrackAceBackend:
|
|
|
294
296
|
qubit.append(
|
|
295
297
|
LHVQubit(
|
|
296
298
|
toClone=(
|
|
297
|
-
toClone.
|
|
299
|
+
toClone._qubits[tot_qubits][2] if toClone else None
|
|
298
300
|
)
|
|
299
301
|
)
|
|
300
302
|
)
|
|
@@ -311,7 +313,7 @@ class QrackAceBackend:
|
|
|
311
313
|
if not c:
|
|
312
314
|
sim_id = (sim_id + 1) % sim_count
|
|
313
315
|
|
|
314
|
-
self.
|
|
316
|
+
self._qubits.append(qubit)
|
|
315
317
|
tot_qubits += 1
|
|
316
318
|
|
|
317
319
|
self.sim = []
|
|
@@ -336,7 +338,8 @@ class QrackAceBackend:
|
|
|
336
338
|
|
|
337
339
|
# You can still "monkey-patch" this, after the constructor.
|
|
338
340
|
if "QRACK_QUNIT_SEPARABILITY_THRESHOLD" not in os.environ:
|
|
339
|
-
|
|
341
|
+
# (1 - 1 / sqrt(2)) / 4 (but empirically tuned)
|
|
342
|
+
self.sim[i].set_sdrp(0.073223304703363119)
|
|
340
343
|
|
|
341
344
|
def clone(self):
|
|
342
345
|
return QrackAceBackend(toClone=self)
|
|
@@ -427,7 +430,7 @@ class QrackAceBackend:
|
|
|
427
430
|
self._qec_x(c)
|
|
428
431
|
|
|
429
432
|
def _unpack(self, lq):
|
|
430
|
-
return self.
|
|
433
|
+
return self._qubits[lq]
|
|
431
434
|
|
|
432
435
|
def _get_qb_lhv_indices(self, hq):
|
|
433
436
|
qb = []
|
|
@@ -443,43 +446,50 @@ class QrackAceBackend:
|
|
|
443
446
|
|
|
444
447
|
return qb, lhv
|
|
445
448
|
|
|
449
|
+
def _get_lhv_bloch_angles(self, sim):
|
|
450
|
+
# Z axis
|
|
451
|
+
z = sim.bloch[2]
|
|
452
|
+
|
|
453
|
+
# X axis
|
|
454
|
+
x = sim.bloch[0]
|
|
455
|
+
|
|
456
|
+
# Y axis
|
|
457
|
+
y = sim.bloch[1]
|
|
458
|
+
|
|
459
|
+
inclination = math.atan2(math.sqrt(x**2 + y**2), z)
|
|
460
|
+
azimuth = math.atan2(y, x)
|
|
461
|
+
|
|
462
|
+
return azimuth, inclination
|
|
463
|
+
|
|
446
464
|
def _get_bloch_angles(self, hq):
|
|
447
|
-
sim = self.sim[hq[0]]
|
|
465
|
+
sim = self.sim[hq[0]].clone()
|
|
448
466
|
q = hq[1]
|
|
467
|
+
sim.separate([q])
|
|
449
468
|
|
|
450
469
|
# Z axis
|
|
451
470
|
z = 1 - 2 * sim.prob(q)
|
|
452
|
-
prob = z**2
|
|
453
471
|
|
|
454
472
|
# X axis
|
|
455
473
|
sim.h(q)
|
|
456
474
|
x = 1 - 2 * sim.prob(q)
|
|
457
|
-
prob += x**2
|
|
458
475
|
sim.h(q)
|
|
459
476
|
|
|
460
477
|
# Y axis
|
|
461
478
|
sim.adjs(q)
|
|
462
479
|
sim.h(q)
|
|
463
480
|
y = 1 - 2 * sim.prob(q)
|
|
464
|
-
prob += y**2
|
|
465
481
|
sim.h(q)
|
|
466
482
|
sim.s(q)
|
|
467
483
|
|
|
468
|
-
prob = math.sqrt(prob)
|
|
469
484
|
inclination = math.atan2(math.sqrt(x**2 + y**2), z)
|
|
470
485
|
azimuth = math.atan2(y, x)
|
|
471
486
|
|
|
472
|
-
return
|
|
487
|
+
return azimuth, inclination
|
|
473
488
|
|
|
474
|
-
def _rotate_to_bloch(
|
|
475
|
-
self, hq, azimuth_curr, inclination_curr, azimuth_target, inclination_target
|
|
476
|
-
):
|
|
489
|
+
def _rotate_to_bloch(self, hq, delta_azimuth, delta_inclination):
|
|
477
490
|
sim = self.sim[hq[0]]
|
|
478
491
|
q = hq[1]
|
|
479
492
|
|
|
480
|
-
delta_azimuth = azimuth_target - azimuth_curr
|
|
481
|
-
delta_inclination = inclination_target - inclination_curr
|
|
482
|
-
|
|
483
493
|
# Apply rotation as "Azimuth, Inclination" (AI)
|
|
484
494
|
cosA = math.cos(delta_azimuth)
|
|
485
495
|
sinA = math.sin(delta_azimuth)
|
|
@@ -493,8 +503,21 @@ class QrackAceBackend:
|
|
|
493
503
|
|
|
494
504
|
sim.mtrx([m00, m01, m10, m11], q)
|
|
495
505
|
|
|
506
|
+
def _rotate_lhv_to_bloch(self, sim, delta_azimuth, delta_inclination):
|
|
507
|
+
# Apply rotation as "Azimuth, Inclination" (AI)
|
|
508
|
+
cosA = math.cos(delta_azimuth)
|
|
509
|
+
sinA = math.sin(delta_azimuth)
|
|
510
|
+
cosI = math.cos(delta_inclination / 2)
|
|
511
|
+
sinI = math.sin(delta_inclination / 2)
|
|
512
|
+
|
|
513
|
+
m00 = complex(cosI, 0)
|
|
514
|
+
m01 = complex(-cosA, sinA) * sinI
|
|
515
|
+
m10 = complex(cosA, sinA) * sinI
|
|
516
|
+
m11 = complex(cosI, 0)
|
|
517
|
+
|
|
518
|
+
sim.mtrx([m00, m01, m10, m11])
|
|
496
519
|
|
|
497
|
-
def _correct(self, lq, phase=False):
|
|
520
|
+
def _correct(self, lq, phase=False, skip_rotation=False):
|
|
498
521
|
hq = self._unpack(lq)
|
|
499
522
|
|
|
500
523
|
if len(hq) == 1:
|
|
@@ -545,31 +568,32 @@ class QrackAceBackend:
|
|
|
545
568
|
else:
|
|
546
569
|
self.sim[hq[q][0]].x(hq[q][1])
|
|
547
570
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
a_target
|
|
565
|
-
i_target
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
571
|
+
if not skip_rotation:
|
|
572
|
+
a, i = [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]
|
|
573
|
+
a[0], i[0] = self._get_bloch_angles(hq[0])
|
|
574
|
+
a[1], i[1] = self._get_bloch_angles(hq[1])
|
|
575
|
+
a[2], i[2] = self._get_lhv_bloch_angles(hq[2])
|
|
576
|
+
a[3], i[3] = self._get_bloch_angles(hq[3])
|
|
577
|
+
a[4], i[4] = self._get_bloch_angles(hq[4])
|
|
578
|
+
|
|
579
|
+
a_target = 0
|
|
580
|
+
i_target = 0
|
|
581
|
+
for x in range(5):
|
|
582
|
+
if x == 2:
|
|
583
|
+
continue
|
|
584
|
+
a_target += a[x]
|
|
585
|
+
i_target += i[x]
|
|
586
|
+
|
|
587
|
+
a_target /= 5
|
|
588
|
+
i_target /= 5
|
|
589
|
+
for x in range(5):
|
|
590
|
+
if x == 2:
|
|
591
|
+
self._rotate_lhv_to_bloch(
|
|
592
|
+
hq[x], a_target - a[x], i_target - i[x]
|
|
593
|
+
)
|
|
594
|
+
else:
|
|
595
|
+
self._rotate_to_bloch(hq[x], a_target - a[x], i_target - i[x])
|
|
596
|
+
|
|
573
597
|
else:
|
|
574
598
|
# RMS
|
|
575
599
|
p = [
|
|
@@ -589,29 +613,29 @@ class QrackAceBackend:
|
|
|
589
613
|
else:
|
|
590
614
|
self.sim[hq[q][0]].x(hq[q][1])
|
|
591
615
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
a_target
|
|
607
|
-
i_target
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
616
|
+
if not skip_rotation:
|
|
617
|
+
a, i = [0, 0, 0], [0, 0, 0]
|
|
618
|
+
a[0], i[0] = self._get_bloch_angles(hq[0])
|
|
619
|
+
a[1], i[1] = self._get_bloch_angles(hq[1])
|
|
620
|
+
a[2], i[2] = self._get_lhv_bloch_angles(hq[2])
|
|
621
|
+
|
|
622
|
+
a_target = 0
|
|
623
|
+
i_target = 0
|
|
624
|
+
for x in range(3):
|
|
625
|
+
if x == 2:
|
|
626
|
+
continue
|
|
627
|
+
a_target += a[x]
|
|
628
|
+
i_target += i[x]
|
|
629
|
+
|
|
630
|
+
a_target /= 3
|
|
631
|
+
i_target /= 3
|
|
632
|
+
for x in range(3):
|
|
633
|
+
if x == 2:
|
|
634
|
+
self._rotate_lhv_to_bloch(
|
|
635
|
+
hq[x], a_target - a[x], i_target - i[x]
|
|
636
|
+
)
|
|
637
|
+
else:
|
|
638
|
+
self._rotate_to_bloch(hq[x], a_target - a[x], i_target - i[x])
|
|
615
639
|
|
|
616
640
|
if phase:
|
|
617
641
|
for q in qb:
|
|
@@ -620,6 +644,29 @@ class QrackAceBackend:
|
|
|
620
644
|
b = hq[lhv]
|
|
621
645
|
b.h()
|
|
622
646
|
|
|
647
|
+
def apply_magnetic_bias(self, q, b):
|
|
648
|
+
if b == 0:
|
|
649
|
+
return
|
|
650
|
+
b = math.exp(b)
|
|
651
|
+
for x in q:
|
|
652
|
+
hq = self._unpack(x)
|
|
653
|
+
for c in range(len(hq)):
|
|
654
|
+
h = hq[c]
|
|
655
|
+
if c == 2:
|
|
656
|
+
a, i = self._get_lhv_bloch_angles(h)
|
|
657
|
+
self._rotate_lhv_to_bloch(
|
|
658
|
+
h,
|
|
659
|
+
math.atan(math.tan(a) * b) - a,
|
|
660
|
+
math.atan(math.tan(i) * b) - i,
|
|
661
|
+
)
|
|
662
|
+
else:
|
|
663
|
+
a, i = self._get_bloch_angles(h)
|
|
664
|
+
self._rotate_to_bloch(
|
|
665
|
+
h,
|
|
666
|
+
math.atan(math.tan(a) * b) - a,
|
|
667
|
+
math.atan(math.tan(i) * b) - i,
|
|
668
|
+
)
|
|
669
|
+
|
|
623
670
|
def u(self, lq, th, ph, lm):
|
|
624
671
|
hq = self._unpack(lq)
|
|
625
672
|
if len(hq) < 2:
|
|
@@ -636,8 +683,8 @@ class QrackAceBackend:
|
|
|
636
683
|
b = hq[lhv]
|
|
637
684
|
b.u(th, ph, lm)
|
|
638
685
|
|
|
639
|
-
self._correct(lq, False)
|
|
640
|
-
self._correct(lq, True)
|
|
686
|
+
self._correct(lq, False, True)
|
|
687
|
+
self._correct(lq, True, False)
|
|
641
688
|
|
|
642
689
|
def r(self, p, th, lq):
|
|
643
690
|
hq = self._unpack(lq)
|
|
@@ -661,7 +708,7 @@ class QrackAceBackend:
|
|
|
661
708
|
b.rz(th)
|
|
662
709
|
|
|
663
710
|
if p != Pauli.PauliZ:
|
|
664
|
-
self._correct(lq, False)
|
|
711
|
+
self._correct(lq, False, p != Pauli.PauliX)
|
|
665
712
|
if p != Pauli.PauliX:
|
|
666
713
|
self._correct(lq, True)
|
|
667
714
|
|
|
@@ -885,7 +932,7 @@ class QrackAceBackend:
|
|
|
885
932
|
|
|
886
933
|
self._correct(lq1, True)
|
|
887
934
|
if pauli != Pauli.PauliZ:
|
|
888
|
-
self._correct(lq2, False)
|
|
935
|
+
self._correct(lq2, False, pauli != Pauli.PauliX)
|
|
889
936
|
if pauli != Pauli.PauliX:
|
|
890
937
|
self._correct(lq2, True)
|
|
891
938
|
|
pyqrack/qrack_simulator.py
CHANGED
|
@@ -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()
|
|
@@ -1053,9 +1055,16 @@ class QrackSimulator:
|
|
|
1053
1055
|
Returns:
|
|
1054
1056
|
Measurement result of all qubits.
|
|
1055
1057
|
"""
|
|
1056
|
-
|
|
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)
|
|
1057
1062
|
self._throw_if_error()
|
|
1058
|
-
|
|
1063
|
+
r = 0
|
|
1064
|
+
for w in range(num_words):
|
|
1065
|
+
r <<= 64
|
|
1066
|
+
r |= _r[w]
|
|
1067
|
+
return r
|
|
1059
1068
|
|
|
1060
1069
|
def measure_pauli(self, b, q):
|
|
1061
1070
|
"""Pauli Measurement gate
|
|
@@ -2125,9 +2134,7 @@ class QrackSimulator:
|
|
|
2125
2134
|
def decompose(self, q):
|
|
2126
2135
|
"""Decompose system
|
|
2127
2136
|
|
|
2128
|
-
|
|
2129
|
-
Warning: The qubit subsystem state must be separable, or the behavior
|
|
2130
|
-
of this method is undefined.
|
|
2137
|
+
Factorize a set of contiguous bits with minimal fidelity loss.
|
|
2131
2138
|
|
|
2132
2139
|
Args:
|
|
2133
2140
|
q: qubit id
|
|
@@ -2137,7 +2144,7 @@ class QrackSimulator:
|
|
|
2137
2144
|
RuntimeError: QrackSimulator with isTensorNetwork=True option cannot decompose()! (Turn off just this option, in the constructor.)
|
|
2138
2145
|
|
|
2139
2146
|
Returns:
|
|
2140
|
-
|
|
2147
|
+
Decomposed subsystem simulator.
|
|
2141
2148
|
"""
|
|
2142
2149
|
if self.is_tensor_network:
|
|
2143
2150
|
raise RuntimeError(
|
|
@@ -2154,10 +2161,8 @@ class QrackSimulator:
|
|
|
2154
2161
|
def dispose(self, q):
|
|
2155
2162
|
"""Dispose qubits
|
|
2156
2163
|
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
Warning: The qubit subsystem state must be separable, or the behavior
|
|
2160
|
-
of this method is undefined.
|
|
2164
|
+
Factorize a set of contiguous bits with minimal fidelity loss,
|
|
2165
|
+
and discard the separable bits.
|
|
2161
2166
|
|
|
2162
2167
|
Args:
|
|
2163
2168
|
q: qubit
|
|
@@ -2165,9 +2170,6 @@ class QrackSimulator:
|
|
|
2165
2170
|
Raises:
|
|
2166
2171
|
RuntimeError: QrackSimulator raised an exception.
|
|
2167
2172
|
RuntimeError: QrackSimulator with isTensorNetwork=True option cannot dispose()! (Turn off just this option, in the constructor.)
|
|
2168
|
-
|
|
2169
|
-
Returns:
|
|
2170
|
-
State of the systems.
|
|
2171
2173
|
"""
|
|
2172
2174
|
if self.is_tensor_network:
|
|
2173
2175
|
raise RuntimeError(
|
|
@@ -2285,6 +2287,72 @@ class QrackSimulator:
|
|
|
2285
2287
|
self._throw_if_error()
|
|
2286
2288
|
return list(probs)
|
|
2287
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
|
+
|
|
2288
2356
|
def prob_all(self, q):
|
|
2289
2357
|
"""Probabilities of all subset permutations
|
|
2290
2358
|
|
|
Binary file
|
|
Binary file
|
|
@@ -87,19 +87,22 @@ class QrackSystem:
|
|
|
87
87
|
CFUNCTYPE(c_ulonglong, c_double, c_double),
|
|
88
88
|
]
|
|
89
89
|
|
|
90
|
-
# These next
|
|
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 = [
|
|
@@ -790,6 +800,9 @@ class QrackSystem:
|
|
|
790
800
|
self.qrack_lib.MAll.restype = c_ulonglong
|
|
791
801
|
self.qrack_lib.MAll.argtypes = [c_ulonglong]
|
|
792
802
|
|
|
803
|
+
self.qrack_lib.MAllLong.restype = None
|
|
804
|
+
self.qrack_lib.MAllLong.argtypes = [c_ulonglong, POINTER(c_ulonglong)]
|
|
805
|
+
|
|
793
806
|
self.qrack_lib.Measure.restype = c_ulonglong
|
|
794
807
|
self.qrack_lib.Measure.argtypes = [
|
|
795
808
|
c_ulonglong,
|
{pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyqrack-cpu-complex128
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.70.2
|
|
4
4
|
Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
|
|
5
5
|
Home-page: https://github.com/vm6502q/pyqrack
|
|
6
6
|
Author: Daniel Strano
|
|
@@ -52,7 +52,7 @@ Dynamic: provides-extra
|
|
|
52
52
|
Dynamic: summary
|
|
53
53
|
|
|
54
54
|
# pyqrack
|
|
55
|
-
[](https://pepy.tech/project/pyqrack-cpu) [](https://pepy.tech/project/pyqrack-cpu) [](https://pepy.tech/project/pyqrack-cpu)
|
|
55
|
+
[](https://pepy.tech/project/pyqrack-cpu-complex128) [](https://pepy.tech/project/pyqrack-cpu-complex128) [](https://pepy.tech/project/pyqrack-cpu-complex128)
|
|
56
56
|
|
|
57
57
|
Pure Python bindings for the pure C++11 Qrack quantum computer simulator library
|
|
58
58
|
|
|
@@ -88,4 +88,4 @@ For custom Qrack build floating-point precision, where options are `half`, `floa
|
|
|
88
88
|
|
|
89
89
|
Please feel welcome to open an issue, if you'd like help. 😃
|
|
90
90
|
|
|
91
|
-
**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!**
|
|
91
|
+
**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,23 +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=
|
|
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=
|
|
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=
|
|
12
|
+
pyqrack/qrack_system/qrack_system.py,sha256=3NFejSMePILaND-h3bdwRrX-WuhdZj-Uzt-8i90_xQE,43719
|
|
13
13
|
pyqrack/qrack_system/qrack_cl_precompile/qrack_cl_precompile,sha256=Yt1YxAOJ9vqlndghgIIXrosZEE3AZDG7eNpsmVUqBr4,16392
|
|
14
|
-
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so,sha256=
|
|
15
|
-
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so.9.
|
|
14
|
+
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so,sha256=M_0LKmuwKaMZ0dytTZAn_EGGfffzoZpP-iJhzFFepWU,4517232
|
|
15
|
+
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.so.9.29.2,sha256=M_0LKmuwKaMZ0dytTZAn_EGGfffzoZpP-iJhzFFepWU,4517232
|
|
16
16
|
pyqrack/stats/__init__.py,sha256=Hla85my2fY_roR9lIjGBVpEG7ySOTMwjWa8D6-kgCnY,276
|
|
17
17
|
pyqrack/stats/load_quantized_data.py,sha256=z12u9F7Nt3P-i44nY1xxvso_klS6WIHS3iqq7R2_lqE,1184
|
|
18
18
|
pyqrack/stats/quantize_by_range.py,sha256=UM0_7jJDdQ7g30cR3UQAxkbzkqrmsy1oUfqg0h11FUY,2270
|
|
19
|
-
pyqrack_cpu_complex128-1.
|
|
20
|
-
pyqrack_cpu_complex128-1.
|
|
21
|
-
pyqrack_cpu_complex128-1.
|
|
22
|
-
pyqrack_cpu_complex128-1.
|
|
23
|
-
pyqrack_cpu_complex128-1.
|
|
19
|
+
pyqrack_cpu_complex128-1.70.2.dist-info/licenses/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
|
|
20
|
+
pyqrack_cpu_complex128-1.70.2.dist-info/METADATA,sha256=IREfHo0IjEzILMenknlMSoy9jN4rafGh76kZ-I3D_fM,6258
|
|
21
|
+
pyqrack_cpu_complex128-1.70.2.dist-info/WHEEL,sha256=k8EuOMBHdXsN9XSTE5LrpwS4FtdLkoSlyO_7W-lE_zg,109
|
|
22
|
+
pyqrack_cpu_complex128-1.70.2.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
|
|
23
|
+
pyqrack_cpu_complex128-1.70.2.dist-info/RECORD,,
|
|
Binary file
|
|
File without changes
|
{pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{pyqrack_cpu_complex128-1.58.9.dist-info → pyqrack_cpu_complex128-1.70.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|