Giter VIP home page Giter VIP logo

quizx's Introduction

QuiZX: a quick Rust port of PyZX

PyZX is a Python library for quantum circuit optimisation and compiling using the ZX-calculus. It's great for hacking, learning, and trying things out in Jupyter notebooks. However, it's written to maximise clarity and fun, not performance.

This is a port of some of the core functionality of PyZX to the Rust programming language. This is a modern systems programming language, which enables writing software that is very fast and memory efficient.

See the CONTRIBUTING.md file for detailed instructions for building the libraries from source and contributing to the project.

A bit about performance

As a very anecdotal example of the performance difference, the program spider_chain builds a chain of 1 million green spiders and fuses them all. In PyZX, you can fuse all the spiders in a ZX-diagram as follows:

from pyzx.basicrules import *

success = True
while success
    success = any(fuse(g, g.edge_s(e), g.edge_t(e)) for e in g.edges()):

In QuiZX, the Rust code is slightly more verbose, but similar in spirit:

use quizx::basic_rules::*;

loop {
    match g.find_edge(|v0,v1,_| check_spider_fusion(&g, v0, v1)) {
        Some((v0,v1,_)) => spider_fusion_unsafe(&mut g, v0, v1),
        None => break,
    };
}

On my laptop, the PyZX code takes about 98 seconds to fuse 1 million spiders, whereas the QuiZX code takes 17 milliseconds.

TODO

QuiZX is very much a work in progress. It is not intended to have all the features of PyZX, but certainly the core stuff. Here's where it's at:

  • ZX-diagrams
    • building ZX-diagrams and doing basic graph manipulations
    • converting ZX-diagrams to Z + hadamard form
    • switchable underlying graph model (fast vector-based model for sparse graphs, slower hash-based model for dense graphs)
  • ZX-calculus rules
    • spider fusion
    • local complementation
    • pivoting
    • remove identity spiders
    • colour-change
    • pivoting variations (boundary-pivot and gadget-pivot)
  • simplifiers
    • clifford simplifier (from this paper)
    • phase gadget simplifier (from this paper)
    • simplification-based equality checker
  • tensor evaluation based on ndarray
    • exact scalars with cyclotomic rational numbers
    • floating point scalars based on num_complex
    • tensor contraction for arbitrary ZX-diagrams
    • equality of tensors with exact scalars
    • approximate equality of tensors with floating point scalars
    • space optimisations
    • choose good contraction ordering (currently uses reverse-insertion-order)
    • more human-readable tensor output (e.g. converting to normal matrices, pretty printing)
  • circuits
    • circuit data type
    • read and write QASM
    • conversion from circuits to ZX-diagrams
    • circuit extraction (working, but buggy)

Pull requests are welcome!

quizx's People

Contributors

aborgna avatar aborgna-q avatar akissinger avatar dependabot[bot] avatar jarofghosts avatar jpopesculian avatar jvdwetering avatar rvilmart avatar tuomas56 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.