PyQrackIsing 7.4.7__tar.gz → 7.4.9__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-7.4.7/pyqrackising.egg-info → pyqrackising-7.4.9}/PKG-INFO +1 -1
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyproject.toml +1 -1
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/maxcut_tfim.py +5 -4
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/maxcut_tfim_sparse.py +5 -4
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/maxcut_tfim_streaming.py +5 -4
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/maxcut_tfim_util.py +7 -2
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/tsp_maxcut.py +3 -1
- {pyqrackising-7.4.7 → pyqrackising-7.4.9/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/setup.py +1 -1
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/CMakeLists.txt +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/LICENSE.md +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/MANIFEST.in +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/README.md +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/__init__.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising/tsp.py +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-7.4.7 → pyqrackising-7.4.9}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "7.4.
|
|
15
|
+
version = "7.4.9"
|
|
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"}
|
|
@@ -212,14 +212,14 @@ def run_sampling_opencl(G_m_np, thresholds_np, shots, n, is_g_buf_reused):
|
|
|
212
212
|
|
|
213
213
|
|
|
214
214
|
@njit
|
|
215
|
-
def cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype):
|
|
215
|
+
def cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype, epsilon):
|
|
216
216
|
J_eff, degrees = init_J_and_z(G_m, dtype)
|
|
217
217
|
hamming_prob = init_thresholds(n_qubits, dtype)
|
|
218
218
|
|
|
219
219
|
maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, hamming_prob, dtype)
|
|
220
220
|
|
|
221
221
|
degrees = None
|
|
222
|
-
J_eff = 1.0 / (1.0 +
|
|
222
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
223
223
|
|
|
224
224
|
best_solution, best_value = sample_for_solution(G_m, shots, hamming_prob, J_eff, dtype)
|
|
225
225
|
|
|
@@ -248,6 +248,7 @@ def maxcut_tfim(
|
|
|
248
248
|
is_base_maxcut_gpu=True
|
|
249
249
|
):
|
|
250
250
|
dtype = opencl_context.dtype
|
|
251
|
+
epsilon = opencl_context.epsilon
|
|
251
252
|
wgs = opencl_context.work_group_size
|
|
252
253
|
nodes = None
|
|
253
254
|
n_qubits = 0
|
|
@@ -291,7 +292,7 @@ def maxcut_tfim(
|
|
|
291
292
|
grid_size = n_steps * n_qubits
|
|
292
293
|
|
|
293
294
|
if (not is_base_maxcut_gpu) or (not IS_OPENCL_AVAILABLE):
|
|
294
|
-
return cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype)
|
|
295
|
+
return cpu_footer(shots, quality, n_qubits, G_m, nodes, dtype, epsilon)
|
|
295
296
|
|
|
296
297
|
J_eff, degrees = init_J_and_z(G_m, dtype)
|
|
297
298
|
|
|
@@ -351,7 +352,7 @@ def maxcut_tfim(
|
|
|
351
352
|
|
|
352
353
|
if not is_alt_gpu_sampling:
|
|
353
354
|
degrees = None
|
|
354
|
-
J_eff = 1.0 / (1.0 +
|
|
355
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
355
356
|
|
|
356
357
|
return gpu_footer(shots, n_qubits, G_m, J_eff, hamming_prob, nodes, dtype)
|
|
357
358
|
|
|
@@ -245,14 +245,14 @@ def run_sampling_opencl(G_m_csr, thresholds_np, shots, n, is_g_buf_reused):
|
|
|
245
245
|
|
|
246
246
|
|
|
247
247
|
@njit
|
|
248
|
-
def cpu_footer(shots, quality, n_qubits, G_data, G_rows, G_cols, nodes, dtype):
|
|
248
|
+
def cpu_footer(shots, quality, n_qubits, G_data, G_rows, G_cols, nodes, dtype, epsilon):
|
|
249
249
|
J_eff, degrees = init_J_and_z(G_data, G_rows, G_cols, dtype)
|
|
250
250
|
hamming_prob = init_thresholds(n_qubits, dtype)
|
|
251
251
|
|
|
252
252
|
maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, hamming_prob, dtype)
|
|
253
253
|
|
|
254
254
|
degrees = None
|
|
255
|
-
J_eff = 1.0 / (1.0 +
|
|
255
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
256
256
|
|
|
257
257
|
best_solution, best_value = sample_for_solution(G_data, G_rows, G_cols, shots, hamming_prob, J_eff, dtype)
|
|
258
258
|
|
|
@@ -281,6 +281,7 @@ def maxcut_tfim_sparse(
|
|
|
281
281
|
is_base_maxcut_gpu=True
|
|
282
282
|
):
|
|
283
283
|
dtype = opencl_context.dtype
|
|
284
|
+
epsilon = opencl_context.epsilon
|
|
284
285
|
wgs = opencl_context.work_group_size
|
|
285
286
|
nodes = None
|
|
286
287
|
n_qubits = 0
|
|
@@ -324,7 +325,7 @@ def maxcut_tfim_sparse(
|
|
|
324
325
|
grid_size = n_steps * n_qubits
|
|
325
326
|
|
|
326
327
|
if (not is_base_maxcut_gpu) or (not IS_OPENCL_AVAILABLE):
|
|
327
|
-
return cpu_footer(shots, quality, n_qubits, G_m.data, G_m.indptr, G_m.indices, nodes, dtype)
|
|
328
|
+
return cpu_footer(shots, quality, n_qubits, G_m.data, G_m.indptr, G_m.indices, nodes, dtype, epsilon)
|
|
328
329
|
|
|
329
330
|
J_eff, degrees = init_J_and_z(G_m.data, G_m.indptr, G_m.indices, dtype)
|
|
330
331
|
|
|
@@ -384,7 +385,7 @@ def maxcut_tfim_sparse(
|
|
|
384
385
|
|
|
385
386
|
if not is_alt_gpu_sampling:
|
|
386
387
|
degrees = None
|
|
387
|
-
J_eff = 1.0 / (1.0 +
|
|
388
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
388
389
|
|
|
389
390
|
return gpu_footer(shots, n_qubits, G_m.data, G_m.indptr, G_m.indices, J_eff, hamming_prob, nodes, dtype)
|
|
390
391
|
|
|
@@ -144,7 +144,7 @@ def init_J_and_z(G_func, nodes, dtype):
|
|
|
144
144
|
|
|
145
145
|
|
|
146
146
|
@njit
|
|
147
|
-
def cpu_footer(shots, quality, n_qubits, G_func, nodes, dtype):
|
|
147
|
+
def cpu_footer(shots, quality, n_qubits, G_func, nodes, dtype, epsilon):
|
|
148
148
|
J_eff, degrees, G_max = init_J_and_z(G_func, nodes, dtype)
|
|
149
149
|
hamming_prob = init_thresholds(n_qubits, dtype)
|
|
150
150
|
|
|
@@ -152,7 +152,7 @@ def cpu_footer(shots, quality, n_qubits, G_func, nodes, dtype):
|
|
|
152
152
|
|
|
153
153
|
max_weight = degrees.sum()
|
|
154
154
|
degrees = None
|
|
155
|
-
J_eff = 1.0 / (1.0 +
|
|
155
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
156
156
|
|
|
157
157
|
best_solution, best_value = sample_for_solution(G_func, nodes, G_max, shots, hamming_prob, max_weight, J_eff, n_qubits, dtype)
|
|
158
158
|
|
|
@@ -180,6 +180,7 @@ def maxcut_tfim_streaming(
|
|
|
180
180
|
is_base_maxcut_gpu=True
|
|
181
181
|
):
|
|
182
182
|
dtype = opencl_context.dtype
|
|
183
|
+
epsilon = opencl_context.epsilon
|
|
183
184
|
wgs = opencl_context.work_group_size
|
|
184
185
|
n_qubits = len(nodes)
|
|
185
186
|
|
|
@@ -208,7 +209,7 @@ def maxcut_tfim_streaming(
|
|
|
208
209
|
grid_size = n_steps * n_qubits
|
|
209
210
|
|
|
210
211
|
if (not is_base_maxcut_gpu) or (not IS_OPENCL_AVAILABLE):
|
|
211
|
-
return cpu_footer(shots, quality, n_qubits, G_func, nodes, dtype)
|
|
212
|
+
return cpu_footer(shots, quality, n_qubits, G_func, nodes, dtype, epsilon)
|
|
212
213
|
|
|
213
214
|
J_eff, degrees, G_max = init_J_and_z(G_func, nodes, dtype)
|
|
214
215
|
|
|
@@ -268,6 +269,6 @@ def maxcut_tfim_streaming(
|
|
|
268
269
|
|
|
269
270
|
max_weight = degrees.sum()
|
|
270
271
|
degrees = None
|
|
271
|
-
J_eff = 1.0 / (1.0 +
|
|
272
|
+
J_eff = 1.0 / (1.0 + epsilon - J_eff)
|
|
272
273
|
|
|
273
274
|
return gpu_footer(shots, n_qubits, G_func, nodes, G_max, J_eff, degrees, hamming_prob, max_weight, dtype)
|
|
@@ -178,11 +178,12 @@ def probability_by_hamming_weight(J, h, z, theta, t, n_qubits, dtype):
|
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
class OpenCLContext:
|
|
181
|
-
def __init__(self, p, a, w, d, r, c, q, i, m, b, s, x, y, k, l):
|
|
181
|
+
def __init__(self, p, a, w, d, e, r, c, q, i, m, b, s, x, y, k, l):
|
|
182
182
|
self.MAX_GPU_PROC_ELEM = p
|
|
183
183
|
self.IS_OPENCL_AVAILABLE = a
|
|
184
184
|
self.work_group_size = w
|
|
185
185
|
self.dtype = d
|
|
186
|
+
self.epsilon = e
|
|
186
187
|
self.max_alloc = r
|
|
187
188
|
self.ctx = c
|
|
188
189
|
self.queue = q
|
|
@@ -204,6 +205,7 @@ ctx = None
|
|
|
204
205
|
queue = None
|
|
205
206
|
compute_units = None
|
|
206
207
|
dtype = np.float32
|
|
208
|
+
epsilon = 2 ** -23
|
|
207
209
|
work_group_size = 32
|
|
208
210
|
max_alloc = 0xFFFFFFFFFFFFFFFF
|
|
209
211
|
init_theta_kernel = None
|
|
@@ -219,6 +221,7 @@ dtype_bits = int(os.getenv('PYQRACKISING_FPPOW', '5'))
|
|
|
219
221
|
kernel_src = ''
|
|
220
222
|
if dtype_bits <= 4:
|
|
221
223
|
dtype = np.float16
|
|
224
|
+
epsilon = 2 ** -10
|
|
222
225
|
kernel_src += "#pragma OPENCL EXTENSION cl_khr_fp16 : enable\n"
|
|
223
226
|
kernel_src += "#define FP16 1\n"
|
|
224
227
|
kernel_src += "#define real1 half\n"
|
|
@@ -229,6 +232,7 @@ if dtype_bits <= 4:
|
|
|
229
232
|
kernel_src += "#define TWO_R1 ((half)2.0f)\n"
|
|
230
233
|
elif dtype_bits >= 6:
|
|
231
234
|
dtype = np.float64
|
|
235
|
+
epsilon = 2 ** -52
|
|
232
236
|
kernel_src += "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n"
|
|
233
237
|
kernel_src += "#define real1 double\n"
|
|
234
238
|
kernel_src += "#define qint long\n"
|
|
@@ -238,6 +242,7 @@ elif dtype_bits >= 6:
|
|
|
238
242
|
kernel_src += "#define TWO_R1 2.0\n"
|
|
239
243
|
else:
|
|
240
244
|
dtype = np.float32
|
|
245
|
+
epsilon = 2 ** -23
|
|
241
246
|
kernel_src += "#define real1 float\n"
|
|
242
247
|
kernel_src += "#define qint int\n"
|
|
243
248
|
kernel_src += "#define EPSILON FLT_EPSILON\n"
|
|
@@ -280,4 +285,4 @@ except ImportError:
|
|
|
280
285
|
IS_OPENCL_AVAILABLE = False
|
|
281
286
|
print("PyOpenCL not installed. (If you have any OpenCL accelerator devices with available ICDs, you might want to optionally install pyopencl.)")
|
|
282
287
|
|
|
283
|
-
opencl_context = OpenCLContext(compute_units, IS_OPENCL_AVAILABLE, work_group_size, dtype, max_alloc, ctx, queue, init_theta_kernel, maxcut_hamming_cdf_kernel, bootstrap_kernel, bootstrap_sparse_kernel, bootstrap_segmented_kernel, bootstrap_sparse_segmented_kernel, sample_for_solution_best_bitset_kernel, sample_for_solution_best_bitset_sparse_kernel)
|
|
288
|
+
opencl_context = OpenCLContext(compute_units, IS_OPENCL_AVAILABLE, work_group_size, dtype, epsilon, max_alloc, ctx, queue, init_theta_kernel, maxcut_hamming_cdf_kernel, bootstrap_kernel, bootstrap_sparse_kernel, bootstrap_segmented_kernel, bootstrap_sparse_segmented_kernel, sample_for_solution_best_bitset_kernel, sample_for_solution_best_bitset_sparse_kernel)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from .maxcut_tfim_util import binary_search, to_scipy_sparse_upper_triangular
|
|
1
|
+
from .maxcut_tfim_util import binary_search, opencl_context, to_scipy_sparse_upper_triangular
|
|
2
2
|
from .tsp import tsp_symmetric, tsp_symmetric_sparse, tsp_symmetric_streaming
|
|
3
3
|
from .spin_glass_solver import spin_glass_solver
|
|
4
4
|
from .spin_glass_solver_sparse import spin_glass_solver_sparse
|
|
@@ -93,6 +93,7 @@ def early_exit(G_m, partition, nodes):
|
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
def tsp_maxcut(G, k_neighbors=20, is_optimized=False, is_parallel=True, **kwargs):
|
|
96
|
+
dtype = opencl_context.dtype
|
|
96
97
|
G_m = None
|
|
97
98
|
if isinstance(G, nx.Graph):
|
|
98
99
|
nodes = list(G.nodes())
|
|
@@ -200,6 +201,7 @@ def early_exit_sparse(G_data, G_rows, G_cols, partition, nodes):
|
|
|
200
201
|
|
|
201
202
|
|
|
202
203
|
def tsp_maxcut_sparse(G, k_neighbors=20, is_optimized=False, is_parallel=True, **kwargs):
|
|
204
|
+
dtype = opencl_context.dtype
|
|
203
205
|
G_m = None
|
|
204
206
|
if isinstance(G, nx.Graph):
|
|
205
207
|
nodes = list(G.nodes())
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='7.4.
|
|
54
|
+
version='7.4.9',
|
|
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
|
|
File without changes
|
|
File without changes
|