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
🎶😤 Generate an image indicating what you are listening to 😳

I'm Listening to This (song that I've sent you an image about detailing its metadata in a nifty way) Few lines describing your project. 📝 Table of Co

Connor B - Viibrant 4 Nov 03, 2021
Generate waves art for an image

waves-art Generate waves art for an image. Requirements: OpenCV Numpy Example Usage python waves_art.py --image_path tests/test1.jpg --patch_size 15 T

Hamza Rawal 18 Apr 04, 2022
⚡ZenGL is a minimalist Python module providing exactly one way to render scenes with OpenGL.

ZenGL is a minimalist Python module providing exactly one way to render scenes with OpenGL.

Szabolcs Dombi 133 Dec 17, 2022
LabelMe annotation tool source code

LabelMe annotation tool source code Here you will find the source code to install the LabelMe annotation tool on your server. LabelMe is an annotation

MIT CSAIL Computer Vision 1.3k Jan 03, 2023
Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom

Clip Bing Maps backgound as RGB geotif image using center-point from vector data of a shapefile and Bing Maps zoom. Also, rasterize shapefile vectors as corresponding label image.

Gounari Olympia 2 Nov 22, 2021
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
An esoteric visual language that takes image files as input based on a multi-tape turing machine, designed for compatibility with C.

vizh An esoteric visual language that takes image files as input based on a multi-tape turing machine, designed for compatibility with C. Overview Her

Sy Brand 228 Dec 17, 2022
Ascify-Art - An easy to use, GUI based and user-friendly colored ASCII art generator from images!

Ascify-Art This is a python based colored ASCII art generator for free! How to Install? You can download and use the python version if you want, modul

Akash Bora 14 Dec 31, 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
Pnuemonia Normal detection by using XRay images.

Pnuemonia Normal detection by using XRay images. Got image datas from kaggle(link is given in sources.txt file) also normal xray images from other site (also link is given) in order to avoid data dis

Zarina 1 Feb 28, 2022
Depix is a tool for recovering passwords from pixelized screenshots.

This implementation works on pixelized images that were created with a linear box filter. In this article I cover background information on pixelization and similar research.

23.1k Jan 04, 2023
将位图转为彩色矢量 svg 图片

一个将位图描摹为彩色矢量 svg 图片的程序,是一个命令行工具,使用 Python 脚本实现,运行环境 Python3.8+。 ✨ 效果 以一个字帖图片为例,这是 png 格式的位图(370KB): 这是颜

Haujet Zhao 104 Dec 30, 2022
Change the image one color channel at a time.

Building-a-Contact-Sheet This hands-on Project is in Python 3 Programming Specialization offered by University of Michigan via Coursera. change the im

Eszter Pai 1 Jan 03, 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 08, 2023
A scalable implementation of WobblyStitcher for 3D microscopy images

WobblyStitcher Introduction A scalable implementation of WobblyStitcher Dependencies $ python -m pip install numpy scikit-image Visualization ImageJ

CSE Lab, ETH Zurich 7 Jul 25, 2022
Fast Image Retrieval (FIRe) is an open source image retrieval project

Fast Image Retrieval (FIRe) is an open source image retrieval project release by Center of Image and Signal Processing Lab (CISiP Lab), Universiti Malaya. This project implements most of the major bi

CISiP Lab 39 Nov 25, 2022
Craft PNG files that appear completely different in Apple software

Ambiguous PNG Packer Craft PNG files that appear completely different in Apple software

David Buchanan 1k Dec 29, 2022
Python Program that lets you write in your handwriting!

Handwriting with Python Python Program that lets you write in your handwriting! Inspired by: thaisribeiro.in How to run? Install Unidecode and Pillow

Amanda Rodrigues Vieira 2 Oct 25, 2021
A minimal, standalone viewer for 3D animations stored as stop-motion sequences of individual .obj mesh files.

ObjSequenceViewer V0.5 A minimal, standalone viewer for 3D animations stored as stop-motion sequences of individual .obj mesh files. Installation: pip

csmailis 2 Aug 04, 2022
Goddard Image Analysis and Navigation Tool

Copyright 2021 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is clai

NASA 12 Dec 23, 2022