PyQrackIsing 1.10.5__tar.gz → 1.10.6__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.10.5/PyQrackIsing.egg-info → pyqrackising-1.10.6}/PKG-INFO +1 -1
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/_pyqrack_ising.cpp +1 -50
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/maxcut_tfim.py +18 -14
- {pyqrackising-1.10.5 → pyqrackising-1.10.6/PyQrackIsing.egg-info}/PKG-INFO +1 -1
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/pyproject.toml +1 -1
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/setup.py +1 -1
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/CMakeLists.txt +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/LICENSE.md +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/MANIFEST.in +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/__init__.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/generate_tfim_samples.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/spin_glass_solver.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/tfim_magnetization.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/tfim_square_magnetization.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing/tsp_symmetric.py +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing.egg-info/not-zip-safe +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/PyQrackIsing.egg-info/top_level.txt +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/README.md +0 -0
- {pyqrackising-1.10.5 → pyqrackising-1.10.6}/setup.cfg +0 -0
|
@@ -27,7 +27,7 @@ std::random_device rd = std::random_device{};
|
|
|
27
27
|
std::mt19937 rng(rd());
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
std::vector<double> probability_by_hamming_weight(double J, double h, double z, double theta, double t, size_t n_qubits)
|
|
30
|
+
static inline std::vector<double> probability_by_hamming_weight(double J, double h, double z, double theta, double t, size_t n_qubits)
|
|
31
31
|
{
|
|
32
32
|
// critical angle
|
|
33
33
|
const double theta_c = std::asin(std::max(-1.0, std::min(1.0, (std::abs(z * J) >= (std::numeric_limits<double>::epsilon() / 2)) ? std::abs(h) / (z * J) : (J > 0 ? 1.0 : -1.0))));
|
|
@@ -73,53 +73,6 @@ static inline std::string int_to_bitstring(BigInteger integer, size_t length) {
|
|
|
73
73
|
return s;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
std::vector<double> maxcut_hamming_cdf(size_t n_qubits, std::vector<double> J_func, std::vector<double> degrees, int mult_log2) {
|
|
77
|
-
if (!n_qubits) {
|
|
78
|
-
return std::vector<double>();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const size_t n_steps = n_qubits << mult_log2;
|
|
82
|
-
const size_t shots = n_qubits << mult_log2;
|
|
83
|
-
const double delta_t = 1.0 / (n_steps << (mult_log2 >> 1));
|
|
84
|
-
const double h_mult = (1 << (mult_log2 >> 1)) / (n_steps * delta_t);
|
|
85
|
-
std::vector<double> hamming_prob(n_qubits - 1U, 0.0);
|
|
86
|
-
|
|
87
|
-
for (size_t step = 0; step < n_steps; ++step) {
|
|
88
|
-
double t = step * delta_t;
|
|
89
|
-
double tm1 = (step - 1) * delta_t;
|
|
90
|
-
for (size_t q = 0; q < n_qubits; ++q) {
|
|
91
|
-
const double& z = degrees[q];
|
|
92
|
-
const double J_eff = J_func[q];
|
|
93
|
-
const double h_t = h_mult * t;
|
|
94
|
-
auto bias = probability_by_hamming_weight(J_eff, h_t, z, 0.0, t, n_qubits);
|
|
95
|
-
if (step == 0) {
|
|
96
|
-
for (size_t i = 0U; i < hamming_prob.size(); ++i) {
|
|
97
|
-
hamming_prob[i] += bias[i + 1U];
|
|
98
|
-
}
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
auto last_bias = probability_by_hamming_weight(J_eff, h_t, z, 0.0, tm1, n_qubits);
|
|
102
|
-
for (size_t i = 0U; i < hamming_prob.size(); ++i) {
|
|
103
|
-
hamming_prob[i] += bias[i + 1U] - last_bias[i + 1U];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
double tot_prob = std::accumulate(hamming_prob.begin(), hamming_prob.end(), 0.0);
|
|
109
|
-
for (auto& x : hamming_prob) {
|
|
110
|
-
x /= tot_prob;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
tot_prob = 0.0;
|
|
114
|
-
for (size_t i = 0U; i < hamming_prob.size(); ++i) {
|
|
115
|
-
tot_prob += hamming_prob[i];
|
|
116
|
-
hamming_prob[i] = tot_prob;
|
|
117
|
-
}
|
|
118
|
-
hamming_prob.back() = 1.0;
|
|
119
|
-
|
|
120
|
-
return hamming_prob;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
76
|
static inline double closeness_like_bits(BigInteger perm, size_t n_rows, size_t n_cols) {
|
|
124
77
|
std::string bits = int_to_bitstring(perm, n_rows * n_cols);
|
|
125
78
|
double like_count = 0.0;
|
|
@@ -293,7 +246,5 @@ PYBIND11_MODULE(tfim_sampler, m) {
|
|
|
293
246
|
m.def("_generate_tfim_samples", &generate_tfim_samples_cpp, "Generate measurement samples from globally-uniform TFIM");
|
|
294
247
|
m.def("_tfim_magnetization", &tfim_magnetization, "Magnetization expectation value from globally-uniform TFIM");
|
|
295
248
|
m.def("_tfim_square_magnetization", &tfim_square_magnetization, "Square magnetization expectation value from globally-uniform TFIM");
|
|
296
|
-
m.def("_maxcut_hamming_cdf", &maxcut_hamming_cdf, "Adiabatic TFIM Hamming weight probability density function");
|
|
297
|
-
m.def("_probability_by_hamming_weight", &probability_by_hamming_weight, "Trace probability from globally-uniform TFIM by Hamming weight");
|
|
298
249
|
}
|
|
299
250
|
|
|
@@ -51,38 +51,42 @@ def probability_by_hamming_weight(J, h, z, theta, t, n_qubits):
|
|
|
51
51
|
|
|
52
52
|
@njit(parallel=True)
|
|
53
53
|
def maxcut_hamming_cdf(n_qubits, J_func, degrees, mult_log2):
|
|
54
|
-
if n_qubits
|
|
54
|
+
if n_qubits < 2:
|
|
55
55
|
return np.empty(0, dtype=np.float64)
|
|
56
56
|
|
|
57
57
|
n_steps = n_qubits << mult_log2
|
|
58
58
|
shots = n_qubits << mult_log2
|
|
59
59
|
delta_t = 1.0 / (n_steps << (mult_log2 >> 1))
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
tot_t = (n_steps - 1) * delta_t
|
|
61
|
+
h_mult = (1 << (mult_log2 >> 1)) / tot_t
|
|
62
|
+
n_bias = n_qubits - 1
|
|
63
|
+
hamming_prob = np.zeros(n_bias)
|
|
64
|
+
|
|
65
|
+
for q in prange(n_qubits):
|
|
66
|
+
z = degrees[q]
|
|
67
|
+
J_eff = J_func[q]
|
|
68
|
+
bias = probability_by_hamming_weight(J_eff, h_mult, z, 0.0, 0, n_qubits)
|
|
69
|
+
for i in range(n_bias):
|
|
70
|
+
hamming_prob[i] += bias[i + 1]
|
|
71
|
+
|
|
72
|
+
for step in range(1, n_steps):
|
|
64
73
|
t = step * delta_t
|
|
65
74
|
tm1 = (step - 1) * delta_t
|
|
66
75
|
for q in prange(n_qubits):
|
|
67
76
|
z = degrees[q]
|
|
68
77
|
J_eff = J_func[q]
|
|
69
|
-
h_t = h_mult * t
|
|
78
|
+
h_t = h_mult * (tot_t - t)
|
|
70
79
|
bias = probability_by_hamming_weight(J_eff, h_t, z, 0.0, t, n_qubits)
|
|
71
|
-
if step == 0:
|
|
72
|
-
for i in range(len(hamming_prob)):
|
|
73
|
-
hamming_prob[i] += bias[i + 1]
|
|
74
|
-
continue
|
|
75
|
-
|
|
76
80
|
last_bias = probability_by_hamming_weight(J_eff, h_t, z, 0.0, tm1, n_qubits)
|
|
77
|
-
for i in range(
|
|
81
|
+
for i in range(n_bias):
|
|
78
82
|
hamming_prob[i] += bias[i + 1] - last_bias[i + 1]
|
|
79
83
|
|
|
80
84
|
tot_prob = sum(hamming_prob)
|
|
81
|
-
for i in prange(
|
|
85
|
+
for i in prange(n_bias):
|
|
82
86
|
hamming_prob[i] /= tot_prob
|
|
83
87
|
|
|
84
88
|
tot_prob = 0.0
|
|
85
|
-
for i in range(
|
|
89
|
+
for i in range(n_bias):
|
|
86
90
|
tot_prob += hamming_prob[i]
|
|
87
91
|
hamming_prob[i] = tot_prob
|
|
88
92
|
hamming_prob[-1] = 1.0
|
|
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "PyQrackIsing"
|
|
14
|
-
version = "1.10.
|
|
14
|
+
version = "1.10.6"
|
|
15
15
|
requires-python = ">=3.8"
|
|
16
16
|
description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
|
|
17
17
|
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.10.
|
|
54
|
+
version='1.10.6',
|
|
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
|