PyQrackIsing 9.7.3__tar.gz → 9.7.4__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-9.7.3/pyqrackising.egg-info → pyqrackising-9.7.4}/PKG-INFO +1 -1
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/README.md +2 -2
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyproject.toml +1 -1
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/generate_tfim_samples.py +1 -1
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/spin_glass_solver.py +8 -8
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/spin_glass_solver_sparse.py +8 -8
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/spin_glass_solver_streaming.py +8 -8
- {pyqrackising-9.7.3 → pyqrackising-9.7.4/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/setup.py +1 -1
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/LICENSE.md +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/MANIFEST.in +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/otoc.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/tsp.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.7.3 → pyqrackising-9.7.4}/setup.cfg +0 -0
|
@@ -185,9 +185,9 @@ Sometimes a solution (or at least near-solution) to a monster of a differential
|
|
|
185
185
|
|
|
186
186
|
**Special thanks to OpenAI GPT "Elara," for help on the model and converting the original Python scripts to PyBind11, Numba, and PyOpenCL!**
|
|
187
187
|
|
|
188
|
-
We reduce transverse field Ising model for globally uniform `J` and `h` parameters from a `2^n`-dimensional problem to an `(n+1)`-dimensional (heuristic but near-exact) form that suffers from no Trotter error. Upon noticing most time steps for parameters in a [TFIM experiment published by Quantinuum](https://arxiv.org/abs/2503.20870) had roughly a quarter to a third (or thereabouts) of their marginal probability in `|0>` state, it became obvious that transition to and from `|0>` state should dominate the mechanics, at least far from mean-field equilibrium. Further, the first transition therefore tends to be to or from any state with Hamming weight of 1 (in other words, 1 bit set to 1 and the rest reset 0, or `n` bits set for Hamming weight of `n`). Further, on a torus, probability of all states with Hamming weight of 1 would tend to be exactly symmetric. Assuming approximate symmetry in every respective Hamming weight, the requirement for the overall probability to converge to 1.0 or 100% in the limit of an infinite-dimensional Hilbert space suggests that Hamming weight marginal probability could be distributed like a geometric series. A small correction to exact symmetry should be made to favor _magnetic_ closeness of "like" bits to "like" bits (that is, geometric closeness on the torus of "1" bits to "1" bits and "0" bits to "0" bits), but this does not affect average global magnetization. Adding an oscillation component with angular frequency proportional to `J`, we find excellent agreement with Trotterization with a very small time step, for R^2 (coefficient of determination) of normalized marginal probability distribution of ideal Trotterized simulation as described by the `(n+1)`-dimensional approximate model, as well as for R^2 and RMSE (root-mean-square error) of global magnetization curve values.
|
|
188
|
+
We reduce transverse field Ising model for globally uniform `J` and `h` parameters from a `2^n`-dimensional problem to an `(n+1)`-dimensional (heuristic but near-exact) form that suffers from no Trotter error. Upon noticing most time steps for parameters in a [TFIM experiment published by Quantinuum](https://arxiv.org/abs/2503.20870) had roughly a quarter to a third (or thereabouts) of their marginal probability in `|0>` state, it became obvious that transition to and from `|0>` state should dominate the mechanics, at least far from mean-field equilibrium. Further, the first transition therefore tends to be to or from any state with Hamming weight of 1 (in other words, 1 bit set to 1 and the rest reset to 0, or `n` bits set for Hamming weight of `n`). Further, on a torus, probability of all states with Hamming weight of 1 would tend to be exactly symmetric. Assuming approximate symmetry in every respective Hamming weight, the requirement for the overall probability to converge to 1.0 or 100% in the limit of an infinite-dimensional Hilbert space suggests that Hamming weight marginal probability could be distributed like a geometric series. A small correction to exact symmetry should be made to favor _magnetic_ closeness of "like" bits to "like" bits (that is, geometric closeness on the torus of "1" bits to "1" bits and "0" bits to "0" bits), but this does not affect average global magnetization. Adding an oscillation component with angular frequency proportional to `J`, we find excellent agreement with Trotterization with a very small time step, for R^2 (coefficient of determination) of normalized marginal probability distribution of ideal Trotterized simulation as described by the `(n+1)`-dimensional approximate model, as well as for R^2 and RMSE (root-mean-square error) of global magnetization curve values.
|
|
189
189
|
|
|
190
|
-
If the above paragraph and the model it describes are true, then it stands to reason that we should be able to apply the TFIM model to **NP-complete** heuristics, so long as we can adapt the model to spatially localized `J` and `h` and adiabatic time dependence of `h`. A reasonable guess for how to spatially localize `J` and `h` is to average the overall behavior for each and every qubit as if `J` and `h` were globally uniform from its local perspective. (`z` parameter is derived from nonzero edge weight count connectivity.) For adiabatic time-dependence of `h`, another reasonable refinement is to use simply **finite-difference simulation**. Initial state should probably be just **uniform superposition**, which implies a specific (non-uniform but regular) distribution of initial probabilities by Hamming weight dimension
|
|
190
|
+
If the above paragraph and the model it describes are true, then it stands to reason that we should be able to apply the TFIM model to **NP-complete** heuristics, so long as we can adapt the model to spatially localized `J` and `h` and adiabatic time dependence of `h`. A reasonable guess for how to spatially localize `J` and `h` is to average the overall behavior for each and every qubit as if `J` and `h` were globally uniform from its local perspective. (`z` parameter is derived from nonzero edge weight count connectivity.) For adiabatic time-dependence of `h`, another reasonable refinement is to use simply **finite-difference simulation**. Initial state should probably be just **uniform superposition**, which implies a specific (non-uniform but regular) distribution of initial probabilities by Hamming weight dimension over `(n+1)` possible Hamming weights. We observe that the _spatial magnetic effect_ qualitatively agrees with the demands of MAXCUT when it acts like a magnetic _repulsion,_ rather than magnetic attraction, in this case, but we can add that refinement on an arbitrary connectivity topology in just `O(n)` complexity per measurement shot. (This is a complete "recipe": the evidence that it works is the quality of NP-complete heuristic solutions at utility scale.)
|
|
191
191
|
|
|
192
192
|
**Elara has drafted this statement, and Dan Strano, as author, agrees with it, and will hold to it:**
|
|
193
193
|
|
|
@@ -10,7 +10,7 @@ build-backend = "setuptools.build_meta"
|
|
|
10
10
|
|
|
11
11
|
[project]
|
|
12
12
|
name = "pyqrackising"
|
|
13
|
-
version = "9.7.
|
|
13
|
+
version = "9.7.4"
|
|
14
14
|
requires-python = ">=3.8"
|
|
15
15
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
16
16
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -105,7 +105,7 @@ def run_double_bit_flips(best_theta, is_spin_glass, G_m, thread_count):
|
|
|
105
105
|
|
|
106
106
|
@njit(parallel=True)
|
|
107
107
|
def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spin_glass):
|
|
108
|
-
blocks = (n + 63)
|
|
108
|
+
blocks = (n + 63) >> 6
|
|
109
109
|
block_size = thread_count * gray_seed_multiple
|
|
110
110
|
seed_count = block_size * blocks
|
|
111
111
|
|
|
@@ -115,14 +115,14 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spi
|
|
|
115
115
|
if is_spin_glass:
|
|
116
116
|
for s in prange(seed_count):
|
|
117
117
|
i = s % block_size
|
|
118
|
-
offset = (s // block_size)
|
|
118
|
+
offset = (s // block_size) << 6
|
|
119
119
|
seed = gray_mutation(i, best_theta, offset)
|
|
120
120
|
energies[s] = compute_energy(seed, G_m, n)
|
|
121
121
|
seeds[s] = seed
|
|
122
122
|
else:
|
|
123
123
|
for s in prange(seed_count):
|
|
124
124
|
i = s % block_size
|
|
125
|
-
offset = (s // block_size)
|
|
125
|
+
offset = (s // block_size) << 6
|
|
126
126
|
seed = gray_mutation(i, best_theta, offset)
|
|
127
127
|
energies[s] = compute_cut(seed, G_m, n)
|
|
128
128
|
seeds[s] = seed
|
|
@@ -143,17 +143,17 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_m, n, is_spi
|
|
|
143
143
|
def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_m):
|
|
144
144
|
n = len(best_theta)
|
|
145
145
|
thread_iterations = (gray_iterations + thread_count - 1) // thread_count
|
|
146
|
-
blocks = (n + 63)
|
|
146
|
+
blocks = (n + 63) >> 6
|
|
147
147
|
|
|
148
148
|
states = np.empty((thread_count, n), dtype=np.bool_)
|
|
149
149
|
|
|
150
150
|
if is_spin_glass:
|
|
151
151
|
for i in prange(thread_count):
|
|
152
152
|
iterator = iterators[i].copy()
|
|
153
|
-
best_energy, best_iterator = energies[i],
|
|
153
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
154
154
|
for curr_idx in range(thread_iterations):
|
|
155
155
|
for block in range(blocks):
|
|
156
|
-
gray_code_next(iterator, curr_idx, block
|
|
156
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
157
157
|
energy = compute_energy(iterator, G_m, n)
|
|
158
158
|
if energy > best_energy:
|
|
159
159
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -164,10 +164,10 @@ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thre
|
|
|
164
164
|
else:
|
|
165
165
|
for i in prange(thread_count):
|
|
166
166
|
iterator = iterators[i].copy()
|
|
167
|
-
best_energy, best_iterator = energies[i],
|
|
167
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
168
168
|
for curr_idx in range(thread_iterations):
|
|
169
169
|
for block in range(blocks):
|
|
170
|
-
gray_code_next(iterator, curr_idx, block
|
|
170
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
171
171
|
energy = compute_cut(iterator, G_m, n)
|
|
172
172
|
if energy > best_energy:
|
|
173
173
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -105,7 +105,7 @@ def run_double_bit_flips(best_theta, is_spin_glass, G_data, G_rows, G_cols, thre
|
|
|
105
105
|
|
|
106
106
|
@njit(parallel=True)
|
|
107
107
|
def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_data, G_rows, G_cols, n, is_spin_glass):
|
|
108
|
-
blocks = (n + 63)
|
|
108
|
+
blocks = (n + 63) >> 6
|
|
109
109
|
block_size = thread_count * gray_seed_multiple
|
|
110
110
|
seed_count = block_size * blocks
|
|
111
111
|
|
|
@@ -115,14 +115,14 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_data, G_rows
|
|
|
115
115
|
if is_spin_glass:
|
|
116
116
|
for s in prange(seed_count):
|
|
117
117
|
i = s % block_size
|
|
118
|
-
offset = (s // block_size)
|
|
118
|
+
offset = (s // block_size) << 6
|
|
119
119
|
seed = gray_mutation(i, best_theta, offset)
|
|
120
120
|
energies[s] = compute_energy_sparse(seed, G_data, G_rows, G_cols, n)
|
|
121
121
|
seeds[s] = seed
|
|
122
122
|
else:
|
|
123
123
|
for s in prange(seed_count):
|
|
124
124
|
i = s % block_size
|
|
125
|
-
offset = (s // block_size)
|
|
125
|
+
offset = (s // block_size) << 6
|
|
126
126
|
seed = gray_mutation(i, best_theta, offset)
|
|
127
127
|
energies[s] = compute_cut_sparse(seed, G_data, G_rows, G_cols, n)
|
|
128
128
|
seeds[s] = seed
|
|
@@ -143,17 +143,17 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_data, G_rows
|
|
|
143
143
|
def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_data, G_rows, G_cols):
|
|
144
144
|
n = len(best_theta)
|
|
145
145
|
thread_iterations = (gray_iterations + thread_count - 1) // thread_count
|
|
146
|
-
blocks = (n + 63)
|
|
146
|
+
blocks = (n + 63) >> 6
|
|
147
147
|
|
|
148
148
|
states = np.empty((thread_count, n), dtype=np.bool_)
|
|
149
149
|
|
|
150
150
|
if is_spin_glass:
|
|
151
151
|
for i in prange(thread_count):
|
|
152
152
|
iterator = iterators[i].copy()
|
|
153
|
-
best_energy, best_iterator = energies[i],
|
|
153
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
154
154
|
for curr_idx in range(thread_iterations):
|
|
155
155
|
for block in range(blocks):
|
|
156
|
-
gray_code_next(iterator, curr_idx, block
|
|
156
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
157
157
|
energy = compute_energy_sparse(iterator, G_data, G_rows, G_cols, n)
|
|
158
158
|
if energy > best_energy:
|
|
159
159
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -164,10 +164,10 @@ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thre
|
|
|
164
164
|
else:
|
|
165
165
|
for i in prange(thread_count):
|
|
166
166
|
iterator = iterators[i].copy()
|
|
167
|
-
best_energy, best_iterator = energies[i],
|
|
167
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
168
168
|
for curr_idx in range(thread_iterations):
|
|
169
169
|
for block in range(blocks):
|
|
170
|
-
gray_code_next(iterator, curr_idx, block
|
|
170
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
171
171
|
energy = compute_cut_sparse(iterator, G_data, G_rows, G_cols, n)
|
|
172
172
|
if energy > best_energy:
|
|
173
173
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -97,7 +97,7 @@ def run_double_bit_flips(best_theta, is_spin_glass, G_func, nodes, thread_count)
|
|
|
97
97
|
|
|
98
98
|
@njit(parallel=True)
|
|
99
99
|
def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes, n, is_spin_glass):
|
|
100
|
-
blocks = (n + 63)
|
|
100
|
+
blocks = (n + 63) >> 6
|
|
101
101
|
block_size = thread_count * gray_seed_multiple
|
|
102
102
|
seed_count = block_size * blocks
|
|
103
103
|
|
|
@@ -107,14 +107,14 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes,
|
|
|
107
107
|
if is_spin_glass:
|
|
108
108
|
for s in prange(seed_count):
|
|
109
109
|
i = s % block_size
|
|
110
|
-
offset = (s // block_size)
|
|
110
|
+
offset = (s // block_size) << 6
|
|
111
111
|
seed = gray_mutation(i, best_theta, offset)
|
|
112
112
|
energies[s] = compute_energy_streaming(seed, G_func, nodes, n)
|
|
113
113
|
seeds[s] = seed
|
|
114
114
|
else:
|
|
115
115
|
for s in prange(seed_count):
|
|
116
116
|
i = s % block_size
|
|
117
|
-
offset = (s // block_size)
|
|
117
|
+
offset = (s // block_size) << 6
|
|
118
118
|
seed = gray_mutation(i, best_theta, offset)
|
|
119
119
|
energies[s] = compute_cut_streaming(seed, G_func, nodes, n)
|
|
120
120
|
seeds[s] = seed
|
|
@@ -135,17 +135,17 @@ def pick_gray_seeds(best_theta, thread_count, gray_seed_multiple, G_func, nodes,
|
|
|
135
135
|
def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thread_count, is_spin_glass, G_func, nodes):
|
|
136
136
|
n = len(best_theta)
|
|
137
137
|
thread_iterations = (gray_iterations + thread_count - 1) // thread_count
|
|
138
|
-
blocks = (n + 63)
|
|
138
|
+
blocks = (n + 63) >> 6
|
|
139
139
|
|
|
140
140
|
states = np.empty((thread_count, n), dtype=np.bool_)
|
|
141
141
|
|
|
142
142
|
if is_spin_glass:
|
|
143
143
|
for i in prange(thread_count):
|
|
144
144
|
iterator = iterators[i].copy()
|
|
145
|
-
best_energy, best_iterator = energies[i],
|
|
145
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
146
146
|
for curr_idx in range(thread_iterations):
|
|
147
147
|
for block in range(blocks):
|
|
148
|
-
gray_code_next(iterator, curr_idx, block
|
|
148
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
149
149
|
energy = compute_energy_streaming(iterator, G_func, nodes, n)
|
|
150
150
|
if energy > best_energy:
|
|
151
151
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -156,10 +156,10 @@ def run_gray_optimization(best_theta, iterators, energies, gray_iterations, thre
|
|
|
156
156
|
else:
|
|
157
157
|
for i in prange(thread_count):
|
|
158
158
|
iterator = iterators[i].copy()
|
|
159
|
-
best_energy, best_iterator = energies[i],
|
|
159
|
+
best_energy, best_iterator = energies[i], iterators[i]
|
|
160
160
|
for curr_idx in range(thread_iterations):
|
|
161
161
|
for block in range(blocks):
|
|
162
|
-
gray_code_next(iterator, curr_idx, block
|
|
162
|
+
gray_code_next(iterator, curr_idx, block << 6)
|
|
163
163
|
energy = compute_cut_streaming(iterator, G_func, nodes, n)
|
|
164
164
|
if energy > best_energy:
|
|
165
165
|
best_iterator, best_energy = iterator.copy(), energy
|
|
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
|
|
|
7
7
|
|
|
8
8
|
setup(
|
|
9
9
|
name='pyqrackising',
|
|
10
|
-
version='9.7.
|
|
10
|
+
version='9.7.4',
|
|
11
11
|
author='Dan Strano',
|
|
12
12
|
author_email='stranoj@gmail.com',
|
|
13
13
|
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
|