PyQrackIsing 1.18.3__tar.gz → 1.18.4__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.18.3/PyQrackIsing.egg-info → pyqrackising-1.18.4}/PKG-INFO +1 -1
  2. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/maxcut_tfim.py +14 -10
  3. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/spin_glass_solver.py +2 -2
  4. {pyqrackising-1.18.3 → pyqrackising-1.18.4/PyQrackIsing.egg-info}/PKG-INFO +1 -1
  5. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/README.md +1 -1
  6. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/pyproject.toml +1 -1
  7. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/setup.py +1 -1
  8. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/CMakeLists.txt +0 -0
  9. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/LICENSE.md +0 -0
  10. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/MANIFEST.in +0 -0
  11. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/__init__.py +0 -0
  12. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
  13. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/generate_tfim_samples.py +0 -0
  14. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/tfim_magnetization.py +0 -0
  15. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/tfim_square_magnetization.py +0 -0
  16. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing/tsp_symmetric.py +0 -0
  17. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
  18. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
  19. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing.egg-info/not-zip-safe +0 -0
  20. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/PyQrackIsing.egg-info/top_level.txt +0 -0
  21. {pyqrackising-1.18.3 → pyqrackising-1.18.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.18.3
3
+ Version: 1.18.4
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
@@ -59,7 +59,7 @@ except:
59
59
 
60
60
  @njit
61
61
  def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
62
- bias = np.zeros(n_qubits - 1, dtype=np.float64)
62
+ bias = np.empty(n_qubits - 1, dtype=np.float64)
63
63
 
64
64
  # critical angle
65
65
  theta_c = np.arcsin(
@@ -106,7 +106,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
106
106
  h_mult = 32.0 / tot_t
107
107
  n_bias = n_qubits - 1
108
108
 
109
- theta = np.zeros(n_qubits)
109
+ theta = np.empty(n_qubits, dtype=np.float64)
110
110
  for q in prange(n_qubits):
111
111
  J = J_func[q]
112
112
  z = degrees[q]
@@ -136,7 +136,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
136
136
  for i in range(n_bias):
137
137
  hamming_prob[i] += bias[i] - last_bias[i]
138
138
 
139
- tot_prob = sum(hamming_prob)
139
+ tot_prob = hamming_prob.sum()
140
140
  hamming_prob /= tot_prob
141
141
 
142
142
  tot_prob = 0.0
@@ -207,7 +207,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
207
207
 
208
208
  @njit(parallel=True)
209
209
  def local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n):
210
- samples = np.zeros((shots, n), dtype=np.bool_) # (shots × n) boolean mask array
210
+ samples = np.empty((shots, n), dtype=np.bool_) # (shots × n) boolean mask array
211
211
 
212
212
  for s in prange(shots):
213
213
  # First dimension: Hamming weight
@@ -259,7 +259,7 @@ def evaluate_cut_edges(G_m, samples):
259
259
  @njit
260
260
  def init_thresholds(n_qubits):
261
261
  n_bias = n_qubits - 1
262
- thresholds = np.zeros(n_bias, dtype=np.float64)
262
+ thresholds = np.empty(n_bias, dtype=np.float64)
263
263
  tot_prob = 0
264
264
  p = 1.0
265
265
  if n_qubits & 1:
@@ -279,7 +279,7 @@ def init_thresholds(n_qubits):
279
279
 
280
280
  @njit
281
281
  def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
282
- theta = np.zeros(n_qubits)
282
+ theta = np.empty(n_qubits, dtype=np.float64)
283
283
  for q in range(n_qubits):
284
284
  J = J_eff[q]
285
285
  z = degrees[q]
@@ -360,8 +360,12 @@ def maxcut_tfim(
360
360
  grid_size = n_steps * n_qubits
361
361
  grid_dims = (n_steps, n_qubits)
362
362
 
363
- degrees = np.array([sum(G_m[n] != 0.0) for n in range(n_qubits)], dtype=np.uint32)
364
- J_eff = np.array([-sum(G_m[n]) / degrees[n] if degrees[n] else 0.0 for n in range(n_qubits)], dtype=np.float64)
363
+ degrees = np.empty(n_qubits, dtype=np.uint32)
364
+ J_eff = np.empty(n_qubits, dtype=np.float64)
365
+ for n in range(n_qubits):
366
+ degree = sum(G_m[n] != 0.0)
367
+ degrees[n] = degree
368
+ J_eff[n] = -G_m[n].sum() / degree
365
369
 
366
370
  thresholds = init_thresholds(n_qubits)
367
371
 
@@ -373,7 +377,7 @@ def maxcut_tfim(
373
377
 
374
378
  cuda_maxcut_hamming_cdf[grid_dims, group_size](delta_t, tot_t, h_mult, J_eff, degrees, theta, thresholds)
375
379
 
376
- tot_prob = sum(thresholds)
380
+ tot_prob = thresholds.sum()
377
381
  thresholds /= tot_prob
378
382
 
379
383
  tot_prob = 0.0
@@ -385,7 +389,7 @@ def maxcut_tfim(
385
389
  maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, thresholds)
386
390
 
387
391
  adjacency = compute_adjacency(G_m)
388
- J_max = max(J_eff)
392
+ J_max = J_eff.max()
389
393
  weights = 1.0 / (1.0 + (J_max - J_eff))
390
394
  # We only need unique instances
391
395
  samples = list(set(mask_array_to_python_ints(local_repulsion_choice_sample(shots, thresholds, adjacency, degrees, weights, n_qubits))))
@@ -43,7 +43,7 @@ def bootstrap_worker(theta, G_m, indices):
43
43
  @njit(parallel=True)
44
44
  def bootstrap(theta, G_m, k, indices_array):
45
45
  n = len(indices_array) // k
46
- energies = np.empty(n)
46
+ energies = np.empty(n, dtype=np.float64)
47
47
  for i in prange(n):
48
48
  j = i * k
49
49
  energies[i] = bootstrap_worker(theta, G_m, indices_array[j : j + k])
@@ -113,7 +113,7 @@ def spin_glass_solver(G, quality=None, shots=None, correction_quality=None, best
113
113
  )
114
114
  energies = bootstrap(theta, G_m, k, combos)
115
115
 
116
- energy = min(energies)
116
+ energy = energies.min()
117
117
  if energy < min_energy:
118
118
  index_match = np.random.choice(np.where(energies == energy)[0])
119
119
  indices = combos[(index_match * k) : ((index_match + 1) * k)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.18.3
3
+ Version: 1.18.4
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
@@ -49,7 +49,7 @@ G = nx.petersen_graph()
49
49
  best_solution_bit_string, best_cut_value, best_node_groups = maxcut_tfim(G, quality=8)
50
50
  ```
51
51
 
52
- The (integer) `quality` setting is optional, with a default value of `7`, but you can turn it up for higher-quality results, or turn it down to save time. (You can also optionally specify the number of measurement `shots` as an argument, if you want specific fine-grained control over resource usage.) If you want to run MAXCUT on a graph with non-uniform edge weights, specify them as the `weight` attribute of each edge, with `networkx`. (If any `weight` attribute is not defined, the solver assumes it's `1.0` for that edge.)
52
+ The (integer) `quality` setting is optional, with a default value of `8`, but you can turn it up for higher-quality results, or turn it down to save time. (You can also optionally specify the number of measurement `shots` as an argument, if you want specific fine-grained control over resource usage.) If you want to run MAXCUT on a graph with non-uniform edge weights, specify them as the `weight` attribute of each edge, with `networkx`. (If any `weight` attribute is not defined, the solver assumes it's `1.0` for that edge.)
53
53
 
54
54
  Based on a combination of the TFIM-inspired MAXCUT solver and another technique for finding ground-state energy in quantum chemistry that we call the _"binary Clifford eigensolver,"_ we also provide an (approximate) spin glass ground-state solver:
55
55
  ```py
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "PyQrackIsing"
15
- version = "1.18.3"
15
+ version = "1.18.4"
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.18.3',
54
+ version='1.18.4',
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