PyQrackIsing 8.2.1__tar.gz → 8.2.2__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-8.2.1/pyqrackising.egg-info → pyqrackising-8.2.2}/PKG-INFO +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyproject.toml +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim.py +3 -4
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_sparse.py +3 -4
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_streaming.py +3 -4
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/maxcut_tfim_util.py +10 -11
- {pyqrackising-8.2.1 → pyqrackising-8.2.2/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/setup.py +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/CMakeLists.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/LICENSE.md +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/MANIFEST.in +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/README.md +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/__init__.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/tsp.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.2}/setup.cfg +0 -0
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "8.2.
|
|
15
|
+
version = "8.2.2"
|
|
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"}
|
|
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import get_cut, maxcut_hamming_cdf, opencl_context
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
epsilon = opencl_context.epsilon
|
|
11
|
-
dtype = opencl_context.dtype
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
@njit
|
|
@@ -140,7 +139,7 @@ def sample_for_energy(G_m, shots, thresholds, weights):
|
|
|
140
139
|
tot_init_weight = weights.sum()
|
|
141
140
|
|
|
142
141
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
143
|
-
energies = np.empty(shots, dtype=
|
|
142
|
+
energies = np.empty(shots, dtype=np.float64)
|
|
144
143
|
|
|
145
144
|
best_solution = solutions[0]
|
|
146
145
|
best_energy = float("inf")
|
|
@@ -179,7 +178,7 @@ def sample_for_cut(G_m, shots, thresholds, weights):
|
|
|
179
178
|
tot_init_weight = weights.sum()
|
|
180
179
|
|
|
181
180
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
182
|
-
cuts = np.empty(shots, dtype=
|
|
181
|
+
cuts = np.empty(shots, dtype=np.float64)
|
|
183
182
|
|
|
184
183
|
best_solution = solutions[0]
|
|
185
184
|
best_cut = -float("inf")
|
|
@@ -214,7 +213,7 @@ def sample_for_cut(G_m, shots, thresholds, weights):
|
|
|
214
213
|
def init_J_and_z(G_m):
|
|
215
214
|
n_qubits = len(G_m)
|
|
216
215
|
degrees = np.empty(n_qubits, dtype=np.uint32)
|
|
217
|
-
J_eff = np.empty(n_qubits, dtype=
|
|
216
|
+
J_eff = np.empty(n_qubits, dtype=np.float64)
|
|
218
217
|
for n in prange(n_qubits):
|
|
219
218
|
degree = sum(G_m[n] != 0.0)
|
|
220
219
|
J = (-G_m[n].sum() / degree) if degree > 0 else 0
|
|
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import binary_search, get_cut, maxcut_hamming_cdf, opencl
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
epsilon = opencl_context.epsilon
|
|
11
|
-
dtype = opencl_context.dtype
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
@njit
|
|
@@ -152,7 +151,7 @@ def sample_for_energy(G_data, G_rows, G_cols, shots, thresholds, weights):
|
|
|
152
151
|
tot_init_weight = weights.sum()
|
|
153
152
|
|
|
154
153
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
155
|
-
energies = np.empty(shots, dtype=
|
|
154
|
+
energies = np.empty(shots, dtype=np.float64)
|
|
156
155
|
|
|
157
156
|
best_solution = solutions[0]
|
|
158
157
|
best_energy = float("inf")
|
|
@@ -191,7 +190,7 @@ def sample_for_cut(G_data, G_rows, G_cols, shots, thresholds, weights):
|
|
|
191
190
|
tot_init_weight = weights.sum()
|
|
192
191
|
|
|
193
192
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
194
|
-
cuts = np.empty(shots, dtype=
|
|
193
|
+
cuts = np.empty(shots, dtype=np.float64)
|
|
195
194
|
|
|
196
195
|
best_solution = solutions[0]
|
|
197
196
|
best_cut = -float("inf")
|
|
@@ -226,7 +225,7 @@ def sample_for_cut(G_data, G_rows, G_cols, shots, thresholds, weights):
|
|
|
226
225
|
def init_J_and_z(G_data, G_rows, G_cols):
|
|
227
226
|
n_qubits = G_rows.shape[0] - 1
|
|
228
227
|
degrees = np.zeros(n_qubits, dtype=np.uint32)
|
|
229
|
-
J_eff = np.zeros(n_qubits, dtype=
|
|
228
|
+
J_eff = np.zeros(n_qubits, dtype=np.float64)
|
|
230
229
|
for r in prange(n_qubits):
|
|
231
230
|
# Row sum
|
|
232
231
|
start = G_rows[r]
|
|
@@ -8,7 +8,6 @@ from .maxcut_tfim_util import get_cut, maxcut_hamming_cdf, opencl_context
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
epsilon = opencl_context.epsilon
|
|
11
|
-
dtype = opencl_context.dtype
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
@njit
|
|
@@ -139,7 +138,7 @@ def sample_for_energy(G_func, nodes, max_edge, shots, thresholds, degrees_sum, w
|
|
|
139
138
|
tot_init_weight = weights.sum()
|
|
140
139
|
|
|
141
140
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
142
|
-
energies = np.empty(shots, dtype=
|
|
141
|
+
energies = np.empty(shots, dtype=np.float64)
|
|
143
142
|
|
|
144
143
|
best_solution = solutions[0]
|
|
145
144
|
best_energy = float("inf")
|
|
@@ -176,7 +175,7 @@ def sample_for_cut(G_func, nodes, max_edge, shots, thresholds, degrees_sum, weig
|
|
|
176
175
|
tot_init_weight = weights.sum()
|
|
177
176
|
|
|
178
177
|
solutions = np.empty((shots, n), dtype=np.bool_)
|
|
179
|
-
cuts = np.empty(shots, dtype=
|
|
178
|
+
cuts = np.empty(shots, dtype=np.float64)
|
|
180
179
|
|
|
181
180
|
best_solution = solutions[0]
|
|
182
181
|
best_cut = -float("inf")
|
|
@@ -211,7 +210,7 @@ def sample_for_cut(G_func, nodes, max_edge, shots, thresholds, degrees_sum, weig
|
|
|
211
210
|
def init_J_and_z(G_func, nodes):
|
|
212
211
|
n_qubits = len(nodes)
|
|
213
212
|
degrees = np.empty(n_qubits, dtype=np.uint32)
|
|
214
|
-
J_eff = np.empty(n_qubits, dtype=
|
|
213
|
+
J_eff = np.empty(n_qubits, dtype=np.float64)
|
|
215
214
|
G_max = -float("inf")
|
|
216
215
|
for n in prange(n_qubits):
|
|
217
216
|
degree = 0
|
|
@@ -153,7 +153,7 @@ def to_scipy_sparse_upper_triangular(G, nodes, n_nodes):
|
|
|
153
153
|
|
|
154
154
|
@njit(parallel=True)
|
|
155
155
|
def init_theta(h_mult, n_qubits, J_eff, degrees):
|
|
156
|
-
theta = np.empty(n_qubits, dtype=
|
|
156
|
+
theta = np.empty(n_qubits, dtype=np.float64)
|
|
157
157
|
h_mult = abs(h_mult)
|
|
158
158
|
for q in prange(n_qubits):
|
|
159
159
|
J = J_eff[q]
|
|
@@ -167,7 +167,7 @@ def init_theta(h_mult, n_qubits, J_eff, degrees):
|
|
|
167
167
|
@njit
|
|
168
168
|
def init_thresholds(n_qubits):
|
|
169
169
|
n_bias = n_qubits - 1
|
|
170
|
-
thresholds = np.empty(n_bias, dtype=
|
|
170
|
+
thresholds = np.empty(n_bias, dtype=np.float64)
|
|
171
171
|
tot_prob = 0
|
|
172
172
|
p = 1.0
|
|
173
173
|
if n_qubits & 1:
|
|
@@ -188,28 +188,27 @@ def init_thresholds(n_qubits):
|
|
|
188
188
|
@njit
|
|
189
189
|
def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
|
|
190
190
|
if abs(J) < epsilon:
|
|
191
|
-
return np.full(
|
|
191
|
+
return np.full(n_qubits - 1, 1.0 / (n_qubits - 1), dtype=np.float64)
|
|
192
192
|
|
|
193
193
|
ratio = max(1.0, min(-1.0, abs(h) / (z * J)))
|
|
194
194
|
theta_c = np.arcsin(ratio)
|
|
195
195
|
|
|
196
196
|
p = (
|
|
197
|
-
|
|
197
|
+
2.0 ** (abs(J / h) - 1.0)
|
|
198
198
|
* (1.0 + np.sin(theta - theta_c) * np.cos(1.5 * np.pi * J * t + theta) / (1.0 + np.sqrt(t)))
|
|
199
199
|
- 0.5
|
|
200
200
|
)
|
|
201
201
|
|
|
202
202
|
|
|
203
|
-
bias = np.empty(n_qubits - 1, dtype=
|
|
204
|
-
|
|
203
|
+
bias = np.empty(n_qubits - 1, dtype=np.float64)
|
|
204
|
+
factor = 2.0 ** -p
|
|
205
|
+
result = 1.0 / (n_qubits + 1)
|
|
206
|
+
tot_n = 0.0
|
|
205
207
|
for q in range(n_qubits - 1):
|
|
206
|
-
result
|
|
208
|
+
result *= factor
|
|
207
209
|
bias[q] = result
|
|
208
210
|
tot_n += result
|
|
209
211
|
|
|
210
|
-
if np.isnan(tot_n) or np.isinf(tot_n):
|
|
211
|
-
return np.zeros(n_qubits - 1, dtype=dtype)
|
|
212
|
-
|
|
213
212
|
if J > 0.0:
|
|
214
213
|
return bias[::-1]
|
|
215
214
|
|
|
@@ -221,7 +220,7 @@ def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
|
|
|
221
220
|
@njit(parallel=True)
|
|
222
221
|
def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, tot_t, h_mult):
|
|
223
222
|
if n_qubits < 2:
|
|
224
|
-
return np.full((n_qubits,), 1.0 / n_qubits, dtype=
|
|
223
|
+
return np.full((n_qubits,), 1.0 / n_qubits, dtype=np.float64)
|
|
225
224
|
|
|
226
225
|
hamming_prob = init_thresholds(n_qubits)
|
|
227
226
|
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='8.2.
|
|
54
|
+
version='8.2.2',
|
|
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
|
|
File without changes
|