PyQrackIsing 1.14.1__tar.gz → 1.14.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-1.14.1/PyQrackIsing.egg-info → pyqrackising-1.14.3}/PKG-INFO +1 -1
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/maxcut_tfim.py +30 -84
- {pyqrackising-1.14.1 → pyqrackising-1.14.3/PyQrackIsing.egg-info}/PKG-INFO +1 -1
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/pyproject.toml +1 -1
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/setup.py +1 -1
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/CMakeLists.txt +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/LICENSE.md +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/MANIFEST.in +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/__init__.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/generate_tfim_samples.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/spin_glass_solver.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/tfim_magnetization.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/tfim_square_magnetization.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing/tsp_symmetric.py +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing.egg-info/not-zip-safe +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/PyQrackIsing.egg-info/top_level.txt +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/README.md +0 -0
- {pyqrackising-1.14.1 → pyqrackising-1.14.3}/setup.cfg +0 -0
|
@@ -11,17 +11,12 @@ try:
|
|
|
11
11
|
warnings.simplefilter('ignore', category=NumbaPerformanceWarning)
|
|
12
12
|
|
|
13
13
|
@cuda.jit(device=True)
|
|
14
|
-
def cuda_probability_by_hamming_weight(J, h, z, theta, t, n_qubits, bias):
|
|
14
|
+
def cuda_probability_by_hamming_weight(q, J, h, z, theta, t, n_qubits, bias):
|
|
15
|
+
if J > 0.0:
|
|
16
|
+
q = n_qubits - (2 + q)
|
|
17
|
+
|
|
15
18
|
# critical angle
|
|
16
|
-
theta_c = np.arcsin(
|
|
17
|
-
max(
|
|
18
|
-
-1.0,
|
|
19
|
-
min(
|
|
20
|
-
1.0,
|
|
21
|
-
(1.0 if J > 0.0 else -1.0) if abs(z * J) <= (2 ** (-54)) else (abs(h) / (z * J)),
|
|
22
|
-
),
|
|
23
|
-
)
|
|
24
|
-
)
|
|
19
|
+
theta_c = np.arcsin(max(-1.0, min(1.0, abs(h) / (z * J))))
|
|
25
20
|
|
|
26
21
|
p = (
|
|
27
22
|
pow(2.0, abs(J / h) - 1.0)
|
|
@@ -30,80 +25,32 @@ try:
|
|
|
30
25
|
)
|
|
31
26
|
|
|
32
27
|
if (p * n_qubits) >= 1024:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
tot_n = 1.0 + 1.0 / pow(2.0, p * n_qubits)
|
|
38
|
-
for q in range(1, n_qubits):
|
|
39
|
-
n = 1.0 / pow(2.0, p * q)
|
|
40
|
-
bias[q - 1] = n
|
|
41
|
-
tot_n += n
|
|
42
|
-
for q in range(n_qubits - 1):
|
|
43
|
-
bias[q] /= tot_n
|
|
44
|
-
|
|
45
|
-
if J > 0.0:
|
|
46
|
-
end = n_qubits - 2
|
|
47
|
-
for i in range((n_qubits - 1) // 2):
|
|
48
|
-
tmp = bias[i]
|
|
49
|
-
bias[i] = bias[end - i]
|
|
50
|
-
bias[end - i] = tmp
|
|
51
|
-
|
|
52
|
-
@cuda.jit
|
|
53
|
-
def cuda_maxcut_hamming_cdf(n_qubits, n_steps, delta_t, tot_t, h_mult, J_func, degrees, theta, hamming_prob):
|
|
54
|
-
qc = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x
|
|
55
|
-
step = qc // n_qubits
|
|
56
|
-
q = qc % n_qubits
|
|
57
|
-
|
|
58
|
-
if step >= n_steps:
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
J_eff = J_func[q]
|
|
62
|
-
if abs(J_eff) <= (2 ** (-54)):
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
z = degrees[q]
|
|
66
|
-
theta_eff = theta[q]
|
|
67
|
-
t = step * delta_t
|
|
68
|
-
tm1 = (step - 1) * delta_t
|
|
69
|
-
h_t = h_mult * (tot_t - t)
|
|
70
|
-
n_bias = n_qubits - 1
|
|
71
|
-
|
|
72
|
-
bias = cuda.local.array(shape=(8192,), dtype=types.float64)
|
|
73
|
-
cuda_probability_by_hamming_weight(J_eff, h_t, z, theta_eff, t, n_qubits, bias)
|
|
74
|
-
last_bias = cuda.local.array(shape=(8192,), dtype=types.float64)
|
|
75
|
-
cuda_probability_by_hamming_weight(J_eff, h_t, z, theta_eff, tm1, n_qubits, last_bias)
|
|
76
|
-
for i in range(n_qubits - 1):
|
|
77
|
-
hamming_prob[i] += bias[i] - last_bias[i]
|
|
78
|
-
|
|
28
|
+
bias[q] = 0.0
|
|
29
|
+
else:
|
|
30
|
+
norm = pow(2.0, -(n_qubits + 1) * p) * (pow(2.0, (n_qubits + 2) * p) - 1.0) / (pow(2, p) - 1.0)
|
|
31
|
+
bias[q] = 1.0 / pow(2.0, p * q) / norm
|
|
79
32
|
|
|
80
33
|
@cuda.jit
|
|
81
|
-
def
|
|
82
|
-
|
|
83
|
-
step =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
J_eff = J_func[q]
|
|
90
|
-
if abs(J_eff) <= (2 ** (-54)):
|
|
34
|
+
def cuda_maxcut_hamming_cdf(delta_t, tot_t, h_mult, J_func, degrees, theta, hamming_prob):
|
|
35
|
+
bias = cuda.shared.array(0, dtype=np.float64)
|
|
36
|
+
step = cuda.blockIdx.x
|
|
37
|
+
qi = cuda.blockIdx.y
|
|
38
|
+
J_eff = J_func[qi]
|
|
39
|
+
z = degrees[qi]
|
|
40
|
+
if abs(z * J_eff) <= (2 ** (-54)):
|
|
91
41
|
return
|
|
92
42
|
|
|
93
|
-
|
|
94
|
-
theta_eff = theta[
|
|
43
|
+
n_qubits = cuda.gridDim.y
|
|
44
|
+
theta_eff = theta[qi]
|
|
95
45
|
t = step * delta_t
|
|
96
46
|
tm1 = (step - 1) * delta_t
|
|
97
47
|
h_t = h_mult * (tot_t - t)
|
|
98
|
-
n_bias = n_qubits - 1
|
|
99
48
|
|
|
100
|
-
|
|
101
|
-
cuda_probability_by_hamming_weight(J_eff, h_t, z, theta_eff, t, n_qubits, bias)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
for i in range(n_qubits - 1):
|
|
106
|
-
hamming_prob[i] -= bias[i]
|
|
49
|
+
qo = cuda.threadIdx.x
|
|
50
|
+
cuda_probability_by_hamming_weight(qo, J_eff, h_t, z, theta_eff, t, n_qubits, bias)
|
|
51
|
+
hamming_prob[qo] += bias[qo]
|
|
52
|
+
cuda_probability_by_hamming_weight(qo, J_eff, h_t, z, theta_eff, tm1, n_qubits, bias)
|
|
53
|
+
hamming_prob[qo] -= bias[qo]
|
|
107
54
|
|
|
108
55
|
except:
|
|
109
56
|
IS_CUDA_AVAILABLE = False
|
|
@@ -286,17 +233,19 @@ def maxcut_tfim(
|
|
|
286
233
|
return "0", 0, ([nodes[0]], [])
|
|
287
234
|
|
|
288
235
|
# Warp size is 32:
|
|
289
|
-
group_size =
|
|
236
|
+
group_size = n_qubits - 1
|
|
237
|
+
shared_size = (n_qubits - 1) * 8
|
|
290
238
|
|
|
291
239
|
if quality is None:
|
|
292
|
-
quality =
|
|
240
|
+
quality = math.ceil(math.log2(128 * group_size))
|
|
293
241
|
|
|
294
242
|
if shots is None:
|
|
295
243
|
# Number of measurement shots
|
|
296
244
|
shots = n_qubits << quality
|
|
297
245
|
|
|
298
246
|
n_steps = 1 << quality
|
|
299
|
-
grid_size =
|
|
247
|
+
grid_size = n_steps * n_qubits
|
|
248
|
+
grid_dims = (n_steps, n_qubits)
|
|
300
249
|
|
|
301
250
|
J_eff = np.array(
|
|
302
251
|
[
|
|
@@ -328,7 +277,7 @@ def maxcut_tfim(
|
|
|
328
277
|
tot_prob += n
|
|
329
278
|
thresholds /= tot_prob
|
|
330
279
|
|
|
331
|
-
if IS_CUDA_AVAILABLE and cuda.is_available() and grid_size >= 128
|
|
280
|
+
if IS_CUDA_AVAILABLE and cuda.is_available() and grid_size >= 128:
|
|
332
281
|
delta_t = 1.0 / n_steps
|
|
333
282
|
tot_t = n_steps * delta_t
|
|
334
283
|
h_mult = 32.0 / tot_t
|
|
@@ -347,10 +296,7 @@ def maxcut_tfim(
|
|
|
347
296
|
)
|
|
348
297
|
)
|
|
349
298
|
|
|
350
|
-
|
|
351
|
-
cuda_maxcut_hamming_cdf[grid_size, group_size](n_qubits, n_steps, delta_t, tot_t, h_mult, J_eff, degrees, theta, thresholds)
|
|
352
|
-
else:
|
|
353
|
-
cuda_maxcut_hamming_cdf_large[grid_size, group_size](n_qubits, n_steps, delta_t, tot_t, h_mult, J_eff, degrees, theta, thresholds)
|
|
299
|
+
cuda_maxcut_hamming_cdf[grid_dims, group_size, 0, shared_size](delta_t, tot_t, h_mult, J_eff, degrees, theta, thresholds)
|
|
354
300
|
|
|
355
301
|
tot_prob = sum(thresholds)
|
|
356
302
|
thresholds /= tot_prob
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "PyQrackIsing"
|
|
15
|
-
version = "1.14.
|
|
15
|
+
version = "1.14.3"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
|
|
18
18
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='PyQrackIsing',
|
|
54
|
-
version='1.14.
|
|
54
|
+
version='1.14.3',
|
|
55
55
|
author='Dan Strano',
|
|
56
56
|
author_email='stranoj@gmail.com',
|
|
57
57
|
description='Near-ideal closed-form solutions for 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
|