- Introduction
- Dependencies
- Circuits
- State Vectors
- GAN Machine Learning Model
- Results
- Bonus Quantum Heralding Approach
- Bonus Noise Modeling
- Reflections
- Acknowledgements
- Sources
This project was designed to implement a Quantum Generative Adversarial Networks (QGAN) based on the following research paper by Wang et. Al. With the rise in advancements in integrated photonic technology, optical representations of quantum bits are becoming a promising alternative for quantum computation representation. In our project, we explore these photonic systems through the implementation of QGANs in the presence of noise, using stochastically adapted gradient descent to achieve higher fidelity.
Consequently, we will present our own GAN machine learning model which utilizes a modified gradient descent technique. We hope that this GAN machine learning model can be used as a proof of concept about the possibility of performing adversarial training on a photonic chip. While the model is not useful for highly-meaningful tasks, in the future, such models can hopefully improve to higher degrees of utility.
To test the efficacy of GAN model, we trained a generator to produce the
Our accompanying slide deck can be accessed here.
To install all dependencies automatically run:
pip install -r requirements.txt
The following packages will be necessary for our QGAN model:
jupyter==1.0.0
matplotlib==3.8.2
numpy==1.26.3
perceval-quandela==0.10.3
Wang et al. ‘23 describe an elementary QGAN based around a two-player game. Both players utilize variational quantum circuits with trainable parameters. The first player trains a generator with parameters
In our model, the input state is the maximally-entangled state,
The full circuit was modeled with the predefined beam splitters and phase shifters located in perceval.components
, and the full circuit consisted of 8 mode inputs. The generator circuit that we created can be seen below.
Generator:
The discriminator that we created can be seen below.
Discriminator:
Our first main implementation hurdle was figuring out a way to represent the data such that it can be passed through the circuit and modified as such. Our first solution was to use the StateVector class.
The StateVector
class allows for superposition of basic states, so we represented the maximally entangled ququart stf
in our code, as a superposition of four 8-mode states:
calculate_loss
function.
def calculate_loss(generator_angles, discriminator_angles): #for minimizing from an ungenerated vector
for i in range(30):
gen_params[i].set_value(generator_angles[i])
for i in range(12):
discrim_params[i].set_value(discriminator_angles[i])
g_sampler = generate(generator_angles, stf)
g_sample = g_sampler.samples(1)['results'][0]
d_sampler = discriminate(discriminator_angles, g_sample)
dist1 = d_sampler.probs()['results'][pcvl.BasicState("|0, 1, 0, 0, 0, 1, 0, 0>")]
tau_d_sampler = discriminate(discriminator_angles, tau)
dist2 = tau_d_sampler.probs()['results'][pcvl.BasicState("|0, 1, 0, 0, 0, 1, 0, 0>")]
return abs(dist1 - dist2), dist1, dist2
To determine the appropriate phase shift parameters, we applied a modified gradient descent machine learning technique. Due to the stochastic nature of quantum phenomena, our function is non-differentiable, and therefore, the standard gradient descent is not possible. Instead, we used the Newton-Raphson method, and defined a discrete analog to the gradient descent for our version of backpropagation. We considered each angle of phase shifting to be the weights in our model. For each angle
We evaluated our model with two metrics: measurement and fidelity. For measurement, we measured the probability magnitude of the logical
Wang et al. measurement results:
Our model measurement results:
Fidelity is the percent distribution of generated samples that are of the desired target form
Wang et al. fidelity results:
Our model fidelity results:
Since the state vectors used to prepare our quantumly entangled input state are not actually viable on Quandela’s hardware, we attempted to circumvent this through the use of quantum heralding. The goal of this approach was to achieve the end state of
Our idea is to take away the second beam-splitter between 4/5 and to place CNOT gates on 4 and 5, both controlled by 1. This would ensure a 50/50 distribution of the two desired states, as seen above. However, we had trouble designing this type of gate in Perceval and moved on to focus on other parts of the project.
Wang, et. al characterize environmental noise using “the Gaussian noise model”, which is what we used to attempt to model noise. We added random noise to the phase shift weights each iteration by creating an array of random samples of a Gaussian distribution centered on the average weight value. It has a standard deviation of
If we were to go back and do this project again, we would first focus on getting our model working and optimized as soon as possible. Our model performed extremely poorly when we first coded it, and it took hours to debug it and incrementally improve performance. One of the main consequences of this was that we found training for maximizing fidelity instead of minimizing loss yields significantly better results. Within 100 epochs, training against loss reached peak fidelity values of ~40%. In the same timeframe, training against fidelity easily reached peak values of 99.9%. We believe this is due to the inherently contrived nature of the QGAN setup, especially with the uncertainty within the discriminator circuit. The second aspect of our project we would put more time and focus on is understanding the discriminator. After maximizing our cost function from multiple initial states, we noted that some combinations of
We would like to thank Sam, Pierre, Marie, Alexia, and all of the other Quandela representatives who made this challenge possible for us today. We learned a lot of we are extremely appreciative. Thank you to iQuHack and everyone who helped create this academically enriching experience that we hope to take part in again!
Wang, Y., Xue, S., Wang, Y., Liu, Y., Ding, J., Shi, W., Wang, D., Liu, Y., Fu, X., Huang, G., Huang, A., Deng, M., & Wu, J. (2023). Quantum generative adversarial learning in photonics. Optics Letters, 48(20), 5197. https://doi.org/10.1364/ol.505084
Lloyd, S., & Weedbrook, C. (2018). Quantum Generative Adversarial Learning. Physical Review Letters, 121(4). https://doi.org/10.1103/physrevlett.121.040502
Cerezo, M., Arrasmith, A., Babbush, R., Benjamin, S. C., Endo, S., Fujii, K., McClean, J. R., Mitarai, K., Yuan, X., Cincio, Ł., & Coles, P. J. (2021). Variational quantum algorithms. Nature Reviews Physics, 3(9), 625–644. https://doi.org/10.1038/s42254-021-00348-9
Karácsony, M., Oroszlány, L., & Zimborás, Z. (2023). Efficient qudit based scheme for photonic quantum computing. arXiv (Cornell University). https://doi.org/10.48550/arxiv.2302.07357