pyqrack-cuda 1.27.0__tar.gz → 1.32.29__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.
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/LICENSE +1 -1
- pyqrack_cuda-1.32.29/MANIFEST.in +3 -0
- pyqrack_cuda-1.32.29/Makefile +54 -0
- {pyqrack-cuda-1.27.0/pyqrack_cuda.egg-info → pyqrack_cuda-1.32.29}/PKG-INFO +23 -9
- pyqrack_cuda-1.32.29/README.md +34 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/qrack_circuit.py +50 -7
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/qrack_neuron.py +1 -3
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/qrack_simulator.py +501 -24
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/qrack_system/qrack_system.py +257 -43
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29/pyqrack_cuda.egg-info}/PKG-INFO +23 -9
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack_cuda.egg-info/SOURCES.txt +1 -4
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/setup.py +31 -5
- pyqrack-cuda-1.27.0/MANIFEST.in +0 -11
- pyqrack-cuda-1.27.0/README.md +0 -34
- pyqrack-cuda-1.27.0/pyqrack/qrack_cl_precompile/Linux/2_35/qrack_cl_precompile +0 -0
- pyqrack-cuda-1.27.0/pyqrack/qrack_system/qrack_lib/Linux/2_35/libqrack.a +0 -0
- pyqrack-cuda-1.27.0/pyqrack/qrack_system/qrack_lib/Linux/2_35/libqrack_pinvoke.so +0 -0
- pyqrack-cuda-1.27.0/pyqrack/qrack_system/qrack_lib/Linux/2_35/libqrack_pinvoke.so.9.6.0 +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyproject.toml +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/__init__.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/neuron_activation_fn.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/pauli.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/qrack_system/__init__.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/quimb_circuit_type.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/util/__init__.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack/util/convert_qiskit_circuit_to_qasm_experiment.py +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack_cuda.egg-info/dependency_links.txt +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack_cuda.egg-info/not-zip-safe +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack_cuda.egg-info/requires.txt +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/pyqrack_cuda.egg-info/top_level.txt +0 -0
- {pyqrack-cuda-1.27.0 → pyqrack_cuda-1.32.29}/setup.cfg +0 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
PYTHON3 := $(shell which python3 2>/dev/null)
|
2
|
+
|
3
|
+
PYTHON := python3
|
4
|
+
|
5
|
+
UNAME_S := $(shell uname -s)
|
6
|
+
UNAME_P := $(shell uname -p)
|
7
|
+
QRACK_PRESENT := $(wildcard qrack/.)
|
8
|
+
|
9
|
+
.PHONY: help
|
10
|
+
help:
|
11
|
+
@echo "Please use \`make <target>' where <target> is one of"
|
12
|
+
@echo " build-deps to build PennyLane-Qrack C++ dependencies"
|
13
|
+
@echo " install to install PennyLane-Qrack"
|
14
|
+
@echo " wheel to build the PennyLane-Qrack wheel"
|
15
|
+
@echo " dist to package the source distribution"
|
16
|
+
|
17
|
+
.PHONY: build-deps
|
18
|
+
build-deps:
|
19
|
+
ifneq ($(OS),Windows_NT)
|
20
|
+
ifeq ($(QRACK_PRESENT),)
|
21
|
+
git clone https://github.com/unitaryfund/qrack.git; cd qrack; git checkout 3860bfaa265eed44197d3817027f99936db9a6f5; cd ..
|
22
|
+
endif
|
23
|
+
mkdir -p qrack/build
|
24
|
+
ifeq ($(UNAME_S),Linux)
|
25
|
+
ifeq ($(UNAME_P),x86_64)
|
26
|
+
cd qrack/build; cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_OPENCL=OFF -DENABLE_CUDA=ON ..; make all
|
27
|
+
else
|
28
|
+
cd qrack/build; cmake -DENABLE_RDRAND=OFF -DENABLE_DEVRAND=ON -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DENABLE_OPENCL=OFF -DENABLE_CUDA=ON ..; make all
|
29
|
+
endif
|
30
|
+
endif
|
31
|
+
ifeq ($(UNAME_S),Darwin)
|
32
|
+
ifeq ($(UNAME_P),x86_64)
|
33
|
+
cd qrack/build; cmake -DENABLE_OPENCL=OFF -DENABLE_CUDA=ON ..; make all
|
34
|
+
else
|
35
|
+
cd qrack/build; cmake -DENABLE_RDRAND=OFF -DENABLE_COMPLEX_X2=OFF -DENABLE_SSE3=OFF -DENABLE_OPENCL=OFF -DENABLE_CUDA=ON ..; make all
|
36
|
+
endif
|
37
|
+
endif
|
38
|
+
endif
|
39
|
+
mkdir pyqrack/qrack_system/qrack_lib; cp qrack/build/libqrack_pinvoke.* pyqrack/qrack_system/qrack_lib/; cd ../../..
|
40
|
+
|
41
|
+
.PHONY: install
|
42
|
+
install:
|
43
|
+
ifndef PYTHON3
|
44
|
+
@echo "To install PyQrack you need to have Python 3 installed"
|
45
|
+
endif
|
46
|
+
$(PYTHON) setup.py install
|
47
|
+
|
48
|
+
.PHONY: wheel
|
49
|
+
wheel:
|
50
|
+
$(PYTHON) setup.py bdist_wheel
|
51
|
+
|
52
|
+
.PHONY: dist
|
53
|
+
dist:
|
54
|
+
$(PYTHON) setup.py sdist
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyqrack-cuda
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.32.29
|
4
4
|
Summary: pyqrack - Pure Python vm6502q/qrack Wrapper
|
5
5
|
Home-page: https://github.com/vm6502q/pyqrack
|
6
6
|
Author: Daniel Strano
|
@@ -14,12 +14,26 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
14
14
|
Classifier: Operating System :: MacOS
|
15
15
|
Classifier: Operating System :: POSIX :: Linux
|
16
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
|
17
29
|
Classifier: Programming Language :: Python :: 3.5
|
18
30
|
Classifier: Programming Language :: Python :: 3.6
|
19
31
|
Classifier: Programming Language :: Python :: 3.7
|
20
32
|
Classifier: Programming Language :: Python :: 3.8
|
21
33
|
Classifier: Programming Language :: Python :: 3.9
|
22
34
|
Classifier: Programming Language :: Python :: 3.10
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
23
37
|
Classifier: Topic :: Scientific/Engineering
|
24
38
|
Description-Content-Type: text/markdown
|
25
39
|
License-File: LICENSE
|
@@ -27,27 +41,25 @@ Provides-Extra: dev
|
|
27
41
|
Requires-Dist: pytest>=7.3.1; extra == "dev"
|
28
42
|
|
29
43
|
# pyqrack
|
30
|
-
[](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack)
|
44
|
+
[](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack)
|
31
45
|
|
32
46
|
Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library
|
33
47
|
|
34
48
|
(**PyQrack** is just pure Qrack.)
|
35
49
|
|
36
|
-
|
50
|
+
**Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **For PyQrack-CUDA, the package is distributed as source-only on PyPi, so that the Qrack build step can do its best to try to automatically detect your available CUDA architectures.**
|
37
51
|
|
38
|
-
Import and instantiate [`QrackSimulator`](https://github.com/
|
52
|
+
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`.
|
39
53
|
|
40
54
|
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).
|
41
55
|
|
42
|
-
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/
|
56
|
+
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.
|
43
57
|
|
44
58
|
`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**.
|
45
59
|
|
46
|
-
|
60
|
+
To load the required **unitaryfund/qrack** libraries from a different location, set the `PYQRACK_SHARED_LIB_PATH` environment variable.
|
47
61
|
|
48
|
-
|
49
|
-
|
50
|
-
PyQrack v0.4.6 adds 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:
|
62
|
+
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:
|
51
63
|
|
52
64
|
```python
|
53
65
|
sim = QrackSimulator(pyzxCircuit=c)
|
@@ -57,6 +69,8 @@ where `c` is a PyZX circuit object. The circuit will automatically be simulated
|
|
57
69
|
|
58
70
|
See [https://pyqrack.readthedocs.io/en/latest/](https://pyqrack.readthedocs.io/en/latest/) for an API reference.
|
59
71
|
|
72
|
+
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.
|
73
|
+
|
60
74
|
Please feel welcome to open an issue, if you'd like help. 😃
|
61
75
|
|
62
76
|
**Special thanks go to Zeeshan Ahmed, for bug fixes and design suggestions, Ashish Panigrahi, for documentation and design suggestions, WingCode, for documentation, and to the broader community of Qrack contributors, for years of happy Qracking! You rock!**
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# pyqrack
|
2
|
+
[](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack) [](https://pepy.tech/project/pyqrack)
|
3
|
+
|
4
|
+
Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library
|
5
|
+
|
6
|
+
(**PyQrack** is just pure Qrack.)
|
7
|
+
|
8
|
+
**Note, if building from source**: You must build and install [unitaryfund/qrack](https://github.com/unitaryfund/qrack) to build the `main` branch from source. CI/CD builds wheels that contain pre-compiled Qrack binaries, and that is the form published on PyPi. **For PyQrack-CUDA, the package is distributed as source-only on PyPi, so that the Qrack build step can do its best to try to automatically detect your available CUDA architectures.**
|
9
|
+
|
10
|
+
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`.
|
11
|
+
|
12
|
+
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).
|
13
|
+
|
14
|
+
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.
|
15
|
+
|
16
|
+
`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**.
|
17
|
+
|
18
|
+
To load the required **unitaryfund/qrack** libraries from a different location, set the `PYQRACK_SHARED_LIB_PATH` environment variable.
|
19
|
+
|
20
|
+
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:
|
21
|
+
|
22
|
+
```python
|
23
|
+
sim = QrackSimulator(pyzxCircuit=c)
|
24
|
+
```
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
See [https://pyqrack.readthedocs.io/en/latest/](https://pyqrack.readthedocs.io/en/latest/) for an API reference.
|
29
|
+
|
30
|
+
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.
|
31
|
+
|
32
|
+
Please feel welcome to open an issue, if you'd like help. 😃
|
33
|
+
|
34
|
+
**Special thanks go to Zeeshan Ahmed, for bug fixes and design suggestions, Ashish Panigrahi, for documentation and design suggestions, WingCode, for documentation, and to the broader community of Qrack contributors, for years of happy Qracking! You rock!**
|
@@ -12,6 +12,7 @@ _IS_QISKIT_AVAILABLE = True
|
|
12
12
|
try:
|
13
13
|
from qiskit.circuit.quantumcircuit import QuantumCircuit
|
14
14
|
from qiskit.compiler.transpiler import transpile
|
15
|
+
from qiskit.circuit.library import U3Gate, UCGate
|
15
16
|
import numpy as np
|
16
17
|
import math
|
17
18
|
except ImportError:
|
@@ -30,6 +31,23 @@ try:
|
|
30
31
|
except ImportError:
|
31
32
|
_IS_TENSORCIRCUIT_AVAILABLE = False
|
32
33
|
|
34
|
+
|
35
|
+
def euler_angles_1q(m):
|
36
|
+
phase = (m[0][0] * m[1][1] - m[0][1] * m[1][0]) ** (-1.0/2.0)
|
37
|
+
U = [[phase * m[0][0], phase * m[0][1]], [phase * m[1][0], phase * m[1][1]]]
|
38
|
+
|
39
|
+
theta = 2 * math.atan2(abs(U[1][0]), abs(U[0][0]))
|
40
|
+
|
41
|
+
# Find phi and lambda
|
42
|
+
phiplambda = 2 * np.angle(U[1][1])
|
43
|
+
phimlambda = 2 * np.angle(U[1][0])
|
44
|
+
|
45
|
+
phi = (phiplambda + phimlambda) / 2.0
|
46
|
+
lamb = (phiplambda - phimlambda) / 2.0
|
47
|
+
|
48
|
+
return theta, phi, lamb
|
49
|
+
|
50
|
+
|
33
51
|
class QrackCircuit:
|
34
52
|
"""Class that exposes the QCircuit class of Qrack
|
35
53
|
|
@@ -199,6 +217,19 @@ class QrackCircuit:
|
|
199
217
|
|
200
218
|
return out
|
201
219
|
|
220
|
+
def file_gate_count(filename):
|
221
|
+
"""File gate count
|
222
|
+
|
223
|
+
Return the count of gates in a QrackCircuit file
|
224
|
+
|
225
|
+
Args:
|
226
|
+
filename: Name of file
|
227
|
+
"""
|
228
|
+
tokens = []
|
229
|
+
with open(filename, 'r') as file:
|
230
|
+
tokens = file.read().split()
|
231
|
+
return int(tokens[1])
|
232
|
+
|
202
233
|
def file_to_qiskit_circuit(filename):
|
203
234
|
"""Convert an output file to a Qiskit circuit
|
204
235
|
|
@@ -285,13 +316,25 @@ class QrackCircuit:
|
|
285
316
|
payloads[key] = np.array(op)
|
286
317
|
|
287
318
|
gate_list = []
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
319
|
+
control_pow = 1 << control_count
|
320
|
+
pLen = len(payloads)
|
321
|
+
if (pLen == 1) or ((control_pow - pLen) > (1 << 15)):
|
322
|
+
for c, p in payloads.items():
|
323
|
+
theta, phi, lam = euler_angles_1q(p)
|
324
|
+
if control_count > 0:
|
325
|
+
circ.append(
|
326
|
+
U3Gate(theta, phi, lam).control(num_ctrl_qubits=control_count, ctrl_state=c),
|
327
|
+
controls + [target]
|
328
|
+
)
|
329
|
+
else:
|
330
|
+
circ.append(U3Gate(theta, phi, lam), [target])
|
331
|
+
else:
|
332
|
+
for j in range(control_pow):
|
333
|
+
if j in payloads:
|
334
|
+
gate_list.append(payloads[j])
|
335
|
+
else:
|
336
|
+
gate_list.append(np.array([[1, 0],[0, 1]]))
|
337
|
+
circ.append(UCGate(gate_list), controls + [target])
|
295
338
|
|
296
339
|
return circ
|
297
340
|
|
@@ -57,8 +57,6 @@ class QrackNeuron:
|
|
57
57
|
self.alpha = alpha
|
58
58
|
self.tolerance = tolerance
|
59
59
|
|
60
|
-
self.amp_count = 1 << (len(controls) + 1)
|
61
|
-
|
62
60
|
if not _init:
|
63
61
|
return
|
64
62
|
|
@@ -121,7 +119,7 @@ class QrackNeuron:
|
|
121
119
|
Raises:
|
122
120
|
RuntimeError: QrackNeuron C++ library raised an exception.
|
123
121
|
"""
|
124
|
-
ket = self._real1_byref([0.0] * self.
|
122
|
+
ket = self._real1_byref([0.0] * (1 << len(self.controls)))
|
125
123
|
Qrack.qrack_lib.get_qneuron_angles(self.nid, ket)
|
126
124
|
self._throw_if_error()
|
127
125
|
return list(ket)
|