-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40d5404
commit 00cb0cf
Showing
14 changed files
with
945 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
docs/resources | ||
docs/public | ||
docs/.hugo_build.lock | ||
docs/.hugo_build.lock | ||
layerwise_learning_with_qiskit_and_pytorch/1_small_circ.gif | ||
layerwise_learning_with_qiskit_and_pytorch/2_large_circ.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
[ | ||
{ | ||
"id": "qa_nn", | ||
"author": [ | ||
{ | ||
"family": "Verdon", | ||
"given": "Guillaume" | ||
}, | ||
{ | ||
"family": "Broughton", | ||
"given": "Michael" | ||
}, | ||
{ | ||
"family": "Biamonte", | ||
"given": "Jacob" | ||
} | ||
], | ||
"year": "2017", | ||
"month": "12", | ||
"pages": "", | ||
"title": "A quantum algorithm to train neural networks using low-depth circuits" | ||
}, | ||
{ | ||
"id": "qaa", | ||
"author": [ | ||
{ | ||
"family":"Herbert", | ||
"given": "Steven" | ||
} | ||
], | ||
"year":"2019", | ||
"title": "Quantum Computing (CST Part II) Lecture 15: Adiabatic Quantum Computing", | ||
"URL": "https://www.cl.cam.ac.uk/teaching/1920/QuantComp/Quantum_Computing_Lecture_15.pdf" | ||
}, | ||
{ | ||
"id": "qaa_proof", | ||
"author":[ | ||
{ | ||
"family": "Childs", | ||
"given": "Andrew" | ||
} | ||
], | ||
"year": "2008", | ||
"title": "Quantum algorithms (CO 781, Winter 2008): LECTURE 18: The quantum adiabatic theorem", | ||
"URL": "https://www.cs.umd.edu/~amchilds/teaching/w08/l18.pdf" | ||
}, | ||
{ | ||
"id":"pulser_tut", | ||
"author":[ | ||
{ | ||
"family": "Pasqal", | ||
"given": "Pulser" | ||
} | ||
], | ||
"title": "QAOA and QAA to solve a QUBO problem", | ||
"URL": "https://pulser.readthedocs.io/en/stable/tutorials/qubo.html" | ||
}, | ||
{ | ||
"id": "pulser_lib", | ||
"author": [ | ||
{ | ||
"family": "Henrique", | ||
"given": "Silvério" | ||
}, | ||
{ | ||
"family": "Grijalva", | ||
"given": "Seb" | ||
}, | ||
{ | ||
"family": "Henriet", | ||
"given": "Loïc" | ||
}, | ||
{ | ||
"family": "Cornillot", | ||
"given": "Antoine" | ||
}, | ||
{ | ||
"family": "AJDNIK", | ||
"given": "Laurent" | ||
}, | ||
{ | ||
"family": "Karalekas", | ||
"given": "Peter" | ||
}, | ||
{ | ||
"family": "et al.", | ||
"given": "" | ||
} | ||
], | ||
"year": "2023", | ||
"title": "pasqal-io/Pulser: Release v0.15.3", | ||
"publisher": "Zenodo", | ||
"URL": "https://github.com/pasqal-io/Pulser" | ||
}, | ||
{ | ||
"id": "qat", | ||
"author": [ | ||
{ | ||
"family":"Pesah", | ||
"given":"Arthur" | ||
} | ||
], | ||
"title": "Adiabatic Quantum Computing", | ||
"URL": "https://arthurpesah.me/assets/pdf/introduction-quantum-annealing.pdf" | ||
} | ||
|
||
|
||
|
||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: "Maximum Independent Set with Quantum Adiabatic Algorithm" | ||
date: 2023-11-17 | ||
tags: ["Neutral Atoms"] | ||
author: "Gopal Ramesh Dahale" | ||
ShowToc: true | ||
bibFile: /content/posts/mis/bib.json | ||
categories: ["The Blaise Pascal [Re]generative Quantum Challenge"] | ||
math: true | ||
--- | ||
|
||
Recently, I participated in the [The Blaise Pascal [re]Generative Quantum Challenge](https://www.pasqal.com/articles/the-blaise-pascal-re-generative-quantum-challenge) by Pasqal and got to learn about Pasqal's neutral atom arrays and pulse-level programming as well as implementing quantum algorithms on an analog device. Here, I will share my learnings and in this blog particularly, we will solve the MIS problem with the quantum adiabatic algorithm using Pulser {{<cite "pulser_lib">}}. | ||
|
||
## MIS as QUBO | ||
|
||
An independent set (IS) of a graph is defined as a subset $S$ of nodes such that no two nodes in $S$ are adjacent. An IS is **maximal** if no node can be added to $S$ without violating IS. A **maximum** independent set (MIS) is one of maximum cardinality. | ||
|
||
MIS can be represented as a QUBO problem. Every node of the graph $G = (V, E)$ is assigned with a binary variable $x_i$. If the $i^{th}$ vertex is present in the MIS then we assing $x_i = 1$ otherwise $x_i = 0$. The goal is to then minimize the below cost function | ||
|
||
$$ C(x_1, x_2, \dots x_N) = - \sum_{i=1}^{N}x_i + U \sum_{(i,j) \in E} x_i x_j \tag{1} $$ | ||
|
||
where $N$ is the number of nodes in $G$. Selecting a node that belongs to MIS decreases the value of $C$ (first term) but since we don't want two adjacent nodes to be in the MIS, we add a positive penalization (second term) with a penalty coefficient $U > 0$. | ||
|
||
## Analog Quantum Computing | ||
|
||
The below expression represents the neutral atoms quantum computer globlal hamiltonian. | ||
|
||
$$H_Q = \sum_{i=1}^N \frac{\hbar\Omega(t)}{2} \sigma_i^x - \sum_{i=1}^N \frac{\hbar \delta(t)}{2} \sigma_i^z+\sum_{j \lt i} \frac{C_6}{|\textbf{r}_i-\textbf{r}_j|^{6}}n_i n_j \tag{2} $$ | ||
|
||
|
||
We have three contributions here. | ||
|
||
- The first contribution is controlled by the amplitude of the laser $\Omega$ (Rabi frequency). | ||
- The second term is controlled by the detuning $\delta$ of the laser beam. | ||
- The third term models the dipole-dipole interactions between pairs of atom. | ||
|
||
The combined expression of the last two terms is similar to the cost function $C$. The idea is to encode the cost function in $H_Q$ and then find the ground state of the global hamiltonian by continuous manipulation of $\Omega(t)$ and $\delta(t)$. | ||
|
||
But what about the first term and how will we find the ground state of $H_Q$? The next section answers these questions by describing the analog quantum algorithms framework. | ||
|
||
## Adiabatic evolution | ||
|
||
In analog quantum computing, we consider a hamiltonian of the following form: | ||
|
||
$$ H(t) = u(t) H_M + (1 - u(t)) H_C $$ | ||
|
||
where $H_C$ is the "cost" hamiltonian which encodes the optimization task that we are trying to solve. Here it is the MIS problem. $H_M$ is the "mixer" hamiltonian which encodes the quantum mixing (eg. a uniform transverse field on qubits) and $u(t) \in [0,1]$ is the control function. | ||
|
||
The approach is to start with a hamiltonian $H_M$ whose ground state can be found easily. The system is set in the ground sate of $H_M$ at $t = 0, u(0) = 1$ and then slowly evolved, converging to the ground state of $H_C$ ($t = t_F, u(t_F) = 1$). At any time through the evolution, we will have a hamiltonian that is a linear combination of $H_M$ and $H_C$ controlled by $u(t)$. | ||
|
||
We encode $H_C$ in the last two terms of $H_Q$ i.e. the problem hamiltonian and then $H_M$ will become the first term of $H_Q$ representing the mixer hamiltonian. | ||
|
||
### Quantum Adiabatic Theorem | ||
|
||
Consider a time-varying Hamiltonian, $H(t)$, which is initially $H_M$ at $t = 0$, and subsequently $H_C$ at some later time, $t = t_F$ , then if the system is initially in the ground-state of $H_M$, and as long as the time-evolution of the Hamiltonian is **sufficiently slow**, the state is likely to remain in the ground-state throughout the evolution, therefore being in the ground-state of $H_C$ at $t = t_F$ {{<cite "qaa">}}. | ||
|
||
But how slow is sufficiently slow? Well, the proof {{<cite "qaa_proof">}} is complex, however we will see it in pratice that if we do not give sufficient time for the evolution of $H(t)$, the probability of finding the ground state or in our case finding the MIS turns out to near zero. | ||
|
||
## Problem Formulation | ||
|
||
We take a small graph with 7 nodes depicted below | ||
|
||
<p align="center"> | ||
<img src="../images/example_graph.png"> | ||
</p> | ||
|
||
## Quantum Adiabatic Algorithm | ||
|
||
In the beginning, we want to be in ground state of $H_M$ so $\delta (0) = 0$. Instead of the this we take $\Omega(0)=0, \delta(0)<0$. This will make the second term of (2) positive as $\delta(0) < 0$. The idea is to prepare the initial state of the system in the first half of the evolution. After the first half, we will have a superpostition of states that reproduces an independent set of various sizes. In the second half, we turn off $\Omega$ and turn on the detuning $\delta$ ending with $\Omega(0)=0, \delta>0$. If this evolution is slow enough, we are supposed to obtain a superpostion of states that can produce a maximal independent set. This can be achieved with the following pulse | ||
|
||
<p align="center"> | ||
<img src="../images/adiabatic_pulse.png"> | ||
</p> | ||
|
||
Note the duration of pulse ($4 \mu$s). Simulation results into the following historgram of counts. | ||
|
||
<p align="center"> | ||
<img src="../images/qaa_hist.png"> | ||
</p> | ||
|
||
The bitstring with maximum counts is `1010011` which is indeed the MIS for the given graph. The set of nodes is $\\{0, 2, 5, 6\\}$. | ||
|
||
### Effect of time evolution on quality of MIS | ||
|
||
We test with different time durations ranging from $1 - 15 \mu$s and observe the probability of successfully obtaining the MIS. | ||
|
||
<p align="center"> | ||
<img src="../images/qaa_prob_sucess.png"> | ||
</p> | ||
|
||
After a certain point (~ $12 \mu$s), we see that the success probability flattens out. This time duration is sufficiently large. A precise definition of sufficiently large can be found here {{<cite "qat">}}. | ||
|
||
The code to reproduce the figures can be found [here](https://github.com/Gopal-Dahale/ILearnQuantum/tree/main/mis_neutral_atoms). A more general tutorial is available in the Pulser's docs {{<cite "pulser_tut">}}. | ||
|
||
## References | ||
|
||
{{< bibliography cited >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
title: "QAOA to solve MIS" | ||
date: 2023-11-18 | ||
tags: ["Neutral Atoms"] | ||
author: "Gopal Ramesh Dahale" | ||
ShowToc: true | ||
bibFile: /content/posts/mis/bib.json | ||
categories: ["The Blaise Pascal [Re]generative Quantum Challenge"] | ||
math: true | ||
--- | ||
|
||
In the last blog, we talked about the Quantum Adiabatic Algorithm (QAA) and used it solve the MIS problem. Here, we will discuss the Quantum Approximation Optimization Algorithm (QAOA) which is popular algorithm in the gate based quantum computing. We will use QAOA to solve the same MIS problem that we tackled in the last blog. | ||
|
||
## Algorithm description | ||
|
||
In QAOA, we start with an eigenstate of the mixer hamiltonian. We then exponentiate and parameterize in $p$ steps by $p$ betas and gammas: | ||
|
||
$$\lvert \psi(\boldsymbol{\beta}, \boldsymbol{\gamma}) \rangle = \underbrace{U(\boldsymbol{\beta}) U(\boldsymbol{\gamma}) \cdots U(\boldsymbol{\beta}) U(\boldsymbol{\gamma})}_{p \ \text{times}} \lvert \psi_0 \rangle$$ | ||
|
||
where betas and gammas are to be optimized with a classical opitimizer. Here $U(\boldsymbol{\beta}) = e^{-i \boldsymbol{\beta} H_M}$ and $U(\boldsymbol{\gamma}) = e^{-i \boldsymbol{\gamma} H_C}$. Remember $H_M$ and $H_C$ are the mixer and cost hamiltonian respectively. The idea here is that instead of having a continuous evolution, we evolve with one hamiltonian at a time $H_C$ or $H_M$ and repeat it for $p$ steps. | ||
|
||
## Comparing with QAA | ||
|
||
The figure below from {{<cite "qa_nn">}}, shows how the control function $u(t)$ is continuous slow varying function in QAA, while in QAOA, we have discretized control function so we evolve with $H_C$ and $H_M$ alternatively. | ||
|
||
<img src="../images/qaoa_analogy.png" width=600 alt="QAOA analogy" style="margin:auto" /> | ||
|
||
|
||
The discretized control function can be written as | ||
|
||
$$u_i = \frac{\beta_i}{\gamma_i + \beta_i} $$ | ||
|
||
At the begining, $H_M$ will be dominationg, so betas will be large and gammas will be small. This way, the control function will tend to the value of 1. In the end, gammas will increase making the control funciton to zero thereby dominating $H_C$. | ||
|
||
## Implementation | ||
|
||
We build parameterized sequences in pulser to implement the alternating hamiltonians $H_M$ and $H_C$. Remember the expression for the global hamiltonian | ||
|
||
$$H_Q = \sum_{i=1}^N \frac{\hbar\Omega(t)}{2} \sigma_i^x - \sum_{i=1}^N \frac{\hbar \delta(t)}{2} \sigma_i^z+\sum_{j \lt i} \frac{C_6}{|\textbf{r}_i-\textbf{r}_j|^{6}}n_i n_j $$ | ||
|
||
We can observe that the $H_M$ is defined when the laser is turned on and detuning is turned off i.e. $\Omega > 0, \delta = 0$. Therefore to implement a beta pulse for the mixer hamiltonian, we choose $\Omega = 1, \delta = 0$. In constrast, for the cost hamiltonian we choose $\Omega = 0, \delta = 1$. The parameters control the duration of pulses which will be optimized by the classical optimizer. | ||
|
||
<div> | ||
<img src="../images/qaoa_seq.png" alt="QAOA sequences" style="margin:auto" /> | ||
<p align='center'>Pulses for $H_M$ and $H_C$ with random parameters for 2 alternating layers</p> | ||
</div> | ||
|
||
The cost function which we aim to minimize remains the same that we used in QAA | ||
|
||
$$ C(x_1, x_2, \dots x_N) = - \sum_{i=1}^{N}x_i + U \sum_{(i,j) \in E} x_i x_j$$ | ||
|
||
To implement this cost for QAOA, we can represent it as follows | ||
|
||
$$ f(z) = -1^{T}x + Ux^{T}Ax $$ | ||
|
||
where A is the adjacency matrix of the graph $G=(V,E)$, $U$ is the penalty coefficient and $x$ is a binary vector representing the nodes in the independent. We consider only the upper triangular matrix of A otherwise the cost function will count the node connections twice. We use the Nelder-Mead classical optimizer from scipy. Simulation results into the following historgram of counts. | ||
|
||
<p align="center"> | ||
<img src="../images/qaoa_hist.png"> | ||
</p> | ||
|
||
The bitstring with maximum counts is `1010011` which is indeed the MIS for the given graph. The set of nodes is $\\{0, 2, 5, 6\\}$. The optimal parameters result into the following pulses. | ||
|
||
<div> | ||
<img src="../images/optimal_qaoa_seq.png" alt="QAOA sequences" style="margin:auto" /> | ||
<p align='center'>Pulses for $H_M$ and $H_C$ with optimized parameters</p> | ||
</div> | ||
|
||
Compared to QAA, QAOA is not much effective. Although, increasing the number of layers can boost the probability of success, it comes at the cost of high depths. | ||
|
||
The code to reproduce the figures can be found [here](https://github.com/Gopal-Dahale/ILearnQuantum/tree/main/mis_neutral_atoms). A more general tutorial is available in the Pulser's docs {{<cite "pulser_tut">}}. | ||
|
||
## References | ||
|
||
{{< bibliography cited >}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Maximum Independent Set (MIS) using Pasqal's Pulser | ||
|
||
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Gopal-Dahale/ILearnQuantum/blob/main/mis_neutral_atoms/mis_neutral_atoms.ipynb) |
Oops, something went wrong.