PyQrackIsing 9.12.1__tar.gz → 9.12.2__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 (35) hide show
  1. {pyqrackising-9.12.1/pyqrackising.egg-info → pyqrackising-9.12.2}/PKG-INFO +1 -1
  2. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyproject.toml +1 -1
  3. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/maxcut_tfim.py +7 -7
  4. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/maxcut_tfim_sparse.py +6 -6
  5. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/maxcut_tfim_streaming.py +7 -7
  6. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/maxcut_tfim_util.py +23 -23
  7. pyqrackising-9.12.2/pyqrackising/solve_maxcut_exact.py +321 -0
  8. pyqrackising-9.12.2/pyqrackising/solve_maxcut_exact_sparse.py +322 -0
  9. pyqrackising-9.12.2/pyqrackising/solve_maxcut_exact_streaming.py +292 -0
  10. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/spin_glass_solver.py +4 -4
  11. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/spin_glass_solver_sparse.py +4 -4
  12. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/spin_glass_solver_streaming.py +4 -4
  13. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/tsp.py +45 -45
  14. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/tsp_maxcut.py +8 -8
  15. {pyqrackising-9.12.1 → pyqrackising-9.12.2/pyqrackising.egg-info}/PKG-INFO +1 -1
  16. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/setup.py +1 -1
  17. pyqrackising-9.12.1/pyqrackising/solve_maxcut_exact.py +0 -355
  18. pyqrackising-9.12.1/pyqrackising/solve_maxcut_exact_sparse.py +0 -404
  19. pyqrackising-9.12.1/pyqrackising/solve_maxcut_exact_streaming.py +0 -356
  20. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/LICENSE.md +0 -0
  21. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/MANIFEST.in +0 -0
  22. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/README.md +0 -0
  23. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/__init__.py +0 -0
  24. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  25. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/generate_tfim_samples.py +0 -0
  26. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/kernels.cl +0 -0
  27. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/otoc.py +0 -0
  28. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/tfim_magnetization.py +0 -0
  29. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising/tfim_square_magnetization.py +0 -0
  30. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising.egg-info/SOURCES.txt +0 -0
  31. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising.egg-info/dependency_links.txt +0 -0
  32. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising.egg-info/not-zip-safe +0 -0
  33. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising.egg-info/requires.txt +0 -0
  34. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/pyqrackising.egg-info/top_level.txt +0 -0
  35. {pyqrackising-9.12.1 → pyqrackising-9.12.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.12.1
3
+ Version: 9.12.2
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 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "pyqrackising"
10
- version = "9.12.1"
10
+ version = "9.12.2"
11
11
  requires-python = ">=3.8"
12
12
  description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
13
13
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -33,7 +33,7 @@ dtype = opencl_context.dtype
33
33
  wgs = opencl_context.work_group_size
34
34
 
35
35
 
36
- @njit
36
+ @njit(cache=True)
37
37
  def update_repulsion_choice(G_m, weights, n, used, node, repulsion_base):
38
38
  # Select node
39
39
  used[node] = True
@@ -49,7 +49,7 @@ def update_repulsion_choice(G_m, weights, n, used, node, repulsion_base):
49
49
 
50
50
 
51
51
  # Written by Elara (OpenAI custom GPT) and improved by Dan Strano
52
- @njit
52
+ @njit(cache=True)
53
53
  def local_repulsion_choice(G_m, repulsion_base, n, m, s):
54
54
  """
55
55
  Pick m nodes out of n with repulsion bias:
@@ -78,7 +78,7 @@ def local_repulsion_choice(G_m, repulsion_base, n, m, s):
78
78
  return used
79
79
 
80
80
 
81
- @njit(parallel=True)
81
+ @njit(parallel=True, cache=True)
82
82
  def sample_measurement(G_m, shots, thread_count, thresholds, repulsion_base, is_spin_glass):
83
83
  shot_segment = (max(1, shots >> 1) + thread_count - 1) // thread_count
84
84
  shots = shot_segment * thread_count
@@ -140,7 +140,7 @@ def sample_measurement(G_m, shots, thread_count, thresholds, repulsion_base, is_
140
140
  return best_solution, best_energy
141
141
 
142
142
 
143
- @njit(parallel=True)
143
+ @njit(parallel=True, cache=True)
144
144
  def shot_loop(G_m, thresholds, repulsion_base, n, shots, solutions):
145
145
  for s in prange(shots):
146
146
  # First dimension: Hamming weight
@@ -190,7 +190,7 @@ def sample_for_opencl(
190
190
  return best_solution, float(best_energy)
191
191
 
192
192
 
193
- @njit(parallel=True)
193
+ @njit(parallel=True, cache=True)
194
194
  def init_J_and_z(G_m, repulsion_base):
195
195
  G_min = G_m.min()
196
196
  n_qubits = len(G_m)
@@ -289,7 +289,7 @@ def run_cut_opencl(
289
289
  return samples[max_index_host[best_x]].copy(), energy
290
290
 
291
291
 
292
- @njit
292
+ @njit(cache=True)
293
293
  def exact_maxcut(G):
294
294
  """Brute-force exact MAXCUT solver using Numba JIT."""
295
295
  n = G.shape[0]
@@ -316,7 +316,7 @@ def exact_maxcut(G):
316
316
  return best_bits, max_cut
317
317
 
318
318
 
319
- @njit
319
+ @njit(cache=True)
320
320
  def exact_spin_glass(G):
321
321
  """Brute-force exact spin-glass solver using Numba JIT."""
322
322
  n = G.shape[0]
@@ -34,7 +34,7 @@ dtype = opencl_context.dtype
34
34
  wgs = opencl_context.work_group_size
35
35
 
36
36
 
37
- @njit
37
+ @njit(cache=True)
38
38
  def update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repulsion_base):
39
39
  # Select node
40
40
  used[node] = True
@@ -60,7 +60,7 @@ def update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repu
60
60
 
61
61
 
62
62
  # Written by Elara (OpenAI custom GPT) and improved by Dan Strano
63
- @njit
63
+ @njit(cache=True)
64
64
  def local_repulsion_choice(G_data, G_rows, G_cols, repulsion_base, n, m, s):
65
65
  """
66
66
  Pick m nodes out of n with repulsion bias:
@@ -89,7 +89,7 @@ def local_repulsion_choice(G_data, G_rows, G_cols, repulsion_base, n, m, s):
89
89
  return used
90
90
 
91
91
 
92
- @njit(parallel=True)
92
+ @njit(parallel=True, cache=True)
93
93
  def sample_measurement(G_data, G_rows, G_cols, shots, thread_count, thresholds, repulsion_base, is_spin_glass):
94
94
  shot_segment = (max(1, shots >> 1) + thread_count - 1) // thread_count
95
95
  shots = shot_segment * thread_count
@@ -148,7 +148,7 @@ def sample_measurement(G_data, G_rows, G_cols, shots, thread_count, thresholds,
148
148
  return best_solution, best_energy
149
149
 
150
150
 
151
- @njit(parallel=True)
151
+ @njit(parallel=True, cache=True)
152
152
  def shot_loop(G_data, G_rows, G_cols, thresholds, repulsion_base, n, shots, solutions):
153
153
  for s in prange(shots):
154
154
  # First dimension: Hamming weight
@@ -307,7 +307,7 @@ def run_cut_opencl(
307
307
  return samples[max_index_host[best_x]].copy(), energy
308
308
 
309
309
 
310
- @njit
310
+ @njit(cache=True)
311
311
  def exact_maxcut(G_data, G_rows, G_cols):
312
312
  """Brute-force exact MAXCUT solver using Numba JIT."""
313
313
  n = G_rows.shape[0] - 1
@@ -339,7 +339,7 @@ def exact_maxcut(G_data, G_rows, G_cols):
339
339
  return best_bits, max_cut
340
340
 
341
341
 
342
- @njit
342
+ @njit(cache=True)
343
343
  def exact_spin_glass(G_data, G_rows, G_cols):
344
344
  """Brute-force exact spin-glass solver using Numba JIT."""
345
345
  n = G_rows.shape[0] - 1
@@ -22,7 +22,7 @@ epsilon = opencl_context.epsilon
22
22
  dtype = opencl_context.dtype
23
23
 
24
24
 
25
- @njit
25
+ @njit(cache=True)
26
26
  def update_repulsion_choice(G_func, nodes, weights, n, used, node, repulsion_base):
27
27
  # Select node
28
28
  used[node] = True
@@ -38,7 +38,7 @@ def update_repulsion_choice(G_func, nodes, weights, n, used, node, repulsion_bas
38
38
 
39
39
 
40
40
  # Written by Elara (OpenAI custom GPT) and improved by Dan Strano
41
- @njit
41
+ @njit(cache=True)
42
42
  def local_repulsion_choice(G_func, nodes, repulsion_base, n, m, s):
43
43
  """
44
44
  Pick m nodes out of n with repulsion bias:
@@ -67,7 +67,7 @@ def local_repulsion_choice(G_func, nodes, repulsion_base, n, m, s):
67
67
  return used
68
68
 
69
69
 
70
- @njit(parallel=True)
70
+ @njit(parallel=True, cache=True)
71
71
  def sample_measurement(G_func, nodes, shots, thread_count, thresholds, n, repulsion_base, is_spin_glass):
72
72
  shot_segment = (max(1, shots >> 1) + thread_count - 1) // thread_count
73
73
  shots = shot_segment * thread_count
@@ -128,7 +128,7 @@ def sample_measurement(G_func, nodes, shots, thread_count, thresholds, n, repuls
128
128
  return best_solution, best_energy
129
129
 
130
130
 
131
- @njit(parallel=True)
131
+ @njit(parallel=True, cache=True)
132
132
  def init_J_and_z(G_func, nodes, G_min, repulsion_base):
133
133
  n_qubits = len(nodes)
134
134
  degrees = np.empty(n_qubits, dtype=np.uint32)
@@ -150,7 +150,7 @@ def init_J_and_z(G_func, nodes, G_min, repulsion_base):
150
150
  return J_eff, degrees
151
151
 
152
152
 
153
- @njit
153
+ @njit(cache=True)
154
154
  def find_G_min(G_func, nodes, n_nodes):
155
155
  G_min = float("inf")
156
156
  for i in range(n_nodes):
@@ -164,7 +164,7 @@ def find_G_min(G_func, nodes, n_nodes):
164
164
  return G_min
165
165
 
166
166
 
167
- @njit
167
+ @njit(cache=True)
168
168
  def exact_maxcut(G_func, n):
169
169
  """Brute-force exact MAXCUT solver using Numba JIT."""
170
170
  max_cut = -1.0
@@ -190,7 +190,7 @@ def exact_maxcut(G_func, n):
190
190
  return best_bits, max_cut
191
191
 
192
192
 
193
- @njit
193
+ @njit(cache=True)
194
194
  def exact_spin_glass(G_func, n):
195
195
  """Brute-force exact spin-glass solver using Numba JIT."""
196
196
  max_cut = -1.0
@@ -301,7 +301,7 @@ def make_best_theta_buf_64(theta):
301
301
  return theta_buf
302
302
 
303
303
 
304
- @njit(parallel=True)
304
+ @njit(parallel=True, cache=True)
305
305
  def convert_bool_to_uint(samples):
306
306
  shots = samples.shape[0]
307
307
  n = samples.shape[1]
@@ -316,7 +316,7 @@ def convert_bool_to_uint(samples):
316
316
  return theta
317
317
 
318
318
 
319
- @njit
319
+ @njit(cache=True)
320
320
  def compute_energy(sample, G_m, n_qubits):
321
321
  energy = 0.0
322
322
  for u in range(n_qubits):
@@ -328,7 +328,7 @@ def compute_energy(sample, G_m, n_qubits):
328
328
  return energy
329
329
 
330
330
 
331
- @njit
331
+ @njit(cache=True)
332
332
  def compute_cut(sample, G_m, n_qubits):
333
333
  l, r = get_cut_base(sample, n_qubits)
334
334
  cut = 0
@@ -339,7 +339,7 @@ def compute_cut(sample, G_m, n_qubits):
339
339
  return cut
340
340
 
341
341
 
342
- @njit
342
+ @njit(cache=True)
343
343
  def compute_cut_diff(u, sample, G_m, n_qubits):
344
344
  energy = 0.0
345
345
  u_bit = sample[u]
@@ -354,7 +354,7 @@ def compute_cut_diff(u, sample, G_m, n_qubits):
354
354
  return energy
355
355
 
356
356
 
357
- @njit
357
+ @njit(cache=True)
358
358
  def compute_cut_diff_2(k, l, sample, G_m, n_qubits):
359
359
  if l < k:
360
360
  t = k
@@ -384,7 +384,7 @@ def compute_cut_diff_2(k, l, sample, G_m, n_qubits):
384
384
  return energy
385
385
 
386
386
 
387
- @njit
387
+ @njit(cache=True)
388
388
  def compute_energy_sparse(sample, G_data, G_rows, G_cols, n_qubits):
389
389
  energy = 0.0
390
390
  for u in range(n_qubits):
@@ -396,7 +396,7 @@ def compute_energy_sparse(sample, G_data, G_rows, G_cols, n_qubits):
396
396
  return energy
397
397
 
398
398
 
399
- @njit
399
+ @njit(cache=True)
400
400
  def compute_cut_sparse(sample, G_data, G_rows, G_cols, n_qubits):
401
401
  l, r = get_cut_base(sample, n_qubits)
402
402
  s = l if len(l) < len(r) else r
@@ -410,7 +410,7 @@ def compute_cut_sparse(sample, G_data, G_rows, G_cols, n_qubits):
410
410
  return cut
411
411
 
412
412
 
413
- @njit
413
+ @njit(cache=True)
414
414
  def compute_energy_streaming(sample, G_func, nodes, n_qubits):
415
415
  energy = 0.0
416
416
  for u in range(n_qubits):
@@ -422,7 +422,7 @@ def compute_energy_streaming(sample, G_func, nodes, n_qubits):
422
422
  return energy
423
423
 
424
424
 
425
- @njit
425
+ @njit(cache=True)
426
426
  def compute_cut_streaming(sample, G_func, nodes, n_qubits):
427
427
  l, r = get_cut_base(sample, n_qubits)
428
428
  cut = 0
@@ -433,7 +433,7 @@ def compute_cut_streaming(sample, G_func, nodes, n_qubits):
433
433
  return cut
434
434
 
435
435
 
436
- @njit
436
+ @njit(cache=True)
437
437
  def compute_cut_diff_streaming(u, sample, G_func, nodes, n_qubits):
438
438
  energy = 0.0
439
439
  u_bit = sample[u]
@@ -447,7 +447,7 @@ def compute_cut_diff_streaming(u, sample, G_func, nodes, n_qubits):
447
447
  return energy
448
448
 
449
449
 
450
- @njit
450
+ @njit(cache=True)
451
451
  def compute_cut_diff_2_streaming(k, l, sample, G_func, nodes, n_qubits):
452
452
  if l < k:
453
453
  t = k
@@ -475,7 +475,7 @@ def compute_cut_diff_2_streaming(k, l, sample, G_func, nodes, n_qubits):
475
475
  return energy
476
476
 
477
477
 
478
- @njit
478
+ @njit(cache=True)
479
479
  def compute_cut_diff_between(o_theta, n_theta, G_m, n_qubits):
480
480
  energy = 0.0
481
481
 
@@ -494,7 +494,7 @@ def compute_cut_diff_between(o_theta, n_theta, G_m, n_qubits):
494
494
  return energy
495
495
 
496
496
 
497
- @njit
497
+ @njit(cache=True)
498
498
  def compute_cut_diff_between_streaming(o_theta, n_theta, G_func, nodes, n_qubits):
499
499
  energy = 0.0
500
500
 
@@ -512,7 +512,7 @@ def compute_cut_diff_between_streaming(o_theta, n_theta, G_func, nodes, n_qubits
512
512
  return energy
513
513
 
514
514
 
515
- @njit
515
+ @njit(cache=True)
516
516
  def get_cut(solution, nodes, n):
517
517
  bit_string = ""
518
518
  l, r = [], []
@@ -527,7 +527,7 @@ def get_cut(solution, nodes, n):
527
527
  return bit_string, l, r
528
528
 
529
529
 
530
- @njit
530
+ @njit(cache=True)
531
531
  def get_cut_base(solution, n):
532
532
  l, r = [], []
533
533
  for i in range(n):
@@ -544,7 +544,7 @@ def int_to_bitstring(integer, length):
544
544
  return (bin(integer)[2:].zfill(length))[::-1]
545
545
 
546
546
 
547
- @njit
547
+ @njit(cache=True)
548
548
  def binary_search(l, t):
549
549
  left = 0
550
550
  right = len(l) - 1
@@ -575,7 +575,7 @@ def to_scipy_sparse_upper_triangular(G, nodes, n_nodes):
575
575
  return lil.tocsr()
576
576
 
577
577
 
578
- @njit(parallel=True)
578
+ @njit(parallel=True, cache=True)
579
579
  def init_theta(h_mult, n_qubits, J_eff, degrees):
580
580
  theta = np.empty(n_qubits, dtype=np.float64)
581
581
  h_mult = abs(h_mult)
@@ -608,7 +608,7 @@ def init_thresholds(n_qubits):
608
608
  return thresholds
609
609
 
610
610
 
611
- @njit
611
+ @njit(cache=True)
612
612
  def probability_by_hamming_weight(J, h, z, theta, t, n_bias, normalized=True, omega=1.5 * np.pi):
613
613
  zJ = z * J
614
614
  theta_c = ((np.pi if J > 0 else -np.pi) / 2) if abs(zJ) < epsilon else np.arcsin(max(-1.0, min(1.0, h / zJ)))
@@ -634,7 +634,7 @@ def probability_by_hamming_weight(J, h, z, theta, t, n_bias, normalized=True, om
634
634
  return bias
635
635
 
636
636
 
637
- @njit
637
+ @njit(cache=True)
638
638
  def maxcut_hamming_cdf(hamming_prob, n_qubits, J_func, degrees, quality, tot_t, h_mult, omega=1.5 * np.pi):
639
639
  n_steps = 1 << quality
640
640
  delta_t = tot_t / n_steps
@@ -670,7 +670,7 @@ def maxcut_hamming_cdf(hamming_prob, n_qubits, J_func, degrees, quality, tot_t,
670
670
  return cum_prob
671
671
 
672
672
 
673
- @njit
673
+ @njit(cache=True)
674
674
  def sample_mag(cum_prob):
675
675
  p = np.random.random()
676
676
  m = 0
@@ -690,7 +690,7 @@ def sample_mag(cum_prob):
690
690
  return m
691
691
 
692
692
 
693
- @njit
693
+ @njit(cache=True)
694
694
  def bit_pick(weights, used, n):
695
695
  # Count available
696
696
  p = 0.0
@@ -714,7 +714,7 @@ def bit_pick(weights, used, n):
714
714
  return node
715
715
 
716
716
 
717
- @njit
717
+ @njit(cache=True)
718
718
  def gray_code_next(state, curr_idx, offset):
719
719
  prev = curr_idx
720
720
  curr = curr_idx + 1
@@ -727,7 +727,7 @@ def gray_code_next(state, curr_idx, offset):
727
727
  return flip_bit
728
728
 
729
729
 
730
- @njit
730
+ @njit(cache=True)
731
731
  def gray_mutation(index, seed_bits, offset):
732
732
  """Apply Gray-code-indexed bit flips to a seed bitstring."""
733
733
  n = seed_bits.shape[0]