PyQrackIsing 6.1.2__tar.gz → 6.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.
- {pyqrackising-6.1.2/pyqrackising.egg-info → pyqrackising-6.1.3}/PKG-INFO +1 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyproject.toml +1 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/maxcut_tfim.py +6 -6
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/maxcut_tfim_sparse.py +6 -6
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/maxcut_tfim_util.py +9 -2
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/spin_glass_solver.py +2 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/spin_glass_solver_sparse.py +2 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/setup.py +1 -1
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/CMakeLists.txt +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/LICENSE.md +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/MANIFEST.in +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/README.md +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/__init__.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising/tsp.py +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-6.1.2 → pyqrackising-6.1.3}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "6.1.
|
|
15
|
+
version = "6.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"}
|
|
@@ -139,8 +139,9 @@ def run_sampling_opencl(G_m_np, thresholds_np, shots, n, is_g_buf_reused):
|
|
|
139
139
|
queue = opencl_context.queue
|
|
140
140
|
kernel = opencl_context.sample_for_solution_best_bitset_kernel
|
|
141
141
|
dtype = opencl_context.dtype
|
|
142
|
+
wgs = opencl_context.work_group_size
|
|
142
143
|
|
|
143
|
-
max_local_size =
|
|
144
|
+
max_local_size = wgs # tune
|
|
144
145
|
max_global_size = ((opencl_context.MAX_GPU_PROC_ELEM + max_local_size - 1) // max_local_size) * max_local_size # corresponds to MAX_PROC_ELEM macro in OpenCL kernel program
|
|
145
146
|
global_size = min(((shots + max_local_size - 1) // max_local_size) * max_local_size, max_global_size)
|
|
146
147
|
local_size = max_local_size
|
|
@@ -248,6 +249,7 @@ def maxcut_tfim(
|
|
|
248
249
|
is_base_maxcut_gpu=True
|
|
249
250
|
):
|
|
250
251
|
dtype = opencl_context.dtype
|
|
252
|
+
wgs = opencl_context.work_group_size
|
|
251
253
|
nodes = None
|
|
252
254
|
n_qubits = 0
|
|
253
255
|
G_m = None
|
|
@@ -284,7 +286,7 @@ def maxcut_tfim(
|
|
|
284
286
|
n_steps = n_qubits << quality
|
|
285
287
|
grid_size = n_steps * n_qubits
|
|
286
288
|
|
|
287
|
-
if (not is_base_maxcut_gpu) or not
|
|
289
|
+
if (not is_base_maxcut_gpu) or (not IS_OPENCL_AVAILABLE):
|
|
288
290
|
return cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype)
|
|
289
291
|
|
|
290
292
|
J_eff, degrees = init_J_and_z(G_m, dtype)
|
|
@@ -306,7 +308,7 @@ def maxcut_tfim(
|
|
|
306
308
|
theta_buf = cl.Buffer(opencl_context.ctx, mf.READ_WRITE, size=(n_qubits * dtype().nbytes))
|
|
307
309
|
|
|
308
310
|
# Warp size is 32:
|
|
309
|
-
group_size = min(
|
|
311
|
+
group_size = min(wgs, n_qubits)
|
|
310
312
|
global_size = ((n_qubits + group_size - 1) // group_size) * group_size
|
|
311
313
|
|
|
312
314
|
opencl_context.init_theta_kernel(
|
|
@@ -317,9 +319,7 @@ def maxcut_tfim(
|
|
|
317
319
|
hamming_prob = init_thresholds(n_qubits, dtype)
|
|
318
320
|
|
|
319
321
|
# Warp size is 32:
|
|
320
|
-
group_size = n_qubits - 1
|
|
321
|
-
if group_size > 256:
|
|
322
|
-
group_size = 256
|
|
322
|
+
group_size = min(wgs, n_qubits - 1)
|
|
323
323
|
grid_dim = n_steps * n_qubits * group_size
|
|
324
324
|
|
|
325
325
|
# Move to GPU
|
|
@@ -186,8 +186,9 @@ def run_sampling_opencl(G_m_csr, thresholds_np, shots, n, is_g_buf_reused):
|
|
|
186
186
|
queue = opencl_context.queue
|
|
187
187
|
kernel = opencl_context.sample_for_solution_best_bitset_sparse_kernel
|
|
188
188
|
dtype = opencl_context.dtype
|
|
189
|
+
wgs = opencl_context.work_group_size
|
|
189
190
|
|
|
190
|
-
max_local_size =
|
|
191
|
+
max_local_size = wqs # tune
|
|
191
192
|
max_global_size = ((opencl_context.MAX_GPU_PROC_ELEM + max_local_size - 1) // max_local_size) * max_local_size # corresponds to MAX_PROC_ELEM macro in OpenCL kernel program
|
|
192
193
|
global_size = min(((shots + max_local_size - 1) // max_local_size) * max_local_size, max_global_size)
|
|
193
194
|
local_size = max_local_size
|
|
@@ -313,6 +314,7 @@ def maxcut_tfim_sparse(
|
|
|
313
314
|
is_base_maxcut_gpu=True
|
|
314
315
|
):
|
|
315
316
|
dtype = opencl_context.dtype
|
|
317
|
+
wgs = opencl_context.work_group_size
|
|
316
318
|
nodes = None
|
|
317
319
|
n_qubits = 0
|
|
318
320
|
G_m = None
|
|
@@ -349,7 +351,7 @@ def maxcut_tfim_sparse(
|
|
|
349
351
|
n_steps = n_qubits << quality
|
|
350
352
|
grid_size = n_steps * n_qubits
|
|
351
353
|
|
|
352
|
-
if (not is_base_maxcut_gpu) or not
|
|
354
|
+
if (not is_base_maxcut_gpu) or (not IS_OPENCL_AVAILABLE):
|
|
353
355
|
return cpu_footer(shots, quality, n_qubits, G_m.data, G_m.indptr, G_m.indices, nodes, dtype)
|
|
354
356
|
|
|
355
357
|
J_eff, degrees = init_J_and_z(G_m.data, G_m.indptr, G_m.indices, dtype)
|
|
@@ -371,7 +373,7 @@ def maxcut_tfim_sparse(
|
|
|
371
373
|
theta_buf = cl.Buffer(opencl_context.ctx, mf.READ_WRITE, size=(n_qubits * 4))
|
|
372
374
|
|
|
373
375
|
# Warp size is 32:
|
|
374
|
-
group_size = min(
|
|
376
|
+
group_size = min(wgs, n_qubits)
|
|
375
377
|
global_size = ((n_qubits + group_size - 1) // group_size) * group_size
|
|
376
378
|
|
|
377
379
|
opencl_context.init_theta_kernel(
|
|
@@ -382,9 +384,7 @@ def maxcut_tfim_sparse(
|
|
|
382
384
|
hamming_prob = init_thresholds(n_qubits, dtype)
|
|
383
385
|
|
|
384
386
|
# Warp size is 32:
|
|
385
|
-
group_size = n_qubits - 1
|
|
386
|
-
if group_size > 256:
|
|
387
|
-
group_size = 256
|
|
387
|
+
group_size = min(wgs, n_qubits - 1)
|
|
388
388
|
grid_dim = n_steps * n_qubits * group_size
|
|
389
389
|
|
|
390
390
|
# Move to GPU
|
|
@@ -146,9 +146,10 @@ def probability_by_hamming_weight(J, h, z, theta, t, n_qubits, dtype):
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
class OpenCLContext:
|
|
149
|
-
def __init__(self, p, a, d, c, q, i, m, b, s, k, l):
|
|
149
|
+
def __init__(self, p, a, w, d, c, q, i, m, b, s, k, l):
|
|
150
150
|
self.MAX_GPU_PROC_ELEM = p
|
|
151
151
|
self.IS_OPENCL_AVAILABLE = a
|
|
152
|
+
self.work_group_size = w
|
|
152
153
|
self.dtype = d
|
|
153
154
|
self.ctx = c
|
|
154
155
|
self.queue = q
|
|
@@ -168,6 +169,7 @@ ctx = None
|
|
|
168
169
|
queue = None
|
|
169
170
|
compute_units = None
|
|
170
171
|
dtype = np.float32
|
|
172
|
+
work_group_size = 32
|
|
171
173
|
init_theta_kernel = None
|
|
172
174
|
maxcut_hamming_cdf_kernel = None
|
|
173
175
|
bootstrap_kernel = None
|
|
@@ -224,8 +226,13 @@ try:
|
|
|
224
226
|
bootstrap_sparse_kernel = program.bootstrap_sparse
|
|
225
227
|
sample_for_solution_best_bitset_kernel = program.sample_for_solution_best_bitset
|
|
226
228
|
sample_for_solution_best_bitset_sparse_kernel = program.sample_for_solution_best_bitset_sparse
|
|
229
|
+
|
|
230
|
+
work_group_size = bootstrap_kernel.get_work_group_info(
|
|
231
|
+
cl.kernel_work_group_info.PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
|
|
232
|
+
ctx.devices[0]
|
|
233
|
+
)
|
|
227
234
|
except ImportError:
|
|
228
235
|
IS_OPENCL_AVAILABLE = False
|
|
229
236
|
print("PyOpenCL not installed. (If you have any OpenCL accelerator devices with available ICDs, you might want to optionally install pyopencl.)")
|
|
230
237
|
|
|
231
|
-
opencl_context = OpenCLContext(compute_units, IS_OPENCL_AVAILABLE, dtype, ctx, queue, init_theta_kernel, maxcut_hamming_cdf_kernel, bootstrap_kernel, bootstrap_sparse_kernel, sample_for_solution_best_bitset_kernel, sample_for_solution_best_bitset_sparse_kernel)
|
|
238
|
+
opencl_context = OpenCLContext(compute_units, IS_OPENCL_AVAILABLE, work_group_size, dtype, ctx, queue, init_theta_kernel, maxcut_hamming_cdf_kernel, bootstrap_kernel, bootstrap_sparse_kernel, sample_for_solution_best_bitset_kernel, sample_for_solution_best_bitset_sparse_kernel)
|
|
@@ -72,6 +72,7 @@ def run_bootstrap_opencl(best_theta, G_m_buf, indices_array_np, k, min_energy):
|
|
|
72
72
|
queue = opencl_context.queue
|
|
73
73
|
bootstrap_kernel = opencl_context.bootstrap_kernel
|
|
74
74
|
dtype = opencl_context.dtype
|
|
75
|
+
wgs = opencl_context.work_group_size
|
|
75
76
|
|
|
76
77
|
n = best_theta.shape[0]
|
|
77
78
|
combo_count = len(indices_array_np) // k
|
|
@@ -95,7 +96,7 @@ def run_bootstrap_opencl(best_theta, G_m_buf, indices_array_np, k, min_energy):
|
|
|
95
96
|
min_index_buf = cl.Buffer(ctx, mf.WRITE_ONLY, min_index_host.nbytes)
|
|
96
97
|
|
|
97
98
|
# Local memory allocation (1 float per work item)
|
|
98
|
-
local_size = min(
|
|
99
|
+
local_size = min(wgs, n)
|
|
99
100
|
global_size = ((combo_count + local_size - 1) // local_size) * local_size
|
|
100
101
|
local_energy_buf = cl.LocalMemory(np.dtype(dtype).itemsize * local_size)
|
|
101
102
|
local_index_buf = cl.LocalMemory(np.dtype(np.int32).itemsize * local_size)
|
|
@@ -75,6 +75,7 @@ def run_bootstrap_opencl(best_theta, G_data_buf, G_rows_buf, G_cols_buf, indices
|
|
|
75
75
|
queue = opencl_context.queue
|
|
76
76
|
bootstrap_kernel = opencl_context.bootstrap_sparse_kernel
|
|
77
77
|
dtype = opencl_context.dtype
|
|
78
|
+
wgs = opencl_context.work_group_size
|
|
78
79
|
|
|
79
80
|
n = best_theta.shape[0]
|
|
80
81
|
combo_count = len(indices_array_np) // k
|
|
@@ -98,7 +99,7 @@ def run_bootstrap_opencl(best_theta, G_data_buf, G_rows_buf, G_cols_buf, indices
|
|
|
98
99
|
min_index_buf = cl.Buffer(ctx, mf.WRITE_ONLY, min_index_host.nbytes)
|
|
99
100
|
|
|
100
101
|
# Local memory allocation (1 float per work item)
|
|
101
|
-
local_size = min(
|
|
102
|
+
local_size = min(wgs, n)
|
|
102
103
|
global_size = ((combo_count + local_size - 1) // local_size) * local_size
|
|
103
104
|
local_energy_buf = cl.LocalMemory(np.dtype(dtype).itemsize * local_size)
|
|
104
105
|
local_index_buf = cl.LocalMemory(np.dtype(np.int32).itemsize * local_size)
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='6.1.
|
|
54
|
+
version='6.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|