QCEngine and LIQUi|>

This is an active QC simulator, which provides a programming interface, as well as a programmer's visual model, for QC operations. It's not finished yet, but you're welcome to browse. Please give feedback to qc@machinelevel.com!

©2016 All rights reserved. For more information, please send email to qc@machinelevel.com

Welcome!

QCEngine and LIQUi|> are both quantum computation simulators. They have overlapping functionality, and there are great reasons to try using both when doing QC simulation.

As I'm getting to know LIQUi|>, I've started by porting some of the samples into QCEngine (which is sort of my own personal shop tool), to verify that the two simulations produce the same answers.

This page is a side-by-side exploration of these two. I have a special attachment to one, but I actively use both, in order to have the right tool for the right job at all times.

Overall characteristics

Platforms/Languages
  • JavaScript - The version you're running now (it's built into this page). This is the primary version, as it's the most convenient to use. The core code is written in JavaScript, and then the WebGL is used (optionally) to access the GPU for faster computation.

  • C++ - The native C++ version provides more speed, access to SSE/AVX features, as well as multicore and multi-machine access.
Platforms/Languages
  • F# - Programming and scripting language, using Microsoft's Visual Studio tools, which provide a strong development and debugging feature set. The DLL can be used from compiled code, or accessed from an F# script.

Simulation Modes
  • Qubit - This is a general gate-oriented qubit simulation, written to provide a convenient way to code up quantum logic devices. To simulate N qubits, it uses 2N complex floating point numbers.

  • Linear Optics - This mode logically simulates Fock states in quantum photonics components such as optical beamsplitters, phase shifters, photon pair sources, and polarization gratings. The amount of space used for simulation depends on the number of photons, the number of modes, and the connections between modes in the program itself.

  • Stabilizer - An implementation of Stott Aaronson's CHP stabilizer simulation has been integrated for handling limited gates on large numbers of qubits.
For a little more detail on the approach to the qubit sim, see this whitepaper.

One interesting note: The qubit and linear optics simulations can be combined in the same circuit or program. Sometimes it's covenient to sketch something out as qubits, get it working, and then try to build it in linear optics.


Simulation Modes
  • Universal - Optimized, efficient and general, this is the version of the simulator I'll be using in this exploration. This is the one I've got the most experience with so far. The memory required is 2N for N entangled qubits.

  • Physical - This is a Hamiltonian simulator which simulates physical operation times by solving differential equations.

  • Stabilizer - Using a subset of quantum gates (the Clifford group), this one allows giant circuits to be simulated, by avoiding the need to store 2N items for N qubits.

For much more detail on these eimulations, see the LIQUi|> user manual, and also this paper.


Documentation

At this point, there's just a Quick Reference Guide, and a whole bunch of samples such as the ones on this introduction page.


Documentation

Extensive and comprehensive documentation is included in the download materials. In addition to the User Manual, there's a .chm reference, which is very handy. In addition, their website has a ton of useful material.


Visualization


As you step through the program, the quantum state is drawn as a grid of two-dimensional slices, based on the "Circle Paper" technique described in this whitepaper.


Visualization


LIQUi|> scripts can export circuit drawings, as handy Tex, SVG and HTML. Click here to see the output produced by the command Liquid.exe "__Entangle2(5)"



Running Liquid's built-in samples in both systems

In this section, I've taken samples from the LIQUi|> distribution and ported them to JavaScript, to run inside QCEngine. In each case, there's a built-in command, but also the source code, for side-by-side comparison.

If you're already familiar with one system, trying these out is a great way to learn the other one.

Entanglement
The entanglement samples just entangle a bunch of qubits, and then read the result.
Here's what the core of the code looks like in each system:








Notice that although they're in different languages (JavaScript and F# in this case), they're essentially doing the same thing. Each one allows you to write code as though you had a functioning quantim computer. In fact, each one will probably provide a handy way to control a real quantum computer, once those are readily available.




__Entangle1() is the basic entanglement demo.

Note: Anything up to 28 qubits should work fine, but if you do more than 22, you may want to show the browser's console output (F12 or ctrl-shift-J in Chrome or Firefox) in order to see the program's progress.




To run the same sample in LIQUi|>, use the command line:
Liquid.exe "__Entangle1(22)"


__Entangle2() has a different printing format, and allows LIQUi|> to test compiling and optimizing the circuit, to see the run speed. For QCEngine, there's no such step, so it's only a bit faster than __Entangle1() because it does less printing.




To run the same sample in LIQUi|>, use the command line:
Liquid.exe "__Entangle2(22)"


__Entangles() runs a 16-qubit entanglement 100 times, verifying the result by printing values which should be all-zero or all-one.





To run the same sample in LIQUi|>, use the command line:
Liquid.exe "__Entangles()"


Teleportation
The entanglement samples perform a typical teleport operation several times on randomly generated qubit states, printing the input and output states each time.




Something to try: After running the program, open the individual qubit displays in the circle chart, and then step through the program (by clicking on it). You'll actually see the state move from Src to Dest.
. .


To run the same sample in LIQUi|>, use the command line:
Liquid.exe "__Teleport()"

Here's what the source looks like in QCEngine:


...and here's the LIQUi|> version of the same thing:

More to come
That's it for now. There are more involved samples for both simulators (Shor and Grover and such), but I don't yet have matching implementations for a side-by-side demo.

Each of these sims has specific strengths, so I'm actively using both of them in my day-to-day work.
If you found this useful, or have questions, please feel drop me a note at qc@machinelevel.com.


About the Author
Eric Johnston is an inventor and acrobat who values surprise and whimsy above all other things. He lives in London, working independently as a machine-level code optimization specialist, and also as a postdoctoral researcher in Quantum Engineering at the University of Bristol Centre for Quantum Photonics.