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

Overview

pyqrack

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

(PyQrack is just pure Qrack.)

IMPORTANT: You must build and install vm6502q/qrack to use this.

(This barrier to usage will be removed, shortly.)

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 matrices 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 specifiied 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.

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

Comments
  • General help thread

    General help thread

    The only dependency of pyqrack, being the underlying https://github.com/vm6502q/qrack library, is stable, validated, and relatively quiescent, for now, in my estimation as lead developer. A few months ago, it would have been more difficult to package shared library builds for it, for a project like pyqrack. However, I think it's likely that my upcoming development time on vm6502q will tend be in "superstructure" plugins, at least a good while, like Unity3D, respective "Big 5" framework plugins, and now pyqrack.

    So, I want to add this library to the pypi registry, bundled with respective qrack shared library builds appropriate to each wheel. Maybe I can solicit advice from those with more Python experience: what's the best way to do this?

    Over in my OpenRelativity fork, for Unity3D, I build an excessive number of OS/CPU combination shared library versions of qrack. These include the following:

    1. x86_64 Linux
    2. ARMv7 Linux
    3. ARM64 Liinux
    4. x86_64 Mac
    5. ARM64 iOS ("Any iOS device," in XCode)
    6. x86_64 Windows
    7. x86 Windows
    8. ARMv7 Android
    9. ARM64 Android
    10. x86 Android
    11. WASM

    ... I think that's it, so far. In fact, I don't plan to update qrack code, right now, so I think I'm about to build all of the above again, right now, just as part of my development cycle. For the python package, for those platforms that actually support GPU, I'd probably also like to build separate CPU/GPU binary packages, potentially. The GPU binaries actually will automatically detect if 0 OpenCL devices are available, and fall back to CPU-only defaults, (without needing to link any more OpenCL in qrack user code, by the way, if we're at C++ level). However, initializing the qrack OpenCL environment, to perform this check, or just in general, adds a significant one-time delay to scripts, every time the shared library is loaded, and I'd like people to be able to bypass this.

    Who can suggest the best way to package these, for pypi? (I'll do it all myself, if necessary, and track progress in this issue.)

    help wanted 
    opened by WrathfulSpatula 9
  • Consider using pybind for seamless operability between C++11 and python

    Consider using pybind for seamless operability between C++11 and python

    Hi Dan!

    Now that pyqrack has been made with the intention of providing python bindings for qrack, might I suggest using the pybind library made specifically for this purpose. This will reduce a lot of work writing these bindings from scratch. :-)

    opened by paniash 7
  • Minor bug fixes.

    Minor bug fixes.

    There were a few minor bugs that went unnoticed, a few more of them persist that require discussion that can be continued on this thread before it is merged with the main branch.

    opened by Zshan0 5
  • Official PyQrack Documentation

    Official PyQrack Documentation

    PyQrack has no documentation, beyond its README. The reason this can be, despite some hundred thousand downloads worth of utilization by others, is that PyQrack exposes a quantum gate API that is well-known colloquialism; what "T" means as a gate name in any quantum computing API is what it means in PyQrack, and so on for most-to-all gates in qrack_simulator.py, basically. This isn't entirely welcoming to new users, though. Many would benefit from a repository of readable API definition, at least.

    Work toward formal documentation of PyQrack API can constitute unitaryHACK contribution. I can start a vm6502q organization repository for this, before or during unitaryHACK.

    help wanted unitaryhack-bounty 
    opened by WrathfulSpatula 5
  • Strange (but good?) stabilizer performance

    Strange (but good?) stabilizer performance

    Having fixed the fundamentally slow measure_shots() performance, from obviously sub-optimal implementation, I'm finding anomalous performance results on a universal random gate set that seems to be engaging solely our extension to stabilizer simulation, but also returning seemingly correct results. (i.e. Performance appears linear over qubit width.)

    The gate set in question can include [X, Y, Z, H, S, T, AdjS, AdjT] / [SWAP, CX, CY, CZ, CCX, CCY, CCZ, ACX, ACY, ACZ, ACCX, ACCY, ACCZ], and measure_shots() for at least specifically a single "shot" measurement sample. (Therefore, this specifically might not include mid-circuit "collapsing" measurement, though.)

    I'm asking any interested persons in the community to apply maximum scrutiny, here. Tests conducted so far include Qiskit Aer unit tests over the PyQrack/Qiskit plugin, (for at least sanity check on individual gates,) mirror circuit checks for self-consistency of benchmark circuits (which can tell us that a round-trip of benchmark circuit "mirrored" with its inverse, for every width/depth combination in the benchmark suite, returns to a known and and exact permutation basis state) and "eyeballing" measurement distribution comparison on L1 norm between PyQrack and Qiskit Aer on the exact same trial circuits, for basic plausibility.

    Claiming linear performance on this gate set, happening solely by extension of stabilizer, probably requires "extraordinary" evidence, or at least a perfectly transparent proof via experiment, if proof is as simple to provide as my tests above. I'm asking our community, please "poke" this with some scrutiny, and report if any logical tests fail.

    help wanted 
    opened by WrathfulSpatula 5
  • v0.9.0: Exception handling and choice of CPU-only

    v0.9.0: Exception handling and choice of CPU-only

    Currently, if any OpenCL device ICD is visible to the PyQrack package binaries, then CPU-only simulation cannot be selected, at all. (It is possible to force CPU-only operation by installing PyQrack from source, along with Qrack from source, installed in /usr/local with CMake and make, but...) We should give the full discretion to explicitly choose CPU-only simulation. This will constitute v0.9.0, with any further updates in the Qrack binary.

    opened by WrathfulSpatula 3
  • OpenCL (multiple) platform interop instability

    OpenCL (multiple) platform interop instability

    By default, the underlying Qrack library tries to use every OpenCL device available on the system, as best it can, at once. We give the option to control the primary device, via environment variable, but I've run into a situation, just in the past couple of days, where my Intel HD doesn't interop correctly with my NVIDIA RTX, under significant load.

    We should give users another environment variable to soft-ban OpenCL devices from automatic attempts at load balancing. Alternatively, we might rather state this option in terms of a list of devices to include exclusively in Qrack's automatic multiple-device operation. Either way, I'm currently using VirtualCL to hide OpenCL devices from the Qrack environment context, but this overhead shouldn't be necessary, when this would be trivial to implement in Qrack directly.

    bug wontfix 
    opened by WrathfulSpatula 3
  • Expose Qrack arithmetic

    Expose Qrack arithmetic

    I'm working, in off hours, on a set of Jupyter notebooks to demonstrate useful applications of pyqrack. Big, obviously interesting examples include Shor's algorithm and Grover's algorithm. Both of these are much more easily implemented if Qrack's optimized "ALU" is exposed to the shared library, (that is, the arithmetic methods).

    I'll be iterating to v0.3.0 within the next day or two, or no later than the end of the upcoming weekend, specifically to expose the ALU methods, via a regularized set of signatures. Since we now have a constant time SWAP gate, (believe it or not,) there's no performance disincentive to letting users supply Python lists of arbitrary-order qubit indices, for arithmetic methods.

    enhancement 
    opened by WrathfulSpatula 3
  • Pennylane plugin

    Pennylane plugin

    Qrack has offered a Qiskit QrackProvider plugin for Pennylane, but the wrapping in Qiskit is likely sub-optimal compared to a direct PyQrack plugin.

    I am starting a new repository for such a plugin. Contribution to its materials can constitute a unitaryHACK contribution, including documentation and example programs.

    opened by WrathfulSpatula 2
  • [unitaryhack] Official documentation

    [unitaryhack] Official documentation

    As mentioned in #16, there is no official documentation present for pyqrack. The documentation was made on the pyqrack.github.io repository and is being added as docstrings in the original source code. To avoid merge conflicts and other python issues, the code present in the files of the website counterpart has no functionality and has only the docstrings attached to the function.

    unitaryhack-accepted 
    opened by Zshan0 1
  • Exposed measurement operations are fundamentally slow

    Exposed measurement operations are fundamentally slow

    Comparing Qrack performance to that of PyQrack, PyQrack is at an extreme disadvantage on a task like a QFT of a permutation basis eigenstate. Controlling for other potential causes, I have identified that this is due to the measurement methods selectively exposed in PyQrack.

    At least for single-shot circuit simulation, we should directly expose non-sampling-based measurement methods. Ultimately, we should address the efficiency of sampling methods, as well.

    opened by WrathfulSpatula 1
  • CI publishing pipeline

    CI publishing pipeline

    It would be great to have a continuous integration (CI) build and publishing pipeline. (The primitiveness of my current method should rightly embarrass me, but "I know why I do it my way.") pyqrack might require something a little particular for its wheel variants, which is to build one (or two) binary distributions respective to the platforms of its available wheels, and just package that one binary variant in each respective wheel, where the Python code can find the right Qrack binary paths also based upon its own access to system information.

    We want each wheel to have a respective Qrack binary build on the same platform as the wheel tag, and only that respective binary, with many respective wheel with binary pairings. I'd love and deeply appreciate help from the community, on this one, for I do spend too much time manually building to produce such a result.

    enhancement help wanted 
    opened by WrathfulSpatula 0
  • Unit tests: mirror circuits

    Unit tests: mirror circuits

    We rely on Qrack library unit tests, but a random mirror circuit integration test should be adapted from the underlying Qrack test suite. It can give excellent coverage in a fast test, though it's not modular. At least, it's a tractable atomic step toward PyQrack unit tests and tooling.

    good first issue help wanted unitaryhack-bounty 
    opened by WrathfulSpatula 1
Releases(v0.21.20)
Owner
vm6502q
Qrack quantum computer simulator, VM6502Q, and external integrations
vm6502q
HyperBlend is a new type of hyperspectral image simulator based on Blender.

HyperBlend version 0.1.0 This is the HyperBlend leaf spectra simulator developed in Spectral Laboratory of University of Jyväskylä. You can use and mo

SILMAE 2 Jun 20, 2022
A pure python implementation of the GIMP XCF image format. Use this to interact with GIMP image formats

Pure Python implementation of the GIMP image formats (.xcf projects as well as brushes, patterns, etc)

FHPyhtonUtils 8 Dec 30, 2022
Sombra is simple Raytracer written in pure Python.

Sombra Sombra is simple Raytracer written in pure Python. It's main purpose is to help understand how raytracing works with a clean code. If you are l

Hernaldo Jesus Henriquez Nuñez 10 Jul 16, 2022
Computer art based on quadtrees.

Quads Computer art based on quadtrees. The program targets an input image. The input image is split into four quadrants. Each quadrant is assigned an

Michael Fogleman 1.1k Dec 23, 2022
Computer art based on joining transparent images

Computer Art There is no must in art because art is free. Introduction The following tutorial exaplains how to generate computer art based on a series

Computer Art 12 Jul 30, 2022
The friendly PIL fork (Python Imaging Library)

Pillow Python Imaging Library (Fork) Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lund

Pillow 10.4k Dec 31, 2022
Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard.

Vignette Vignette is a Python library to create and manage thumbnails following the FreeDesktop standard. Thumbnails are stored in a shared directory

null 3 Feb 6, 2022
Python library for ascii graphics

Python library for ascii graphics

Anton 6 Oct 20, 2021
kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns

kikuchipy is an open-source Python library for processing and analysis of electron backscatter diffraction (EBSD) patterns. The library builds on the

pyxem 53 Dec 29, 2022
Seaborn-image is a Python image visualization library based on matplotlib and provides a high-level API to draw attractive and informative images quickly and effectively.

seaborn-image: image data visualization Description Seaborn-image is a Python image visualization library based on matplotlib and provides a high-leve

null 48 Jan 5, 2023
starfish is a Python library for processing images of image-based spatial transcriptomics.

starfish: scalable pipelines for image-based transcriptomics starfish is a Python library for processing images of image-based spatial transcriptomics

null 199 Dec 8, 2022
A python based library to help you create unique generative images based on Rarity for your next NFT Project

Generative-NFT Generate Unique Images based on Rarity A python based library to help you create unique generative images based on Rarity for your next

Kartikay Bhutani 8 Sep 21, 2022
A 3D structural engineering finite element library for Python.

An easy to use elastic 3D structural engineering finite element analysis library for Python.

Craig 220 Dec 27, 2022
Python binding to Skia Graphics Library

Skia python binding Python binding to Skia Graphics Library. Binding based on pybind11. Currently, the binding is under active development. Install Bi

Kota Yamaguchi 170 Jan 6, 2023
An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright.

Playwright nonoCAPTCHA An async Python library to automate solving ReCAPTCHA v2 by audio using Playwright. Disclaimer This project is for educational

Michael Mooney 69 Dec 28, 2022
PIX is an image processing library in JAX, for JAX.

PIX PIX is an image processing library in JAX, for JAX. Overview JAX is a library resulting from the union of Autograd and XLA for high-performance ma

DeepMind 294 Jan 8, 2023
impy is an all-in-one image analysis library, equipped with parallel processing, GPU support, GUI based tools and so on.

impy is All You Need in Image Analysis impy is an all-in-one image analysis library, equipped with parallel processing, GPU support, GUI based tools a

null 24 Dec 20, 2022
A tool and a library for SVG path data transformations.

SVG path data transformation toolkit A tool and a library for SVG path data transformations. Currently it supports a translation and a scaling. Usage

Igor Mikushkin 2 Mar 7, 2022
A tool to maintain an archive/mirror of your Google Photos library for backup purposes.

Google Photos Archiver Updated Instructions 8/9/2021 Version 2.0.6 Instructions: Download the script (exe or python script listed below) Follow the in

Nick Dawson 116 Jan 3, 2023