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
Photini - A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS.

A free, easy to use, digital photograph metadata (Exif, IPTC, XMP) editing application for Linux, Windows and MacOS. "Metadata" is said to mea

Jim Easterbrook 120 Dec 20, 2022
pix2tex: Using a ViT to convert images of equations into LaTeX code.

The goal of this project is to create a learning based system that takes an image of a math formula and returns corresponding LaTeX code.

Lukas Blecher 2.6k Dec 30, 2022
NFT collection generator. Generates layered images

NFT collection generator Generates layered images, whole collections. Provides additional functionality. Repository includes three scripts generate.py

Gleb Gonchar 10 Nov 15, 2022
Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery.

AtollGeoMorph Python scripts for semi-automated morphometric analysis of atolls from Landsat satellite Imagery. The python scripts included allow user

1 Dec 16, 2022
Snowfall - helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions

snowfall helpful image handling utils - abstracts various file and opencv and pil features into result oriented functions usage examples: from image_h

Less Wright 2 Jan 09, 2022
A Python package implementing various HDRI / Radiance image processing algorithms.

Colour - HDRI A Python package implementing various HDRI / Radiance image processing algorithms. It is open source and freely available under the New

colour-science 111 Dec 06, 2022
Random collage/montage generator with drop-shadow

Random Collage Example Usage These are the sample input files in $PWD for the below examples: 1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10

M B 1 Dec 07, 2021
Image Processing HighPass Filter With Python

Image_Processing_HighPassFilter High Pass Filter take the high frequency and ignore the low frequency High Pass Filter can be use to sharpening an ima

Felix Pratamasan 1 Dec 27, 2021
㊙️ Create standard barcodes with Python. No external dependencies. 100% Organic Python.

python-barcode python-barcode provides a simple way to create barcodes in Python. There are no external dependencies when generating SVG files. Pillow

Hugo Barrera 419 Dec 26, 2022
:rocket: A minimalist comic reader

Pynocchio A minimalist comic reader Features | Installation | Contributing | Credits This screenshots contains a page of the webcomic Pepper&Carrot by

Michell Stuttgart 73 Aug 02, 2022
Generate meme GIFs in which an image you choose can be viewed by the user only after they wait a whole hour.

Generate meme GIFs in which an image you choose can be viewed by the user only after they wait a whole hour.

Feliks Maak 1 Jan 31, 2022
Fix datetime EXIF data in photos downloaded from Google Takeout

fix-google-takeout Warning Use at your own risk. Backup your photos. Overview Google takeout for photos

Mayank Mandava 20 Nov 05, 2022
Combinatorial image generator for generative NFT art.

ImageGen Stitches multiple image layers together into one image. Run usage: stitch.py [-h] backgrounds_dir dinos_dir traits_dir texture_file

Dinosols NFT 19 Sep 16, 2022
PyGram Instagram-like image filters.

PyGram Instagram-like image filters. Usage First, import the client: from filters import * Instanciate a filter and apply it: f = Nashville("image.jp

Ajay Kumar Nagaraj 102 Feb 21, 2022
Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine.

img2dataset Easily turn large sets of image urls to an image dataset. Can download, resize and package 100M urls in 20h on one machine. Also supports

Romain Beaumont 1.4k Jan 01, 2023
TRREASURE_IMAGE is python lib by which you can hide anything in a .jpg image with Command-Line Interface[cli] feature

TRREASURE_IMAGE TRREASURE_IMAGE is a python third-party library with Command-Line Interface[cli] feature. Table of Contents General Info Python librar

Fatin Shadab 3 Jun 07, 2022
👷 Build images with images

👷 Build images with images. About Tiler is a tool to create an image using all kinds of other smaller images (tiles). It is different from other mosa

5.5k Jan 03, 2023
【萝莉图片算法】高损图像压缩算法!?

【萝莉图片算法】高损图像压缩算法!? 我又发明出新算法了! 这次我发明的是新型高损图像压缩算法——萝莉图片算法!为什么是萝莉图片,这是因为它是使动用法,让图片变小所以是萝莉图片,大家一定要学好语文哦! 压缩效果 太神奇了!压缩率竟然高达99.97%! 与常见压缩算法对比 在图片最终大小为1KB的情况

黄巍 49 Oct 17, 2022
LSB Image Steganography Using Python

Steganography is the science that involves communicating secret data in an appropriate multimedia carrier, e.g., image, audio, and video files

Mahmut Can Gönül 2 Nov 04, 2021
PyPixelArt - A keyboard-centered pixel editor

PyPixelArt - A keyboard-centered pixel editor The idea behind PyPixelArt is uniting: a cmdpxl inspired pixel image editor applied to pixel art. vim 's

Douglas 18 Nov 14, 2022