node-red-qiskit-quantum-learning v0.1.7
Node-RED Qiskit Quantum Learning Framework
Our objective is to create a Node-RED-based learning and interactive platform, supported by IBM's Qiskit, to make quantum computing more accessible. Qiskit, a powerful quantum computing library, has a steep learning curve. To address this, we use Node-RED's visual interface to simplify quantum programming by breaking down complex concepts into manageable components. Our project abstracts core Qiskit functionalities into Node-RED nodes, each representing a fundamental quantum operation, helping software developers with little or no knowledge of quantum physics effectively use the Qiskit library.
Firstly, we transform complex Qiskit documentation into easy-to-follow, graphical Node-RED flows with detailed explanations and code snippets. Additionally, we designed the Interactive Node Framework, allowing users to design quantum circuits and algorithms through a user-friendly graphical interface, eliminating the need for coding. This hands-on approach not only simplifies quantum computing but also fosters a deeper understanding of quantum concepts, making the field more approachable and inclusive. Ultimately, this package encourages critical thinking and experimentation with quantum algorithms, enhancing users' comprehension of quantum computing.
Prerequisites
- Node.js v21.0.0
- Node-RED v3.1.9
- Python 3.11
Installation
Install Node-RED:
- Follow the installation instructions provided on the official Node-RED website: Node-RED Installation Guide.
Install Node-RED Qiskit Quantum Learning Framework:
- Navigate to your Node-RED user directory. This is typically located at
~/.node-red
. - Run the following command to install the Node-RED Qiskit Functionality package:
npm install node-red-qiskit-quantum-learning
- Navigate to your Node-RED user directory. This is typically located at
Start Node-RED:
- Use the following command in your terminal to start Node-RED:
node-red
- After starting Node-RED, check whether the Qiskit nodes appear in the Node-RED palette.
- Use the following command in your terminal to start Node-RED:
Create virtual environment
- Create a virtual environment with a name of your choice
- Activate your virtual ennvironment
Install Python Packages:
- Install the required Python packages listed in the
requirements.txt
file inside the virtual environment - You can install these packages either globally or within a virtual environment. To install the packages, run:
pip install -r requirements.txt
- Install the required Python packages listed in the
How to Use
Qiskit Learning flow
The Qiskit Learning Flow integrates Qiskit documents into the more graphical step-by-step prebuilt Node-RED flows. It consists of a series of pre-built flows. To begin, you need to click the menu button on the top right, click "Import" and choose the desired learning content from Local/flows/node-red-qiskit-quantum-learning/Learning/flows
into your Node-RED workspace and deploy it. Once deployed, you can follow these steps to explore and learn from the content in the flow:
Click the button on the Start node to execute this flow.
Select the connected node and review the information in the sidebar. The information sidebar includes details on the quantum knowledge related to the node, code snippets, explanations of those code snippets, and information about Node input and output.
After completing the current node, click on the Next node and use the Information sidebar to learn about the connected node. Continue this process for each subsequent node.
After clicking the Start or Next node, if any connected nodes contain code snippets, these snippets will be executed. The results will either be displayed as images in the workspace or as text in the debug sidebar, helping users to better understand the code. (Tips: Some nodes require input parameters to execute their code. Please remember to open the Edit palette to check if any parameters need to be entered)
After you complete learning the content of a node, its status will change from red to green, indicating that you have studied the material in that node. This allows you to track your learning progress.
Once completing your study, you can revisit the flow by re-importing and redeploying it for further learning.
Interactive Node Framework
The Interactive Node Framework simplifies quantum computing by allowing users to design circuits and develop algorithms through a user-friendly graphical interface, eliminating the need for coding. The nodes in the Interactive Node Framework are categorized as follows:
Flow
The purpose of the Flow category is to define the scope of the entire flow. The Start node should be placed at the beginning of the flow, while the End node should be positioned at the end of the flow. The output generated by the End node includes the following components:
msg.payload.result.code
: The final code snippet in text format.msg.payload.result.code_snapshot
: The final code snippet in image format.msg.payload.result.result
: The execution result of the final code snippet. After the End node, only the debug node or the image output node can be used to display the results.
Functions
The Functions category includes various functional nodes, such as those for defining a sampler for a quantum circuit or converting results into readable output. Each node has a distinct responsibility, and you can use these nodes according to your needs. Note that these responsibilities do not involve operations at the qubit level, so function nodes should always be placed outside the quantum circuit you defined.
Gates
The Gates category includes various gates that can be applied to qubits, such as the Hadamard gate and the NOT gate. These gates can be arranged and combined in any order, but they must be placed after the qubit node.
Math
The Math category includes operations related to mathematics, which are used to support the construction of quantum computing at a mathematical level. For example, it can receive an Adjacency Matrix representing a graph in JSON format.
Programming
The purpose of the Programming node is to enhance the flexibility and scalability of the framework. It includes a text input box where users can manually enter Python code snippets and insert this node at any location in the flow to customize the final generated code.
Quantum Circuit
The QuantumCircuit class is used to define and construct quantum circuits, and it also includes some fundamental operations for quantum circuits. The Quantum-Circuit-Begin and Quantum-Circuit-End nodes define the scope of the quantum circuit. Users should start with the Quantum-Circuit-Begin node and follow it with the desired number of qubit nodes. After adding operation nodes such as Gate and Measure to the qubit nodes, the circuit should be ended with the Quantum-Circuit-End node.
Tools
The Tools category includes various useful functions, such as draw circuit and print, that assist in constructing and outputting flows more conveniently.
This framework provides different levels of abstraction so that users can engage with quantum computing at the level that suits their expertise and project requirements. We created QAOA algorithm flows using these nodes across three levels of abstraction as demonstration. To import them, you need to click the menu button on the top right, click "Import" and choose the desired content from Local/flows/node-red-qiskit-quantum-learning/interactive-nodes/flows
into your Node-RED workspace and deploy it.
The "customized_(algorithm)" flow corresponds to the lowest level, where the entire algorithm is built from the gate level.
The "qiskit_(algorithm)" flow represents the intermediate level, encapsulating common operation sequences into single nodes.
The "whole_(algorithm)" flow belongs to the highest level, where entire quantum algorithms or large sections of a quantum process are encapsulated in single nodes.
Contributing
For information on how to contribute, please read the CONTRIBUTING guidelines.
Acknowledgements
For more information about the authors, please refer to the AUTHORS file.
This Node-RED library was created as part of a partnership between UCL IXN and IBM. IBM defined and arranged the project, which was assigned to students from UCL's Computer Science Department as part of their Master's thesis. Special thanks go to John McNamara for managing the project's development, David Clark for serving as Academic Supervisors, and Roberto LoNardo for serving as our Quantum Mento advisors and guides.