PyQrackIsing 8.0.0__tar.gz → 8.0.1__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.0.0/pyqrackising.egg-info → pyqrackising-8.0.1}/PKG-INFO +1 -1
  2. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyproject.toml +1 -1
  3. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/maxcut_tfim.py +2 -84
  4. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/maxcut_tfim_sparse.py +0 -89
  5. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/maxcut_tfim_streaming.py +0 -6
  6. {pyqrackising-8.0.0 → pyqrackising-8.0.1/pyqrackising.egg-info}/PKG-INFO +1 -1
  7. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/setup.py +1 -1
  8. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/CMakeLists.txt +0 -0
  9. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/LICENSE.md +0 -0
  10. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/MANIFEST.in +0 -0
  11. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/README.md +0 -0
  12. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/__init__.py +0 -0
  13. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/_pyqrack_ising.cpp +0 -0
  14. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  15. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/generate_tfim_samples.py +0 -0
  16. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/kernels.cl +0 -0
  17. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/maxcut_tfim_util.py +0 -0
  18. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/spin_glass_solver.py +0 -0
  19. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  20. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  21. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/spin_glass_solver_util.py +0 -0
  22. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/tfim_magnetization.py +0 -0
  23. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/tfim_square_magnetization.py +0 -0
  24. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/tsp.py +0 -0
  25. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising/tsp_maxcut.py +0 -0
  26. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
  27. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
  28. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising.egg-info/not-zip-safe +0 -0
  29. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/pyqrackising.egg-info/top_level.txt +0 -0
  30. {pyqrackising-8.0.0 → pyqrackising-8.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.0.0
3
+ Version: 8.0.1
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.0.0"
15
+ version = "8.0.1"
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"}
@@ -6,12 +6,6 @@ from numba import njit, prange
6
6
 
7
7
  from .maxcut_tfim_util import fix_cdf, get_cut, init_theta, init_thresholds, maxcut_hamming_cdf, opencl_context
8
8
 
9
- IS_OPENCL_AVAILABLE = True
10
- try:
11
- import pyopencl as cl
12
- except ImportError:
13
- IS_OPENCL_AVAILABLE = False
14
-
15
9
 
16
10
  epsilon = opencl_context.epsilon
17
11
 
@@ -120,7 +114,8 @@ def compute_energy(sample, G_m, n_qubits):
120
114
  energy = 0
121
115
  for u in range(n_qubits):
122
116
  for v in range(u + 1, n_qubits):
123
- energy += G_m[u, v] * (1 if sample[u] == sample[v] else -1)
117
+ val = G_m[u, v]
118
+ energy += val if sample[u] == sample[v] else -val
124
119
 
125
120
  return energy
126
121
 
@@ -188,83 +183,6 @@ def init_J_and_z(G_m, dtype):
188
183
  return J_eff, degrees
189
184
 
190
185
 
191
- def run_sampling_opencl(G_m_np, thresholds_np, shots, n, is_g_buf_reused):
192
- ctx = opencl_context.ctx
193
- queue = opencl_context.queue
194
- kernel = opencl_context.sample_for_solution_best_bitset_kernel
195
- dtype = opencl_context.dtype
196
- wgs = opencl_context.work_group_size
197
-
198
- local_size = min(wgs, shots) # tune
199
- max_global_size = ((opencl_context.MAX_GPU_PROC_ELEM + local_size - 1) // local_size) * local_size # corresponds to MAX_PROC_ELEM macro in OpenCL kernel program
200
- global_size = min(((shots + local_size - 1) // local_size) * local_size, max_global_size)
201
- num_groups = global_size // local_size
202
-
203
- # Bit-packing params
204
- words = (n + 31) // 32
205
-
206
- # Random seeds (host)
207
- rng_seeds_np = np.random.randint(1, 2**31-1, size=global_size, dtype=np.uint32)
208
-
209
- # Device buffers
210
- mf = cl.mem_flags
211
- G_m_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=G_m_np)
212
- thresholds_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=thresholds_np)
213
- rng_buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=rng_seeds_np)
214
-
215
- # Solutions buffer: each work-item writes a candidate bitset
216
- solutions_buf = cl.Buffer(ctx, mf.READ_WRITE, size=num_groups * words * np.uint32().nbytes)
217
-
218
- # Best energies and solutions (per group)
219
- # We'll reuse solutions_buf to hold them after reduction (kernel copies winners into group slices)
220
- best_energies_np = np.empty(num_groups, dtype=dtype)
221
- best_energies_buf = cl.Buffer(ctx, mf.WRITE_ONLY, best_energies_np.nbytes)
222
-
223
- # Local memory buffers
224
- local_energy_buf = cl.LocalMemory(np.dtype(dtype).itemsize * local_size)
225
- local_index_buf = cl.LocalMemory(np.dtype(np.int32).itemsize * local_size)
226
-
227
- # Set kernel args
228
- kernel.set_args(
229
- G_m_buf,
230
- thresholds_buf,
231
- np.int32(n),
232
- np.int32(shots),
233
- dtype(G_m_np.max()),
234
- rng_buf,
235
- solutions_buf,
236
- best_energies_buf,
237
- local_energy_buf,
238
- local_index_buf
239
- )
240
-
241
- # Launch
242
- cl.enqueue_nd_range_kernel(queue, kernel, (global_size,), (local_size,))
243
-
244
- # Copy back
245
- cl.enqueue_copy(queue, best_energies_np, best_energies_buf)
246
- solutions_np = np.empty(num_groups * words, dtype=np.uint32)
247
- cl.enqueue_copy(queue, solutions_np, solutions_buf) # all candidates, includes per-group winners
248
- queue.finish()
249
-
250
- # Host reduction
251
- best_group = np.argmax(best_energies_np) # max cut
252
- best_energy = float(best_energies_np[best_group])
253
- best_solution_bits = solutions_np[best_group * words : (best_group + 1) * words]
254
-
255
- # Unpack bitset into boolean vector
256
- best_solution = np.zeros(n, dtype=np.bool_)
257
- for u in range(n):
258
- w = u >> 5
259
- b = u & 31
260
- best_solution[u] = (best_solution_bits[w] >> b) & 1
261
-
262
- if is_g_buf_reused:
263
- opencl_context.G_m_buf = G_m_buf
264
-
265
- return best_solution, best_energy
266
-
267
-
268
186
  @njit
269
187
  def cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype):
270
188
  J_eff, degrees = init_J_and_z(G_m, dtype)
@@ -6,12 +6,6 @@ from numba import njit, prange
6
6
 
7
7
  from .maxcut_tfim_util import binary_search, fix_cdf, get_cut, init_theta, init_thresholds, maxcut_hamming_cdf, opencl_context, to_scipy_sparse_upper_triangular
8
8
 
9
- IS_OPENCL_AVAILABLE = True
10
- try:
11
- import pyopencl as cl
12
- except ImportError:
13
- IS_OPENCL_AVAILABLE = False
14
-
15
9
 
16
10
  epsilon = opencl_context.epsilon
17
11
 
@@ -217,89 +211,6 @@ def init_J_and_z(G_data, G_rows, G_cols, dtype):
217
211
  return J_eff, degrees
218
212
 
219
213
 
220
- def run_sampling_opencl(G_m_csr, thresholds_np, shots, n, is_g_buf_reused):
221
- ctx = opencl_context.ctx
222
- queue = opencl_context.queue
223
- kernel = opencl_context.sample_for_solution_best_bitset_sparse_kernel
224
- dtype = opencl_context.dtype
225
- wgs = opencl_context.work_group_size
226
-
227
- local_size = min(wgs, shots) # tune
228
- max_global_size = ((opencl_context.MAX_GPU_PROC_ELEM + local_size - 1) // local_size) * local_size # corresponds to MAX_PROC_ELEM macro in OpenCL kernel program
229
- global_size = min(((shots + local_size - 1) // local_size) * local_size, max_global_size)
230
- num_groups = global_size // local_size
231
-
232
- # Bit-packing params
233
- words = (n + 31) // 32
234
-
235
- # Random seeds (host)
236
- rng_seeds_np = np.random.randint(1, 2**31-1, size=global_size, dtype=np.uint32)
237
-
238
- # Device buffers
239
- mf = cl.mem_flags
240
- G_data_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=G_m_csr.data)
241
- G_rows_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=G_m_csr.indptr)
242
- G_cols_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=G_m_csr.indices)
243
- thresholds_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=thresholds_np)
244
- rng_buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=rng_seeds_np)
245
-
246
- # Solutions buffer: each work-item writes a candidate bitset
247
- solutions_buf = cl.Buffer(ctx, mf.READ_WRITE, size=num_groups * words * np.uint32().nbytes)
248
-
249
- # Best energies and solutions (per group)
250
- # We'll reuse solutions_buf to hold them after reduction (kernel copies winners into group slices)
251
- best_energies_np = np.empty(num_groups, dtype=dtype)
252
- best_energies_buf = cl.Buffer(ctx, mf.WRITE_ONLY, best_energies_np.nbytes)
253
-
254
- # Local memory buffers
255
- local_energy_buf = cl.LocalMemory(np.dtype(dtype).itemsize * local_size)
256
- local_index_buf = cl.LocalMemory(np.dtype(np.int32).itemsize * local_size)
257
-
258
- # Set kernel args
259
- kernel.set_args(
260
- G_data_buf,
261
- G_rows_buf,
262
- G_cols_buf,
263
- thresholds_buf,
264
- np.int32(n),
265
- np.int32(shots),
266
- dtype(G_m_csr.data.max()),
267
- rng_buf,
268
- solutions_buf,
269
- best_energies_buf,
270
- local_energy_buf,
271
- local_index_buf
272
- )
273
-
274
- # Launch
275
- cl.enqueue_nd_range_kernel(queue, kernel, (global_size,), (local_size,))
276
-
277
- # Copy back
278
- cl.enqueue_copy(queue, best_energies_np, best_energies_buf)
279
- solutions_np = np.empty(num_groups * words, dtype=np.uint32)
280
- cl.enqueue_copy(queue, solutions_np, solutions_buf) # all candidates, includes per-group winners
281
- queue.finish()
282
-
283
- # Host reduction
284
- best_group = np.argmax(best_energies_np) # max cut
285
- best_energy = float(best_energies_np[best_group])
286
- best_solution_bits = solutions_np[best_group * words : (best_group + 1) * words]
287
-
288
- # Unpack bitset into boolean vector
289
- best_solution = np.zeros(n, dtype=np.bool_)
290
- for u in range(n):
291
- w = u >> 5
292
- b = u & 31
293
- best_solution[u] = (best_solution_bits[w] >> b) & 1
294
-
295
- if is_g_buf_reused:
296
- opencl_context.G_data_buf = G_data_buf
297
- opencl_context.G_rows_buf = G_rows_buf
298
- opencl_context.G_cols_buf = G_cols_buf
299
-
300
- return best_solution, best_energy
301
-
302
-
303
214
  @njit
304
215
  def cpu_footer(shots, quality, n_qubits, G_data, G_rows, G_col, nodes, dtype):
305
216
  J_eff, degrees = init_J_and_z(G_data, G_rows, G_col, dtype)
@@ -6,12 +6,6 @@ from numba import njit, prange
6
6
 
7
7
  from .maxcut_tfim_util import fix_cdf, get_cut, init_theta, init_thresholds, maxcut_hamming_cdf, opencl_context, probability_by_hamming_weight
8
8
 
9
- IS_OPENCL_AVAILABLE = True
10
- try:
11
- import pyopencl as cl
12
- except ImportError:
13
- IS_OPENCL_AVAILABLE = False
14
-
15
9
 
16
10
  epsilon = opencl_context.epsilon
17
11
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 8.0.0
3
+ Version: 8.0.1
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.0.0',
54
+ version='8.0.1',
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