pyqrack-cpu-complex128 2.29.3__tar.gz → 2.29.5__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 (31) hide show
  1. {pyqrack_cpu_complex128-2.29.3/pyqrack_cpu_complex128.egg-info → pyqrack_cpu_complex128-2.29.5}/PKG-INFO +1 -1
  2. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_ace_backend.py +182 -83
  3. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5/pyqrack_cpu_complex128.egg-info}/PKG-INFO +1 -1
  4. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/setup.py +1 -1
  5. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/LICENSE +0 -0
  6. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/MANIFEST.in +0 -0
  7. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/Makefile +0 -0
  8. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/README.md +0 -0
  9. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyproject.toml +0 -0
  10. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/__init__.py +0 -0
  11. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/neuron_activation_fn.py +0 -0
  12. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/pauli.py +0 -0
  13. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_ace_mps_backend.py +0 -0
  14. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_circuit.py +0 -0
  15. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_near_clifford_qec_backend.py +0 -0
  16. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_neuron.py +0 -0
  17. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  18. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_simulator.py +0 -0
  19. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_stabilizer.py +0 -0
  20. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_system/__init__.py +0 -0
  21. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/qrack_system/qrack_system.py +0 -0
  22. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/quimb_circuit_type.py +0 -0
  23. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/stats/__init__.py +0 -0
  24. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/stats/load_quantized_data.py +0 -0
  25. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack/stats/quantize_by_range.py +0 -0
  26. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack_cpu_complex128.egg-info/SOURCES.txt +0 -0
  27. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack_cpu_complex128.egg-info/dependency_links.txt +0 -0
  28. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack_cpu_complex128.egg-info/not-zip-safe +0 -0
  29. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack_cpu_complex128.egg-info/requires.txt +0 -0
  30. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/pyqrack_cpu_complex128.egg-info/top_level.txt +0 -0
  31. {pyqrack_cpu_complex128-2.29.3 → pyqrack_cpu_complex128-2.29.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cpu-complex128
3
- Version: 2.29.3
3
+ Version: 2.29.5
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -262,7 +262,7 @@ class QrackAceBackend:
262
262
  is_torus=True,
263
263
  is_1d_chain=False,
264
264
  is_error_detection=True,
265
- is_boundary_repetition_code=False,
265
+ is_boundary_repetition_code=True,
266
266
  use_crossbars=True,
267
267
  to_clone=None,
268
268
  ):
@@ -429,6 +429,7 @@ class QrackAceBackend:
429
429
  # exactly mirroring how every other per-simulator allocation below
430
430
  # already guards for "nothing to allocate."
431
431
  has_boundary = self.use_crossbars and (boundary_count > 0)
432
+ self._crossbar_sim = boundary_sim_id if has_boundary else None
432
433
  if has_boundary:
433
434
  sim_counts.append(boundary_count)
434
435
  sim_count += 1
@@ -471,31 +472,39 @@ class QrackAceBackend:
471
472
  lq_idx = len(self.qubits)
472
473
  self.qubits.append([(sim_id, phys_idx)])
473
474
  self.detect_ancilla_lq.append(lq_idx)
474
- # Boundary repetition code, on-demand design: only the couplers
475
- # are actually noisy here -- single-qubit gates are already
476
- # exactly transversal, per-replica, with zero error, so there's
477
- # no need to maintain a permanently-synced repetition code across
478
- # them at all. Instead: TWO dedicated, reusable scratch ancillae
479
- # per patch (separate from _detect_ancilla above, to avoid any
480
- # contention between this mechanism and that one within the same
481
- # coupling event), allocated ONCE, and reused across every
482
- # boundary qubit that patch ever protects -- not one allocation
483
- # per boundary qubit the way the earlier, always-on version did.
484
- # See _cpauli for the actual encode/couple/decode/correct cycle
485
- # built around these; this block is just the qubit-index
486
- # bookkeeping, in the same style as _detect_ancilla above.
487
- rep_code_ancilla = []
488
- if self.is_boundary_repetition_code:
489
- for i in range(len(sim_counts)):
490
- rep_code_ancilla.append(sim_counts[i])
491
- sim_counts[i] += 1
492
-
475
+ # Boundary repetition code (zero-ancilla, "authority" decoder).
476
+ #
477
+ # A boundary qubit's replicas ARE already a repetition code: 2-5
478
+ # copies of one logical qubit, one per simulator. Single-qubit gates
479
+ # act on every copy exactly, so the only place the copies can
480
+ # diverge is a coupling with a qubit on some other simulator. In
481
+ # that coupling, exactly the replica(s) sharing a simulator with the
482
+ # partner receive the REAL gate (and any real entanglement it
483
+ # creates); every other copy receives only the classical shadow.
484
+ # So the decoder has side information a hardware repetition code
485
+ # doesn't: it knows WHICH copy is fresh. That is the lesson of the
486
+ # Shor-9 layout experiments (ace_shor_9_one_side.py): a code works
487
+ # on ACE when the state lives in the one simulator that shares the
488
+ # couplings, and the far-side copies are what needs reconciling.
489
+ #
490
+ # With this option on, every multi-replica coupling records which
491
+ # replica slot(s) of each boundary participant were real-gated
492
+ # ("authority"). correct() then treats the authority copy as the
493
+ # decoder's ground truth -- flipping stale copies to match it when
494
+ # it is decisive, rotating them toward its Bloch direction when it
495
+ # is still separable, and never touching the authority copy itself
496
+ # -- instead of the fixed home-slot-first cascade (which is right
497
+ # only when the partner happened to share the home simulator).
498
+ # prob() reads the authority copy's own marginal. No qubits are
499
+ # allocated: qubit overhead is zero. The authority record clears
500
+ # whenever every replica is fresh again (a fully matched coupling,
501
+ # or a measurement).
502
+ self._authority = (
503
+ {k: set(v) for k, v in to_clone._authority.items()} if to_clone else {}
504
+ )
505
+ # Kept (always empty) for compatibility with code that inspected the
506
+ # old per-patch scratch ancillae of the previous on-demand design.
493
507
  self.rep_code_ancilla_lq = []
494
- if self.is_boundary_repetition_code:
495
- for sim_id, phys_idx in enumerate(rep_code_ancilla):
496
- lq_idx = len(self.qubits)
497
- self.qubits.append([(sim_id, phys_idx)])
498
- self.rep_code_ancilla_lq.append(lq_idx)
499
508
 
500
509
  # capture calls (see _apply_coupling): those calls go through
501
510
  # the ordinary _cpauli -> _apply_coupling path themselves, which
@@ -892,7 +901,10 @@ class QrackAceBackend:
892
901
  if lq in self.lhv:
893
902
  self.lhv[lq].h()
894
903
 
895
- if len(hq) == 4:
904
+ fresh = self._authority.get(lq) if self.is_boundary_repetition_code else None
905
+ if fresh:
906
+ self._correct_by_authority(lq, hq, fresh, skip_rotation)
907
+ elif len(hq) == 4:
896
908
  # Corner-boundary qubit: 4 real replicas remain (home,
897
909
  # adjacent-patch, and the 2 diagonal-patch shadows) now that
898
910
  # the crossbar replica that used to sit at old-index-2 is
@@ -1592,6 +1604,100 @@ class QrackAceBackend:
1592
1604
 
1593
1605
  return connected, boundary
1594
1606
 
1607
+ def _update_lineage(self, lq1, hq1, lq2, hq2):
1608
+ # Lineage-tracking authority: a replica stays "clean" only while every
1609
+ # coupling it has taken part in was a REAL gate with a clean replica of
1610
+ # the partner. The authority for each participant becomes the clean
1611
+ # replicas that just met a clean partner replica in a shared simulator.
1612
+ # A replica with an unbroken real-gate history holds the qubit's full
1613
+ # coherent state, including entanglement accumulated across several
1614
+ # couplings -- e.g. the shared crossbar simulator, which holds a replica
1615
+ # of every boundary qubit, keeps a seam-to-seam subcircuit fully
1616
+ # coherent across every patch boundary. Only if no clean pair shares a
1617
+ # simulator does it fall back to the plain fresh-copy rule.
1618
+ if (not self.is_boundary_repetition_code) or self._in_gadget_capture or (lq1 is None) or (lq2 is None):
1619
+ return
1620
+ if (len(hq1) < 2) and (len(hq2) < 2):
1621
+ return
1622
+
1623
+ def clean(lq, hq):
1624
+ a = self._authority.get(lq) if len(hq) > 1 else None
1625
+ return set(range(len(hq))) if a is None else set(a)
1626
+
1627
+ c1, c2 = clean(lq1, hq1), clean(lq2, hq2)
1628
+ new1 = {i for i in c1 if any(hq1[i][0] == hq2[j][0] for j in c2)}
1629
+ new2 = {j for j in c2 if any(hq1[i][0] == hq2[j][0] for i in c1)}
1630
+ if not new1:
1631
+ sims2 = {b[0] for b in hq2}
1632
+ new1 = {i for i, b in enumerate(hq1) if b[0] in sims2}
1633
+ sims1 = {b[0] for b in hq1}
1634
+ new2 = {j for j, b in enumerate(hq2) if b[0] in sims1}
1635
+ # When both participants are boundary qubits, their crossbar replicas
1636
+ # (one shared simulator for every boundary qubit in the grid) are the
1637
+ # only copies guaranteed to see the WHOLE seam-to-seam history; copies
1638
+ # in a patch simulator can be left holding a pairwise correlation that
1639
+ # a later coupling elsewhere has made stale. So a clean crossbar pair
1640
+ # becomes the sole authority.
1641
+ cb = self._crossbar_sim
1642
+ if (cb is not None) and (len(hq1) > 1) and (len(hq2) > 1):
1643
+ i_cb = [i for i in new1 if hq1[i][0] == cb]
1644
+ j_cb = [j for j in new2 if hq2[j][0] == cb]
1645
+ if i_cb and j_cb:
1646
+ new1, new2 = set(i_cb), set(j_cb)
1647
+ for lq, hq, new in ((lq1, hq1, new1), (lq2, hq2, new2)):
1648
+ if len(hq) < 2 or not new:
1649
+ continue
1650
+ if len(new) == len(hq):
1651
+ self._authority.pop(lq, None)
1652
+ else:
1653
+ self._authority[lq] = new
1654
+
1655
+ def _set_authority(self, lq, hq, partner_hq):
1656
+ # Record which replica slot(s) of boundary qubit lq just received a
1657
+ # REAL coupling gate (they share a simulator with the partner). See
1658
+ # the constructor for the decoder this feeds. Skipped for the
1659
+ # detection gadget's own internal captures, which must not move it.
1660
+ if (not self.is_boundary_repetition_code) or self._in_gadget_capture or (lq is None) or (len(hq) < 2):
1661
+ return
1662
+ partner_sims = {b[0] for b in partner_hq}
1663
+ fresh = {i for i, b in enumerate(hq) if b[0] in partner_sims}
1664
+ if not fresh:
1665
+ # Shadow-only coupling: no copy is fresher than before.
1666
+ return
1667
+ if len(fresh) == len(hq):
1668
+ # Every copy got the real gate: no copy is privileged.
1669
+ self._authority.pop(lq, None)
1670
+ else:
1671
+ self._authority[lq] = fresh
1672
+
1673
+ def _correct_by_authority(self, lq, hq, fresh, skip_rotation):
1674
+ # Decode boundary qubit lq's replica repetition code with the
1675
+ # fresh copy (or copies) as ground truth. See the constructor.
1676
+ auth = sorted(fresh)
1677
+ p_auth = sum(self.sim[hq[i][0]].prob(hq[i][1]) for i in auth) / len(auth)
1678
+ if abs(p_auth - 0.5) > self._epsilon:
1679
+ result = p_auth >= 0.5
1680
+ for q, b in enumerate(hq):
1681
+ if q in fresh:
1682
+ continue
1683
+ p = self.sim[b[0]].prob(b[1])
1684
+ if (1 - p if result else p) > (0.5 + self._epsilon):
1685
+ self.sim[b[0]].x(b[1])
1686
+ if skip_rotation:
1687
+ return
1688
+ a0, i0, r0 = self._get_bloch_angles(hq[auth[0]])
1689
+ if r0 > self._rot_epsilon:
1690
+ # The fresh copy is itself entangled with its partner: it has no
1691
+ # well-defined direction to copy, and the stale copies cannot
1692
+ # hold that entanglement anyway. prob() reads the fresh copy.
1693
+ return
1694
+ for q, b in enumerate(hq):
1695
+ if q in fresh:
1696
+ continue
1697
+ a, i, r = self._get_bloch_angles(b)
1698
+ if r <= self._rot_epsilon:
1699
+ self._rotate_to_bloch(b, a0 - a, i0 - i)
1700
+
1595
1701
  def _apply_coupling(self, pauli, anti, qb1, hq1, qb2, hq2, lq1_lr, lq1=None, lq2=None):
1596
1702
  shadow_targets = []
1597
1703
 
@@ -1601,6 +1707,7 @@ class QrackAceBackend:
1601
1707
  gate_fn, shadow_fn = self._get_gate(pauli, anti, sim_id)
1602
1708
  _, idx2 = hq2[i]
1603
1709
  gate_fn([idx1], idx2)
1710
+ self._update_lineage(lq1, hq1, lq2, hq2)
1604
1711
  return
1605
1712
 
1606
1713
  # Logical-level error-detection gadget: an earlier version of this
@@ -1629,7 +1736,7 @@ class QrackAceBackend:
1629
1736
  # a lq2-invariant check for that gate family, same reasoning as
1630
1737
  # the single-replica CZ dual-check elsewhere.
1631
1738
  anc = None
1632
- if self.is_error_detection and (not self._in_gadget_capture) and ((len(hq1) > 1) or (len(hq2) > 1)):
1739
+ if (not self.is_boundary_repetition_code) and self.is_error_detection and (not self._in_gadget_capture) and ((len(hq1) > 1) or (len(hq2) > 1)):
1633
1740
  anc_sim = hq1[0][0]
1634
1741
  t_sims = {y[0] for y in hq2 if y[0] >= 0}
1635
1742
  for x in hq1:
@@ -1702,6 +1809,8 @@ class QrackAceBackend:
1702
1809
  shadow_fn(b1, b2)
1703
1810
  shadow_targets.append(b2)
1704
1811
 
1812
+ self._update_lineage(lq1, hq1, lq2, hq2)
1813
+
1705
1814
  if not self._in_gadget_capture:
1706
1815
  if pauli != Pauli.PauliZ:
1707
1816
  self.correct(lq2, False, pauli != Pauli.PauliX)
@@ -1754,55 +1863,18 @@ class QrackAceBackend:
1754
1863
  lq1_lr = len(hq1) == 1
1755
1864
  lq2_lr = len(hq2) == 1
1756
1865
 
1757
- t2 = [lq2]
1758
- anc, anc_sim = None, None
1759
- if self.is_boundary_repetition_code and (not self._in_gadget_capture) and lq1_lr and (not lq2_lr):
1760
- # Encode:
1761
- anc_sim = hq1[0][0]
1762
- t_sims = {y[0] for y in hq2 if y[0] >= 0}
1763
- for x in hq1:
1764
- if x[0] in t_sims:
1765
- anc_sim = x[0]
1766
- break
1767
- anc = self.rep_code_ancilla_lq[anc_sim]
1768
- self._in_gadget_capture = True
1769
- self.cx(lq2, anc)
1770
- self._in_gadget_capture = False
1771
- t2.append(anc)
1772
-
1773
1866
  qb1, _ = QrackAceBackend._get_qb_lhv_indices(hq1)
1774
1867
 
1775
1868
  # Apply cross coupling on every real replica in hq1/h2 (the LHV
1776
1869
  # proxy is coupled separately, just below, via _cpauli_lhv -- it
1777
- # is not one of hq's indices). Also apply across target repetition.
1778
- for l2 in t2:
1779
- h2 = self._unpack(l2)
1780
- qb2, _ = QrackAceBackend._get_qb_lhv_indices(h2)
1781
- self._apply_coupling(pauli, anti, qb1, hq1, qb2, h2, lq1_lr, lq1, l2)
1870
+ # is not one of hq's indices).
1871
+ qb2, _ = QrackAceBackend._get_qb_lhv_indices(hq2)
1872
+ self._apply_coupling(pauli, anti, qb1, hq1, qb2, hq2, lq1_lr, lq1, lq2)
1782
1873
 
1783
1874
  if lq2 in self.lhv:
1784
1875
  ctrl_prob = self.sim[hq1[0][0]].prob(hq1[0][1])
1785
1876
  _cpauli_lhv(ctrl_prob, self.lhv[lq2], pauli, anti)
1786
1877
 
1787
- if anc is not None:
1788
- # Decode:
1789
- self._in_gadget_capture = True
1790
- self.cx(lq2, anc)
1791
- self._in_gadget_capture = False
1792
-
1793
- # After we corrected any mismatch above, it's unlikely
1794
- # that we can't post-select no-error on this ancilla.
1795
-
1796
- anc_sim, anc_idx = self.qubits[anc][0]
1797
- p = self.sim[anc_sim].prob(anc_idx)
1798
- if self._ps_epsilon >= (1.0 - p):
1799
- b = self.m(anc)
1800
- else:
1801
- b = self.force_m(anc, False)
1802
- if b:
1803
- self.x(anc)
1804
- self.x(lq2)
1805
-
1806
1878
  def cx(self, lq1, lq2):
1807
1879
  self._cpauli(lq1, lq2, False, Pauli.PauliX)
1808
1880
 
@@ -2071,6 +2143,13 @@ class QrackAceBackend:
2071
2143
  if lhv1 is not None:
2072
2144
  self.lhv[lq2] = lhv1
2073
2145
 
2146
+ auth1 = self._authority.pop(lq1, None)
2147
+ auth2 = self._authority.pop(lq2, None)
2148
+ if auth2 is not None:
2149
+ self._authority[lq1] = auth2
2150
+ if auth1 is not None:
2151
+ self._authority[lq2] = auth1
2152
+
2074
2153
  # Boundary repetition code needs no bookkeeping here, unlike
2075
2154
  # self.qubits/self.lhv just above: it's on-demand now, not
2076
2155
  # a permanent, per-logical-index dict of pre-allocated
@@ -2161,6 +2240,23 @@ class QrackAceBackend:
2161
2240
  self.cz(lq1, lq2)
2162
2241
  self.swap(lq1, lq2)
2163
2242
 
2243
+ def _ccx_decomp(self, c1, c2, t):
2244
+ self.h(t)
2245
+ self.cx(c2, t)
2246
+ self.adjt(t)
2247
+ self.cx(c1, t)
2248
+ self.t(t)
2249
+ self.cx(c2, t)
2250
+ self.adjt(t)
2251
+ self.cx(c1, t)
2252
+ self.t(t)
2253
+ self.h(t)
2254
+ self.t(c2)
2255
+ self.cx(c1, c2)
2256
+ self.t(c1)
2257
+ self.adjt(c2)
2258
+ self.cx(c1, c2)
2259
+
2164
2260
  def ccx(self, c1, c2, t):
2165
2261
  hq1 = self._unpack(c1)
2166
2262
  hq2 = self._unpack(c2)
@@ -2170,6 +2266,11 @@ class QrackAceBackend:
2170
2266
  self.mcx([c1, c2], t)
2171
2267
  return
2172
2268
 
2269
+ if (len(hq1) > 1) or (len(hq2) > 1):
2270
+ self._ccx_decomp(c1, c2, t)
2271
+
2272
+ return
2273
+
2173
2274
  qb1, _ = QrackAceBackend._get_qb_lhv_indices(hq1)
2174
2275
  qb2, _ = QrackAceBackend._get_qb_lhv_indices(hq2)
2175
2276
  qbt, _ = QrackAceBackend._get_qb_lhv_indices(hqt)
@@ -2194,26 +2295,12 @@ class QrackAceBackend:
2194
2295
  witnesses.append(witness)
2195
2296
 
2196
2297
  if needs_shadow:
2197
- self.h(t)
2198
- self.cx(c2, t)
2199
- self.adjt(t)
2200
- self.cx(c1, t)
2201
- self.t(t)
2202
- self.cx(c2, t)
2203
- self.adjt(t)
2204
- self.cx(c1, t)
2205
- self.t(t)
2206
- self.h(t)
2207
- self.t(c2)
2208
- self.cx(c1, c2)
2209
- self.t(c1)
2210
- self.adjt(c2)
2211
- self.cx(c1, c2)
2298
+ self._ccx_decomp(c1, c2, t)
2212
2299
 
2213
2300
  return
2214
2301
 
2215
2302
  anc_and = None
2216
- if self.is_error_detection and not self._in_gadget_capture and ((len(hqt) > 1) or (len(hq1) > 1) or (len(hq2) > 1)):
2303
+ if (not self.is_boundary_repetition_code) and self.is_error_detection and (not self._in_gadget_capture):
2217
2304
  found = False
2218
2305
  anc_sim = hq1[0][0]
2219
2306
  t_sims = {y[0] for y in hqt if y[0] >= 0}
@@ -2292,6 +2379,12 @@ class QrackAceBackend:
2292
2379
  # re-weighting any particular replica specially here would
2293
2380
  # reintroduce the same center-dragging distortion the cascade in
2294
2381
  # correct() was built to avoid.
2382
+ fresh = self._authority.get(lq) if self.is_boundary_repetition_code else None
2383
+ if fresh:
2384
+ # The fresh copy carries the real marginal (and any real
2385
+ # entanglement); the stale copies were just reconciled to it.
2386
+ return sum(self.sim[hq[i][0]].prob(hq[i][1]) for i in fresh) / len(fresh)
2387
+
2295
2388
  p = [self.sim[b[0]].prob(b[1]) for b in hq]
2296
2389
  n = len(p)
2297
2390
  prms = math.sqrt(sum(x**2 for x in p) / n)
@@ -2325,6 +2418,9 @@ class QrackAceBackend:
2325
2418
  if result:
2326
2419
  lhv.x()
2327
2420
 
2421
+ # Every replica now agrees on a definite value: none is fresher.
2422
+ self._authority.pop(lq, None)
2423
+
2328
2424
  return result
2329
2425
 
2330
2426
  def force_m(self, lq, result):
@@ -2352,6 +2448,9 @@ class QrackAceBackend:
2352
2448
  if result:
2353
2449
  lhv.x()
2354
2450
 
2451
+ # Every replica now agrees on a definite value: none is fresher.
2452
+ self._authority.pop(lq, None)
2453
+
2355
2454
  return result
2356
2455
 
2357
2456
  def m_all(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cpu-complex128
3
- Version: 2.29.3
3
+ Version: 2.29.5
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 = "2.29.3"
10
+ VERSION = "2.29.5"
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')