PyQrackIsing 5.5.0__tar.gz → 5.5.1__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-5.5.0/pyqrackising.egg-info → pyqrackising-5.5.1}/PKG-INFO +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/README.md +2 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyproject.toml +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/kernels.cl +98 -11
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/maxcut_tfim_sparse.py +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/maxcut_tfim_util.py +1 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/spin_glass_solver_sparse.py +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/setup.py +1 -1
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/CMakeLists.txt +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/LICENSE.md +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/MANIFEST.in +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/__init__.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising/tsp.py +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-5.5.0 → pyqrackising-5.5.1}/setup.cfg +0 -0
|
@@ -143,6 +143,8 @@ solution_bit_string, cut_value, node_groups, energy = spin_glass_solver_streamin
|
|
|
143
143
|
|
|
144
144
|
We expose an environment variable, "`PYQRACKISING_MAX_GPU_PROC_ELEM`", for when `is_alt_gpu_sampling=True`. The default value (when the variable is not set) is queried from the OpenCL device properties. You might see performance benefit from tuning this manually to several times your device's number of "compute units" (or tune it down to reduce private memory usage).
|
|
145
145
|
|
|
146
|
+
Similarly, for `is_alt_gpu_sampling=True`, define the "top-`n`" count of highest-weight direct neighbors to retain during sampling with environment variable "`PYQRACKISING_GPU_TOP_N`". The default is `32`. Increasing this might increase solution quality, but it will also increase time-to-solution and private memory usage.
|
|
147
|
+
|
|
146
148
|
## About
|
|
147
149
|
Transverse field Ising model (TFIM) is the basis of most claimed algorithmic "quantum advantage," circa 2025, with the notable exception of Shor's integer factoring algorithm.
|
|
148
150
|
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "5.5.
|
|
15
|
+
version = "5.5.1"
|
|
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"}
|
|
@@ -323,8 +323,12 @@ __kernel void sample_for_solution_best_bitset(
|
|
|
323
323
|
temp_sol[(gid >> 5) & MAX_WORDS_MASK] |= 1U << (gid & 31);
|
|
324
324
|
|
|
325
325
|
for (int count = 1; count < m; ++count) {
|
|
326
|
-
double
|
|
327
|
-
int
|
|
326
|
+
double highest_weights[TOP_N];
|
|
327
|
+
int best_bits[TOP_N];
|
|
328
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
329
|
+
highest_weights[x] = -INFINITY;
|
|
330
|
+
best_bits[x] = -1;
|
|
331
|
+
}
|
|
328
332
|
|
|
329
333
|
for (int i = 0; i < n; i += 32) {
|
|
330
334
|
for (int j = 0; j < 32; ++j) {
|
|
@@ -349,10 +353,50 @@ __kernel void sample_for_solution_best_bitset(
|
|
|
349
353
|
}
|
|
350
354
|
}
|
|
351
355
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
356
|
+
|
|
357
|
+
int lowest_option = 0;
|
|
358
|
+
double lowest_weight = highest_weights[0];
|
|
359
|
+
if (lowest_weight != -INFINITY) {
|
|
360
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
361
|
+
double val = highest_weights[x];
|
|
362
|
+
if (val < lowest_weight) {
|
|
363
|
+
lowest_option = x;
|
|
364
|
+
lowest_weight = highest_weights[x];
|
|
365
|
+
if (val == -INFINITY) {
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
355
370
|
}
|
|
371
|
+
|
|
372
|
+
if (weight > lowest_weight) {
|
|
373
|
+
highest_weights[lowest_option] = weight;
|
|
374
|
+
best_bits[lowest_option] = u;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
double total_weight = 0.0;
|
|
380
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
381
|
+
const double val = highest_weights[x];
|
|
382
|
+
if (val == -INFINITY) {
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
total_weight += val;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
const float bit_prob = rand_uniform(&state);
|
|
389
|
+
double tot_prob = 0.0;
|
|
390
|
+
int best_bit = 0;
|
|
391
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
392
|
+
const double val = highest_weights[x];
|
|
393
|
+
if (val == -INFINITY) {
|
|
394
|
+
continue;
|
|
395
|
+
}
|
|
396
|
+
tot_prob += val;
|
|
397
|
+
if ((total_weight * bit_prob) < tot_prob) {
|
|
398
|
+
best_bit = best_bits[x];
|
|
399
|
+
break;
|
|
356
400
|
}
|
|
357
401
|
}
|
|
358
402
|
|
|
@@ -475,7 +519,7 @@ __kernel void sample_for_solution_best_bitset_sparse(
|
|
|
475
519
|
for (int gid = gid_orig; gid < shots; gid += MAX_PROC_ELEM) {
|
|
476
520
|
|
|
477
521
|
// --- 1. Choose Hamming weight
|
|
478
|
-
float mag_prob = rand_uniform(&state);
|
|
522
|
+
const float mag_prob = rand_uniform(&state);
|
|
479
523
|
int m = 0;
|
|
480
524
|
while (m < n && thresholds[m] < mag_prob) m++;
|
|
481
525
|
m++;
|
|
@@ -485,8 +529,12 @@ __kernel void sample_for_solution_best_bitset_sparse(
|
|
|
485
529
|
temp_sol[(gid >> 5) & MAX_WORDS_MASK] |= 1U << (gid & 31);
|
|
486
530
|
|
|
487
531
|
for (int count = 1; count < m; ++count) {
|
|
488
|
-
double
|
|
489
|
-
int
|
|
532
|
+
double highest_weights[TOP_N];
|
|
533
|
+
int best_bits[TOP_N];
|
|
534
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
535
|
+
highest_weights[x] = -INFINITY;
|
|
536
|
+
best_bits[x] = -1;
|
|
537
|
+
}
|
|
490
538
|
|
|
491
539
|
for (int i = 0; i < n; i += 32) {
|
|
492
540
|
for (int j = 0; j < 32; ++j) {
|
|
@@ -521,10 +569,49 @@ __kernel void sample_for_solution_best_bitset_sparse(
|
|
|
521
569
|
}
|
|
522
570
|
}
|
|
523
571
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
572
|
+
int lowest_option = 0;
|
|
573
|
+
double lowest_weight = highest_weights[0];
|
|
574
|
+
if (lowest_weight != -INFINITY) {
|
|
575
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
576
|
+
double val = highest_weights[x];
|
|
577
|
+
if (val < lowest_weight) {
|
|
578
|
+
lowest_option = x;
|
|
579
|
+
lowest_weight = highest_weights[x];
|
|
580
|
+
if (val == -INFINITY) {
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
527
585
|
}
|
|
586
|
+
|
|
587
|
+
if (weight > lowest_weight) {
|
|
588
|
+
highest_weights[lowest_option] = weight;
|
|
589
|
+
best_bits[lowest_option] = u;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
double total_weight = 0.0;
|
|
595
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
596
|
+
const double val = highest_weights[x];
|
|
597
|
+
if (val == -INFINITY) {
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
total_weight += val;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
const float bit_prob = rand_uniform(&state);
|
|
604
|
+
double tot_prob = 0.0;
|
|
605
|
+
int best_bit = 0;
|
|
606
|
+
for (int x = 0; x < TOP_N; ++x) {
|
|
607
|
+
const double val = highest_weights[x];
|
|
608
|
+
if (val == -INFINITY) {
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
tot_prob += val;
|
|
612
|
+
if ((total_weight * bit_prob) < tot_prob) {
|
|
613
|
+
best_bit = best_bits[x];
|
|
614
|
+
break;
|
|
528
615
|
}
|
|
529
616
|
}
|
|
530
617
|
|
|
@@ -179,6 +179,7 @@ try:
|
|
|
179
179
|
|
|
180
180
|
# Load and build OpenCL kernels
|
|
181
181
|
kernel_src = f"#define MAX_PROC_ELEM {compute_units}\n"
|
|
182
|
+
kernel_src += f"#define TOP_N {os.getenv('PYQRACKISING_GPU_TOP_N', '32')}\n"
|
|
182
183
|
kernel_src += open(os.path.dirname(os.path.abspath(__file__)) + "/kernels.cl").read()
|
|
183
184
|
program = cl.Program(ctx, kernel_src).build()
|
|
184
185
|
init_theta_kernel = program.init_theta
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='5.5.
|
|
54
|
+
version='5.5.1',
|
|
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
|