Measurement-Based Quantum Computation (MBQC) module is a simulation tool for universal quantum computing, developed based on Baidu PaddlePaddle. Unlike the conventional quantum circuit model, MBQC has its unique way of computing [1-8] and thus common circuit simulation tools cannot be directly used for the simulation of this model. To facilitate further research and exploration of MBQC, we have designed and provided several core modules in the module that are required for simulation.
Measurement-Based Quantum Computation (MBQC) module is a simulation tool for universal quantum computing, developed based on Paddle Quantum. Unlike the conventional quantum circuit model, MBQC has its unique way of computing [1-8] and thus common circuit simulation tools cannot be directly used for the simulation of this model. To facilitate further research and exploration of MBQC, we have designed and provided several core modules that are required for simulation.
On the one hand, as with common quantum circuit simulators, we can use the module to quickly build and train quantum neural networks, which have powerful application prospects in the field of artificial intelligence such as quantum chemistry, quantum natural language processing, and quantum finance. On the other hand, the MBQC module demonstrates its unique advantages in computational efficiency in some special cases, especially in quantum shallow circuit simulations, where the required computational resource can be significantly reduced, leading to a potential opportunity for larger-scale quantum algorithm simulations.
Our module is currently the first and the only systematic tool in the industry that supports the simulation of MBQC. We sincerely look forward to its learning and usage by quantum computing enthusiasts and researchers. Welcome to join us and discover the infinite possibilities of MBQC together!
Our module is the first and only systematic tool in the industry that supports the simulation of MBQC. We sincerely look forward to its learning and usage by quantum computing enthusiasts and researchers. Welcome to join us and discover the infinite possibilities of MBQC together!
## Features
...
...
@@ -103,7 +103,9 @@ shortly.
- Q: How is the MBQC physically implemented?
A: The difficulty in the physical implementation of MBQC is mainly the preparation of resource states. Unlike the superconducting techniques used in the quantum circuit model, the resource states are mostly prepared using linear optics or cold atoms, see e.g. [2,12,13] for the currently available techniques for the resource states preparation.
A: The difficulty in the physical implementation of MBQC is mainly the preparation of resource states. Unlike
the superconducting techniques used in the quantum circuit model, the resource states are mostly prepared using
linear optics or cold atoms, see e.g. [2,12,13] for the existing techniques of resource states preparation.
"- **量子图态准备**:即准备一个多体纠缠态。一般地,我们给出图(点和边)的信息,初始化图中节点为加态,根据图中节点的连线方式作用控制 Z 门,便可以生成量子图态。以此对应关系,每当我们给定一个图的信息,我们便可以在其上定义对应的量子图态。此外,我们还可以根据需要选择性替换图态中某些节点上的加态为指定的输入态。\n",
"<div style=\"text-align:center\">Table 2: Frequently used methods of the class MBQC and their functionalities </div>\n",
"<br/>\n",
"\n",
"In the ``simulator`` module, we provide two simulation modes, \"graph\" and \"pattern\", corresponding to the two equivalent descriptions of the MBQC computation process respectively. If we set a graph, the whole computation needs to follow the \"three-step\" process. It is worth mentioning that we design a **vertex dynamic classification algorithm** to simulate the MBQC computation process efficiently. Roughly speaking, we integrate the first two steps of the process, change the execution order of entanglement and measurement operations automatically to reduce the number of effective qubits involved in the computation and thereby improve the efficiency. The outline to use the simulation module is as follows:\n",
"In the ``simulator`` module, we provide two simulation modes, \"graph\" and \"pattern\", corresponding to the two equivalent descriptions of the MBQC computation process respectively. If we set a graph, the whole computation needs to follow the \"three-step\" process. It is worth mentioning that we design a **vertex dynamic classification algorithm** to simulate the MBQC computation process efficiently. Roughly speaking, we integrate the first two steps of the process, change the execution order of entanglement and measurement operations automatically to reduce the number of effective qubits involved in the computation and thereby improve the efficiency. The outline to use the simulation module is as follows:\n",
"# Polynomial Unconstrained Boolean Optimization Problem in MBQC\n",
"\n",
"<em> Copyright (c) 2021 Institute for Quantum Computing, Baidu Inc. All Rights Reserved. </em>"
],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the tutorial [Measurement-based Quantum Approximate Optimization Algorithm](QAOA_EN.ipynb), we give a brief introduction to the **polynomial unconstrained boolean optimization (PUBO) problem** and propose the **measurement-based quantum approximate optimization algorithm (MB-QAOA)** to solve it. For interested readers, please refer to the previous tutorial for more information. In this tutorial, we will showcase two specific examples as practical demonstrations of MB-QAOA. The first one is a concrete PUBO problem, while the second one is a **maximum cut (MaxCut)** problem.\n",
"\n",
...
...
@@ -29,12 +30,13 @@
"$$\n",
"\n",
"For code implementation, we require that a standard polynomial is input as a list whose first item is the number of variables and the second item is a dictionary of all the monomials ('cons' stands for the constant item). In the dictionary, we make monomial variables split with ',' as keys and the corresponding coefficients as values. For example, suppose we want to input a polynomial $x_1 + x_2 - x_3 + x_1 x_2 - x_1 x_2 x_3 + 0.5$, we need to code as follows: "
"**Note:** As the variables are boolean, the power of variables in a monomial should be no greater than 1. That is, each variable should appear at most once in a key of the dictionary. For instance, it is not a valid to input something like {'x_1,x_1,x_2': 1}. Also, we set variable subscripts by consecutive numbers starting from '1' to be consistent with math conventions. A polynomial like $x_1 x_2 + x_6$ will raise an error automatically. A valid polynomial should be like $x_1x_2 + x_3$. \n",
"We define a function ``mbqc_pubo`` which takes in the objective polynomial and returns an optimal solution. **The core part of ``mbqc_pubo`` is the ``MBQC_QAOA_Net`` class**, which integrates MB-QAOA and the optimization net. Please refer to [Measurement-Based Quantum Approximate Optimization Algorithm](QAOA_EN.ipynb) for more details. Here we directly call the function."
"To check the correctness of the training result, we provide a `brute_force_search` function in `pubo` that finds a global optimal value by brute force search. We can compare the training result with the optimal one.\n",
"After defining the main function, let's input the parameters to run the code!"
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Define the main function\n",
"def main():\n",
...
...
@@ -223,14 +227,13 @@
"\n",
"if __name__ == '__main__':\n",
" main()"
],
"outputs": [],
"metadata": {
"tags": []
}
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"## Example: MaxCut\n",
"\n",
...
...
@@ -241,37 +244,35 @@
"In graph theory, a graph is represented by $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges. For example, a square can be characterized by the graph $G = (V,E)$ with $V = [1,2,3,4]$ and $E = [(1,2),(2,3),(3,4),(1,4)]$.\n",
"\n",
"For code implementation, we can use the `plot_graph` function in `maxcut` to plot a graph."
"A cut in the graph is a partition separating the vertices set $V$ into two complementary subsets $S_0$ and $S_1$. If two vertices of an edge in the graph are separated into different subsets, we score a goal. The size of a cut is defined by the total scores that we get. Then the MaxCut problem is to find a cut of graph with maximal size. \n",
"\n",
"As for the above square $G$, one of the optimal solutions to the MaxCut problem is to put $1$ and $3$ into subset $S_0$ and put $2$ and $4$ into subset $S_1$. "
],
"metadata": {}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Transformation to a PUBO problem\n",
"\n",
...
...
@@ -294,12 +295,13 @@
"$$\n",
"\n",
"We provide a function `graph_to_poly` in `maxcut` which takes in the graph to be cut and returns the equivalent objective polynomial in PUBO."
"### Code implementation to solve MaxCut problem\n",
"\n",
"Once obtaining the objective polynomial, we can follow the same process as the previous example and solve the MaxCut problem as a special case of PUBO. The complete code implementation is as follows:"
"After defining the main function, let's input the parameters to run the code!"
],
"metadata": {}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"def main():\n",
" # A graph to be cut\n",
...
...
@@ -447,34 +451,28 @@
"\n",
"if __name__ == '__main__':\n",
" main()"
],
"outputs": [],
"metadata": {
"tags": []
}
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Now, we have completed the demonstration of two examples. The implementation of MB-QAOA indicates a great potential of MBQC in the field of quantum machine learning. Apparently, MBQC model can realize quantities of algorithms far beyond QAOA. We therefore are \n",
"looking forward to exploring more on this and to show some unparalleled advantages in practice. \n",
"\n",
"As a matter of fact, we have found an interesting application of MBQC in simulating a special class of quantum circuits! So, let's continue our exploration to the next tutorial together."
],
"metadata": {}
"looking forward to exploring more on this and to show some unparalleled advantages in practice."