pyqrack-cpu 1.58.9__py3-none-macosx_13_0_x86_64.whl → 1.59.0__py3-none-macosx_13_0_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.
Potentially problematic release.
This version of pyqrack-cpu might be problematic. Click here for more details.
- pyqrack/qrack_ace_backend.py +95 -59
- {pyqrack_cpu-1.58.9.dist-info → pyqrack_cpu-1.59.0.dist-info}/METADATA +1 -1
- {pyqrack_cpu-1.58.9.dist-info → pyqrack_cpu-1.59.0.dist-info}/RECORD +6 -6
- {pyqrack_cpu-1.58.9.dist-info → pyqrack_cpu-1.59.0.dist-info}/LICENSE +0 -0
- {pyqrack_cpu-1.58.9.dist-info → pyqrack_cpu-1.59.0.dist-info}/WHEEL +0 -0
- {pyqrack_cpu-1.58.9.dist-info → pyqrack_cpu-1.59.0.dist-info}/top_level.txt +0 -0
pyqrack/qrack_ace_backend.py
CHANGED
|
@@ -207,8 +207,8 @@ class QrackAceBackend:
|
|
|
207
207
|
def __init__(
|
|
208
208
|
self,
|
|
209
209
|
qubit_count=1,
|
|
210
|
-
long_range_columns=
|
|
211
|
-
long_range_rows=
|
|
210
|
+
long_range_columns=4,
|
|
211
|
+
long_range_rows=4,
|
|
212
212
|
is_transpose=False,
|
|
213
213
|
isTensorNetwork=False,
|
|
214
214
|
isSchmidtDecomposeMulti=False,
|
|
@@ -443,6 +443,25 @@ class QrackAceBackend:
|
|
|
443
443
|
|
|
444
444
|
return qb, lhv
|
|
445
445
|
|
|
446
|
+
def _get_lhv_bloch_angles(self, sim):
|
|
447
|
+
# Z axis
|
|
448
|
+
z = 1 - 2 * sim.prob(Pauli.PauliZ)
|
|
449
|
+
prob = z**2
|
|
450
|
+
|
|
451
|
+
# X axis
|
|
452
|
+
x = 1 - 2 * sim.prob(Pauli.PauliX)
|
|
453
|
+
prob += x**2
|
|
454
|
+
|
|
455
|
+
# Y axis
|
|
456
|
+
y = 1 - 2 * sim.prob(Pauli.PauliY)
|
|
457
|
+
prob += y**2
|
|
458
|
+
|
|
459
|
+
prob = math.sqrt(prob)
|
|
460
|
+
inclination = math.atan2(math.sqrt(x**2 + y**2), z)
|
|
461
|
+
azimuth = math.atan2(y, x)
|
|
462
|
+
|
|
463
|
+
return prob, azimuth, inclination
|
|
464
|
+
|
|
446
465
|
def _get_bloch_angles(self, hq):
|
|
447
466
|
sim = self.sim[hq[0]]
|
|
448
467
|
q = hq[1]
|
|
@@ -472,14 +491,11 @@ class QrackAceBackend:
|
|
|
472
491
|
return prob, azimuth, inclination
|
|
473
492
|
|
|
474
493
|
def _rotate_to_bloch(
|
|
475
|
-
self, hq,
|
|
494
|
+
self, hq, delta_azimuth, delta_inclination
|
|
476
495
|
):
|
|
477
496
|
sim = self.sim[hq[0]]
|
|
478
497
|
q = hq[1]
|
|
479
498
|
|
|
480
|
-
delta_azimuth = azimuth_target - azimuth_curr
|
|
481
|
-
delta_inclination = inclination_target - inclination_curr
|
|
482
|
-
|
|
483
499
|
# Apply rotation as "Azimuth, Inclination" (AI)
|
|
484
500
|
cosA = math.cos(delta_azimuth)
|
|
485
501
|
sinA = math.sin(delta_azimuth)
|
|
@@ -494,7 +510,24 @@ class QrackAceBackend:
|
|
|
494
510
|
sim.mtrx([m00, m01, m10, m11], q)
|
|
495
511
|
|
|
496
512
|
|
|
497
|
-
def
|
|
513
|
+
def _rotate_lhv_to_bloch(
|
|
514
|
+
self, sim, delta_azimuth, delta_inclination
|
|
515
|
+
):
|
|
516
|
+
# Apply rotation as "Azimuth, Inclination" (AI)
|
|
517
|
+
cosA = math.cos(delta_azimuth)
|
|
518
|
+
sinA = math.sin(delta_azimuth)
|
|
519
|
+
cosI = math.cos(delta_inclination / 2)
|
|
520
|
+
sinI = math.sin(delta_inclination / 2)
|
|
521
|
+
|
|
522
|
+
m00 = complex(cosI, 0)
|
|
523
|
+
m01 = complex(-cosA, sinA) * sinI
|
|
524
|
+
m10 = complex(cosA, sinA) * sinI
|
|
525
|
+
m11 = complex(cosI, 0)
|
|
526
|
+
|
|
527
|
+
sim.mtrx([m00, m01, m10, m11])
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
def _correct(self, lq, phase=False, skip_rotation=False):
|
|
498
531
|
hq = self._unpack(lq)
|
|
499
532
|
|
|
500
533
|
if len(hq) == 1:
|
|
@@ -545,31 +578,33 @@ class QrackAceBackend:
|
|
|
545
578
|
else:
|
|
546
579
|
self.sim[hq[q][0]].x(hq[q][1])
|
|
547
580
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
581
|
+
if not skip_rotation:
|
|
582
|
+
p, a, i = [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]
|
|
583
|
+
p[0], a[0], i[0] = self._get_bloch_angles(hq[0])
|
|
584
|
+
p[1], a[1], i[1] = self._get_bloch_angles(hq[1])
|
|
585
|
+
p[3], a[3], i[3] = self._get_bloch_angles(hq[3])
|
|
586
|
+
p[4], a[4], i[4] = self._get_bloch_angles(hq[4])
|
|
587
|
+
|
|
588
|
+
indices = []
|
|
589
|
+
a_target = 0
|
|
590
|
+
i_target = 0
|
|
591
|
+
weight = 0
|
|
592
|
+
for x in range(5):
|
|
593
|
+
if p[x] < 0.5:
|
|
594
|
+
continue
|
|
595
|
+
indices.append(x)
|
|
596
|
+
w = (1.5 - p[x])
|
|
597
|
+
w *= w
|
|
598
|
+
a_target += w * a[x]
|
|
599
|
+
i_target += w * i[x]
|
|
600
|
+
weight += w
|
|
601
|
+
|
|
602
|
+
if len(indices) > 1:
|
|
603
|
+
a_target /= weight
|
|
604
|
+
i_target /= weight
|
|
605
|
+
for x in indices:
|
|
606
|
+
self._rotate_to_bloch(hq[x], a_target - a[x], i_target - i[x])
|
|
607
|
+
|
|
573
608
|
else:
|
|
574
609
|
# RMS
|
|
575
610
|
p = [
|
|
@@ -589,29 +624,30 @@ class QrackAceBackend:
|
|
|
589
624
|
else:
|
|
590
625
|
self.sim[hq[q][0]].x(hq[q][1])
|
|
591
626
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
627
|
+
if not skip_rotation:
|
|
628
|
+
p, a, i = [0, 0, 0], [0, 0, 0], [0, 0, 0]
|
|
629
|
+
p[0], a[0], i[0] = self._get_bloch_angles(hq[0])
|
|
630
|
+
p[1], a[1], i[1] = self._get_bloch_angles(hq[1])
|
|
631
|
+
|
|
632
|
+
indices = []
|
|
633
|
+
a_target = 0
|
|
634
|
+
i_target = 0
|
|
635
|
+
weight = 0
|
|
636
|
+
for x in range(3):
|
|
637
|
+
if p[x] < 0.5:
|
|
638
|
+
continue
|
|
639
|
+
indices.append(x)
|
|
640
|
+
w = (1.5 - p[x])
|
|
641
|
+
w *= w
|
|
642
|
+
a_target += w * a[x]
|
|
643
|
+
i_target += w * i[x]
|
|
644
|
+
weight += w
|
|
645
|
+
|
|
646
|
+
if len(indices) > 1:
|
|
647
|
+
a_target /= weight
|
|
648
|
+
i_target /= weight
|
|
649
|
+
for x in indices:
|
|
650
|
+
self._rotate_to_bloch(hq[x], a_target - a[x], i_target - i[x])
|
|
615
651
|
|
|
616
652
|
if phase:
|
|
617
653
|
for q in qb:
|
|
@@ -636,8 +672,8 @@ class QrackAceBackend:
|
|
|
636
672
|
b = hq[lhv]
|
|
637
673
|
b.u(th, ph, lm)
|
|
638
674
|
|
|
639
|
-
self._correct(lq, False)
|
|
640
|
-
self._correct(lq, True)
|
|
675
|
+
self._correct(lq, False, True)
|
|
676
|
+
self._correct(lq, True, False)
|
|
641
677
|
|
|
642
678
|
def r(self, p, th, lq):
|
|
643
679
|
hq = self._unpack(lq)
|
|
@@ -661,7 +697,7 @@ class QrackAceBackend:
|
|
|
661
697
|
b.rz(th)
|
|
662
698
|
|
|
663
699
|
if p != Pauli.PauliZ:
|
|
664
|
-
self._correct(lq, False)
|
|
700
|
+
self._correct(lq, False, p != Pauli.PauliX)
|
|
665
701
|
if p != Pauli.PauliX:
|
|
666
702
|
self._correct(lq, True)
|
|
667
703
|
|
|
@@ -885,7 +921,7 @@ class QrackAceBackend:
|
|
|
885
921
|
|
|
886
922
|
self._correct(lq1, True)
|
|
887
923
|
if pauli != Pauli.PauliZ:
|
|
888
|
-
self._correct(lq2, False)
|
|
924
|
+
self._correct(lq2, False, pauli != Pauli.PauliX)
|
|
889
925
|
if pauli != Pauli.PauliX:
|
|
890
926
|
self._correct(lq2, True)
|
|
891
927
|
|
|
@@ -1,7 +1,7 @@
|
|
|
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=tjP8rkRYN5PrK5HRp4tllDjOiwu9OOa3uuIAG3S9Ph8,48908
|
|
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
|
|
@@ -16,8 +16,8 @@ pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib,sha256=zcQuUTTXLbR_nbM_de9
|
|
|
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-1.
|
|
20
|
-
pyqrack_cpu-1.
|
|
21
|
-
pyqrack_cpu-1.
|
|
22
|
-
pyqrack_cpu-1.
|
|
23
|
-
pyqrack_cpu-1.
|
|
19
|
+
pyqrack_cpu-1.59.0.dist-info/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
|
|
20
|
+
pyqrack_cpu-1.59.0.dist-info/METADATA,sha256=weDkyqKmq8RCL3JbjJCFka-H0X0Nbt_acRg2audiCb8,5910
|
|
21
|
+
pyqrack_cpu-1.59.0.dist-info/WHEEL,sha256=nZx8s83OrgdDmpcWX-8FgI0sEAjdQimt4SdYsdcCaC8,107
|
|
22
|
+
pyqrack_cpu-1.59.0.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
|
|
23
|
+
pyqrack_cpu-1.59.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|