PyQrackIsing 8.2.0__tar.gz → 8.2.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 (30) hide show
  1. {pyqrackising-8.2.0/pyqrackising.egg-info → pyqrackising-8.2.2}/PKG-INFO +1 -1
  2. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyproject.toml +1 -1
  3. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim.py +3 -4
  4. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_sparse.py +3 -4
  5. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_streaming.py +4 -5
  6. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_util.py +14 -10
  7. {pyqrackising-8.2.0 → pyqrackising-8.2.2/pyqrackising.egg-info}/PKG-INFO +1 -1
  8. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/setup.py +1 -1
  9. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/CMakeLists.txt +0 -0
  10. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/LICENSE.md +0 -0
  11. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/MANIFEST.in +0 -0
  12. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/README.md +0 -0
  13. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/__init__.py +0 -0
  14. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/_pyqrack_ising.cpp +0 -0
  15. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  16. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/generate_tfim_samples.py +0 -0
  17. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/kernels.cl +0 -0
  18. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver.py +0 -0
  19. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  20. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  21. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_util.py +0 -0
  22. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/tfim_magnetization.py +0 -0
  23. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/tfim_square_magnetization.py +0 -0
  24. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/tsp.py +0 -0
  25. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising/tsp_maxcut.py +0 -0
  26. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising.egg-info/SOURCES.txt +0 -0
  27. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising.egg-info/dependency_links.txt +0 -0
  28. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising.egg-info/not-zip-safe +0 -0
  29. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/pyqrackising.egg-info/top_level.txt +0 -0
  30. {pyqrackising-8.2.0 → pyqrackising-8.2.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.2.0
3
+ Version: 8.2.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
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "pyqrackising"
15
- version = "8.2.0"
15
+ version = "8.2.2"
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"}
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import get_cut, maxcut_hamming_cdf, opencl_context
8
8
 
9
9
 
10
10
  epsilon = opencl_context.epsilon
11
- dtype = opencl_context.dtype
12
11
 
13
12
 
14
13
  @njit
@@ -140,7 +139,7 @@ def sample_for_energy(G_m, shots, thresholds, weights):
140
139
  tot_init_weight = weights.sum()
141
140
 
142
141
  solutions = np.empty((shots, n), dtype=np.bool_)
143
- energies = np.empty(shots, dtype=dtype)
142
+ energies = np.empty(shots, dtype=np.float64)
144
143
 
145
144
  best_solution = solutions[0]
146
145
  best_energy = float("inf")
@@ -179,7 +178,7 @@ def sample_for_cut(G_m, shots, thresholds, weights):
179
178
  tot_init_weight = weights.sum()
180
179
 
181
180
  solutions = np.empty((shots, n), dtype=np.bool_)
182
- cuts = np.empty(shots, dtype=dtype)
181
+ cuts = np.empty(shots, dtype=np.float64)
183
182
 
184
183
  best_solution = solutions[0]
185
184
  best_cut = -float("inf")
@@ -214,7 +213,7 @@ def sample_for_cut(G_m, shots, thresholds, weights):
214
213
  def init_J_and_z(G_m):
215
214
  n_qubits = len(G_m)
216
215
  degrees = np.empty(n_qubits, dtype=np.uint32)
217
- J_eff = np.empty(n_qubits, dtype=dtype)
216
+ J_eff = np.empty(n_qubits, dtype=np.float64)
218
217
  for n in prange(n_qubits):
219
218
  degree = sum(G_m[n] != 0.0)
220
219
  J = (-G_m[n].sum() / degree) if degree > 0 else 0
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import binary_search, get_cut, maxcut_hamming_cdf, opencl
8
8
 
9
9
 
10
10
  epsilon = opencl_context.epsilon
11
- dtype = opencl_context.dtype
12
11
 
13
12
 
14
13
  @njit
@@ -152,7 +151,7 @@ def sample_for_energy(G_data, G_rows, G_cols, shots, thresholds, weights):
152
151
  tot_init_weight = weights.sum()
153
152
 
154
153
  solutions = np.empty((shots, n), dtype=np.bool_)
155
- energies = np.empty(shots, dtype=dtype)
154
+ energies = np.empty(shots, dtype=np.float64)
156
155
 
157
156
  best_solution = solutions[0]
158
157
  best_energy = float("inf")
@@ -191,7 +190,7 @@ def sample_for_cut(G_data, G_rows, G_cols, shots, thresholds, weights):
191
190
  tot_init_weight = weights.sum()
192
191
 
193
192
  solutions = np.empty((shots, n), dtype=np.bool_)
194
- cuts = np.empty(shots, dtype=dtype)
193
+ cuts = np.empty(shots, dtype=np.float64)
195
194
 
196
195
  best_solution = solutions[0]
197
196
  best_cut = -float("inf")
@@ -226,7 +225,7 @@ def sample_for_cut(G_data, G_rows, G_cols, shots, thresholds, weights):
226
225
  def init_J_and_z(G_data, G_rows, G_cols):
227
226
  n_qubits = G_rows.shape[0] - 1
228
227
  degrees = np.zeros(n_qubits, dtype=np.uint32)
229
- J_eff = np.zeros(n_qubits, dtype=dtype)
228
+ J_eff = np.zeros(n_qubits, dtype=np.float64)
230
229
  for r in prange(n_qubits):
231
230
  # Row sum
232
231
  start = G_rows[r]
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import get_cut, maxcut_hamming_cdf, opencl_context
8
8
 
9
9
 
10
10
  epsilon = opencl_context.epsilon
11
- dtype = opencl_context.dtype
12
11
 
13
12
 
14
13
  @njit
@@ -139,7 +138,7 @@ def sample_for_energy(G_func, nodes, max_edge, shots, thresholds, degrees_sum, w
139
138
  tot_init_weight = weights.sum()
140
139
 
141
140
  solutions = np.empty((shots, n), dtype=np.bool_)
142
- energies = np.empty(shots, dtype=dtype)
141
+ energies = np.empty(shots, dtype=np.float64)
143
142
 
144
143
  best_solution = solutions[0]
145
144
  best_energy = float("inf")
@@ -176,7 +175,7 @@ def sample_for_cut(G_func, nodes, max_edge, shots, thresholds, degrees_sum, weig
176
175
  tot_init_weight = weights.sum()
177
176
 
178
177
  solutions = np.empty((shots, n), dtype=np.bool_)
179
- cuts = np.empty(shots, dtype=dtype)
178
+ cuts = np.empty(shots, dtype=np.float64)
180
179
 
181
180
  best_solution = solutions[0]
182
181
  best_cut = -float("inf")
@@ -211,7 +210,7 @@ def sample_for_cut(G_func, nodes, max_edge, shots, thresholds, degrees_sum, weig
211
210
  def init_J_and_z(G_func, nodes):
212
211
  n_qubits = len(nodes)
213
212
  degrees = np.empty(n_qubits, dtype=np.uint32)
214
- J_eff = np.empty(n_qubits, dtype=dtype)
213
+ J_eff = np.empty(n_qubits, dtype=np.float64)
215
214
  G_max = -float("inf")
216
215
  for n in prange(n_qubits):
217
216
  degree = 0
@@ -276,7 +275,7 @@ def maxcut_tfim_streaming(
276
275
  return "01", weight, ([nodes[0]], [nodes[1]])
277
276
 
278
277
  if quality is None:
279
- quality = 5
278
+ quality = 8
280
279
 
281
280
  if anneal_t is None:
282
281
  anneal_t = 8.0
@@ -153,7 +153,7 @@ def to_scipy_sparse_upper_triangular(G, nodes, n_nodes):
153
153
 
154
154
  @njit(parallel=True)
155
155
  def init_theta(h_mult, n_qubits, J_eff, degrees):
156
- theta = np.empty(n_qubits, dtype=dtype)
156
+ theta = np.empty(n_qubits, dtype=np.float64)
157
157
  h_mult = abs(h_mult)
158
158
  for q in prange(n_qubits):
159
159
  J = J_eff[q]
@@ -167,7 +167,7 @@ def init_theta(h_mult, n_qubits, J_eff, degrees):
167
167
  @njit
168
168
  def init_thresholds(n_qubits):
169
169
  n_bias = n_qubits - 1
170
- thresholds = np.empty(n_bias, dtype=dtype)
170
+ thresholds = np.empty(n_bias, dtype=np.float64)
171
171
  tot_prob = 0
172
172
  p = 1.0
173
173
  if n_qubits & 1:
@@ -188,35 +188,39 @@ def init_thresholds(n_qubits):
188
188
  @njit
189
189
  def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
190
190
  if abs(J) < epsilon:
191
- return np.full((n_qubits - 1,), 1.0 / (n_qubits - 1), dtype=dtype)
191
+ return np.full(n_qubits - 1, 1.0 / (n_qubits - 1), dtype=np.float64)
192
192
 
193
193
  ratio = max(1.0, min(-1.0, abs(h) / (z * J)))
194
194
  theta_c = np.arcsin(ratio)
195
195
 
196
196
  p = (
197
- pow(2.0, abs(J / h) - 1.0)
197
+ 2.0 ** (abs(J / h) - 1.0)
198
198
  * (1.0 + np.sin(theta - theta_c) * np.cos(1.5 * np.pi * J * t + theta) / (1.0 + np.sqrt(t)))
199
199
  - 0.5
200
200
  )
201
201
 
202
- numerator = pow(2.0, (n_qubits + 2) * p) - 1.0
203
- denominator = pow(2.0, p) - 1.0
204
202
 
205
- bias = np.empty(n_qubits - 1, dtype=dtype)
203
+ bias = np.empty(n_qubits - 1, dtype=np.float64)
204
+ factor = 2.0 ** -p
205
+ result = 1.0 / (n_qubits + 1)
206
+ tot_n = 0.0
206
207
  for q in range(n_qubits - 1):
207
- result = numerator * pow(2.0, -((n_qubits + 1) * p) - p * q) / denominator
208
- bias[q] = 0.0 if np.isnan(result) or np.isinf(result) else result
208
+ result *= factor
209
+ bias[q] = result
210
+ tot_n += result
209
211
 
210
212
  if J > 0.0:
211
213
  return bias[::-1]
212
214
 
215
+ tot_n += result
216
+
213
217
  return bias
214
218
 
215
219
 
216
220
  @njit(parallel=True)
217
221
  def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, tot_t, h_mult):
218
222
  if n_qubits < 2:
219
- return np.full((n_qubits,), 1.0 / n_qubits, dtype=dtype)
223
+ return np.full((n_qubits,), 1.0 / n_qubits, dtype=np.float64)
220
224
 
221
225
  hamming_prob = init_thresholds(n_qubits)
222
226
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.2.0
3
+ Version: 8.2.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
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='8.2.0',
54
+ version='8.2.2',
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