PyQrackIsing 5.1.1__tar.gz → 5.1.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 (27) hide show
  1. {pyqrackising-5.1.1/pyqrackising.egg-info → pyqrackising-5.1.3}/PKG-INFO +1 -1
  2. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyproject.toml +1 -1
  3. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/maxcut_tfim.py +11 -12
  4. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/maxcut_tfim_sparse.py +15 -15
  5. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/maxcut_tfim_streaming.py +12 -14
  6. {pyqrackising-5.1.1 → pyqrackising-5.1.3/pyqrackising.egg-info}/PKG-INFO +1 -1
  7. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/setup.py +1 -1
  8. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/CMakeLists.txt +0 -0
  9. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/LICENSE.md +0 -0
  10. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/MANIFEST.in +0 -0
  11. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/README.md +0 -0
  12. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/__init__.py +0 -0
  13. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/_pyqrack_ising.cpp +0 -0
  14. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/generate_tfim_samples.py +0 -0
  15. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/kernels.cl +0 -0
  16. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/maxcut_tfim_util.py +0 -0
  17. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/spin_glass_solver.py +0 -0
  18. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  19. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  20. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/tfim_magnetization.py +0 -0
  21. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/tfim_square_magnetization.py +0 -0
  22. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising/tsp.py +0 -0
  23. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
  24. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
  25. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising.egg-info/not-zip-safe +0 -0
  26. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/pyqrackising.egg-info/top_level.txt +0 -0
  27. {pyqrackising-5.1.1 → pyqrackising-5.1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 5.1.1
3
+ Version: 5.1.3
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
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "pyqrackising"
15
- version = "5.1.1"
15
+ version = "5.1.3"
16
16
  requires-python = ">=3.8"
17
17
  description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
18
18
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -15,7 +15,7 @@ except ImportError:
15
15
 
16
16
  @njit
17
17
  def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
18
- bias = np.empty(n_qubits - 1, dtype=np.float64)
18
+ bias = np.empty(n_qubits - 1, dtype=np.float32)
19
19
 
20
20
  # critical angle
21
21
  theta_c = np.arcsin(max(-1.0, min(1.0, abs(h) / (z * J))))
@@ -56,7 +56,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
56
56
  h_mult = 2.0 / tot_t
57
57
  n_bias = n_qubits - 1
58
58
 
59
- theta = np.empty(n_qubits, dtype=np.float64)
59
+ theta = np.empty(n_qubits, dtype=np.float32)
60
60
  for q in range(n_qubits):
61
61
  J = J_func[q]
62
62
  z = degrees[q]
@@ -166,7 +166,7 @@ def sample_for_solution(G_m, shots, thresholds, degrees_sum, J_eff, n):
166
166
  weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
167
167
 
168
168
  solutions = np.empty((shots, n), dtype=np.bool_)
169
- energies = np.empty(shots, dtype=np.float64)
169
+ energies = np.empty(shots, dtype=np.float32)
170
170
 
171
171
  for s in prange(shots):
172
172
  # First dimension: Hamming weight
@@ -193,20 +193,19 @@ def sample_for_solution(G_m, shots, thresholds, degrees_sum, J_eff, n):
193
193
  return best_solution, best_value
194
194
 
195
195
 
196
- @njit
196
+ @njit(parallel=True)
197
197
  def init_J_and_z(G_m):
198
198
  n_qubits = len(G_m)
199
199
  degrees = np.empty(n_qubits, dtype=np.uint32)
200
- J_eff = np.empty(n_qubits, dtype=np.float64)
200
+ J_eff = np.empty(n_qubits, dtype=np.float32)
201
201
  J_max = -float("inf")
202
- for n in range(n_qubits):
202
+ for n in prange(n_qubits):
203
203
  degree = sum(G_m[n] != 0.0)
204
204
  J = -G_m[n].sum() / degree if degree > 0 else 0
205
205
  degrees[n] = degree
206
206
  J_eff[n] = J
207
207
  J_abs = abs(J)
208
- if J_abs > J_max:
209
- J_max = J_abs
208
+ J_max = max(J_abs, J_max)
210
209
  J_eff /= J_max
211
210
 
212
211
  return J_eff, degrees
@@ -215,7 +214,7 @@ def init_J_and_z(G_m):
215
214
  @njit
216
215
  def init_thresholds(n_qubits):
217
216
  n_bias = n_qubits - 1
218
- thresholds = np.empty(n_bias, dtype=np.float64)
217
+ thresholds = np.empty(n_bias, dtype=np.float32)
219
218
  tot_prob = 0
220
219
  p = 1.0
221
220
  if n_qubits & 1:
@@ -233,10 +232,10 @@ def init_thresholds(n_qubits):
233
232
  return thresholds
234
233
 
235
234
 
236
- @njit
235
+ @njit(parallel=True)
237
236
  def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
238
- theta = np.empty(n_qubits, dtype=np.float64)
239
- for q in range(n_qubits):
237
+ theta = np.empty(n_qubits, dtype=np.float32)
238
+ for q in prange(n_qubits):
240
239
  J = J_eff[q]
241
240
  z = degrees[q]
242
241
  theta[q] = np.arcsin(
@@ -15,7 +15,7 @@ except ImportError:
15
15
 
16
16
  @njit
17
17
  def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
18
- bias = np.empty(n_qubits - 1, dtype=np.float64)
18
+ bias = np.empty(n_qubits - 1, dtype=np.float32)
19
19
 
20
20
  # critical angle
21
21
  theta_c = np.arcsin(max(-1.0, min(1.0, abs(h) / (z * J))))
@@ -56,7 +56,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
56
56
  h_mult = 2.0 / tot_t
57
57
  n_bias = n_qubits - 1
58
58
 
59
- theta = np.empty(n_qubits, dtype=np.float64)
59
+ theta = np.empty(n_qubits, dtype=np.float32)
60
60
  for q in range(n_qubits):
61
61
  J = J_func[q]
62
62
  z = degrees[q]
@@ -198,7 +198,7 @@ def sample_for_solution(G_data, G_rows, G_cols, shots, thresholds, J_eff):
198
198
  weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
199
199
 
200
200
  solutions = np.empty((shots, n), dtype=np.bool_)
201
- energies = np.empty(shots, dtype=np.float64)
201
+ energies = np.empty(shots, dtype=np.float32)
202
202
 
203
203
  for s in prange(shots):
204
204
  # First dimension: Hamming weight
@@ -225,13 +225,12 @@ def sample_for_solution(G_data, G_rows, G_cols, shots, thresholds, J_eff):
225
225
  return best_solution, best_value
226
226
 
227
227
 
228
- @njit
228
+ @njit(parallel=True)
229
229
  def init_J_and_z(G_data, G_rows, G_cols):
230
230
  n_qubits = G_rows.shape[0] - 1
231
231
  degrees = np.empty(n_qubits, dtype=np.uint32)
232
- J_eff = np.empty(n_qubits, dtype=np.float64)
233
- J_max = -float("inf")
234
- for r in range(n_qubits):
232
+ J_eff = np.empty(n_qubits, dtype=np.float32)
233
+ for r in prange(n_qubits):
235
234
  # Row sum
236
235
  start = G_rows[r]
237
236
  end = G_rows[r + 1]
@@ -248,21 +247,22 @@ def init_J_and_z(G_data, G_rows, G_cols):
248
247
  degrees[c] += 1
249
248
  J_eff[c] += G_data[idx]
250
249
 
251
- for r in range(n_qubits):
250
+ J_max = -float("inf")
251
+ for r in prange(n_qubits):
252
252
  J = J_eff[r]
253
253
  degree = degrees[r]
254
254
  J_eff[r] = -J / degree if degree > 0 else 0
255
255
  J_abs = abs(J)
256
- if J_abs > J_max:
257
- J_max = J_abs
256
+ J_max = max(J_abs, J_max)
258
257
  J_eff /= J_max
259
258
 
260
259
  return J_eff, degrees
261
260
 
261
+
262
262
  @njit
263
263
  def init_thresholds(n_qubits):
264
264
  n_bias = n_qubits - 1
265
- thresholds = np.empty(n_bias, dtype=np.float64)
265
+ thresholds = np.empty(n_bias, dtype=np.float32)
266
266
  tot_prob = 0
267
267
  p = 1.0
268
268
  if n_qubits & 1:
@@ -280,10 +280,10 @@ def init_thresholds(n_qubits):
280
280
  return thresholds
281
281
 
282
282
 
283
- @njit
283
+ @njit(parallel=True)
284
284
  def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
285
- theta = np.empty(n_qubits, dtype=np.float64)
286
- for q in range(n_qubits):
285
+ theta = np.empty(n_qubits, dtype=np.float32)
286
+ for q in prange(n_qubits):
287
287
  J = J_eff[q]
288
288
  z = degrees[q]
289
289
  theta[q] = np.arcsin(
@@ -300,7 +300,7 @@ def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
300
300
 
301
301
 
302
302
  def to_scipy_sparse_upper_triangular(G, nodes, n_nodes):
303
- lil = lil_matrix((n_nodes, n_nodes), dtype=np.float64)
303
+ lil = lil_matrix((n_nodes, n_nodes), dtype=np.float32)
304
304
  for u in range(n_nodes):
305
305
  u_node = nodes[u]
306
306
  for v in range(u + 1, n_nodes):
@@ -15,7 +15,7 @@ except ImportError:
15
15
 
16
16
  @njit
17
17
  def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
18
- bias = np.empty(n_qubits - 1, dtype=np.float64)
18
+ bias = np.empty(n_qubits - 1, dtype=np.float32)
19
19
 
20
20
  # critical angle
21
21
  theta_c = np.arcsin(max(-1.0, min(1.0, abs(h) / (z * J))))
@@ -56,7 +56,7 @@ def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, hamming_prob):
56
56
  h_mult = 2.0 / tot_t
57
57
  n_bias = n_qubits - 1
58
58
 
59
- theta = np.empty(n_qubits, dtype=np.float64)
59
+ theta = np.empty(n_qubits, dtype=np.float32)
60
60
  for q in range(n_qubits):
61
61
  J = J_func[q]
62
62
  z = degrees[q]
@@ -165,7 +165,7 @@ def sample_for_solution(G_func, G_func_args_tuple, nodes, max_weight, shots, thr
165
165
  weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
166
166
 
167
167
  solutions = np.empty((shots, n), dtype=np.bool_)
168
- energies = np.empty(shots, dtype=np.float64)
168
+ energies = np.empty(shots, dtype=np.float32)
169
169
 
170
170
  for s in prange(shots):
171
171
  # First dimension: Hamming weight
@@ -192,14 +192,14 @@ def sample_for_solution(G_func, G_func_args_tuple, nodes, max_weight, shots, thr
192
192
  return best_solution, best_value
193
193
 
194
194
 
195
- @njit
195
+ @njit(parallel=True)
196
196
  def init_J_and_z(G_func, G_func_args_tuple, nodes):
197
197
  n_qubits = len(nodes)
198
198
  degrees = np.empty(n_qubits, dtype=np.uint32)
199
- J_eff = np.empty(n_qubits, dtype=np.float64)
199
+ J_eff = np.empty(n_qubits, dtype=np.float32)
200
200
  J_max = -float("inf")
201
201
  G_max = -float("inf")
202
- for n in range(n_qubits):
202
+ for n in prange(n_qubits):
203
203
  degree = 0
204
204
  J = 0.0
205
205
  for m in range(n_qubits):
@@ -207,14 +207,12 @@ def init_J_and_z(G_func, G_func_args_tuple, nodes):
207
207
  if val != 0.0:
208
208
  degree += 1
209
209
  J += val
210
- if val > G_max:
211
- G_max = val
210
+ G_max = max(val, G_max)
212
211
  J = -J / degree if degree > 0 else 0
213
212
  degrees[n] = degree
214
213
  J_eff[n] = J
215
214
  J_abs = abs(J)
216
- if J_abs > J_max:
217
- J_max = J_abs
215
+ J_max = max(J_abs, J_max)
218
216
  J_eff /= J_max
219
217
 
220
218
  return J_eff, degrees, G_max
@@ -223,7 +221,7 @@ def init_J_and_z(G_func, G_func_args_tuple, nodes):
223
221
  @njit
224
222
  def init_thresholds(n_qubits):
225
223
  n_bias = n_qubits - 1
226
- thresholds = np.empty(n_bias, dtype=np.float64)
224
+ thresholds = np.empty(n_bias, dtype=np.float32)
227
225
  tot_prob = 0
228
226
  p = 1.0
229
227
  if n_qubits & 1:
@@ -241,10 +239,10 @@ def init_thresholds(n_qubits):
241
239
  return thresholds
242
240
 
243
241
 
244
- @njit
242
+ @njit(parallel=True)
245
243
  def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
246
- theta = np.empty(n_qubits, dtype=np.float64)
247
- for q in range(n_qubits):
244
+ theta = np.empty(n_qubits, dtype=np.float32)
245
+ for q in prange(n_qubits):
248
246
  J = J_eff[q]
249
247
  z = degrees[q]
250
248
  theta[q] = np.arcsin(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 5.1.1
3
+ Version: 5.1.3
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
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='5.1.1',
54
+ version='5.1.3',
55
55
  author='Dan Strano',
56
56
  author_email='stranoj@gmail.com',
57
57
  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