pyqrack 1.70.0__py3-none-macosx_13_0_x86_64.whl
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.
- pyqrack/__init__.py +20 -0
- pyqrack/neuron_activation_fn.py +21 -0
- pyqrack/pauli.py +19 -0
- pyqrack/qrack_ace_backend.py +1544 -0
- pyqrack/qrack_circuit.py +584 -0
- pyqrack/qrack_neuron.py +262 -0
- pyqrack/qrack_neuron_torch_layer.py +170 -0
- pyqrack/qrack_simulator.py +4498 -0
- pyqrack/qrack_stabilizer.py +58 -0
- pyqrack/qrack_system/__init__.py +9 -0
- pyqrack/qrack_system/qrack_cl_precompile/qrack_cl_precompile +0 -0
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.9.29.0.dylib +0 -0
- pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib +0 -0
- pyqrack/qrack_system/qrack_system.py +1351 -0
- pyqrack/quimb_circuit_type.py +17 -0
- pyqrack/stats/__init__.py +6 -0
- pyqrack/stats/load_quantized_data.py +35 -0
- pyqrack/stats/quantize_by_range.py +56 -0
- pyqrack-1.70.0.dist-info/LICENSE +21 -0
- pyqrack-1.70.0.dist-info/METADATA +82 -0
- pyqrack-1.70.0.dist-info/RECORD +23 -0
- pyqrack-1.70.0.dist-info/WHEEL +5 -0
- pyqrack-1.70.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Pauli operators are specified for "b" (or "basis") parameters.
|
|
4
|
+
#
|
|
5
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
7
|
+
|
|
8
|
+
from enum import IntEnum
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class QuimbCircuitType(IntEnum):
|
|
12
|
+
# Class for simulating quantum circuits using tensor networks.
|
|
13
|
+
Circuit = 0
|
|
14
|
+
# Quantum circuit simulation keeping the state in full dense form.
|
|
15
|
+
CircuitDense = 1
|
|
16
|
+
# Quantum circuit simulation keeping the state always in a MPS form.
|
|
17
|
+
CircuitMPS = 3
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
4
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
5
|
+
|
|
6
|
+
from .quantize_by_range import quantize_by_range
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Load quantized data into a QrackSimulator
|
|
4
|
+
#
|
|
5
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def load_data(sim, index_bits, value_bits, data):
|
|
10
|
+
"""
|
|
11
|
+
Take discretized features from quantize_by_range and load into a QrackSimulator
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
sim (QrackSimulator): Simulator into which to load data
|
|
15
|
+
index_bits (list[int]): List of index bits, least-to-most significant
|
|
16
|
+
value_bits (list[int]): List of value bits, least-to-most significant
|
|
17
|
+
data (list[list[bool]]): Data to load, row-major
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
Value error: Length of value_bits does not match data feature column count!
|
|
21
|
+
"""
|
|
22
|
+
if (len(data) > 0) and (len(value_bits) != len(data[0])):
|
|
23
|
+
raise ValueError(
|
|
24
|
+
"Length of value_bits does not match data feature column count!"
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
for i in range(index_bits):
|
|
28
|
+
if sim.m(i):
|
|
29
|
+
sim.x(i)
|
|
30
|
+
sim.h(i)
|
|
31
|
+
|
|
32
|
+
if len(data) == 0:
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
sim.lda(list(range(index_bits)), list(range(value_bits)), data)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# (C) Daniel Strano and the Qrack contributors 2017-2025. All rights reserved.
|
|
2
|
+
#
|
|
3
|
+
# Use of this source code is governed by an MIT-style license that can be
|
|
4
|
+
# found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
# Written by Elara (custom OpenAI GPT)
|
|
8
|
+
import numpy as np
|
|
9
|
+
|
|
10
|
+
def quantize_by_range(data, feature_indices, bits):
|
|
11
|
+
"""
|
|
12
|
+
Discretize selected features of a dataset into binary variables using numpy.linspace binning.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
data (np.ndarray): Input data of shape (n_samples, n_features).
|
|
16
|
+
feature_indices (list[int]): Indices of features to discretize.
|
|
17
|
+
bits (int): Number of bits to represent each discretized feature (e.g., 2 bits = 4 quantiles).
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
np.ndarray: Transformed data with selected features replaced by binary bit columns.
|
|
21
|
+
"""
|
|
22
|
+
n_samples, n_features = data.shape
|
|
23
|
+
n_bins = 2**bits
|
|
24
|
+
|
|
25
|
+
new_features = []
|
|
26
|
+
for i in range(n_features):
|
|
27
|
+
if i in feature_indices:
|
|
28
|
+
min_val, max_val = data[:, i].min(), data[:, i].max()
|
|
29
|
+
thresholds = np.linspace(min_val, max_val, n_bins + 1)[1:-1]
|
|
30
|
+
bins = np.digitize(data[:, i], bins=thresholds)
|
|
31
|
+
bin_bits = ((bins[:, None] & (1 << np.arange(bits)[::-1])) > 0).astype(
|
|
32
|
+
int
|
|
33
|
+
)
|
|
34
|
+
new_features.append(bin_bits)
|
|
35
|
+
else:
|
|
36
|
+
new_features.append(data[:, i][:, None]) # Keep original
|
|
37
|
+
|
|
38
|
+
return np.hstack(new_features)
|
|
39
|
+
|
|
40
|
+
except ImportError:
|
|
41
|
+
|
|
42
|
+
def quantize_by_range(data, feature_indices, bits):
|
|
43
|
+
"""
|
|
44
|
+
Discretize selected features of a dataset into binary variables using numpy.linspace binning.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
data (np.ndarray): Input data of shape (n_samples, n_features).
|
|
48
|
+
feature_indices (list[int]): Indices of features to discretize.
|
|
49
|
+
bits (int): Number of bits to represent each discretized feature (e.g., 2 bits = 4 quantiles).
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
np.ndarray: Transformed data with selected features replaced by binary bit columns.
|
|
53
|
+
"""
|
|
54
|
+
raise NotImplementedError(
|
|
55
|
+
"You must have numpy installed to use quantize_by_percentile()!"
|
|
56
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2023 vm6502q
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pyqrack
|
|
3
|
+
Version: 1.70.0
|
|
4
|
+
Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
|
|
5
|
+
Home-page: https://github.com/vm6502q/pyqrack
|
|
6
|
+
Author: Daniel Strano
|
|
7
|
+
Author-email: dan@unitary.fund
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: pyqrack qrack simulator quantum gpu
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: C++
|
|
17
|
+
Classifier: Programming Language :: Python :: 2
|
|
18
|
+
Classifier: Programming Language :: Python :: 2.3
|
|
19
|
+
Classifier: Programming Language :: Python :: 2.4
|
|
20
|
+
Classifier: Programming Language :: Python :: 2.5
|
|
21
|
+
Classifier: Programming Language :: Python :: 2.6
|
|
22
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
23
|
+
Classifier: Programming Language :: Python :: 3
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.0
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.1
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.2
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.3
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
29
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
30
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
31
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
32
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=7.3.1; extra == "dev"
|
|
42
|
+
|
|
43
|
+
# pyqrack
|
|
44
|
+
[](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack)
|
|
45
|
+
|
|
46
|
+
Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library
|
|
47
|
+
|
|
48
|
+
(**PyQrack** is just pure Qrack.)
|
|
49
|
+
|
|
50
|
+
**Note: You must also install OpenCL to use this version of Qrack.** (There are also CPU-only and CUDA version.)
|
|
51
|
+
|
|
52
|
+
**If you're looking for Mac ARM support, use the package `pyqrack`, not `pyqrack-cpu`.** Mac officially "deprecated" OpenCL years ago. Hence, accelerator support is not included in ARM-based Mac wheels, and OpenCL installation is **not** required on these systems, but, if you have a CUDA accelerator on ARM-based Mac, you could try the package `pyqrack-cuda` instead.
|
|
53
|
+
|
|
54
|
+
**Performance can benefit greatly from following the [Qrack repository "Quick Start" and "Power user considerations."](https://github.com/unitaryfund/qrack/blob/main/README.md#quick-start)**
|
|
55
|
+
|
|
56
|
+
**If you use an integrated graphics accelerator, like the Intel HD,** setting environment variable `PYQRACK_HOST_POINTER_DEFAULT_ON=1` (or to any "truthy" value) will automatically set the default of `isHostPointer` option of `QrackSimulator` to `True`, to engage "zero-copy" mode by default.
|
|
57
|
+
|
|
58
|
+
Import and instantiate [`QrackSimulator`](https://github.com/unitaryfund/pyqrack/blob/main/pyqrack/qrack_simulator.py) instances. This simulator can perform arbitrary single qubit and controlled-single-qubit gates, as well as other specific gates like `SWAP`.
|
|
59
|
+
|
|
60
|
+
Any 2x2 bit operator matrix is represented by a list of 4 `complex` floating point numbers, in [**row-major order**](https://en.wikipedia.org/wiki/Row-_and_column-major_order).
|
|
61
|
+
|
|
62
|
+
Single and array "`b`" parameters represent [**Pauli operator bases**](https://en.wikipedia.org/wiki/Pauli_matrices). They are specified according to the enumeration of the [`Pauli`](https://github.com/unitaryfund/pyqrack/blob/main/pyqrack/pauli.py) class.
|
|
63
|
+
|
|
64
|
+
`MC[x]` and `MAC[x]` methods are controlled single bit gates, with as many control qubits as you specify via Python list `c` argument. `MCX` is multiply-controlled Pauli X, and `MACX` is "anti-"controlled Pauli X, i.e. "anti-control" activates the gate if all control bits are specifically **off**, as opposed to **on**.
|
|
65
|
+
|
|
66
|
+
To load the required **unitaryfund/qrack** libraries from a different location, set the `PYQRACK_SHARED_LIB_PATH` environment variable.
|
|
67
|
+
|
|
68
|
+
PyQrack has experimental support for [PyZX](https://github.com/Quantomatic/pyzx) `Circuit` definitions as an intermediate representation for `QrackSimulator`. To try this, load a `Circuit` in PyZX, (use that module to optimize your circuit, as you like,) and create a `QrackSimulator()` instance using the `pyzxCircuit` named argument of the constructor, like so:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
sim = QrackSimulator(pyzxCircuit=c)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
where `c` is a PyZX circuit object. The circuit will automatically be simulated in the constructed `QrackSimulator` instance. This also allows loading from QASM and other intermediate representations supported by PyZX.
|
|
75
|
+
|
|
76
|
+
See [https://pyqrack.readthedocs.io/en/latest/](https://pyqrack.readthedocs.io/en/latest/) for an API reference.
|
|
77
|
+
|
|
78
|
+
For custom Qrack build floating-point precision, where options are `half`, `float`, `double`, and `quad`, set an environment variable via `export QRACK_FPPOW=[n]` (or as appropriate to your shell) where `[n]` is the logarithm base 2 of the number of bits in the systemic floating point type (`4`, `5`, `6`, or `7`, with `5` or `float` as default, i.e. `2**5=32` for 32-bit `float`). Your Qrack installation floating-point build option must match this specific value, which might require a custom Qrack build.
|
|
79
|
+
|
|
80
|
+
Please feel welcome to open an issue, if you'd like help. 😃
|
|
81
|
+
|
|
82
|
+
**Special thanks go to Zeeshan Ahmed, for bug fixes and design suggestions, Ashish Panigrahi, for documentation and design suggestions, WingCode, for documentation, Or Golan, for CI build pipeline tooling, and to the broader community of Qrack contributors, for years of happy Qracking! You rock!**
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
pyqrack/__init__.py,sha256=3tBwfCCD-zQjQ2g1EUZdggKdn-3b2uSFTbT7LS0YLaU,785
|
|
2
|
+
pyqrack/neuron_activation_fn.py,sha256=fQTTFfsvwcot_43Vopacot47IV2Rxk8pelUyuzwpXPs,593
|
|
3
|
+
pyqrack/pauli.py,sha256=wg500wDOwdIU4lEVJoMmjtbAdmtakZYzLPjdzC2rwUQ,654
|
|
4
|
+
pyqrack/qrack_ace_backend.py,sha256=Prw1NhVVt0csbHiJeW8MJI9rl1P1YS63sXM5quoNPrI,49392
|
|
5
|
+
pyqrack/qrack_circuit.py,sha256=vDCKGbcEHJDFUKprjCpWgit8lXFnMrPimKHURD2_Hj4,19538
|
|
6
|
+
pyqrack/qrack_neuron.py,sha256=UiJdjAGB6usjAGHWSosSFCUUeIkhh3MtZbsaxfsIsNw,9043
|
|
7
|
+
pyqrack/qrack_neuron_torch_layer.py,sha256=Bs5BLC2GFevfSpo_jSJ2AZl-hfDRJmzlGN9pFw1CtoQ,6160
|
|
8
|
+
pyqrack/qrack_simulator.py,sha256=PSrcEIlzCt33WXjoEo5dZdmzx9zR90QI_Dw9LTphjMg,146030
|
|
9
|
+
pyqrack/qrack_stabilizer.py,sha256=O-7VJ9Vw4h25PK_kesSjIqHXGSo8lLrQLIyGgmzG7Co,2124
|
|
10
|
+
pyqrack/quimb_circuit_type.py,sha256=Sk-Tmn38kUYmAkJJ75btWuhYZyTXOOezmowFhfdiGDc,621
|
|
11
|
+
pyqrack/qrack_system/__init__.py,sha256=-oZ9dsb1hixsnrkUJRY_C5DzQ_l6MtifF_Z465BgqV4,334
|
|
12
|
+
pyqrack/qrack_system/qrack_system.py,sha256=ToxxggEEJmEJjWwvnBDe5ZYbN-iks5OmWlWXYE5Oiw8,43719
|
|
13
|
+
pyqrack/qrack_system/qrack_cl_precompile/qrack_cl_precompile,sha256=8xQYqoFTKIl-5v6ZkqmbWp14Eowkl8ty2vNF2shC5hU,35040
|
|
14
|
+
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.9.29.0.dylib,sha256=7AQFOBvzwpDj6vtIPrVNlBPbYMfuAYxxHOff3qsc_m4,3898384
|
|
15
|
+
pyqrack/qrack_system/qrack_lib/libqrack_pinvoke.dylib,sha256=7AQFOBvzwpDj6vtIPrVNlBPbYMfuAYxxHOff3qsc_m4,3898384
|
|
16
|
+
pyqrack/stats/__init__.py,sha256=Hla85my2fY_roR9lIjGBVpEG7ySOTMwjWa8D6-kgCnY,276
|
|
17
|
+
pyqrack/stats/load_quantized_data.py,sha256=z12u9F7Nt3P-i44nY1xxvso_klS6WIHS3iqq7R2_lqE,1184
|
|
18
|
+
pyqrack/stats/quantize_by_range.py,sha256=UM0_7jJDdQ7g30cR3UQAxkbzkqrmsy1oUfqg0h11FUY,2270
|
|
19
|
+
pyqrack-1.70.0.dist-info/LICENSE,sha256=HxB-7SaWTuewAk1nz-3_3FUD6QhgX73kNT_taKVUTq8,1069
|
|
20
|
+
pyqrack-1.70.0.dist-info/METADATA,sha256=_nsxdb0SMXlE7M3GAJa7Z_-cxeg2gm_O8kjJoKqa-fY,5892
|
|
21
|
+
pyqrack-1.70.0.dist-info/WHEEL,sha256=nZx8s83OrgdDmpcWX-8FgI0sEAjdQimt4SdYsdcCaC8,107
|
|
22
|
+
pyqrack-1.70.0.dist-info/top_level.txt,sha256=YE_3q9JTGRLMilNg2tGP1y7uU-Dx8PDao2OhwoIbv8E,8
|
|
23
|
+
pyqrack-1.70.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pyqrack
|