PyQrackIsing 8.10.4__tar.gz → 8.11.0__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 (28) hide show
  1. {pyqrackising-8.10.4/pyqrackising.egg-info → pyqrackising-8.11.0}/PKG-INFO +1 -1
  2. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyproject.toml +1 -1
  3. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/maxcut_tfim.py +9 -2
  4. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/maxcut_tfim_sparse.py +32 -34
  5. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/maxcut_tfim_streaming.py +22 -6
  6. {pyqrackising-8.10.4 → pyqrackising-8.11.0/pyqrackising.egg-info}/PKG-INFO +1 -1
  7. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/setup.py +1 -1
  8. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/LICENSE.md +0 -0
  9. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/MANIFEST.in +0 -0
  10. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/README.md +0 -0
  11. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/__init__.py +0 -0
  12. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  13. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/generate_tfim_samples.py +0 -0
  14. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/kernels.cl +0 -0
  15. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/maxcut_tfim_util.py +0 -0
  16. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/spin_glass_solver.py +0 -0
  17. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  18. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  19. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/spin_glass_solver_util.py +0 -0
  20. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/tfim_magnetization.py +0 -0
  21. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/tfim_square_magnetization.py +0 -0
  22. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/tsp.py +0 -0
  23. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising/tsp_maxcut.py +0 -0
  24. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
  25. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
  26. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising.egg-info/not-zip-safe +0 -0
  27. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/pyqrackising.egg-info/top_level.txt +0 -0
  28. {pyqrackising-8.10.4 → pyqrackising-8.11.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.10.4
3
+ Version: 8.11.0
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
10
10
 
11
11
  [project]
12
12
  name = "pyqrackising"
13
- version = "8.10.4"
13
+ version = "8.11.0"
14
14
  requires-python = ">=3.8"
15
15
  description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
16
16
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -121,6 +121,7 @@ def sample_measurement(G_m, max_edge, shots, thresholds, weights, repulsion_base
121
121
 
122
122
  @njit(parallel=True)
123
123
  def init_J_and_z(G_m):
124
+ G_min = G_m.min()
124
125
  n_qubits = len(G_m)
125
126
  degrees = np.empty(n_qubits, dtype=np.uint32)
126
127
  J_eff = np.empty(n_qubits, dtype=np.float64)
@@ -130,16 +131,22 @@ def init_J_and_z(G_m):
130
131
  J = 0.0
131
132
  for m in range(n_qubits):
132
133
  val = G_m[n, m]
134
+ if val > G_max:
135
+ G_max = val
136
+ val -= G_min
133
137
  if val != 0.0:
134
138
  degree += 1
135
139
  J += val
136
140
  val = abs(val)
137
- if val > G_max:
138
- G_max = val
139
141
  J = -J / degree if degree > 0 else 0
140
142
  degrees[n] = degree
141
143
  J_eff[n] = J
142
144
 
145
+ G_min = abs(G_min)
146
+ G_max = abs(G_max)
147
+ if G_min > G_max:
148
+ G_max = G_min
149
+
143
150
  return J_eff, degrees, G_max
144
151
 
145
152
 
@@ -130,43 +130,44 @@ def sample_measurement(max_edge, G_data, G_rows, G_cols, shots, thresholds, weig
130
130
  return best_solution, best_energy
131
131
 
132
132
 
133
- @njit(parallel=True)
134
- def init_J_and_z(G_data, G_rows, G_cols):
135
- n_qubits = G_rows.shape[0] - 1
136
- degrees = np.zeros(n_qubits, dtype=np.uint32)
137
- J_eff = np.zeros(n_qubits, dtype=np.float64)
138
- for r in prange(n_qubits):
139
- # Row sum
140
- start = G_rows[r]
141
- end = G_rows[r + 1]
142
- degree = end - start
143
- val = G_data[start:end].sum()
144
-
145
- degrees[r] += degree
146
- J_eff[r] += val
147
-
148
- # Column sum
149
- for idx in range(start, end):
150
- c = G_cols[idx]
151
- degrees[c] += 1
152
- J_eff[c] += G_data[idx]
153
-
154
- for r in prange(n_qubits):
155
- degree = degrees[r]
156
- J_eff[r] = -J_eff[r] / degree if degree > 0 else 0
157
-
158
- return J_eff, degrees
133
+ def init_J_and_z(G_m):
134
+ G_min = G_m.min()
135
+ n_qubits = G_m.shape[0]
136
+ degrees = np.empty(n_qubits, dtype=np.uint32)
137
+ J_eff = np.empty(n_qubits, dtype=np.float64)
138
+ G_max = -float("inf")
139
+ for n in prange(n_qubits):
140
+ degree = 0
141
+ J = 0.0
142
+ for m in range(n_qubits):
143
+ val = G_m[n, m]
144
+ if val > G_max:
145
+ G_max = val
146
+ val -= G_min
147
+ if val != 0.0:
148
+ degree += 1
149
+ J += val
150
+ val = abs(val)
151
+ J = -J / degree if degree > 0 else 0
152
+ degrees[n] = degree
153
+ J_eff[n] = J
154
+
155
+ G_min = abs(G_min)
156
+ G_max = abs(G_max)
157
+ if G_min > G_max:
158
+ G_max = G_min
159
+
160
+ return J_eff, degrees, G_max
159
161
 
160
162
 
161
163
  @njit
162
- def cpu_footer(shots, quality, n_qubits, max_edge, G_data, G_rows, G_col, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base):
163
- J_eff, degrees = init_J_and_z(G_data, G_rows, G_col)
164
+ def cpu_footer(J_eff, degrees, shots, quality, n_qubits, G_max, G_data, G_rows, G_col, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base):
164
165
  hamming_prob = maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, anneal_t, anneal_h)
165
166
 
166
167
  degrees = None
167
168
  J_eff = 1.0 / (1.0 + epsilon - J_eff)
168
169
 
169
- best_solution, best_value = sample_measurement(max_edge, G_data, G_rows, G_col, shots, hamming_prob, J_eff, repulsion_base, is_spin_glass)
170
+ best_solution, best_value = sample_measurement(G_max, G_data, G_rows, G_col, shots, hamming_prob, J_eff, repulsion_base, is_spin_glass)
170
171
 
171
172
  bit_string, l, r = get_cut(best_solution, nodes)
172
173
 
@@ -225,12 +226,9 @@ def maxcut_tfim_sparse(
225
226
  if repulsion_base is None:
226
227
  repulsion_base = 8.0
227
228
 
228
- max_edge = abs(G_m.max())
229
- min_edge = abs(G_m.min())
230
- if min_edge > max_edge:
231
- max_edge = min_edge
229
+ J_eff, degrees, G_max = init_J_and_z(G_m)
232
230
 
233
- bit_string, best_value, partition = cpu_footer(shots, quality, n_qubits, max_edge, G_m.data, G_m.indptr, G_m.indices, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base)
231
+ bit_string, best_value, partition = cpu_footer(J_eff, degrees, shots, quality, n_qubits, G_max, G_m.data, G_m.indptr, G_m.indices, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base)
234
232
 
235
233
  if best_value < 0.0:
236
234
  # Best cut is trivial partition, all/empty
@@ -119,7 +119,7 @@ def sample_measurement(G_func, nodes, max_edge, shots, thresholds, degrees_sum,
119
119
 
120
120
 
121
121
  @njit(parallel=True)
122
- def init_J_and_z(G_func, nodes):
122
+ def init_J_and_z(G_func, nodes, G_min):
123
123
  n_qubits = len(nodes)
124
124
  degrees = np.empty(n_qubits, dtype=np.uint32)
125
125
  J_eff = np.empty(n_qubits, dtype=np.float64)
@@ -129,22 +129,36 @@ def init_J_and_z(G_func, nodes):
129
129
  J = 0.0
130
130
  for m in range(n_qubits):
131
131
  val = G_func(nodes[n], nodes[m])
132
+ if val > G_max:
133
+ G_max = val
134
+ val -= G_min
132
135
  if val != 0.0:
133
136
  degree += 1
134
137
  J += val
135
138
  val = abs(val)
136
- if val > G_max:
137
- G_max = val
138
139
  J = -J / degree if degree > 0 else 0
139
140
  degrees[n] = degree
140
141
  J_eff[n] = J
141
142
 
142
143
  return J_eff, degrees, G_max
143
144
 
145
+ @njit
146
+ def find_G_min(G_func, nodes, n_nodes):
147
+ G_min = float("inf")
148
+ for i in range(n_nodes):
149
+ u = nodes[i]
150
+ for j in range(i + 1, n_nodes):
151
+ v = nodes[j]
152
+ val = G_func(u, v)
153
+ if val < G_min:
154
+ G_min = val
155
+
156
+ return G_min
157
+
144
158
 
145
159
  @njit
146
- def cpu_footer(shots, quality, n_qubits, G_func, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base):
147
- J_eff, degrees, max_edge = init_J_and_z(G_func, nodes)
160
+ def cpu_footer(shots, quality, n_qubits, G_min, G_func, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base):
161
+ J_eff, degrees, max_edge = init_J_and_z(G_func, nodes, G_min)
148
162
  hamming_prob = maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, anneal_t, anneal_h)
149
163
  degrees_sum = degrees.sum()
150
164
 
@@ -201,7 +215,9 @@ def maxcut_tfim_streaming(
201
215
  if repulsion_base is None:
202
216
  repulsion_base = 8.0
203
217
 
204
- bit_string, best_value, partition = cpu_footer(shots, quality, n_qubits, G_func, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base)
218
+ G_min = find_G_min(G_func, nodes, n_qubits)
219
+
220
+ bit_string, best_value, partition = cpu_footer(shots, quality, n_qubits, G_min, G_func, nodes, is_spin_glass, anneal_t, anneal_h, repulsion_base)
205
221
 
206
222
  if best_value < 0.0:
207
223
  # Best cut is trivial partition, all/empty
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.10.4
3
+ Version: 8.11.0
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
7
7
 
8
8
  setup(
9
9
  name='pyqrackising',
10
- version='8.10.4',
10
+ version='8.11.0',
11
11
  author='Dan Strano',
12
12
  author_email='stranoj@gmail.com',
13
13
  description='Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)',
File without changes
File without changes
File without changes
File without changes