Skip to content

Building Quantum Circuits

Theo Reignier edited this page Sep 1, 2021 · 16 revisions

The 'Quantum' node library can be used to build and run quantum programs in Node-RED.

How to Use

The 'Quantum Circuit' node can generate a quantum circuit with qubits. The qubits will then flow through a certain set of nodes corresponding to quantum operations, or gates. Finally, all qubits must be connected to a single output node that will process the circuit and output the results.

The nodes are organised into 4 categories:

  • Input nodes (gray) are used to set up a quantum circuit and output qubits. To start, use the 'Quantum Circuit' node to generate one qubit through each output.

  • Qubit nodes (blue) are used to keep track and manage qubits, such as resetting them. The 'Qubit' node receives qubits as input but does not execute any operation on it. It can be used to identify qubits, by printing some text under the node, or to rearrange the position of qubits into the editor.

  • Quantum Gate nodes correspond to quantum operations. When a qubit flow through a quantum gate node, the operation is executed on the qubit. There are 2 type of quantum gates:

    • Singe qubit gates (purple) receive a qubit, execute an operation, and output the qubit. The 'NOT Gate' flips the state of the qubit (0 → 1 & 1 → 0).
    • Multi qubits gates (red) receive a certain number of qubits, execute a control operation and output the qubits. Control operations correspond to the conditional execution of a single quantum gate. If the 'control' qubits are in the correct state, then the gate is applied on a 'target' qubit. The 'CNOT Gate', operating on 2 qubits, applies a NOT gate on the 'target' qubit if the 'control' qubit is in the '1' state.
  • Output nodes (grey) are used to process the quantum circuit and generate an output. All qubits of the quantum circuit must be connected to the same output node for it to work. The output format varies between each node, please refer to the documentation. The 'Local Simulator' node simulates a quantum computer using the local Qiskit library. It runs the quantum circuit and outputs the results.

Rules

  1. Do not duplicate qubits
    To avoid inconsistencies, there should always be 1 instance of each qubit at all times. A node can take multiple qubits as input but only one wire should be connected to each output. To do so, always input as many qubits as the node outputs.

  2. Wait for quantum circuit to execute
    Do not double-click the inject button, wait for the circuit to have finished executing before runnning it again.
    If such an issue occurs, please restart Node-RED.

Input nodes Qubit nodes Single qubit gate nodes Multi qubits gate nodes Output nodes
Input nodes palette Qubit node palette Single qubit quantum gate node palette Multi qubits quantum gate node palette Output node palette

Click on the images to access more detailed documentation on each node.