PyQrackIsing 1.14.7__tar.gz → 1.14.8__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 (21) hide show
  1. {pyqrackising-1.14.7/PyQrackIsing.egg-info → pyqrackising-1.14.8}/PKG-INFO +1 -1
  2. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/maxcut_tfim.py +13 -17
  3. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/tsp_symmetric.py +1 -1
  4. {pyqrackising-1.14.7 → pyqrackising-1.14.8/PyQrackIsing.egg-info}/PKG-INFO +1 -1
  5. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/README.md +2 -2
  6. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/pyproject.toml +1 -1
  7. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/setup.py +1 -1
  8. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/CMakeLists.txt +0 -0
  9. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/LICENSE.md +0 -0
  10. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/MANIFEST.in +0 -0
  11. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/__init__.py +0 -0
  12. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
  13. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/generate_tfim_samples.py +0 -0
  14. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/spin_glass_solver.py +0 -0
  15. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/tfim_magnetization.py +0 -0
  16. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing/tfim_square_magnetization.py +0 -0
  17. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
  18. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
  19. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing.egg-info/not-zip-safe +0 -0
  20. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/PyQrackIsing.egg-info/top_level.txt +0 -0
  21. {pyqrackising-1.14.7 → pyqrackising-1.14.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.14.7
3
+ Version: 1.14.8
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -145,7 +145,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
145
145
 
146
146
 
147
147
  # Written by Elara (OpenAI custom GPT)
148
- @njit
148
+ @njit(parallel=True)
149
149
  def local_repulsion_choice(adjacency, degrees, weights, n, m):
150
150
  """
151
151
  Pick m nodes out of n with repulsion bias:
@@ -162,7 +162,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
162
162
  mask = np.zeros(n, dtype=np.bool_)
163
163
  chosen_count = 0
164
164
 
165
- for _ in range(m):
165
+ for _ in prange(m):
166
166
  # Count available
167
167
  total_w = 0.0
168
168
  for i in range(n):
@@ -201,11 +201,10 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
201
201
  return mask
202
202
 
203
203
 
204
- @njit(parallel=True)
205
204
  def local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n):
206
- samples = np.zeros((shots, n), dtype=np.bool_) # (shots × n) boolean mask array
205
+ samples = []
207
206
 
208
- for s in prange(shots):
207
+ for s in range(shots):
209
208
  # First dimension: Hamming weight
210
209
  mag_prob = np.random.random()
211
210
  m = 0
@@ -214,22 +213,19 @@ def local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights
214
213
  m += 1
215
214
 
216
215
  # Second dimension: permutation within Hamming weight
217
- samples[s, :] = local_repulsion_choice(adjacency, degrees, weights, n, m)
216
+ samples.append(mask_array_to_python_int(local_repulsion_choice(adjacency, degrees, weights, n, m)))
218
217
 
219
218
  return samples
220
219
 
221
220
 
222
- def mask_array_to_python_ints(masks):
223
- samples = []
224
- for mask in masks:
225
- sample = 0
226
- for b in reversed(mask):
227
- sample <<= 1
228
- if b:
229
- sample |= 1
230
- samples.append(sample)
221
+ def mask_array_to_python_int(mask):
222
+ sample = 0
223
+ for b in reversed(mask):
224
+ sample <<= 1
225
+ if b:
226
+ sample |= 1
231
227
 
232
- return samples
228
+ return sample
233
229
 
234
230
  def evaluate_cut_edges(samples, edge_keys, edge_values):
235
231
  best_value = float("-inf")
@@ -360,7 +356,7 @@ def maxcut_tfim(
360
356
  J_max = max(J_eff)
361
357
  weights = 1.0 / (1.0 + (J_max - J_eff))
362
358
  # We only need unique instances
363
- samples = list(set(mask_array_to_python_ints(local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n_qubits))))
359
+ samples = list(set(local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n_qubits)))
364
360
 
365
361
  edge_keys = []
366
362
  edge_values = []
@@ -21,7 +21,7 @@ def get_best_stitch(adjacency, terminals_a, terminals_b, is_cyclic):
21
21
  return best_weight, best_edge
22
22
 
23
23
 
24
- def tsp_symmetric(G, quality=None, shots=None, correction_quality=None, is_cyclic=True, start_node=None):
24
+ def tsp_symmetric(G, quality=0, shots=None, correction_quality=2, is_cyclic=True, start_node=None):
25
25
  nodes = list(G.nodes())
26
26
  n_nodes = len(nodes)
27
27
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.14.7
3
+ Version: 1.14.8
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -93,13 +93,13 @@ def generate_tsp_graph(n_nodes=64, seed=None):
93
93
 
94
94
  n_nodes = 128
95
95
  G = generate_tsp_graph(n_nodes=n_nodes, seed=42)
96
- circuit, path_length = tsp_symmetric(G, quality=1, is_cyclic=True, start_node=None)
96
+ circuit, path_length = tsp_symmetric(G, quality=0, correction_quality=2, is_cyclic=True, start_node=None)
97
97
 
98
98
  print(f"Node count: {n_nodes}")
99
99
  print(f"Path: {circuit}")
100
100
  print(f"Path length: {path_length}")
101
101
  ```
102
- The (integer) `quality` setting is optional, with a default value of `1`. We only provide a solver for the symmetric version of the TSP (i.e., the distance from "A" to "B" is considered the same as from "B" to "A"). `is_cyclic` controls whether the path must ultimately complete a circuit, if `True`, or a one-way trip, if `False`. When the desired route is acyclic, a fixed starting point can optionally be specified via passing the node label to `start_node` (or, without this parameter, the solver will also attempt to pick an optimal starting point).
102
+ We only provide a solver for the symmetric version of the TSP (i.e., the distance from "A" to "B" is considered the same as from "B" to "A"). `is_cyclic` controls whether the path must ultimately complete a circuit, if `True`, or a one-way trip, if `False`. When the desired route is acyclic, a fixed starting point can optionally be specified via passing the node label to `start_node` (or, without this parameter, the solver will also attempt to pick an optimal starting point).
103
103
 
104
104
  ## About
105
105
  Transverse field Ising model (TFIM) is the basis of most claimed algorithmic "quantum advantage," circa 2025, with the notable exception of Shor's integer factoring algorithm.
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "PyQrackIsing"
15
- version = "1.14.7"
15
+ version = "1.14.8"
16
16
  requires-python = ">=3.8"
17
17
  description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
18
18
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='PyQrackIsing',
54
- version='1.14.7',
54
+ version='1.14.8',
55
55
  author='Dan Strano',
56
56
  author_email='stranoj@gmail.com',
57
57
  description='Near-ideal closed-form solutions for transverse field Ising model (TFIM)',
File without changes
File without changes
File without changes