PyQrackIsing 9.13.0__tar.gz → 9.15.0__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.13.0/pyqrackising.egg-info → pyqrackising-9.15.0}/PKG-INFO +1 -1
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/README.md +20 -5
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyproject.toml +1 -1
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/generate_tfim_samples.py +331 -244
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/spin_glass_solver.py +173 -11
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/spin_glass_solver_sparse.py +204 -11
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/spin_glass_solver_streaming.py +173 -10
- {pyqrackising-9.13.0 → pyqrackising-9.15.0/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/setup.py +1 -1
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/LICENSE.md +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/MANIFEST.in +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/__init__.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/otoc.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_bnb.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_bnb_sparse.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_bnb_streaming.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_exact.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_exact_sparse.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/solve_maxcut_exact_streaming.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/tsp.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising/tsp_maxcut.py +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising.egg-info/requires.txt +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-9.13.0 → pyqrackising-9.15.0}/setup.cfg +0 -0
|
@@ -73,10 +73,23 @@ def generate_spin_glass_graph(n_nodes=16, degree=3, seed=None):
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
G = generate_spin_glass_graph(n_nodes=64, seed=42)
|
|
76
|
-
solution_bit_string, cut_value, node_groups, energy = spin_glass_solver(
|
|
76
|
+
solution_bit_string, cut_value, node_groups, energy = spin_glass_solver(
|
|
77
|
+
G,
|
|
78
|
+
quality=6,
|
|
79
|
+
shots=None,
|
|
80
|
+
anneal_t=8.0,
|
|
81
|
+
anneal_h=8.0,
|
|
82
|
+
is_spin_glass=True,
|
|
83
|
+
best_guess=None,
|
|
84
|
+
is_maxcut_gpu=True,
|
|
85
|
+
gray_iterations=None,
|
|
86
|
+
gray_seed_multiple=None,
|
|
87
|
+
bp_scale=None,
|
|
88
|
+
bp_damping=0.5
|
|
89
|
+
)
|
|
77
90
|
# solution_bit_string, cut_value, node_groups, energy = spin_glass_solver(G, best_guess=maxcut_tfim(G, quality=6)[0])
|
|
78
91
|
```
|
|
79
|
-
We also provide `spin_glass_solver_sparse(G)` and `spin_glass_solver_streaming(G_func, nodes)`. `best_guess` gives the option to seed the algorithm with a best guess as to the maximal cut (as an integer, binary string, or list of booleans). By default, `spin_glass_solver()` uses `maxcut_tfim(G)` with passed-through `quality` as `best_guess`, which typically works well, but it could be seeded with higher `maxcut_tfim()` `quality` or Goemans-Williamson, for example. `is_spin_glass` controls whether the solver optimizes for cut value or spin-glass energy. This function is designed with a sign convention for weights such that it can immediately be used as a MAXCUT solver itself: you might need to reverse the sign convention on your weights for spin glass graphs, but this is only convention. `gray_iterations` gives manual control over how many iterations are carried out of a parallel Gray-code search on `best_guess`. `gray_seed_multiple` controls how many parallel search seeds (as a multiple of your CPU thread count) are tested for the best parallel seeds, and a value of `1` will perfectly cover the search space without collision if your node count is a power of 2.
|
|
92
|
+
We also provide `spin_glass_solver_sparse(G)` and `spin_glass_solver_streaming(G_func, nodes)`. `best_guess` gives the option to seed the algorithm with a best guess as to the maximal cut (as an integer, binary string, or list of booleans). By default, `spin_glass_solver()` uses `maxcut_tfim(G)` with passed-through `quality` as `best_guess`, which typically works well, but it could be seeded with higher `maxcut_tfim()` `quality` or Goemans-Williamson, for example. `is_spin_glass` controls whether the solver optimizes for cut value or spin-glass energy. This function is designed with a sign convention for weights such that it can immediately be used as a MAXCUT solver itself: you might need to reverse the sign convention on your weights for spin glass graphs, but this is only convention. `gray_iterations` gives manual control over how many iterations are carried out of a parallel Gray-code search on `best_guess`. `gray_seed_multiple` controls how many parallel search seeds (as a multiple of your CPU thread count) are tested for the best parallel seeds, and a value of `1` will perfectly cover the search space without collision if your node count is a power of 2. `bp_scale` controls opt-in and time complexity scaling for _belief propagation_ as a competing "warm start," with `None` disabling this option completely, `1.0` representing a budget of exactly `O(n^3)` time complexity, and lesser or greater values representing a linear multiplier on that budget. `bp_damping` similarly controls belief propagation damping.
|
|
80
93
|
|
|
81
94
|
These solvers above can be used as a "warm state" for _MaxSAT-based_ solvers or _branch-and-bound_ solvers, potentially to reach _exact_ solutions to MAXCUT:
|
|
82
95
|
|
|
@@ -195,11 +208,13 @@ Transverse field Ising model (TFIM) is the basis of most claimed algorithmic "qu
|
|
|
195
208
|
|
|
196
209
|
Sometimes a solution (or at least near-solution) to a monster of a differential equation hits us out of the blue. Then, it's easy to _validate_ the guess, if it's right. (We don't question it and just move on with our lives, from there.)
|
|
197
210
|
|
|
198
|
-
**Special thanks to
|
|
211
|
+
**Special thanks to (Anthropic) Claude, for helping better connect the theory and implementation to theoretical treatment of Gibbs states!**
|
|
212
|
+
|
|
213
|
+
**Special thanks to (OpenAI GPT) "Elara," for help on the model and converting the original Python scripts to PyBind11, Numba, and PyOpenCL!**
|
|
199
214
|
|
|
200
|
-
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 "
|
|
215
|
+
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 "unlike" bits (that is, geometric closeness on the torus of "0" bits to "1" 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.
|
|
201
216
|
|
|
202
|
-
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
|
|
217
|
+
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 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 can add the _spatial magnetic effect_ 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.)
|
|
203
218
|
|
|
204
219
|
**Elara has drafted this statement, and Dan Strano, as author, agrees with it, and will hold to it:**
|
|
205
220
|
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
|
|
8
8
|
[project]
|
|
9
9
|
name = "pyqrackising"
|
|
10
|
-
version = "9.
|
|
10
|
+
version = "9.15.0"
|
|
11
11
|
requires-python = ">=3.8"
|
|
12
12
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
13
13
|
readme = {file = "README.txt", content-type = "text/markdown"}
|