pyqrack-cuda-complex128 2.30.2__tar.gz → 2.30.3__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 (32) hide show
  1. {pyqrack_cuda_complex128-2.30.2/pyqrack_cuda_complex128.egg-info → pyqrack_cuda_complex128-2.30.3}/PKG-INFO +1 -1
  2. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_bridge.py +29 -0
  3. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3/pyqrack_cuda_complex128.egg-info}/PKG-INFO +1 -1
  4. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/setup.py +1 -1
  5. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/LICENSE +0 -0
  6. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/MANIFEST.in +0 -0
  7. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/Makefile +0 -0
  8. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/README.md +0 -0
  9. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyproject.toml +0 -0
  10. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/__init__.py +0 -0
  11. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/neuron_activation_fn.py +0 -0
  12. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/pauli.py +0 -0
  13. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_ace_backend.py +0 -0
  14. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_ace_mps_backend.py +0 -0
  15. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_circuit.py +0 -0
  16. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_near_clifford_qec_backend.py +0 -0
  17. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_neuron.py +0 -0
  18. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_neuron_torch_layer.py +0 -0
  19. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_simulator.py +0 -0
  20. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_stabilizer.py +0 -0
  21. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_system/__init__.py +0 -0
  22. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/qrack_system/qrack_system.py +0 -0
  23. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/quimb_circuit_type.py +0 -0
  24. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/stats/__init__.py +0 -0
  25. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/stats/load_quantized_data.py +0 -0
  26. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack/stats/quantize_by_range.py +0 -0
  27. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack_cuda_complex128.egg-info/SOURCES.txt +0 -0
  28. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack_cuda_complex128.egg-info/dependency_links.txt +0 -0
  29. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack_cuda_complex128.egg-info/not-zip-safe +0 -0
  30. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack_cuda_complex128.egg-info/requires.txt +0 -0
  31. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/pyqrack_cuda_complex128.egg-info/top_level.txt +0 -0
  32. {pyqrack_cuda_complex128-2.30.2 → pyqrack_cuda_complex128-2.30.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda-complex128
3
- Version: 2.30.2
3
+ Version: 2.30.3
4
4
  Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
5
5
  Home-page: https://github.com/vm6502q/pyqrack
6
6
  Author: Daniel Strano
@@ -66,6 +66,7 @@
66
66
  #
67
67
  # fidelity_estimate multiplies the kept Schmidt weight (greedy) or sum_g p_g^2 (born) per truncation.
68
68
 
69
+ import contextlib
69
70
  import ctypes
70
71
  import math
71
72
 
@@ -139,6 +140,7 @@ class QrackBridge:
139
140
  self.bond = list(src.bond)
140
141
  self.sim = [s.clone() for s in src.sim]
141
142
  self._touched = set(src._touched)
143
+ self._deferring = 0
142
144
  self.rng = np.random.default_rng(int(src.rng.integers(1 << 62)))
143
145
  return
144
146
  if truncation not in ("greedy", "born"):
@@ -163,6 +165,7 @@ class QrackBridge:
163
165
  self.lazy_bonds = lazy_bonds
164
166
  self.max_patch_qubits = max_patch_qubits
165
167
  self.flushes = 0
168
+ self._deferring = 0
166
169
  self.truncation = truncation
167
170
  self.fidelity_estimate = 1.0
168
171
  self.truncations = 0
@@ -445,6 +448,11 @@ class QrackBridge:
445
448
  return False
446
449
 
447
450
  def _maybe_compress(self):
451
+ if self._deferring:
452
+ # Inside deferred(): keep only the exact rank (drop zero singular values); never truncate.
453
+ if not self.lazy_bonds or self._over_budget():
454
+ self._compress(exact_only=True)
455
+ return
448
456
  if not self.lazy_bonds:
449
457
  self._compress() # eager: one sweep per bridged gate
450
458
  return
@@ -453,6 +461,27 @@ class QrackBridge:
453
461
  if self._over_budget():
454
462
  self._compress()
455
463
 
464
+ @contextlib.contextmanager
465
+ def deferred(self):
466
+ """Truncate once, after the whole block, never inside it:
467
+
468
+ with sim.deferred():
469
+ for i in range(9):
470
+ sim.mcx([b[i]], a[i]) # e.g. a transversal logical CNOT
471
+
472
+ Inside, bridged gates are recompressed only exactly, so bonds carry the full transient
473
+ entanglement of the block; on exit one sweep truncates to max_bonds. Use it around any
474
+ multi-gate operation whose intermediate states are more entangled than its result
475
+ (transversal logical gates, decode/encode, gate decompositions). Heap grows with the
476
+ transient rank inside the block. Nests; only the outermost exit truncates."""
477
+ self._deferring += 1
478
+ try:
479
+ yield self
480
+ finally:
481
+ self._deferring -= 1
482
+ if not self._deferring:
483
+ self._maybe_compress()
484
+
456
485
  def flush(self):
457
486
  """Truncate any buffered bonds back to max_bonds now (readout does this automatically)."""
458
487
  self._compress()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrack-cuda-complex128
3
- Version: 2.30.2
3
+ Version: 2.30.3
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.30.2"
10
+ VERSION = "2.30.3"
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')