pyqrack-cuda 1.58.9__tar.gz → 1.58.10__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.
Files changed (29) hide show
  1. {pyqrack_cuda-1.58.9/pyqrack_cuda.egg-info → pyqrack_cuda-1.58.10}/PKG-INFO +1 -1
  2. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_ace_backend.py +76 -78
  3. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10/pyqrack_cuda.egg-info}/PKG-INFO +1 -1
  4. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/setup.py +1 -1
  5. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/LICENSE +0 -0
  6. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/MANIFEST.in +0 -0
  7. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/Makefile +0 -0
  8. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/README.md +0 -0
  9. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyproject.toml +0 -0
  10. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/__init__.py +0 -0
  11. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/neuron_activation_fn.py +0 -0
  12. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/pauli.py +0 -0
  13. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_circuit.py +0 -0
  14. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_neuron.py +0 -0
  15. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  16. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_simulator.py +0 -0
  17. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_stabilizer.py +0 -0
  18. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_system/__init__.py +0 -0
  19. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/qrack_system/qrack_system.py +0 -0
  20. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/quimb_circuit_type.py +0 -0
  21. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/stats/__init__.py +0 -0
  22. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/stats/load_quantized_data.py +0 -0
  23. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack/stats/quantize_by_range.py +0 -0
  24. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/SOURCES.txt +0 -0
  25. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/dependency_links.txt +0 -0
  26. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/not-zip-safe +0 -0
  27. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/requires.txt +0 -0
  28. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/top_level.txt +0 -0
  29. {pyqrack_cuda-1.58.9 → pyqrack_cuda-1.58.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda
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
@@ -443,12 +443,17 @@ class QrackAceBackend:
443
443
 
444
444
  return qb, lhv
445
445
 
446
- def get_lhv_bloch_angles(self, q):
447
- z = (1 - q.bloch[2]) / 2
446
+ def _get_lhv_bloch_angles(self, sim):
447
+ # Z axis
448
+ z = 1 - 2 * sim.prob(Pauli.PauliZ)
448
449
  prob = z**2
449
- x = (1 - q.bloch[0]) / 2
450
+
451
+ # X axis
452
+ x = 1 - 2 * sim.prob(Pauli.PauliX)
450
453
  prob += x**2
451
- y = (1 - q.bloch[1]) / 2
454
+
455
+ # Y axis
456
+ y = 1 - 2 * sim.prob(Pauli.PauliY)
452
457
  prob += y**2
453
458
 
454
459
  prob = math.sqrt(prob)
@@ -457,7 +462,7 @@ class QrackAceBackend:
457
462
 
458
463
  return prob, azimuth, inclination
459
464
 
460
- def get_bloch_angles(self, hq):
465
+ def _get_bloch_angles(self, hq):
461
466
  sim = self.sim[hq[0]]
462
467
  q = hq[1]
463
468
 
@@ -485,12 +490,13 @@ class QrackAceBackend:
485
490
 
486
491
  return prob, azimuth, inclination
487
492
 
488
- def rotate_lhv_to_bloch(
489
- self, q, azimuth_curr, inclination_curr, azimuth_target, inclination_target
493
+ def _rotate_to_bloch(
494
+ self, hq, delta_azimuth, delta_inclination
490
495
  ):
491
- delta_azimuth = azimuth_target - azimuth_curr
492
- delta_inclination = inclination_target - inclination_curr
496
+ sim = self.sim[hq[0]]
497
+ q = hq[1]
493
498
 
499
+ # Apply rotation as "Azimuth, Inclination" (AI)
494
500
  cosA = math.cos(delta_azimuth)
495
501
  sinA = math.sin(delta_azimuth)
496
502
  cosI = math.cos(delta_inclination / 2)
@@ -501,17 +507,12 @@ class QrackAceBackend:
501
507
  m10 = complex(cosA, sinA) * sinI
502
508
  m11 = complex(cosI, 0)
503
509
 
504
- q.mtrx([m00, m01, m10, m11])
505
-
506
- def rotate_to_bloch(
507
- self, hq, azimuth_curr, inclination_curr, azimuth_target, inclination_target
508
- ):
509
- sim = self.sim[hq[0]]
510
- q = hq[1]
510
+ sim.mtrx([m00, m01, m10, m11], q)
511
511
 
512
- delta_azimuth = azimuth_target - azimuth_curr
513
- delta_inclination = inclination_target - inclination_curr
514
512
 
513
+ def _rotate_lhv_to_bloch(
514
+ self, sim, delta_azimuth, delta_inclination
515
+ ):
515
516
  # Apply rotation as "Azimuth, Inclination" (AI)
516
517
  cosA = math.cos(delta_azimuth)
517
518
  sinA = math.sin(delta_azimuth)
@@ -523,10 +524,10 @@ class QrackAceBackend:
523
524
  m10 = complex(cosA, sinA) * sinI
524
525
  m11 = complex(cosI, 0)
525
526
 
526
- sim.mtrx([m00, m01, m10, m11], q)
527
+ sim.mtrx([m00, m01, m10, m11])
527
528
 
528
529
 
529
- def _correct(self, lq, phase=False):
530
+ def _correct(self, lq, phase=False, skip_rotation=False):
530
531
  hq = self._unpack(lq)
531
532
 
532
533
  if len(hq) == 1:
@@ -577,34 +578,33 @@ class QrackAceBackend:
577
578
  else:
578
579
  self.sim[hq[q][0]].x(hq[q][1])
579
580
 
580
- p, a, i = [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]
581
- p[0], a[0], i[0] = self.get_bloch_angles(hq[0])
582
- p[1], a[1], i[1] = self.get_bloch_angles(hq[1])
583
- p[2], a[2], i[2] = self.get_lhv_bloch_angles(hq[2])
584
- p[3], a[3], i[3] = self.get_bloch_angles(hq[3])
585
- p[4], a[4], i[4] = self.get_bloch_angles(hq[4])
586
-
587
- indices = []
588
- a_target = 0
589
- i_target = 0
590
- weight = 0
591
- for x in range(5):
592
- if p[x] < 0.5:
593
- continue
594
- indices.append(x)
595
- w = (1.5 - p[x])
596
- a_target += w * a[x]
597
- i_target += w * i[x]
598
- weight += w
599
-
600
- if len(indices) > 1:
601
- a_target /= weight
602
- i_target /= weight
603
- for x in indices:
604
- if x == 2:
605
- self.rotate_lhv_to_bloch(hq[x], a[x], i[x], a_target, i_target)
606
- else:
607
- 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
+
608
608
  else:
609
609
  # RMS
610
610
  p = [
@@ -624,32 +624,30 @@ class QrackAceBackend:
624
624
  else:
625
625
  self.sim[hq[q][0]].x(hq[q][1])
626
626
 
627
- p, a, i = [0, 0, 0], [0, 0, 0], [0, 0, 0]
628
- p[0], a[0], i[0] = self.get_bloch_angles(hq[0])
629
- p[1], a[1], i[1] = self.get_bloch_angles(hq[1])
630
- p[2], a[2], i[2] = self.get_lhv_bloch_angles(hq[2])
631
-
632
- indices = []
633
- a_target = 0
634
- i_target = 0
635
- weight = 0
636
- for x in range(2):
637
- if p[x] < 0.5:
638
- continue
639
- indices.append(x)
640
- w = (1.5 - p[x])
641
- a_target += w * a[x]
642
- i_target += w * i[x]
643
- weight += w
644
-
645
- if len(indices) > 1:
646
- a_target /= weight
647
- i_target /= weight
648
- for x in indices:
649
- if x == 2:
650
- self.rotate_lhv_to_bloch(hq[x], a[x], i[x], a_target, i_target)
651
- else:
652
- 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])
653
651
 
654
652
  if phase:
655
653
  for q in qb:
@@ -674,8 +672,8 @@ class QrackAceBackend:
674
672
  b = hq[lhv]
675
673
  b.u(th, ph, lm)
676
674
 
677
- self._correct(lq, False)
678
- self._correct(lq, True)
675
+ self._correct(lq, False, True)
676
+ self._correct(lq, True, False)
679
677
 
680
678
  def r(self, p, th, lq):
681
679
  hq = self._unpack(lq)
@@ -699,7 +697,7 @@ class QrackAceBackend:
699
697
  b.rz(th)
700
698
 
701
699
  if p != Pauli.PauliZ:
702
- self._correct(lq, False)
700
+ self._correct(lq, False, p != Pauli.PauliX)
703
701
  if p != Pauli.PauliX:
704
702
  self._correct(lq, True)
705
703
 
@@ -923,7 +921,7 @@ class QrackAceBackend:
923
921
 
924
922
  self._correct(lq1, True)
925
923
  if pauli != Pauli.PauliZ:
926
- self._correct(lq2, False)
924
+ self._correct(lq2, False, pauli != Pauli.PauliX)
927
925
  if pauli != Pauli.PauliX:
928
926
  self._correct(lq2, True)
929
927
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda
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
@@ -7,7 +7,7 @@ from setuptools import setup
7
7
  from setuptools.command.build_py import build_py
8
8
 
9
9
 
10
- VERSION = "1.58.9"
10
+ VERSION = "1.58.10"
11
11
 
12
12
  # Read long description from README.
13
13
  README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.md')
File without changes
File without changes
File without changes
File without changes