[ANN] Yao.jl: Extensible, Efficient Quantum Algorithm Design for Humans

A slide show is also available:

Yao is a framework for quantum algorithm design. The package provide Julians the ability to design and test your own quantum algorithm on a classical computer (like your laptop).

Background In near term future, quantum devices for computing will only be able to provide a few noisy physical qubits, and although we have IBM Q and many other cloud service, the resources of testing a quantum algorithm could still be limited. But we can use our classical machines to simulate the quantum and associate us to explore the quantum world! And you will be able to learn and explore quantum computation right on your laptop with up to 25+ simulated qubits (depends on the type of circuit and your machine type).

Features Yao is a framework that is about to have the following features:

  • Extensibility
    • define new operations with a minimum number of methods in principle.
    • extend with new operations on different hardware should be easy, (e.g GPUs, near term quantum devices, FPGAs, etc.)
  • Efficiency
    • comparing with python, julia have no significant overhead on small scale circuit.
    • special optimized methods are dispatched to frequently used blocks.
    • double interfaces “apply!” and “cache server + mat” allow us to choose freely when to sacrifice memory for faster simulation and when to sacrifice the speed to simulate more qubits.
  • Easy to Use
    • As a white-box simulator, rather than using a black box, users will be aware of what their simulation are doing right through the interface.
    • Hierarchical APIs from low abstraction quantum operators to highly abstract circuit block objects.

Benchmarks We beat ProjectQ on several benchmarks which could be crucial to classical simulation of a quantum computer. The whole project is implemented in pure Julia, and we achieve much better performance in small number of qubits and similar performance for large number of qubits. However, we are not able to beat all the gates comparing to ProjectQ’s C++ backend, which is only because of we have not optimized them. We will provide more optimization in the following version. For detailed benchmark, please check our docs: https://quantumbfs.github.io/Yao.jl/latest/dev/benchmark/

Please check our README for more info. Questions, Issues and Suggestions are welcome.


ProjectQ is a state of art quantum simulator, it kept the record of 45 qubit quantum circuit simulation for several months: https://arxiv.org/abs/1704.01127
It uses parallisms like SIMD, OpenMP, MPI to speed up calculation.

From the benchmark, we see both the Yao and ProjectQ are close to the theoretical bound in performance.

ProjectQ has C++ backend, while Yao.jl uses pure julia. Yao.jl has significantly less overhead than ProjectQ, which benefits from julia’s jit and multile dispatch.

In some benchmarks, like repeated blocks, Yao.jl can perform much better, this is an algorithmic win. Thanks to julia’s multiple dispatch, we can dispatch any advanced-speciallized algortihm to push the performance for frequently used gates easily, without touching the backend!



How does it compare to other Julia packages such as QuCircuit.jl, QuCmp, QI.jl… and to other languages such as Cirq?
I studied pyshics and electronics but I work as a data analyst. I’d like to go back to my roots, physics, and I’m specially interested on quantum computing.
What language/framework should I learn?

I’m the author of QuCircuit.jl QuCmp.jl, they aren both deprecated projects and are not maintained anymore.

IMO, QI is not a large package and is not for quantum computation. Yao currently is the only quantum computing framework in Julia. Comparing to Cirq, we may have better performance on the simulation and the design of this package is based on an AST like block tree, which allow us to extend, compile quantum circuit related computation easily.

However, we are still in early stage, and lack of some feature, such as qasm compilation, plotting, and unlike cirq and other packages, we currently do not have plan to support experimental hard ware, since we are lack of developers. We will mainly focus to support the theoretical research in quantum algorithms.

In the following release (v0.3), we are planning to support GPU acceleration, and automatic differentiation for quantum circuits. The whole project will be separated to several package and Yao.jl will be a meta package like DifferentialEquations.jl

Rather than learning a package, I would suggest you to learn Neilson’s text book as a start. But please feel free to open an issue under our repo if you have any further questions about the package.




Hi, I’m in a similar situation , I’m new to Julia and searching for a good package for quantum physics and information. As a start I want just to do bra, ket and matrix operations, and print them (I’m writing a book) but also I want to jump into algorithms and start doing experiments with bell states, etc. What’s the book that you recommended to the other poster, Nielsen’s? Or something about Julia scientific programming? I’m thinking in reading Think Julia for the basics . Thanks

Hi, I was working on a tutorial for physicist, but it’s not completely done yet. But I think Think Julia would be a good start if you don’t know Julia before.

As for quantum physics, I would suggest Nielsen if you are interested in Yao and quantum computing. Our framework’s notation is mainly based on Nielsen, thus it should be smooth enough to start. If you have learnt the basics about quantum algorithms, you could directly start reading the examples and QuAlgorithmZoo (the code base is a bit ugly for now, sorry for that).

As for quantum physics in numerics, we don’t really need to have ket and bra explicitly, since this is done by adjoints in most cases. So you could just use adjoint instead, if you need to pretty print things, consider https://github.com/korsbo/Latexify.jl

We don’t have builtin support for Latexify in Yao yet, but anyone who like it could create your own Yao extension as a normal Julia package now!