QCEngine Hands-On Introduction

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!

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

Welcome to the intro!

This page provides a functional hands-on introduction to this system.
The simulator is live and running at all times, so you can write code as though you had an actual QC running.

See this link for a QCEngine Quick Programming Reference .

Why does QCEngine exist?

QCEngine is a quantum computation playground for software engineers which...

1. Basic operation

Here's a simple program which just does a bunch of basic operations.

Try this: Run the program, and then click in the gates on the chart to inspct the quantum state after each operation. You can run the program forward or backward, but be aware that non-reversible operations only really make sense if you run them forward.

Try this: Modify the program! Change the number of qubits. Ask the sim for a hundred of them, or a thousand. That'll work, but once you're above 24 or so, the sim wili become digital-only (non-quantum) so many operations will still work, but not interference or superposition.

2. Entanglement

Here's a program which demonstrates entanglement of two qubits.

Try this: Run the program several times, and watch the output. Notice that the values of the two bits are always random, but always match.

Try this: Click the gates to watch the entanglement happen.

This program does entanglement using a CZ gate instead of a cnot gate.

Try this: Click the gates to watch the entanglement happen.

3. Teleportation

Here's a quick teleportation circuit.

Notice: We've started using the qint type to label the qunbits.

Try this: Increase the "num_bits", so that Alice can teleport more data to bob.

The example above uses the convenient notation of Bob doing a cnot on Alice's result bits. That's not necessary, and here we show reading the values directly and applying them.

Try this: Run it several times, and watch bob change his actions depending on Alice's results.

We don't actually need to construct it from gates each time; all of this can be wrapped up into functions, for convenience.

4. Cluster States

Here we construct all of the different topological 4-bit cluster states.

Notice: The program turns on the "color by phase" option, to make it easier to see the cluster states.

4b. Stabilizer Sim

For working with large graph states, the stabilizer simulation is useful. It's based on CHP, written by Scott Aaronson and Daniel Gottesman. The CHP sim simulates a small subset of gates (CNOT, Hadamard, 90-degree phase) which isn't enough for universal computation.

The CHP simulation may be turned on and off as desired during a program, in order to accelerate operations where it's sufficient.

This simple demo uses CHP to perform entannglement of 1000 qubits, very quickly.

Here we turn on CHP to generate a cluster quickly, but then switch it off to perform a QFT, which is something it can't do.

Note that it prints out the stabilizer state after constructing the cluster.

Pro tips:
  • By clicking in the gates window, you can single-step, in all modes.
  • Use Shift + mousewheel in the circle window to see tiny state vectors.
  • Use Ctrl + mousewheel in the circle or gates window to zoom.

...and here are some of the samples which come with CHP. In the source code, you can see that they're the original content, just inserted as JavaScript strings.

5. Beam Splitters, Part 1

For basic single-qubit beamsplitters, there's just a simple command. Beamsplitters which mix qubit states will be shown later.

Notice: At this stage, the dual-rail representation is cosmetic. Later it gets more serious.

Notice: The first qubit here has a Hadamard made of beamsplitters.

6. QKD

This program shows the basic quantum key distribution model, with quantum RNG for both Alice and Bob.

Here's the version with Eve being a sneaky spy.

7. Integer Math

Using the qint type, math functions (add, subtract, multiply, etc) can be performed on sets of qubits, even in superposition, even if the number of bits isn't the same.

Notice: When we read the register, a random equation is pulled from the superposition, but it's always self-consistent.

8. Beam Splitters, Part 2

To use beam splitters more generally, we need to expand the Fock states to full dual-rail. This program implements the CNOT version of this QCloud Demo.
(This part is under construction)

This builds an optical postselected CNOT gate.

This builds an optical postselected CZ gate.

This builds an optical postselected CZ gate with simple aux-bits.

(Under construction, Jeremy's device)

(Under construction, Comms QKD 1)

(Under construction, Comms QKD 2)

(Under construction, Comms QKD 3)

(Under construction, Comms Dave & Co)

9. Pair sources

10. Distinguishability and Mixed States

Although the sim normally operates on pure states, there's a very common case in photonics where you can't be sure the photons are 100% indistinguishable, which causes faults in the quantum behavior.
Two photons Here we build a simple photonic circuit in a classic HOM-dip test, and then add some code to handle distinguishability-related imperfections.
Try this: Run the program, then change the distinguishability to a new value in [0, 1] and run it again.

(Under Construction) This is an experiment.