Quantum Computing Playground was developed in 2014 by a group of Google engineers.
To report bugs, suggest new features, or send comments, please contact Laura Culp.
The source code of Quantum Computing Playground has been published on GitHub under Apache 2.0 license.
This is a simulated model of a quantum computer, and it has one quantum register, with a fixed size of between 6 and 22 qubits. Users can interact with the simulated quantum computer by writing scripts using a language called QScript, which can then be saved and shared. All saved scripts are public, but are only accessible through knowledge of a specific URL. A development environment, providing compilation and debugging features, can be used, and the quantum state of the register can be visualized in multiple ways.
Internally the quantum register is stored as global vector state of the quantum system,
in a floating point RGB or RGBA texture of the proper size. For example, if a state vector
has 8 qubits, there need to be 256 quantum states, so the texture storing this information
is of size 16 x 16 pixels.
Only the R and G components of the pixel are used
(for the real and imaginary parts of the state; usage of LA textures is still considered,
but apparently the RGBA type of texture is most commonly supported).
Quantum gates are typically implemented as separate GLSL pixel shader programs.
In the shaders we need to address the states of the vector directly through a bitmap,
and since WebGL does not support proper integer arithmetic,
we only have 23 significant bits available in a FP number,
thus our vector size is limited to 22 qubits (it must be even for the maximum
texture size of 2048 x 2048 pixels).
In theory, with more GPU memory available, vectors of up to 28 qubits could be supported,
but addressing the states in any complex way would slow the shader programs.
Operations that need integration of the vector state (like normalization or measurement), use reducing shaders. For an example to find maximum amplitude of a state within a vector of size 16 x 16 pixels, we first calculate partial maximum values and reduce the state to 8 x 8 pixels, then to 4 x 4 pixels, then we read 16 complex numbers with CPU and perform the remaining calculations directly in browser.
The scripting language and its compiler / VM created for the purpose of Quantum Computing Playground have the following features:
|- in-browser compilation into an internal code|
|- single-step and continuous execution of the compiled code|
|- nested procedures|
|- local variables (within procedures)|
|- “for-endfor” loop, “if-else-endif” constructs|
|- full debugging support with call stack and variables inspection|
Although quantum gates operations are applied to specific qubits, in most cases
they affect the entire state of quantum register. For an example the SigmaX gate,
equivalent of simple classical bit negation, would swap the amplitude values
of states XXXX0XXX and XXXX1XXX, for all possible values of the X part (state
number here is represented in binary form for vector size 8).
The following quantum gates are available in the simulator (see also examples of their usage):
|Hadamard||Hadamard gate creates a superposition of states 0 and 1 of a given qubit. It is also its own inverse operation: applying it twice restores the original state.|
|SigmaX, SigmaY, SigmaZ||Sigma X, also known as Pauli X gate, is a quantum equivalent of bit negation. Since qubits are represented by complex numbers, there is no simple concept of negation for them. Sigma Y and Sigma Z gates "negate" qubits in alternative ways.|
|Rx, Ry, Rz||Rotation gates (see page 5).|
|CNot||Controlled NOT gate applies the same transformation as Sigma X gate, except that its execution is conditioned on the value of the first argument - control qubit. The quantum negation is only performed on states where the control qubit has value 1. States where control qubit has value 0 remain unchanged.|
|Toffoli||Toffoli gate operates in the same way as controlled NOT gate, taking two control qubits and the target qubit. Negation is only performed on states where both control qubits have value 1.|
|Phase||Phase gate rotates amplitude of states (a complex number) where target qubit has value 1. Angle of rotation is given as the second argument.|
|CPhase||Works like phase gate, but its operation is conditioned on the first control qubit (like in controlled NOT gate).|
|Swap||Swap gate exchanges amplitude of states for which source and target values of qubits are different (0 and 1, or 1 and 0).|
|Unitary||Unitary gate performs arbitrary unitary operation on target qubit. The operation is defined by giving eight numbers of 2x2 unitary matrix.|
|QFT||QFT gate applies Quantum Fourier Transform to a part of the quantum register. First argument specifies the first qubit of the transform, while the second - width of the transform (number of qubits to which the transform will be applied).|
|InvQFT||Works like QFT gate, performing inverse transform.|
|ExpModN||ExpModN gate applies modular exponentiation operation to a subset of quantum register. On the input it assumes that the quantum state is a superposition of k qubits. In the output state non-zero amplitudes will be present only for states that are the result of modular exponentiation calculation given 2^k superposed states as the input.|
|ShiftLeft, ShiftRight||Shifting gates move entire quantum vector state in given direction by the given number of qubits. The gates assume that the qubits destroyed in the shifting operation have not been used, or have been just measured, so that the vector state will remain normalized.|
|Decoherence||Decoherence gate applies phase damping operation, taking strength factor as the first argument. For an example description of phase damping, see Quantum Computation and Quantum Information, chapter 8.3.6.|
MeasureBit operation applies partial measurement to a single qubit of the quantum vector.
Unlike complete measurement, single qubit measurement partially collapses the vector.
For an example, given 4-qubit vector state:
The global quantum vector state can be visualized in three ways: black and white 2D square, color 2D square, and 3D surface. In 2D views hovering over the visualization shows value of the state that mouse pointer points to. The amplitude of state maps to luminance in 2D views. In color mode, phase is visualized through color of a pixel, in accordance with matrix below (where colors in between are interpolated accordingly). The 3D view uses height of the surface as amplitude, and color as phase. In 3D view user can rotate the view using mouse, touch, or script commands.
|-0.707 + i0.707||i1.0||0.707 + i0.707|
|-0.707 - i0.707||-i1.0||0.707 - i0.707|
|Ctrl + Shift + 1||Switch view mode to 2D.|
|Ctrl + Shift + 2||Switch view mode to 2D + phase.|
|Ctrl + Shift + 3||Switch view mode to 3D.|
|Ctrl + Shift + 4||Compile script.|
|Ctrl + Shift + 5||Run script / continue current execution.|
|Ctrl + Shift + 6||Step back in current execution.|
|Ctrl + Shift + 7||Single step into a script function.|
|Ctrl + Shift + 8||Step over a script function.|