pyqrack-cpu 1.58.9__py3-none-manylinux_2_39_x86_64.whl → 1.58.10__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.

Potentially problematic release.


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

@@ -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, azimuth_curr, inclination_curr, azimuth_target, inclination_target
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 _correct(self, lq, phase=False):
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
- p, a, i = [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]
549
- p[0], a[0], i[0] = self._get_bloch_angles(hq[0])
550
- p[1], a[1], i[1] = self._get_bloch_angles(hq[1])
551
- p[3], a[3], i[3] = self._get_bloch_angles(hq[3])
552
- p[4], a[4], i[4] = self._get_bloch_angles(hq[4])
553
-
554
- indices = []
555
- a_target = 0
556
- i_target = 0
557
- weight = 0
558
- for x in range(5):
559
- if p[x] < 0.5:
560
- continue
561
- indices.append(x)
562
- w = (1.5 - p[x])
563
- w *= w
564
- a_target += w * a[x]
565
- i_target += w * i[x]
566
- weight += w
567
-
568
- if len(indices) > 1:
569
- a_target /= weight
570
- i_target /= weight
571
- for x in indices:
572
- self._rotate_to_bloch(hq[x], a[x], i[x], a_target, i_target)
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
- p, a, i = [0, 0, 0], [0, 0, 0], [0, 0, 0]
593
- p[0], a[0], i[0] = self._get_bloch_angles(hq[0])
594
- p[1], a[1], i[1] = self._get_bloch_angles(hq[1])
595
-
596
- indices = []
597
- a_target = 0
598
- i_target = 0
599
- weight = 0
600
- for x in range(3):
601
- if p[x] < 0.5:
602
- continue
603
- indices.append(x)
604
- w = (1.5 - p[x])
605
- w *= w
606
- a_target += w * a[x]
607
- i_target += w * i[x]
608
- weight += w
609
-
610
- if len(indices) > 1:
611
- a_target /= weight
612
- i_target /= weight
613
- for x in indices:
614
- self._rotate_to_bloch(hq[x], a[x], i[x], a_target, i_target)
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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cpu
3
- Version: 1.58.9
3
+ Version: 1.58.10
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -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=Q9XFDoe2miRqbqTm-ZrMdXBfZ8Bk2dkvJuaBc3RBcM8,47776
4
+ pyqrack/qrack_ace_backend.py,sha256=OLxjlPvGIrICawKFG87dlLtg9L77ZuVI_DT7RcyaIE8,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.so.9.21.0,sha256=iw9qucXX8cw4hZH
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.58.9.dist-info/licenses/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
20
- pyqrack_cpu-1.58.9.dist-info/METADATA,sha256=78H62VRh8Tg2BjJeV3Dihu2iaEu-PjP9hFgUannUs6I,6140
21
- pyqrack_cpu-1.58.9.dist-info/WHEEL,sha256=k8EuOMBHdXsN9XSTE5LrpwS4FtdLkoSlyO_7W-lE_zg,109
22
- pyqrack_cpu-1.58.9.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
23
- pyqrack_cpu-1.58.9.dist-info/RECORD,,
19
+ pyqrack_cpu-1.58.10.dist-info/licenses/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
20
+ pyqrack_cpu-1.58.10.dist-info/METADATA,sha256=bEW6TJr56pErtxBziiUMcV1KP3d3hK67PAGIYpcUbwU,6141
21
+ pyqrack_cpu-1.58.10.dist-info/WHEEL,sha256=k8EuOMBHdXsN9XSTE5LrpwS4FtdLkoSlyO_7W-lE_zg,109
22
+ pyqrack_cpu-1.58.10.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
23
+ pyqrack_cpu-1.58.10.dist-info/RECORD,,