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
: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
Automatic picture transmission(APT) protocol decoder for NOAA weather satellites

Automatic picture transmission(APT) decoder Automatic picture transmission protocol is used by NOAA satellites. They constantly send a frequency modul

Jayachandra Kasarla 25 Aug 05, 2022
Tweet2Image - Convert tweets to Instagram-friendly images.

Convert tweets to Instagram-friendly images. How to use If you want to use this repository as a submodule, don't forget to put the fonts d

Janu Lingeswaran 1 Mar 11, 2022
cmdpxl: a totally practical command-line image editor

cmdpxl: a totally practical command-line image editor Features cmdpxl has many exciting functionalities, including Editing pixels one at a time! Savin

Jieruei Chang 475 Dec 23, 2022
Napari simpleitk image processing

napari-simpleitk-image-processing (n-SimpleITK) Process images using SimpleITK in napari Usage Filters of this napari plugin can be found in the Tools

Robert Haase 11 Dec 19, 2022
A SIXEL encoder/decoder implementation derived from kmiya's sixel

libsixel What is this? This package provides encoder/decoder implementation for DEC SIXEL graphics, and some converter programs. (https://youtu.be/0Sa

Hayaki Saito 2k Jan 09, 2023
💯 Watermark your images with one line of command

Watermarker 💯 Watermark your images with one line of command 🧐 $ pip3 install

Orhan Emre Dikicigil 3 May 01, 2022
QR code python application which can read(decode) and generate(encode) QR codes.

QR Code Application This is a basic QR Code application. Using this application you can generate QR code for you text/links. Using this application yo

Atharva Parkhe 1 Aug 09, 2022
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
Xmas-Tree-GIF-Tool - Convert any given animated gif file into an animation in GIFT CSV format

This repo is made to participate in Matt Parker's XmasTree 2021 event. Convert a

Aven Zitzelberger 2 Dec 30, 2021
Plots the graph of a function with ASCII characters.

ASCII Graph Plotter Plots the graph of a function with ASCII characters. See the change log here. Developed by InformaticFreak (c) 2021 How to use py

InformaticFreak 2 Apr 29, 2022
Parking management project which generates barcode parking ticket with user-friendly Tkinter program GUI

Parking-management-system Parking management project which generates barcode parking ticket with user-friendly Tkinter program GUI How to run Download

1 Jul 03, 2022
An ascii art generator that's actually good. Does edge detection and selects the most appropriate characters.

Ascii Artist An ascii art generator that's actually good. Does edge detection and selects the most appropriate characters. Installing Installing with

18 Jan 03, 2023
Graphical tool to make photo collage posters

PhotoCollage Graphical tool to make photo collage posters PhotoCollage allows you to create photo collage posters. It assembles the input photographs

Adrien Vergé 350 Jan 02, 2023
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
Converting Images Into Minecraft Houses

Converting Images Into Minecraft Houses In this particular project, we turned a 2D Image into Minecraft pixel art and then scaled it in 3D such that i

Mathias Oliver Valdbjørn Jørgensen 1 Feb 02, 2022
利用近邻法的弱点实现图片缩小后变成另一张图

这是我一个视频的配套代码。 视频是:利用近邻法的弱点实现图片缩小后变成另一张图 https://www.bilibili.com/video/BV1Lf4y1r7dZ 配套代码中,仅generate.py是核心文件,其余的图片神马的,都是赠品。 这个核心文件利用了近邻法缩放的弱点,可以将图a的像素按

偶尔有点小迷糊 182 Dec 19, 2022
A procedural Blender pipeline for photorealistic training image generation

BlenderProc2 A procedural Blender pipeline for photorealistic rendering. Documentation | Tutorials | Examples | ArXiv paper | Workshop paper Features

DLR-RM 1.8k Jan 02, 2023
Python Interface of P3D

pyp3d 介绍: pyp3d是一个可在python上使用的工具包,它提供了一种可使用python脚本驱动创建模型的方法,为三维建模提供了全新的思路。 pyp3d中定义了一系列建模相关的必要的数据类型,例如球体、圆锥台、四棱锥台、 拉伸体、圆角管等几何体,pyp3d还提供了许多函数来实现放置集合体、

20 Sep 07, 2022
Bringing vtk.js into Dash and Python

Dash VTK Dash VTK lets you integrate the vtk.js visualization pipeline directly into your Dash app. It is powered by react-vtk-js. Docs Demo Explorer

Plotly 88 Nov 29, 2022