PyQrackIsing 5.1.0__tar.gz → 5.1.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.
- {pyqrackising-5.1.0/pyqrackising.egg-info → pyqrackising-5.1.1}/PKG-INFO +1 -1
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyproject.toml +1 -1
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/maxcut_tfim.py +9 -19
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/maxcut_tfim_sparse.py +9 -19
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/maxcut_tfim_streaming.py +9 -19
- pyqrackising-5.1.1/pyqrackising/maxcut_tfim_util.py +32 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising.egg-info/SOURCES.txt +1 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/setup.py +1 -1
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/CMakeLists.txt +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/LICENSE.md +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/MANIFEST.in +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/README.md +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/__init__.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising/tsp.py +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-5.1.0 → pyqrackising-5.1.1}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "5.1.
|
|
15
|
+
version = "5.1.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"}
|
|
@@ -4,21 +4,11 @@ import numpy as np
|
|
|
4
4
|
import os
|
|
5
5
|
from numba import njit, prange
|
|
6
6
|
|
|
7
|
+
from .maxcut_tfim_util import opencl_context
|
|
7
8
|
|
|
8
9
|
IS_OPENCL_AVAILABLE = True
|
|
9
|
-
ctx = None
|
|
10
|
-
queue = None
|
|
11
10
|
try:
|
|
12
11
|
import pyopencl as cl
|
|
13
|
-
|
|
14
|
-
# Pick a device (GPU if available)
|
|
15
|
-
ctx = cl.create_some_context()
|
|
16
|
-
queue = cl.CommandQueue(ctx)
|
|
17
|
-
|
|
18
|
-
# Load and build OpenCL kernels
|
|
19
|
-
kernel_src = open(os.path.dirname(os.path.abspath(__file__)) + "/kernels.cl").read()
|
|
20
|
-
program = cl.Program(ctx, kernel_src).build()
|
|
21
|
-
maxcut_hamming_cdf_kernel = program.maxcut_hamming_cdf
|
|
22
12
|
except ImportError:
|
|
23
13
|
IS_OPENCL_AVAILABLE = False
|
|
24
14
|
|
|
@@ -324,20 +314,20 @@ def maxcut_tfim(
|
|
|
324
314
|
|
|
325
315
|
# Move to GPU
|
|
326
316
|
mf = cl.mem_flags
|
|
327
|
-
args_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
328
|
-
J_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
329
|
-
deg_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
330
|
-
theta_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
331
|
-
ham_buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
317
|
+
args_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
318
|
+
J_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
319
|
+
deg_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
320
|
+
theta_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
321
|
+
ham_buf = cl.Buffer(opencl_context.ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
332
322
|
|
|
333
323
|
# Kernel execution
|
|
334
|
-
maxcut_hamming_cdf_kernel(
|
|
335
|
-
queue, (grid_dim,), (group_size,),
|
|
324
|
+
opencl_context.maxcut_hamming_cdf_kernel(
|
|
325
|
+
opencl_context.queue, (grid_dim,), (group_size,),
|
|
336
326
|
np.int32(n_qubits), deg_buf, args_buf, J_buf, theta_buf, ham_buf
|
|
337
327
|
)
|
|
338
328
|
|
|
339
329
|
# Fetch results
|
|
340
|
-
cl.enqueue_copy(queue, hamming_prob, ham_buf)
|
|
330
|
+
cl.enqueue_copy(opencl_context.queue, hamming_prob, ham_buf)
|
|
341
331
|
|
|
342
332
|
hamming_prob /= hamming_prob.sum()
|
|
343
333
|
tot_prob = 0.0
|
|
@@ -4,21 +4,11 @@ import numpy as np
|
|
|
4
4
|
import os
|
|
5
5
|
from numba import njit, prange
|
|
6
6
|
|
|
7
|
+
from .maxcut_tfim_util import opencl_context
|
|
7
8
|
|
|
8
9
|
IS_OPENCL_AVAILABLE = True
|
|
9
|
-
ctx = None
|
|
10
|
-
queue = None
|
|
11
10
|
try:
|
|
12
11
|
import pyopencl as cl
|
|
13
|
-
|
|
14
|
-
# Pick a device (GPU if available)
|
|
15
|
-
ctx = cl.create_some_context()
|
|
16
|
-
queue = cl.CommandQueue(ctx)
|
|
17
|
-
|
|
18
|
-
# Load and build OpenCL kernels
|
|
19
|
-
kernel_src = open(os.path.dirname(os.path.abspath(__file__)) + "/kernels.cl").read()
|
|
20
|
-
program = cl.Program(ctx, kernel_src).build()
|
|
21
|
-
maxcut_hamming_cdf_kernel = program.maxcut_hamming_cdf
|
|
22
12
|
except ImportError:
|
|
23
13
|
IS_OPENCL_AVAILABLE = False
|
|
24
14
|
|
|
@@ -383,20 +373,20 @@ def maxcut_tfim_sparse(
|
|
|
383
373
|
|
|
384
374
|
# Move to GPU
|
|
385
375
|
mf = cl.mem_flags
|
|
386
|
-
args_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
387
|
-
J_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
388
|
-
deg_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
389
|
-
theta_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
390
|
-
ham_buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
376
|
+
args_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
377
|
+
J_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
378
|
+
deg_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
379
|
+
theta_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
380
|
+
ham_buf = cl.Buffer(opencl_context.ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
391
381
|
|
|
392
382
|
# Kernel execution
|
|
393
|
-
maxcut_hamming_cdf_kernel(
|
|
394
|
-
queue, (grid_dim,), (group_size,),
|
|
383
|
+
opencl_context.maxcut_hamming_cdf_kernel(
|
|
384
|
+
opencl_context.queue, (grid_dim,), (group_size,),
|
|
395
385
|
np.int32(n_qubits), deg_buf, args_buf, J_buf, theta_buf, ham_buf
|
|
396
386
|
)
|
|
397
387
|
|
|
398
388
|
# Fetch results
|
|
399
|
-
cl.enqueue_copy(queue, hamming_prob, ham_buf)
|
|
389
|
+
cl.enqueue_copy(opencl_context.queue, hamming_prob, ham_buf)
|
|
400
390
|
|
|
401
391
|
hamming_prob /= hamming_prob.sum()
|
|
402
392
|
tot_prob = 0.0
|
|
@@ -4,21 +4,11 @@ import numpy as np
|
|
|
4
4
|
import os
|
|
5
5
|
from numba import njit, prange
|
|
6
6
|
|
|
7
|
+
from .maxcut_tfim_util import opencl_context
|
|
7
8
|
|
|
8
9
|
IS_OPENCL_AVAILABLE = True
|
|
9
|
-
ctx = None
|
|
10
|
-
queue = None
|
|
11
10
|
try:
|
|
12
11
|
import pyopencl as cl
|
|
13
|
-
|
|
14
|
-
# Pick a device (GPU if available)
|
|
15
|
-
ctx = cl.create_some_context()
|
|
16
|
-
queue = cl.CommandQueue(ctx)
|
|
17
|
-
|
|
18
|
-
# Load and build OpenCL kernels
|
|
19
|
-
kernel_src = open(os.path.dirname(os.path.abspath(__file__)) + "/kernels.cl").read()
|
|
20
|
-
program = cl.Program(ctx, kernel_src).build()
|
|
21
|
-
maxcut_hamming_cdf_kernel = program.maxcut_hamming_cdf
|
|
22
12
|
except ImportError:
|
|
23
13
|
IS_OPENCL_AVAILABLE = False
|
|
24
14
|
|
|
@@ -324,20 +314,20 @@ def maxcut_tfim_streaming(
|
|
|
324
314
|
|
|
325
315
|
# Move to GPU
|
|
326
316
|
mf = cl.mem_flags
|
|
327
|
-
args_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
328
|
-
J_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
329
|
-
deg_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
330
|
-
theta_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
331
|
-
ham_buf = cl.Buffer(ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
317
|
+
args_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=args)
|
|
318
|
+
J_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=J_eff)
|
|
319
|
+
deg_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=degrees)
|
|
320
|
+
theta_buf = cl.Buffer(opencl_context.ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=theta)
|
|
321
|
+
ham_buf = cl.Buffer(opencl_context.ctx, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=hamming_prob)
|
|
332
322
|
|
|
333
323
|
# Kernel execution
|
|
334
|
-
maxcut_hamming_cdf_kernel(
|
|
335
|
-
queue, (grid_dim,), (group_size,),
|
|
324
|
+
opencl_context.maxcut_hamming_cdf_kernel(
|
|
325
|
+
opencl_context.queue, (grid_dim,), (group_size,),
|
|
336
326
|
np.int32(n_qubits), deg_buf, args_buf, J_buf, theta_buf, ham_buf
|
|
337
327
|
)
|
|
338
328
|
|
|
339
329
|
# Fetch results
|
|
340
|
-
cl.enqueue_copy(queue, hamming_prob, ham_buf)
|
|
330
|
+
cl.enqueue_copy(opencl_context.queue, hamming_prob, ham_buf)
|
|
341
331
|
|
|
342
332
|
hamming_prob /= hamming_prob.sum()
|
|
343
333
|
tot_prob = 0.0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import networkx as nx
|
|
3
|
+
import numpy as np
|
|
4
|
+
import os
|
|
5
|
+
from numba import njit, prange
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OpenCLContext:
|
|
9
|
+
def __init__(self, a, c, q, k):
|
|
10
|
+
self.IS_OPENCL_AVAILABLE = a
|
|
11
|
+
self.ctx = c
|
|
12
|
+
self.queue = q
|
|
13
|
+
self.maxcut_hamming_cdf_kernel = k
|
|
14
|
+
|
|
15
|
+
IS_OPENCL_AVAILABLE = True
|
|
16
|
+
ctx = None
|
|
17
|
+
queue = None
|
|
18
|
+
try:
|
|
19
|
+
import pyopencl as cl
|
|
20
|
+
|
|
21
|
+
# Pick a device (GPU if available)
|
|
22
|
+
ctx = cl.create_some_context()
|
|
23
|
+
queue = cl.CommandQueue(ctx)
|
|
24
|
+
|
|
25
|
+
# Load and build OpenCL kernels
|
|
26
|
+
kernel_src = open(os.path.dirname(os.path.abspath(__file__)) + "/kernels.cl").read()
|
|
27
|
+
program = cl.Program(ctx, kernel_src).build()
|
|
28
|
+
maxcut_hamming_cdf_kernel = program.maxcut_hamming_cdf
|
|
29
|
+
except ImportError:
|
|
30
|
+
IS_OPENCL_AVAILABLE = False
|
|
31
|
+
|
|
32
|
+
opencl_context = OpenCLContext(IS_OPENCL_AVAILABLE, ctx, queue, maxcut_hamming_cdf_kernel)
|
|
@@ -11,6 +11,7 @@ pyqrackising/kernels.cl
|
|
|
11
11
|
pyqrackising/maxcut_tfim.py
|
|
12
12
|
pyqrackising/maxcut_tfim_sparse.py
|
|
13
13
|
pyqrackising/maxcut_tfim_streaming.py
|
|
14
|
+
pyqrackising/maxcut_tfim_util.py
|
|
14
15
|
pyqrackising/spin_glass_solver.py
|
|
15
16
|
pyqrackising/spin_glass_solver_sparse.py
|
|
16
17
|
pyqrackising/spin_glass_solver_streaming.py
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='5.1.
|
|
54
|
+
version='5.1.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
|
|
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
|