pyqrack-cuda 1.58.8__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.8/pyqrack_cuda.egg-info → pyqrack_cuda-1.58.10}/PKG-INFO +1 -1
  2. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_ace_backend.py +95 -57
  3. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10/pyqrack_cuda.egg-info}/PKG-INFO +1 -1
  4. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/setup.py +1 -1
  5. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/LICENSE +0 -0
  6. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/MANIFEST.in +0 -0
  7. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/Makefile +0 -0
  8. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/README.md +0 -0
  9. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyproject.toml +0 -0
  10. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/__init__.py +0 -0
  11. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/neuron_activation_fn.py +0 -0
  12. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/pauli.py +0 -0
  13. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_circuit.py +0 -0
  14. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_neuron.py +0 -0
  15. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  16. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_simulator.py +0 -0
  17. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_stabilizer.py +0 -0
  18. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_system/__init__.py +0 -0
  19. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/qrack_system/qrack_system.py +0 -0
  20. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/quimb_circuit_type.py +0 -0
  21. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/stats/__init__.py +0 -0
  22. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/stats/load_quantized_data.py +0 -0
  23. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack/stats/quantize_by_range.py +0 -0
  24. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/SOURCES.txt +0 -0
  25. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/dependency_links.txt +0 -0
  26. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/not-zip-safe +0 -0
  27. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/requires.txt +0 -0
  28. {pyqrack_cuda-1.58.8 → pyqrack_cuda-1.58.10}/pyqrack_cuda.egg-info/top_level.txt +0 -0
  29. {pyqrack_cuda-1.58.8 → 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.8
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,7 +443,26 @@ class QrackAceBackend:
443
443
 
444
444
  return qb, lhv
445
445
 
446
- def get_bloch_angles(self, hq):
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
+
465
+ def _get_bloch_angles(self, hq):
447
466
  sim = self.sim[hq[0]]
448
467
  q = hq[1]
449
468
 
@@ -471,15 +490,12 @@ class QrackAceBackend:
471
490
 
472
491
  return prob, azimuth, inclination
473
492
 
474
- def rotate_to_bloch(
475
- self, hq, azimuth_curr, inclination_curr, azimuth_target, inclination_target
493
+ def _rotate_to_bloch(
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,30 +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
- a_target += w * a[x]
564
- i_target += w * i[x]
565
- weight += w
566
-
567
- if len(indices) > 1:
568
- a_target /= weight
569
- i_target /= weight
570
- for x in indices:
571
- 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
+
572
608
  else:
573
609
  # RMS
574
610
  p = [
@@ -588,28 +624,30 @@ class QrackAceBackend:
588
624
  else:
589
625
  self.sim[hq[q][0]].x(hq[q][1])
590
626
 
591
- p, a, i = [0, 0], [0, 0], [0, 0]
592
- p[0], a[0], i[0] = self.get_bloch_angles(hq[0])
593
- p[1], a[1], i[1] = self.get_bloch_angles(hq[1])
594
-
595
- indices = []
596
- a_target = 0
597
- i_target = 0
598
- weight = 0
599
- for x in range(2):
600
- if p[x] < 0.5:
601
- continue
602
- indices.append(x)
603
- w = (1.5 - p[x])
604
- a_target += w * a[x]
605
- i_target += w * i[x]
606
- weight += w
607
-
608
- if len(indices) > 1:
609
- a_target /= weight
610
- i_target /= weight
611
- for x in indices:
612
- 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])
613
651
 
614
652
  if phase:
615
653
  for q in qb:
@@ -634,8 +672,8 @@ class QrackAceBackend:
634
672
  b = hq[lhv]
635
673
  b.u(th, ph, lm)
636
674
 
637
- self._correct(lq, False)
638
- self._correct(lq, True)
675
+ self._correct(lq, False, True)
676
+ self._correct(lq, True, False)
639
677
 
640
678
  def r(self, p, th, lq):
641
679
  hq = self._unpack(lq)
@@ -659,7 +697,7 @@ class QrackAceBackend:
659
697
  b.rz(th)
660
698
 
661
699
  if p != Pauli.PauliZ:
662
- self._correct(lq, False)
700
+ self._correct(lq, False, p != Pauli.PauliX)
663
701
  if p != Pauli.PauliX:
664
702
  self._correct(lq, True)
665
703
 
@@ -883,7 +921,7 @@ class QrackAceBackend:
883
921
 
884
922
  self._correct(lq1, True)
885
923
  if pauli != Pauli.PauliZ:
886
- self._correct(lq2, False)
924
+ self._correct(lq2, False, pauli != Pauli.PauliX)
887
925
  if pauli != Pauli.PauliX:
888
926
  self._correct(lq2, True)
889
927
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda
3
- Version: 1.58.8
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.8"
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