PyQrackIsing 8.2.1__tar.gz → 8.2.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-8.2.1/pyqrackising.egg-info → pyqrackising-8.2.3}/PKG-INFO +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyproject.toml +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/maxcut_tfim.py +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/maxcut_tfim_sparse.py +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/maxcut_tfim_streaming.py +2 -2
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/maxcut_tfim_util.py +13 -12
- {pyqrackising-8.2.1 → pyqrackising-8.2.3/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/setup.py +1 -1
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/CMakeLists.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/LICENSE.md +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/MANIFEST.in +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/README.md +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/__init__.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/tsp.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.3}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-8.2.1 → pyqrackising-8.2.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 = "8.2.
|
|
15
|
+
version = "8.2.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"}
|
|
@@ -214,7 +214,7 @@ def sample_for_cut(G_m, shots, thresholds, weights):
|
|
|
214
214
|
def init_J_and_z(G_m):
|
|
215
215
|
n_qubits = len(G_m)
|
|
216
216
|
degrees = np.empty(n_qubits, dtype=np.uint32)
|
|
217
|
-
J_eff = np.empty(n_qubits, dtype=
|
|
217
|
+
J_eff = np.empty(n_qubits, dtype=np.float64)
|
|
218
218
|
for n in prange(n_qubits):
|
|
219
219
|
degree = sum(G_m[n] != 0.0)
|
|
220
220
|
J = (-G_m[n].sum() / degree) if degree > 0 else 0
|
|
@@ -226,7 +226,7 @@ def sample_for_cut(G_data, G_rows, G_cols, shots, thresholds, weights):
|
|
|
226
226
|
def init_J_and_z(G_data, G_rows, G_cols):
|
|
227
227
|
n_qubits = G_rows.shape[0] - 1
|
|
228
228
|
degrees = np.zeros(n_qubits, dtype=np.uint32)
|
|
229
|
-
J_eff = np.zeros(n_qubits, dtype=
|
|
229
|
+
J_eff = np.zeros(n_qubits, dtype=np.float64)
|
|
230
230
|
for r in prange(n_qubits):
|
|
231
231
|
# Row sum
|
|
232
232
|
start = G_rows[r]
|
|
@@ -31,7 +31,7 @@ def local_repulsion_choice(G_func, nodes, max_edge, weights, tot_init_weight, n,
|
|
|
31
31
|
- High-degree nodes are already less likely
|
|
32
32
|
- After choosing a node, its neighbors' probabilities are further reduced
|
|
33
33
|
adjacency_data, adjacency_rows: CSR-format sparse adjacency data
|
|
34
|
-
weights:
|
|
34
|
+
weights: float array of shape (n,)
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
37
|
weights = weights.copy()
|
|
@@ -211,7 +211,7 @@ def sample_for_cut(G_func, nodes, max_edge, shots, thresholds, degrees_sum, weig
|
|
|
211
211
|
def init_J_and_z(G_func, nodes):
|
|
212
212
|
n_qubits = len(nodes)
|
|
213
213
|
degrees = np.empty(n_qubits, dtype=np.uint32)
|
|
214
|
-
J_eff = np.empty(n_qubits, dtype=
|
|
214
|
+
J_eff = np.empty(n_qubits, dtype=np.float64)
|
|
215
215
|
G_max = -float("inf")
|
|
216
216
|
for n in prange(n_qubits):
|
|
217
217
|
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,40 +188,41 @@ 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
|
|
211
|
-
|
|
212
|
+
if (tot_n == 0.0) or np.isnan(tot_n):
|
|
213
|
+
print("[WARN]: probability_by_hamming_weight() went below maximum precision.")
|
|
214
|
+
return np.full(n_qubits - 1, 1.0 / (n_qubits - 1), dtype=np.float64)
|
|
212
215
|
|
|
213
216
|
if J > 0.0:
|
|
214
217
|
return bias[::-1]
|
|
215
218
|
|
|
216
|
-
tot_n += result
|
|
217
|
-
|
|
218
219
|
return bias
|
|
219
220
|
|
|
220
221
|
|
|
221
222
|
@njit(parallel=True)
|
|
222
223
|
def maxcut_hamming_cdf(n_qubits, J_func, degrees, quality, tot_t, h_mult):
|
|
223
224
|
if n_qubits < 2:
|
|
224
|
-
return np.full((n_qubits,), 1.0 / n_qubits, dtype=
|
|
225
|
+
return np.full((n_qubits,), 1.0 / n_qubits, dtype=np.float64)
|
|
225
226
|
|
|
226
227
|
hamming_prob = init_thresholds(n_qubits)
|
|
227
228
|
|
|
@@ -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.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|