Skip to main content

pyqrack - Pure Python vm6502q/qrack Wrapper

Project description

pyqrack

Downloads Downloads

Pure Python bindings for the pure C++11/OpenCL Qrack quantum computer simulator library

(PyQrack is just pure Qrack.)

To use this package, it's helpful to be familiar with vm6502q/qrack. Users gain much more control over options by building vm6502q/qrack and vm6502q/pyqrack from source. For advanced users, building from source is the intended primary method of PyQrack package distribution and use.

Import and instantiate QrackSimulator instances. This simulator can perform arbitrary single qubit and controlled-single-qubit gates, as well as other specific gates like SWAP.

Any 2x2 bit operator matrix is represented by a list of 4 complex floating point numbers, in row-major order.

Single and array "b" parameters represent Pauli operator bases. They are specified according to the enumeration of the Pauli class.

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.

The package installation directory contains a qrack_cl_precompile folder with executables for supported platforms, to compile OpenCL kernels once, beforehand, avoiding the need to recompile "just-in-time" every time that you load this package in a Python interpreter. If you no longer want to use precompiled kernels, or if precompilation fails, just delete the ~/.qrack directory, or the equivalent .qrack sub-directory in the user home folder of your operating system.

To load the required vm6502q/qrack libraries from a different location, set the PYQRACK_SHARED_LIB_PATH environment variable. If an absolute path is set for this variable, it will be treated as an absolute path. If a relative path is used, the pyqrack package qrack_system directory is the root.

PyQrack v0.4.6 adds experimental support for 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:

sim = QrackSimulator(pyzxCircuit=c)

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.

See https://pyqrack.readthedocs.io/en/latest/ for an API reference.

Please feel welcome to open an issue, if you'd like help. 😃

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!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqrack-1.27.0.tar.gz (31.4 kB view hashes)

Uploaded Source

Built Distributions

pyqrack-1.27.0-py3-none-win_amd64.whl (4.7 MB view hashes)

Uploaded Python 3 Windows x86-64

pyqrack-1.27.0-py3-none-manylinux_2_35_x86_64.whl (4.8 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.35+ x86-64

pyqrack-1.27.0-py3-none-manylinux2014_x86_64.whl (4.8 MB view hashes)

Uploaded Python 3

pyqrack-1.27.0-py3-none-macosx_10_4_universal2.whl (3.1 MB view hashes)

Uploaded Python 3 macOS 10.4+ universal2 (ARM64, x86-64)

pyqrack-1.27.0-py3-none-linux_armv7l.whl (4.6 MB view hashes)

Uploaded Python 3

pyqrack-1.27.0-py3-none-any.whl (26.4 MB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page