pyqrack-cuda 1.46.5__tar.gz → 1.46.7__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.46.5/pyqrack_cuda.egg-info → pyqrack_cuda-1.46.7}/PKG-INFO +1 -1
  2. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_ace_backend.py +41 -47
  3. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7/pyqrack_cuda.egg-info}/PKG-INFO +1 -1
  4. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/setup.py +1 -1
  5. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/LICENSE +0 -0
  6. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/MANIFEST.in +0 -0
  7. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/Makefile +0 -0
  8. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/README.md +0 -0
  9. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyproject.toml +0 -0
  10. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/__init__.py +0 -0
  11. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/neuron_activation_fn.py +0 -0
  12. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/pauli.py +0 -0
  13. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_circuit.py +0 -0
  14. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_neuron.py +0 -0
  15. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  16. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_simulator.py +0 -0
  17. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_stabilizer.py +0 -0
  18. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_system/__init__.py +0 -0
  19. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/qrack_system/qrack_system.py +0 -0
  20. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/quimb_circuit_type.py +0 -0
  21. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/stats/__init__.py +0 -0
  22. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/stats/load_quantized_data.py +0 -0
  23. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack/stats/quantize_by_range.py +0 -0
  24. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack_cuda.egg-info/SOURCES.txt +0 -0
  25. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack_cuda.egg-info/dependency_links.txt +0 -0
  26. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack_cuda.egg-info/not-zip-safe +0 -0
  27. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack_cuda.egg-info/requires.txt +0 -0
  28. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/pyqrack_cuda.egg-info/top_level.txt +0 -0
  29. {pyqrack_cuda-1.46.5 → pyqrack_cuda-1.46.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda
3
- Version: 1.46.5
3
+ Version: 1.46.7
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -54,6 +54,10 @@ class QrackAceBackend:
54
54
  if recursive_stack_depth < 1:
55
55
  recursive_stack_depth = 1
56
56
  self.recursive_stack_depth = recursive_stack_depth
57
+ self._ancilla = 3 * qubit_count
58
+ self._factor_width(qubit_count)
59
+ self.alternating_codes = alternating_codes
60
+ self._is_init = [False] * qubit_count
57
61
  if recursive_stack_depth > 1:
58
62
  recursive_stack_depth -= 1
59
63
  self.sim = (
@@ -61,16 +65,15 @@ class QrackAceBackend:
61
65
  if toClone
62
66
  else QrackAceBackend(3 * qubit_count + 1, recursive_stack_depth=recursive_stack_depth, alternating_codes=alternating_codes, isTensorNetwork=isTensorNetwork, isStabilizerHybrid=isStabilizerHybrid, isBinaryDecisionTree=isBinaryDecisionTree)
63
67
  )
68
+ # This leaves an "odd-man-out" ancillary qubit.
69
+ self.sim.row_length = 3 * self.row_length
70
+ self.sim.col_length = self.col_length
64
71
  else:
65
72
  self.sim = (
66
73
  toClone.sim.clone()
67
74
  if toClone
68
75
  else QrackSimulator(3 * qubit_count + 1, isTensorNetwork=isTensorNetwork, isStabilizerHybrid=isStabilizerHybrid, isBinaryDecisionTree=isBinaryDecisionTree)
69
76
  )
70
- self._ancilla = 3 * qubit_count
71
- self._factor_width(qubit_count)
72
- self.alternating_codes = alternating_codes
73
- self._is_init = [False] * qubit_count
74
77
 
75
78
  def clone(self):
76
79
  return QrackAceBackend(toClone=self)
@@ -135,19 +138,13 @@ class QrackAceBackend:
135
138
 
136
139
  def _encode(self, hq, reverse=False):
137
140
  lq = hq[0] // 3
138
- row = lq // self.row_length
139
- even_row = not (row & 1)
141
+ even_row = not ((lq // self.row_length) & 1)
142
+ # Encode shadow-first
143
+ if self._is_init[lq]:
144
+ self._cx_shadow(hq[0], hq[2])
140
145
  if ((not self.alternating_codes) and reverse) or (even_row == reverse):
141
- if self._is_init[lq]:
142
- # Encode shadow-first
143
- self._cx_shadow(hq[0], hq[1])
144
- self.sim.mcx([hq[1]], hq[2])
145
- else:
146
- self.sim.mcx([hq[2]], hq[1])
146
+ self.sim.mcx([hq[2]], hq[1])
147
147
  else:
148
- if self._is_init[lq]:
149
- # Encode shadow-first
150
- self._cx_shadow(hq[0], hq[2])
151
148
  self.sim.mcx([hq[0]], hq[1])
152
149
  self._is_init[lq] = True
153
150
 
@@ -155,16 +152,14 @@ class QrackAceBackend:
155
152
  lq = hq[0] // 3
156
153
  if not self._is_init[lq]:
157
154
  return
158
- row = lq // self.row_length
159
- even_row = not (row & 1)
155
+ even_row = not ((lq // self.row_length) & 1)
160
156
  if ((not self.alternating_codes) and reverse) or (even_row == reverse):
161
157
  # Decode entangled-first
162
- self.sim.mcx([hq[1]], hq[2])
163
- self._cx_shadow(hq[0], hq[1])
158
+ self.sim.mcx([hq[2]], hq[1])
164
159
  else:
165
160
  # Decode entangled-first
166
161
  self.sim.mcx([hq[0]], hq[1])
167
- self._cx_shadow(hq[0], hq[2])
162
+ self._cx_shadow(hq[0], hq[2])
168
163
 
169
164
  def _correct(self, lq):
170
165
  if not self._is_init[lq]:
@@ -172,20 +167,23 @@ class QrackAceBackend:
172
167
  # We can't use true syndrome-based error correction,
173
168
  # because one of the qubits in the code is separated.
174
169
  # However, we can get pretty close!
175
- shots = 1024
176
- even_row = not ((lq // self.row_length) & 1)
170
+ shots = 512
171
+
177
172
  single_bit = 0
178
173
  other_bits = []
179
- if not self.alternating_codes or even_row:
174
+ if not self.alternating_codes or not ((lq // self.row_length) & 1):
180
175
  single_bit = 2
181
176
  other_bits = [0, 1]
182
177
  else:
183
178
  single_bit = 0
184
179
  other_bits = [1, 2]
180
+
185
181
  hq = self._unpack(lq)
182
+
186
183
  single_bit_value = self.sim.prob(hq[single_bit])
187
184
  single_bit_polarization = max(single_bit_value, 1 - single_bit_value)
188
185
  samples = self.sim.measure_shots([hq[other_bits[0]], hq[other_bits[1]]], shots)
186
+
189
187
  syndrome_indices = (
190
188
  [other_bits[1], other_bits[0]]
191
189
  if (single_bit_value >= 0.5)
@@ -278,6 +276,7 @@ class QrackAceBackend:
278
276
  lm += 2 * math.pi
279
277
  hq = self._unpack(lq)
280
278
  if not math.isclose(ph, -lm) and not math.isclose(abs(ph), math.pi / 2):
279
+ # Produces/destroys superposition
281
280
  self._correct_if_like_h(th, lq)
282
281
  self._decode(hq)
283
282
  self.sim.u(hq[0], th, ph, lm)
@@ -285,6 +284,7 @@ class QrackAceBackend:
285
284
  self.sim.u(hq[2], th, ph, lm)
286
285
  self._encode(hq)
287
286
  else:
287
+ # Shouldn't produce/destroy superposition
288
288
  for b in hq:
289
289
  self.sim.u(b, th, ph, lm)
290
290
 
@@ -297,9 +297,11 @@ class QrackAceBackend:
297
297
  self._correct_if_like_h(th, lq)
298
298
  hq = self._unpack(lq)
299
299
  if (p == Pauli.PauliZ) or math.isclose(abs(th), math.pi):
300
+ # Doesn't produce/destroy superposition
300
301
  for b in hq:
301
302
  self.sim.r(p, th, b)
302
303
  else:
304
+ # Produces/destroys superposition
303
305
  self._decode(hq)
304
306
  self.sim.r(p, th, hq[0])
305
307
  if not self._is_init[lq]:
@@ -374,14 +376,14 @@ class QrackAceBackend:
374
376
 
375
377
  return
376
378
 
377
- lq1_col = lq1 // self.row_length
378
- lq1_row = lq1 % self.row_length
379
- lq2_col = lq2 // self.row_length
380
- lq2_row = lq2 % self.row_length
379
+ lq1_row = lq1 // self.row_length
380
+ lq1_col = lq1 % self.row_length
381
+ lq2_row = lq2 // self.row_length
382
+ lq2_col = lq2 % self.row_length
381
383
 
382
384
  hq1 = None
383
385
  hq2 = None
384
- if (lq2_col == lq1_col) and (((lq1_row + 1) % self.row_length) == lq2_row):
386
+ if (lq2_row == lq1_row) and (((lq1_col + 1) % self.row_length) == lq2_col):
385
387
  self._correct(lq2)
386
388
  hq1 = self._unpack(lq1, True)
387
389
  hq2 = self._unpack(lq2, False)
@@ -390,7 +392,7 @@ class QrackAceBackend:
390
392
  gate([hq1[0]], hq2[0])
391
393
  self._encode(hq2, False)
392
394
  self._encode(hq1, True)
393
- elif (lq1_col == lq2_col) and (((lq2_row + 1) % self.row_length) == lq1_row):
395
+ elif (lq1_row == lq2_row) and (((lq2_col + 1) % self.row_length) == lq1_col):
394
396
  self._correct(lq2)
395
397
  hq2 = self._unpack(lq2, True)
396
398
  hq1 = self._unpack(lq1, False)
@@ -403,7 +405,7 @@ class QrackAceBackend:
403
405
  hq1 = self._unpack(lq1)
404
406
  hq2 = self._unpack(lq2)
405
407
  gate([hq1[0]], hq2[0])
406
- if self.alternating_codes and ((lq2_col & 1) != (lq1_col & 1)):
408
+ if self.alternating_codes and ((lq2_row & 1) != (lq1_row & 1)):
407
409
  shadow(hq1[1], hq2[1])
408
410
  else:
409
411
  gate([hq1[1]], hq2[1])
@@ -476,8 +478,7 @@ class QrackAceBackend:
476
478
 
477
479
  def m(self, lq):
478
480
  hq = self._unpack(lq)
479
- even_row = not ((lq // self.row_length) & 1)
480
- if not self.alternating_codes or even_row:
481
+ if not self.alternating_codes or not ((lq // self.row_length) & 1):
481
482
  single_bit = 2
482
483
  other_bits = [0, 1]
483
484
  else:
@@ -485,18 +486,12 @@ class QrackAceBackend:
485
486
  other_bits = [1, 2]
486
487
  # The syndrome of "other_bits" is guaranteed to be fixed, after this.
487
488
  self._correct(lq)
488
- syndrome = 0
489
- for q in other_bits:
490
- syndrome += self.sim.m(hq[q])
489
+ syndrome = self.sim.m(hq[other_bits[0]])
490
+ syndrome += self.sim.force_m(hq[other_bits[1]], bool(syndrome))
491
491
  # The two separable parts of the code are correlated,
492
492
  # but not non-locally, via entanglement.
493
493
  # Collapse the other separable part toward agreement.
494
- if syndrome == 0:
495
- self.sim.force_m(hq[single_bit], False)
496
- elif syndrome == 2:
497
- syndrome += self.sim.force_m(hq[single_bit], True)
498
- else:
499
- raise RuntimeError("Unexpected syndrome in m()!")
494
+ syndrome += self.sim.force_m(hq[single_bit], bool(syndrome))
500
495
  self._is_init[lq] = False
501
496
 
502
497
  return True if (syndrome > 1) else False
@@ -514,11 +509,11 @@ class QrackAceBackend:
514
509
  result = 0
515
510
  # Randomize the order of measurement to amortize error.
516
511
  # However, locality of collapse matters:
517
- # always measure across rows, and by consecutive rows.
518
- rows = list(range(range(self.col_length)))
512
+ # always measure across rows, and by row directionality.
513
+ rows = list(range(self.col_length))
519
514
  random.shuffle(rows)
520
515
  for lq_row in rows:
521
- col_offset = rand.randint(0, self.row_length - 1)
516
+ col_offset = random.randint(0, self.row_length - 1)
522
517
  col_reverse = self.alternating_codes and (lq_row & 1)
523
518
  for c in range(self.row_length):
524
519
  lq_col = (((self.row_length - (c + 1)) if col_reverse else c) + col_offset) % self.row_length
@@ -532,7 +527,7 @@ class QrackAceBackend:
532
527
  if high_accuracy:
533
528
  samples = []
534
529
  for _ in range(s):
535
- clone = self.sim.clone()
530
+ clone = self.clone()
536
531
  _sample = clone.m_all()
537
532
  sample = 0
538
533
  for i in range(len(q)):
@@ -569,8 +564,7 @@ class QrackAceBackend:
569
564
  def prob(self, lq):
570
565
  self._correct(lq)
571
566
  hq = self._unpack(lq)
572
- even_row = not ((lq // self.row_length) & 1)
573
- if not self.alternating_codes or even_row:
567
+ if not self.alternating_codes or not ((lq // self.row_length) & 1):
574
568
  other_bits = [0, 1]
575
569
  else:
576
570
  other_bits = [1, 2]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda
3
- Version: 1.46.5
3
+ Version: 1.46.7
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.46.5"
10
+ VERSION = "1.46.7"
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
File without changes