Skip to content

Latest commit

 

History

History

documentation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Qhoir Documentation

This document introduces the core features and components of Qhoir. It assumes some basic knowledge of classical circuit construction, as well as the knowledge of quantum information basics from the reader. Other than that, the reader is not required to have a more profound understanding of quantum computing. Instead, Qhoir values the process of learning by doing.

Interface

The quantum circuit editor Qhoir consists of three main components:

  • Breadboard
  • Utensil bal
  • Toolbox

The breadboard is the main component of the editor. It allows you to construct circuits using components taken from the toolbox.

The utensil bar at the top of the interface provides several utensils to interact with your constructed circuit.

Finally, the toolbox contains all components that can be used in Qhoir. You can minimize it by pressing the white rectangle on its right.

In the following, we will go into more detail on each of these components and their elements.

Breadboard

The breadboard is visualized as a grid, where each cell represents a unit size of 1. By dragging your mouse over the editor while holding the left button (while the scroll tool is selected), you may scroll through the breadboard. On the top right, you see the coordinates of the part of the breadboard you are currently viewing.

Components can be added to the circuit by selecting them from the toolbox. While holding a component, a transparent drawing of it will be shown at your current mouse position. If the component cannot be placed, because this part of the circuit is already occupied, it will be indicated by a red highlight.

Some components can be clicked on the breadboard to open up their details view. In this view, more specific changes can be made to the component, and it may also contain further analytical information. More information on details views can be found in the section on components.

Clicking and dragging a placed component allows users to relocate the components to different positions.

Clicking a component's socket will select the socket in the editor, highlighting it in an orange hue. After clicking a second socket on a different component, a wire will be created connecting them. Only compatible sockets can be connected (input <-->output | quantum <--> quantum | classical <--> classical).

Sockets are indicated in the breadboard by circles at the socket's location. Input sockets are further marked by a black dot in their centre. Quantum sockets can be differentiated from classical sockets by their blue hue.

Simulation is performed automatically after each step if the simulator is not paused. Measurement results gathered during the simulation are indicated by measurement components directly in the circuit view. You may also click measurement components to open their details view for more information on the results.

Many classical circuit editing tools provide the functionality of "splitting" wires along their path to send the information of the current bit to multiple components. Due to the no-cloning theorem, creating such copies of qubits is not possible. Therefore, Qhoir generally does not support the splitting of wires directly. For classical bits, however, Qhoir provides the Fork component that has the same functionality.

Utensils

The utensil bar is located at the very top of the editor. It contains the following utensils in order:

Scroll

The scroll tool allows the user to drag the circuit to scroll the view, or to drag existing components. While the scroll tool is selected, users may also click components to open their details views.

The scroll tool is the default tool which is automatically selected if no other tool is active, or by pressing the "Esc" key.

Picking a component from the toolbar deactivates the scroll tool.

Eraser

The eraser can be used to remove existing components from the circuit. In doing so, all the component's details view modifications, as well as its connected wires, are lost as well.

While the eraser is active, moving the mouse over a component in the circuit will highlight it in a red tone.

Picking a component from the toolbar or selecting the scroll tool deactivates the eraser.

Snap

While the snap setting is active, any movement of the mouse in the breadboard is "snapped" to the grid lines. This can be used to place components in a more precise manner next to each other.

The snap tool is selected while the "Alt" button is held. Releasing the "Alt" button will also deactivate the snap tool.

Undo / Redo

The undo and redo utensils can be used to rewind the last modifications made by the user on the circuit.

Please note that undo and redo only affect modifications made to the grid directly, not any modifications made inside a component's details view.

Undo / redo can be called using the shortcuts ctrl + z and ctrl + y respectively.

Save / Load

The save utensil downloads a JSON encoding of the current circuit to your device.

The load component allows users to upload such circuit encodings to the editor and loads them into the workspace.

Play / Pause

The play / pause button is located on the very right of the utensil bar. It can be used to activate / deactivate Qhoir's statevector simulator. While the simulator is active, a simulation is run after each change made to the circuit.

Pausing the simulator will prevent such simulation runs. Please keep in mind that measurement results will not update while the simulator is paused.

Components

The toolbox on the left of the editor consists of a list of components that can be added to your circuit. In this section, we will go into more detail on each of these components.

For a more rigorous introduction to quantum computing, please visit qiskit's textbook.

Tools

Tools represent the most basic components that are required to construct (meaningful) circuits: Sources and Measurements. Each circuit requires at least one source component to be run.

Qhoir distinguishes classical and quantum components. Therefore, a distinction between classical and quantum sources and measurements also has to be made to construct such circuits.

image name description details view
Source (classical) Generates one classical bit. The state of the bit (ON/OFF ) can be set using the details view. Click the slider to change the source state from ON to OFF.
Source (quantum) Generates one quantum bit. The state vector of the bit can be set using the details view. Enter coefficients for the $|0\rangle$ or $|1\rangle$ states by clicking one of the states and entering a number through your keyboard. The coefficient of the opposing state is updated automaticalls so that their squared sum equals 1. Only rational coefficients are supported.
Measurement (classical) Measures a classical bit. If the bit is ON, the component in the circuit lights up in green. A larger display indicating the measured value of the bit.
Measurement (quantum) Measures a quantum bit. The probabilities of states $|0\rangle$ and $|1\rangle$ are indicated by the ratios of the dark and light colours lighting up respectively. A bar chart that shows the probability of each measurement result. By clicking one of the three group names at the top, the component is added to a measurement group.Multiple measurements of the same groups will always be measured together (i.e. the measurement results affect each other), and will have their results displayed together.

Classical Gates

Classical gates represent circuit components that only require classical bits for their computation. As they do not need to be included in the statevector simulator with exponential blow-up, even large numbers of classical gates and bits can be supported and calculated in real time.

In principle, most classical gates supported by Qhoir implement the default logical operations of boolean algebra.

image name description details view
NOT Gate Inverts the classical bit:
0 ⇒ 1, or 1 ⇒ 0
/
AND Gate Takes two classical bit as input and has an output 1 if and only if both inputs are 1. /
OR Gate Takes two classical bit as input and has an output 1 if at least one of the inputs is 1. /
NAND Gate Inverted AND Gate. Has an output of 1, unless both inputs are 1. /
NOR Gate Inverted AND Gate. Has an output of 1 only if both inputs are 0. /
XOR Gate Takes two classical bit as input and has an output 1 if exactly one of the inputs is 1. /
XNOR Gate Inverted XOR Gate. Has an output of 1 if both inputs are either 1 or 0. /
OR Gate Takes two classical bit as input and has an output 1 if at least one of the inputs is 1. /
Fork Splits the wire into two equal outputs. Can be used to copy the value of the bit to two different components. /

Single-Qubit Gates

Single-Qubit gates are unitaries that operate on just one qubit. All quantum gates can be defined as unitary matrices. In this document, we will define gates by the action they perform on an arbitrary qubit of the form $\alpha|0\rangle + \beta|1\rangle$.

The most commonly used and basic single-qubit gates are the three Pauli gates: X, Y, and Z.

image name description details view
X Gate The Pauli X gate is the quantum version of the NOT gate.
$\alpha | 0\rangle + \beta | 1\rangle \Rightarrow \alpha | 1\rangle + \beta | 0\rangle$
/
Y Gate The Pauli Y gate combines the X and Z gates and further adds a factor of "i" to the qubit:
$\alpha | 0\rangle + \beta | 1\rangle \Rightarrow ai| 1\rangle - bi| 0\rangle$
/
Z Gate The Pauli Z gate represents a negative phase shift to the $| 1\rangle$ state while leaving the $| 0\rangle$ state unchanged:
$\alpha | 0\rangle + \beta | 1\rangle \Rightarrow \alpha | 0\rangle - \beta | 1\rangle$
/

Another important single-qubit gate is the Hadamard gate:
image name description details view
Hadamard Creates an equal superposition from a state in the computational basis:
$\alpha| 0⟩ + \beta| 1⟩ \Rightarrow \alpha| +⟩ - \beta|-⟩$
$|+⟩ = \frac{| 0⟩ + | 1⟩}{\sqrt{2}}$,
$|-⟩ = \frac{| 0⟩ - | 1⟩}{\sqrt{2}}$
/

Finally, Qhoir supports three phase-shift gates: S, T, and Rz($\theta$). These gates all leave the state $|0\rangle$ untouched while transforming the state $|1\rangle$ with a given phase shift.

image name description details view
S Gate Multiplies the phase of $|1\rangle$ by the imaginary constant $i$:
$\alpha|0\rangle + \beta|1\rangle ⇒ \alpha|0\rangle + bi|1\rangle$
/
T Gate Multiplies the phase of $|1\rangle$ by $e^{iπ/4}$:
$\alpha|0\rangle + \beta|1\rangle ⇒ \alpha|0\rangle + \beta e^{iπ/4}|1\rangle$
/
Rz($\theta$) Gate Multiplies the phase of $|1\rangle$ by $e^{iθ}$ for a given value of $\theta$:
$\alpha|0\rangle + \beta|1\rangle ⇒ \alpha|0\rangle + \beta e^{i\theta}|1\rangle$
Select a value of theta as a linear combination of $π$ and 1 by clicking the input fields and typing the values. The view on the left shows the angle $\theta$ on the unit circle.

Multi-Qubit Gates

Multi-Qubit Gates take multiple qubits as inputs. Unlike classical gates, quantum gates must be reversible. This means that the number of input and output qubits for a quantum gate must always be equal.

The most common types of two-qubit gates are controlled gates. These gates take two qubits as input, a control qubit and a target qubit. It then performs a given action on the target qubit if the control qubit is equal to $|1\rangle$. Otherwise, it keeps the target unchanged. If the control qubit is in a superposition, the gate is only applied partially to the target, with a factor determined by the coefficient of $|1\rangle$ in the control qubit.

For instance, the CX or CNOT gate performs the X gate on a target qubit. The transformation rules for it are: $|00\rangle \rightarrow |00\rangle$, $|01\rangle \rightarrow |01\rangle$, $|10\rangle \rightarrow |11\rangle$, $|11\rangle \rightarrow |10\rangle$
if the leftmost qubit is the control, or more general: $$\alpha|00\rangle + \beta|01\rangle + \gamma|10\rangle + \delta|11\rangle \rightarrow \alpha|00\rangle + \beta|01\rangle + \gamma|11\rangle + \delta|10\rangle $$

In Qhoir, controlled gates are indicated by a black bar at the top. The control qubit is given through the input socket at the very top and corresponds to the topmost output socket. The following controlled two-qubit gates are available:

image name description details view
CX Gate Applies the Pauli X gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
CY Gate Applies the Pauli Y gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
CZ Gate Applies the Pauli Z gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
Controlled Hadamard Applies the Hadamard gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
CS Gate Applies the S gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
CT Gate Applies the T gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ /
CRz($\theta$) Gate Applies the Rz($\theta$) gate to qubit 2 (left input) if the control (top input) is $|1\rangle$ Select a value of theta as a linear combination of $π$ and 1 by clicking the input fields and typing the values. The view on the left shows the angle $\theta$ on the unit circle.

Controlled gates are not limited to just one control qubit. Generally, in quantum computing, controlled gates may have any number of control qubits, and are expected to perform their action on the target qubit if and only if ALL controls are in the state $|1\rangle$.

Qhoir supports the CCX or CCNOT gate, also known as the Toffoli gate, which applies the Pauli X gate if both inputs (passed through the two topmost input sockets) are equal to $|1\rangle$. The three output sockets correspond to the left and right control qubits and to the action qubit in order.

image name description details view
CCNOT Gate Applies the Pauli X gate to qubit 3 (left input) if both control inputs (top) are in state $|1\rangle$. The two topmost outputs correspond to the left and right control bits in this order, and the bottom output corresponds to the target qubit. /

One final common two-qubit gate is the SWAP gate. It swaps the values of two given qubits. Generally, this gate plays less of an important role in Qhoir, as the position of gates and the directions of layers can be chosen arbitrarily, while usually, quantum circuits are designed with fixed horizontal lines as their quantum wires.

image name description details view
SWAP Gate Swaps the values of two input qubits. The value of the top input will be passed to the bottom output, and the bottom input will be passed to the top output /

UI Blocks

UI Blocks are non-functional components provided by Qhoir to improve the legibility of constructed circuits. They do not affect the values of bits or qubits passing through them but can be used to structure wires and components in the breadbox.

image name description details view
Text Text components can be added to the circuit to display some provided text. Single-line only. Open the details view and type in the text you wish to display.
Area When placing the area component, select two corner positions. The area is rendered as a rectangle through these corner points that can be used to group related components together. To delete, click the border of the area with the eraser. Click the border of the area to open the details view. Click any of the provided colours to select a background hue for the area.
Edge
(classical)
A single classical bit is passed from the input to the output directly without modifications. Can be used to add right-angle edges to the circuit wiring. /
Edge
(quantum)
A single quantum bit is passed from the input to the output directly without modifications. Can be used to add right-angle edges to the circuit wiring. /
Sink
(classical)
A classical bit can be passed to this component to end the wire. This is not required functionally, but it can improve circuit legibility by removing dangling outputs. /
Sink
(quantum)
A quantum bit can be passed to this component to end the wire. This is not required functionally, but it can improve circuit legibility by removing dangling outputs. /