pyqrackising 9.5.8__tar.gz → 9.5.10__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-9.5.8/pyqrackising.egg-info → pyqrackising-9.5.10}/PKG-INFO +1 -1
  2. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyproject.toml +1 -1
  3. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/otoc.py +27 -32
  4. {pyqrackising-9.5.8 → pyqrackising-9.5.10/pyqrackising.egg-info}/PKG-INFO +1 -1
  5. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/setup.py +1 -1
  6. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/LICENSE.md +0 -0
  7. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/MANIFEST.in +0 -0
  8. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/README.md +0 -0
  9. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/__init__.py +0 -0
  10. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  11. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/generate_tfim_samples.py +0 -0
  12. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/kernels.cl +0 -0
  13. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/maxcut_tfim.py +0 -0
  14. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/maxcut_tfim_sparse.py +0 -0
  15. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/maxcut_tfim_streaming.py +0 -0
  16. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/maxcut_tfim_util.py +0 -0
  17. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/spin_glass_solver.py +0 -0
  18. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  19. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  20. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/tfim_magnetization.py +0 -0
  21. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/tfim_square_magnetization.py +0 -0
  22. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/tsp.py +0 -0
  23. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising/tsp_maxcut.py +0 -0
  24. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising.egg-info/SOURCES.txt +0 -0
  25. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising.egg-info/dependency_links.txt +0 -0
  26. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising.egg-info/not-zip-safe +0 -0
  27. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/pyqrackising.egg-info/top_level.txt +0 -0
  28. {pyqrackising-9.5.8 → pyqrackising-9.5.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.5.8
3
+ Version: 9.5.10
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 = "9.5.8"
13
+ version = "9.5.10"
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"}
@@ -15,37 +15,41 @@ def get_otoc_hamming_distribution(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=6
15
15
  bias[0] = 1.0
16
16
  return bias
17
17
 
18
- max_entropy = np.empty(n_bias, dtype=np.float64)
18
+ diff_x = np.empty(n_bias, dtype=np.float64)
19
19
  tot_prob = 0
20
20
  p = 1.0
21
21
  for q in range(n_qubits >> 1):
22
- max_entropy[q] = p
23
- max_entropy[n_bias - (q + 1)] = p
22
+ diff_x[q] = p
23
+ diff_x[n_bias - (q + 1)] = p
24
24
  tot_prob += 2 * p
25
25
  p = math.comb(n_qubits, q + 1)
26
26
  if n_qubits & 1:
27
- max_entropy[n_qubits >> 1] = p
27
+ diff_x[n_qubits >> 1] = p
28
28
  tot_prob += p
29
- max_entropy /= tot_prob
29
+ diff_x *= n_qubits / tot_prob
30
30
 
31
31
  signal_frac = 0.0
32
32
  diff_z = np.zeros(n_bias, dtype=np.float64)
33
+ diff_z[0] = n_qubits
33
34
  for pauli_string in pauli_strings:
34
35
  pauli_string = list(pauli_string)
35
36
  if len(pauli_string) != n_qubits:
36
37
  raise ValueError("OTOCS pauli_string must be same length as n_qubits! (Use 'I' for qubits that aren't changed.)")
37
38
 
38
- signal_frac -= 0.5 * pauli_string.count('X') + pauli_string.count('Z') + 1.5 * pauli_string.count('Y')
39
+ term_signal = 0.5 * pauli_string.count('X') + pauli_string.count('Z') + 1.5 * pauli_string.count('Y')
40
+ if term_signal == 0:
41
+ continue
42
+
43
+ signal_frac -= term_signal
39
44
 
40
45
  fwd = probability_by_hamming_weight(J, h, z, theta, t, n_qubits + 1)
41
46
  rev = probability_by_hamming_weight(-J, -h, z, theta + np.pi, t, n_qubits + 1)
42
47
  diff_theta = rev - fwd
43
- diff_theta[0] += 1.0
44
48
 
45
49
  phi = theta + np.pi / 2
46
50
  fwd = probability_by_hamming_weight(-h, -J, z, phi, t, n_qubits + 1)
47
51
  rev = probability_by_hamming_weight(h, J, z, phi - np.pi, t, n_qubits + 1)
48
- diff_phi = (rev - fwd) + max_entropy
52
+ diff_phi = rev - fwd
49
53
 
50
54
  diff_lam = (diff_theta + diff_phi) / 2
51
55
 
@@ -54,17 +58,19 @@ def get_otoc_hamming_distribution(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=6
54
58
  case 'X':
55
59
  diff_z += diff_theta
56
60
  case 'Z':
57
- diff_z += diff_phi
61
+ diff_x += diff_phi
58
62
  case 'Y':
59
- diff_z += diff_lam
63
+ diff_z += diff_theta
64
+ diff_x += diff_phi
60
65
  case _:
61
- diff_z[0] += 1.0
66
+ pass
62
67
 
63
68
  # Normalize:
64
69
  diff_z /= diff_z.sum()
70
+ diff_x /= diff_x.sum()
65
71
 
66
72
  signal_frac = 2 ** signal_frac
67
- diff_z = signal_frac * diff_z + (1 - signal_frac) * max_entropy
73
+ diff_z = signal_frac * diff_z + (1 - signal_frac) * diff_x
68
74
 
69
75
  # Normalize:
70
76
  diff_z /= diff_z.sum()
@@ -141,13 +147,13 @@ def get_willow_inv_dist(butterfly_idx_x, butterfly_idx_z, n_qubits, row_len, col
141
147
  b_row, b_col = divmod(idx, row_len)
142
148
  for q in range(n_qubits):
143
149
  q_row, q_col = divmod(q, row_len)
144
- inv_dist[q] -= abs(q_row - b_row) + abs(q_col - b_col)
150
+ inv_dist[q] += abs(q_row - b_row) + abs(q_col - b_col)
145
151
  for idx in butterfly_idx_z:
146
152
  b_row, b_col = divmod(idx, row_len)
147
153
  for q in range(n_qubits):
148
154
  q_row, q_col = divmod(q, row_len)
149
- inv_dist[q] += abs(q_row - b_row) + abs(q_col - b_col)
150
- inv_dist -= inv_dist.min()
155
+ inv_dist[q] -= abs(q_row - b_row) + abs(q_col - b_col)
156
+ inv_dist = 2 ** inv_dist
151
157
 
152
158
  return inv_dist
153
159
 
@@ -166,7 +172,7 @@ def get_inv_dist(butterfly_idx_x, butterfly_idx_z, n_qubits, row_len, col_len):
166
172
  col_d = abs(q_col - b_col)
167
173
  if col_d > half_col:
168
174
  col_d = col_len - col_d
169
- inv_dist[q] -= row_d + col_d
175
+ inv_dist[q] += row_d + col_d
170
176
  for idx in butterfly_idx_z:
171
177
  b_row, b_col = divmod(idx, row_len)
172
178
  for q in range(n_qubits):
@@ -177,8 +183,8 @@ def get_inv_dist(butterfly_idx_x, butterfly_idx_z, n_qubits, row_len, col_len):
177
183
  col_d = abs(q_col - b_col)
178
184
  if col_d > half_col:
179
185
  col_d = col_len - col_d
180
- inv_dist[q] += row_d + col_d
181
- inv_dist -= inv_dist.min()
186
+ inv_dist[q] -= row_d + col_d
187
+ inv_dist = 2 ** inv_dist
182
188
 
183
189
  return inv_dist
184
190
 
@@ -186,15 +192,11 @@ def get_inv_dist(butterfly_idx_x, butterfly_idx_z, n_qubits, row_len, col_len):
186
192
  def generate_otoc_samples(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=65, pauli_strings = ['X' + 'I' * 64], shots=100, is_orbifold=True):
187
193
  thresholds = fix_cdf(get_otoc_hamming_distribution(J, h, z, theta, t, n_qubits, pauli_strings))
188
194
 
189
- signal_frac = 0.0
190
- for pauli_string in pauli_strings:
191
- pauli_string = list(pauli_string)
192
- signal_frac -= 0.5 * pauli_string.count('X') + pauli_string.count('Z') + 1.5 * pauli_string.count('Y')
193
- signal_frac = 2 ** signal_frac
194
-
195
195
  row_len, col_len = factor_width(n_qubits)
196
196
  inv_dist = np.zeros(n_qubits, dtype=np.float64)
197
197
  for pauli_string in pauli_strings:
198
+ if (pauli_string.count('X') + pauli_string.count('Y') + pauli_string.count('Z')) == 0:
199
+ continue
198
200
  butterfly_idx_x = find_all_str_occurrences(pauli_string, 'X')
199
201
  butterfly_idx_z = find_all_str_occurrences(pauli_string, 'Z')
200
202
  if is_orbifold:
@@ -216,13 +218,6 @@ def generate_otoc_samples(J=-1.0, h=2.0, z=4, theta=0.0, t=5, n_qubits=65, pauli
216
218
  continue
217
219
 
218
220
  # Second dimension: permutation within Hamming weight
219
- if np.random.random() < signal_frac:
220
- samples.append(take_sample(n_qubits, 0, m, inv_dist))
221
- else:
222
- bit_pows = np.random.choice(qubit_pows, size=m, replace=False)
223
- sample = 0
224
- for bit_pow in bit_pows:
225
- sample |= bit_pow
226
- samples.append(sample)
221
+ samples.append(take_sample(n_qubits, 0, m, inv_dist))
227
222
 
228
223
  return samples
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.5.8
3
+ Version: 9.5.10
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='9.5.8',
10
+ version='9.5.10',
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