Overview
The MIT iQuHack 2024 Quandela challenge asked teams to reproduce the photonic quantum generative adversarial network (QGAN) described by Wang et al. using Perceval, Quandela's linear-optics simulation framework. In the original experiment, a generator and discriminator are implemented on the same photonic chip. The generator prepares quantum states and the discriminator decides whether the state comes from the generator or from an ideal target state.
This arrangement mirrors the classical generative-adversarial network (GAN) paradigm, where a generator and a classifier compete: the discriminator receives real samples and fake samples and must classify them correctly. Over time the generator improves its output until it can fool the discriminator. In the challenge, both the generator and discriminator are variational quantum circuits, and the data are quantum states.
The primary objective was to train a generator to produce the target entangled state:
$$\frac{1}{2}(|01\rangle + |12\rangle + |23\rangle + |30\rangle)$$
starting from a maximally entangled ququart input:
$$\frac{1}{2}(|00\rangle + |11\rangle + |22\rangle + |33\rangle)$$
Participants were encouraged to replicate the circuit shown in the figure below and explore alternative ways of generating the initial entangled state. The challenge also suggested experimenting with different entangled sources and considering noise models and hardware runs on Quandela's Ascella QPU.

Figure 1: Photonic QGAN Architecture
Why Perceval?
Perceval is Quandela's quantum photonics simulator. It provides tools for composing circuits from linear-optical elements such as phase shifters and beam splitters, defining single-photon sources, manipulating Fock states and simulating circuit evolution. This project relies on Perceval to assemble and simulate both the generator and discriminator circuits.
Approach and Implementation
Photonic QGAN Architecture
Our solution mirrors the photonic architecture described in the challenge. The system consists of two variational circuits acting on eight optical modes: one implementing the generator and the other the discriminator. Each circuit is built from a sequence of phase shifters (PS) and beam splitters (BS), which are the basic building blocks in linear-optical quantum computing.
The generator's task is to transform an entangled input state into an output state that approximates the target state, while the discriminator evaluates whether an observed state originates from the generator or represents the true target.
Circuit Construction
Generator Circuit
A Python function gen_circuit(Phi_list)
constructs the generator. It takes a list of 30 phase-shifter angles and assembles an eight-mode photonic circuit by alternately adding phase shifters and beam splitters to appropriate modes. The large number of parameters allows the circuit to express a wide variety of unitary transformations.
Discriminator Circuit
The discriminator uses 12 phase-shifter angles and a similar pattern of beam splitters and phase shifters. Both circuits operate on eight modes so that they can be concatenated easily. Perceval's object-oriented API makes it straightforward to build these circuits and to visualise them using symbolic skins.
Objective Function and Training
We define an objective function that measures how close the generator's output is to the target state. Given parameter vectors \(\theta_g\) and \(\theta_d\) for the generator and discriminator, respectively, the function does the following:
- Prepare states: Construct the initial maximally entangled input state and the target state as sums of
pcvl.BasicState
objects. - Compose circuits: Concatenate the generator and discriminator to form a single composite circuit and also evaluate the discriminator alone.
- Simulate: Use Perceval's simulator to evolve the input state through the circuits and compute the resulting probability distributions. The key metric is the probability of measuring the pattern \(|2,2\rangle\) (two photons in two of the eight modes).
- Loss: Return the absolute difference between the probability obtained from the target state and the generator's output. The goal is to minimise this difference.
A classical optimiser (scipy.optimize.minimize
) minimises this objective over the parameters \(\theta_g, \theta_d\). Because Perceval does not provide analytic gradients for its photonic circuits, we used numerical gradient estimation within the optimiser. To avoid barren plateaux and local minima, we experimented with different initialization strategies and optimisers (e.g., Nelder–Mead and COBYLA). The training loop alternates between updating the generator and discriminator, analogous to classical GAN training.
Repository Structure
The code for this project is available on GitHub: SUINANTHEBUG/quhackx3. The key files include:
- qhack2024.ipynb: Notebook containing the final training workflow and experiment results.
- generator.py: Definition of the generator circuit and helper functions.
- discriminator.py: Definition of the discriminator circuit.
- measurement_function.py: Objective function, simulation utilities, and training loop.
- requirements.txt: Lists Python dependencies (Perceval version 0.10.3, NumPy, SciPy, etc.).
Results and Achievements
Our implementation successfully reproduced the photonic quantum generative adversarial network described in the challenge. After tuning the circuit parameters, the generator produced a state with high fidelity to the target entangled state, as verified by the discriminator's probability distribution and cross-checks using state fidelity metrics. The adversarial training procedure converged within a reasonable number of iterations (≈400 optimisation steps), and the final loss was significantly reduced from its initial value.

Figure 2: Photonic QGAN Values

Figure 3: Photonic QGAN Training Results
Second-place Finish
The project was evaluated by the Quandela mentors during the in-person hackathon. Our solution achieved second place among the participating teams. Factors contributing to this ranking included:
- Implementation completeness: We delivered a working generator/discriminator pair that could be trained end-to-end in simulation.
- Alternative initial states: We explored modifications suggested by the challenge (e.g., preparing different entangled states) and reported how these affected optimisation.
- Clear documentation: Our repository contains well-commented code and a concise README.md to facilitate reproduction.
Lessons Learned and Future Work
Working on this challenge highlighted several insights:
Parameter counting matters
Photonic circuits with too few parameters may not be expressive enough to approximate complicated entangled states. We found that 30 phase-shifter parameters for the generator and 12 for the discriminator provided adequate flexibility without making optimisation intractable.
Optimisation strategies
Without analytic gradients, numerical gradient estimation can be noisy. We mitigated this by averaging over multiple state evolutions and by experimenting with derivative-free optimisers.
Extensions
The challenge encourages further exploration, such as adding noise models or deploying circuits on Quandela's Ascella QPU. Future work could incorporate realistic noise and test hardware execution. Additionally, exploring hybrid classical-quantum training strategies or alternative cost functions might improve convergence.
References and Useful Links
- Challenge description and guidelines: iQuHACK 2024 Quandela challenge repository: the challenge defines the objectives, target state and suggestions for alternative approaches
- Perceval documentation: perceval.quandela.net/docs: explains how to build and simulate photonic circuits
- Our code repository: SUINANTHEBUG/quhackx3: contains all scripts, notebooks and the final presentation