|
1 |
| -# node-red-quantum |
| 1 | +# node-red-quantum <!-- omit in toc --> |
2 | 2 |
|
3 | 3 | [](https://nodered.org)
|
4 | 4 | [](https://github.com/louislefevre/node-red-contrib-quantum/actions/workflows/node.js.yml)
|
5 | 5 | [](https://www.npmjs.com/package/node-red-contrib-quantum)
|
6 | 6 | [](https://nodejs.org/en/)
|
7 | 7 |
|
| 8 | + |
8 | 9 | **Node-RED Quantum** provides a set of nodes to build and run quantum computing algorithms within Node-RED.
|
9 | 10 |
|
10 | 11 | Please be aware that this is a **development version** of Node-RED Quantum, it is still a work in progress and the code is unstable. A full production-ready release will be published soon.
|
11 | 12 |
|
12 |
| -This module is a user-friendly library that is suitable to new quantum computing users thanks to its extensive documentation. It was designed to facilitate the integration of quantum algorithms within classical programs and is fully scalable since all the elemental quantum operations are included. |
| 13 | +This module is a user-friendly library that is suitable for new quantum computing users thanks to its extensive documentation. It was designed to facilitate the integration of quantum algorithms within classical programs and is fully scalable since all the elemental quantum operations are included. |
13 | 14 |
|
14 |
| -This Node-RED library was developed in the context of a UCL IXN partnership with IBM. Defined and arranged by IBM, the project was allocated to students from UCL's computer science department as part of their Master's thesis. |
| 15 | +This Node-RED library was developed in the context of a [UCL IXN](https://www.ucl.ac.uk/computer-science/collaborate/ucl-industry-exchange-network-ucl-ixn) partnership with [IBM](https://www.ibm.com/uk-en). Defined and arranged by IBM, the project was allocated to students from UCL's computer science department as part of their Master's thesis. |
15 | 16 |
|
16 | 17 | For the latest changes, please read the [CHANGELOG](CHANGELOG.md).
|
17 | 18 |
|
18 | 19 | For more details on the authors, please read the [AUTHORS](AUTHORS) file.
|
19 | 20 |
|
20 | 21 | For information on how to contribute, please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines.
|
21 | 22 |
|
22 |
| - |
23 | 23 |
|
24 |
| -## Prerequisites |
25 |
| -Node-RED Quantum requires at minimum [Node-RED 1.0](https://nodered.org) and [Python 3](https://www.python.org/). |
| 24 | + |
| 25 | + |
| 26 | +<br /><br /> |
| 27 | + |
| 28 | +# Table of contents <!-- omit in toc --> |
| 29 | +- [Pre-requisites](#pre-requisites) |
| 30 | +- [Install](#install) |
| 31 | +- [About Quantum Computing](#about-quantum-computing) |
| 32 | +- [*'Quantum'* nodes - Building quantum circuits](#quantum-nodes---building-quantum-circuits) |
| 33 | +- [*'Quantum Algorithms'* nodes - Leveraging quantum computing](#quantum-algorithms-nodes---leveraging-quantum-computing) |
| 34 | +- [Tutorials & Examples](#tutorials--examples) |
| 35 | + |
| 36 | +<br /> |
| 37 | + |
| 38 | +# Pre-requisites |
| 39 | +Node-RED Quantum requires at minimum [Node.js 12.0.0](https://nodejs.org/en/), [Node-RED 1.0](https://nodered.org) and [Python 3](https://www.python.org/). |
| 40 | + |
| 41 | +<br /> |
| 42 | + |
| 43 | +# Install |
| 44 | + |
| 45 | +1. In the terminal of your machine, install **Node-RED** by executing the command: |
| 46 | +`sudo npm install -g --unsafe-perm node-red`. |
| 47 | + |
| 48 | +2. Once **Node-RED** has been installed, start the application by entering the command `node-red` in the terminal. |
| 49 | + |
| 50 | +3. Navigate to **Node-RED** by following the IP address returned in the terminal. This will usually be `http://127.0.0.1:1880/`. |
| 51 | + |
| 52 | +4. In **Node-RED**, navigate to the **Palette Manager** (top-right corner), select **Install** and search for *'quantum'*, as depicted below. |
| 53 | + |
| 54 | +5. Install the **node-red-contrib-quantum** package. Once installed, it will show as quantum nodes in the **Palette** (on the left of the Node-RED editor). Please note that this installation may take a few minutes, as it needs to install the Python virtual environment required for executing the nodes. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +<br /> |
| 59 | + |
| 60 | +# About Quantum Computing |
| 61 | + |
| 62 | +## Qubit State <!-- omit in toc --> |
| 63 | + |
| 64 | +A qubit is the same to a quantum computer than what a bit is to a classical computer: the smallest unit of information.<br /> |
| 65 | +<a href="https://qiskit.org/textbook/ch-states/representing-qubit-states.html#statevectors"> Classical vs Quantum bits - Qiskit textbook</a> |
| 66 | +<br /><br /> |
| 67 | +The <b>Bloch sphere</b> representation is considered as the most simple and ludic way to understand & visualise a qubit (see image below). |
| 68 | +In contrast with classical bits that can only be in a '0' or a '1' state, qubits can store much more information. |
| 69 | +In fact, all points on the sphere represent a different qubit state, the usual classical bit states being labelled as: |
| 70 | +<ul> |
| 71 | +<li>State 0</li> |
| 72 | +<li>State 1</li> |
| 73 | +</ul> |
| 74 | +Quantum states that are in between those 2 points are a weighted combination of the '0' and '1' states. This is called <b>superposition</b>. <br/> |
| 75 | +To set the qubit in a particular state, we operate rotations or reflections of the <b>Bloch sphere</b> while keeping the x, y and z axis unchanged.<br /> |
| 76 | +<a href="https://qiskit.org/textbook/ch-states/representing-qubit-states.html#bloch-sphere-2">Bloch Sphere - Qiskit textbook</a> |
| 77 | +<br /><br /> |
| 78 | +<b>Example -</b> Applying a π radians rotation about the x-axis on a qubit that is in the '0 state' will put it in the '1 state'. |
| 79 | +<br/><br/> |
| 80 | + |
| 81 | +<img src="./resources/quantum-computing/bloch-sphere-horizontal.png" width="750px"/><br /> |
| 82 | + |
| 83 | +## Qubit Measurement <!-- omit in toc --> |
| 84 | + |
| 85 | +It is very important to understand that, even though a qubit can take an infinite number of states, our technology only allows us to measure '0' or '1', like on a classical bit. Since we measure and interpret a qubit state using classical machines, this can be seen as a projection of quantum computing back to classical computing: from quantum states back to binary values. <br /> |
| 86 | +<a href="https://qiskit.org/textbook/ch-states/representing-qubit-states.html#rules-measurement">Qubit measurement - Qiskit textbook</a> |
| 87 | +<br /><br /> |
| 88 | +This leads to probabilistic measurement results. |
| 89 | +In terms of the <b>Bloch Sphere</b>, the closest the qubit state is from the '1 state', the more likely we are to measure a '1'. |
| 90 | +<br/><br/> |
| 91 | +<b>Example -</b> If we measure a 1000 times a qubit that has a state in the x-y plane, then we will get more or less 500 '0' measurements and 500 '1' measurements. |
| 92 | +<br/><br/> |
| 93 | +<b>Careful -</b> The act of measuring a qubit collapses the qubit state: the state of the qubit after being measured |
| 94 | +is not representative of the qubit state before the measurement. Please measure the qubits at the end of the quantum circuit or reset them after a measurement. |
| 95 | + |
| 96 | +<br /> |
| 97 | + |
| 98 | +## Entanglement <!-- omit in toc --> |
| 99 | + |
| 100 | +Referred to as a "spooky action at a distance" by Albert Einstein, **entanglement** is a quantum phenomenon that is extremely powerful in quantum computing. It is a form of connection that can exist between any number of qubits. Here we will illustrate **entanglement** between two qubits. |
| 101 | +<br /><br /> |
| 102 | +Two qubits are said to be **entangled** when their relative states rely on each other. In other words, changing or knowing the state of one qubit can change the state of the other qubit. This connection is independent of time and space: the two qubits can be miles appart and the connection will still be instantaneous. |
| 103 | +<br /><br /> |
| 104 | +In practice, **entanglement** arises when the operation of a gate on a qubit is conditional on the state of another qubit (similar to an `if` block in classical computing). These gates are often referred to as [multi-qubits quantum gates](https://github.com/louislefevre/node-red-contrib-quantum/wiki/Quantum-Gate-Nodes/#multi-qubits-quantum-gates). |
| 105 | +<br /><br /> |
| 106 | +<b>Example -</b> A CNOT gate applies a NOT gate (0 → 1 & 1 → 0) to the 'target' qubit **if and only if** the 'control' qubit is in the '1' state. |
| 107 | +<br /><br /> |
| 108 | +Now, let's assume that the 'control' qubit is in a <b>superposition</b> state (25% '0' / 75% '1'), while the 'target' qubit is in the '0' state.<br /> |
| 109 | +Then, the **combined** state of the 2 qubits after applying the CNOT gate will be: |
| 110 | +<ul> |
| 111 | + <li>'00' with 25% probability</li> |
| 112 | + <li>'11' with 75% probability</li> |
| 113 | +</ul> |
| 114 | +The 2 qubits are now <b>entangled</b>. If we measure one of them to be in the '1' state, then we know that other qubit will be in the '1' state as well. |
| 115 | +<br /><br /> |
| 116 | +<a href="https://qiskit.org/textbook/ch-gates/multiple-qubits-entangled-states.html#entangled">Entanglement - Qiskit textbook</a> |
| 117 | +<br /><br /> |
| 118 | + |
| 119 | +# *'Quantum'* nodes - Building quantum circuits |
| 120 | + |
| 121 | + |
| 122 | +* [Circuit Initialisation nodes](https://github.com/louislefevre/node-red-contrib-quantum/wiki/Circuit-Initialisation-Nodes) |
| 123 | + |
| 124 | +* [Qubit Control nodes](https://github.com/louislefevre/node-red-contrib-quantum/wiki/Qubit-Control-Nodes) |
| 125 | + |
| 126 | +* [Quantum Gate nodes](https://github.com/louislefevre/node-red-contrib-quantum/wiki/Quantum-Gate-Nodes) |
| 127 | + |
| 128 | +* [Circuit Output nodes](https://github.com/louislefevre/node-red-contrib-quantum/wiki/Circuit-Output-Nodes) |
| 129 | + |
| 130 | +<br/> |
| 131 | + |
| 132 | +For detailed information on how to use each node, please head to the [Node-RED Quantum wiki](https://github.com/louislefevre/node-red-contrib-quantum/wiki). |
| 133 | + |
| 134 | +<br /> |
| 135 | + |
| 136 | +# *'Quantum Algorithms'* nodes - Leveraging quantum computing |
| 137 | + |
| 138 | +For detailed information on how to use each node, please head to the [Node-RED Quantum wiki](https://github.com/louislefevre/node-red-contrib-quantum/wiki). |
| 139 | + |
| 140 | +<br /> |
| 141 | + |
| 142 | +# Tutorials & Examples |
| 143 | + |
| 144 | +<br /> |
0 commit comments