Monday, December 26, 2022

Quantum circuit simulation using Julia

For better or worse, most researchers working in quantum computing write and simulate quantum circuits using python libraries such as Qiskit, Amazon Braket, QuTip, and Qibo

Python is great for prototyping, particularly when one can cobble together existing libraries that call low level C or Fortran code to perform the most time-consuming parts of the computation. However the performance of Python code will inevitably be worse than optimised code written for compiled languages. 

This is usually an acceptable tradeoff for physicists - we prefer to do physics over low level code optimization and debugging. Unfortunately state-of-the-art quantum processors have reached a scale where numerically simulating them is extremely slow and (arguably) intractable for classical computers. Cue waiting for hours or even days for code to run.

That's why many researchers are starting to use Julia for simulating quantum circuits. Julia uses just-in-time compilation to achieve speeds comparable to C without sacrificing being easy to write and debug. As an example, the figure below (taken from arXiv:221209537) demonstrates computation of matrix permanents (crucial for simulation of BosonSampling experiments) two orders of magnitude faster than Matlab and Python implementations!

Benchmarking Julia against python and matlab code for computation of matrix permanents using Ryser's algorithm

 Other Julia libraries for quantum being developed include Yao.jl (differentiable quantum circuit simulation), QuantumCumulants.jl (simulation of open quantum systems), QXTools (distributed tensor network simulations of quantum circuits), and Quiqbox.jl (computational quantum chemistry subroutines). For more, see this list of open source quantum software projects.

I have tested Julia on a few photonics-specific problems, including the numerical solutions of the nonlinear Schrodinger equation and photonic band structure calculations. I particularly liked the ease of translating mathematical expressions to working code (for example, Julia supports unicode variables), ability to easily parallelize code, and (optional) type declarations for improving performance and debugging. 

Why not give Julia a try for your next project?

No comments:

Post a Comment