††thanks: These authors contributed equally to this work††thanks: These
authors contributed equally to this work

Website: ]http://bbqlab.org

# Inverse-design of high-dimensional quantum optical circuits in a complex
medium

Suraj Goel  Institute of Photonics and Quantum Sciences, Heriot-Watt
University, Edinburgh, UK  Saroch Leedumrongwatthanakun  Institute of
Photonics and Quantum Sciences, Heriot-Watt University, Edinburgh, UK
<EMAIL_ADDRESS>Natalia Herrera Valencia  Institute of
Photonics and Quantum Sciences, Heriot-Watt University, Edinburgh, UK  Will
McCutcheon  Institute of Photonics and Quantum Sciences, Heriot-Watt
University, Edinburgh, UK  Claudio Conti  Department of Physics, University
Sapienza, Piazzale Aldo Moro 2, 00185 Rome, Italy  Institute for Complex
Systems, National Research Council (ISC-CNR), Via dei Taurini 19, 00185 Rome,
Italy  Research Center Enrico Fermi, Via Panisperna 89a, 00184 Rome, Italy
Pepijn W. H. Pinkse  MESA+ Institute for Nanotechnology, University of Twente,
P.O. Box 217, 7500 AE Enschede, The Netherlands  Mehul Malik<EMAIL_ADDRESS>[ Institute of Photonics and Quantum Sciences, Heriot-Watt University,
Edinburgh, UK

###### Abstract

Programmable optical circuits form a key part of quantum technologies today,
ranging from transceivers for quantum communication to integrated photonic
chips for quantum information processing. As the size of such circuits is
increased, maintaining precise control over every individual component becomes
challenging, leading to a reduction in the quality of the operations
performed. In parallel, minor imperfections in circuit fabrication are
amplified in this regime, dramatically inhibiting their performance. Here we
show how embedding an optical circuit in the higher-dimensional space of a
large, ambient mode-mixer using inverse-design techniques allows us to forgo
control over each individual circuit element, while retaining a high degree of
programmability over the circuit. Using this approach, we implement high-
dimensional linear optical circuits within a complex scattering medium
consisting of a commercial multi-mode fibre placed between two controllable
phase planes. We employ these circuits to manipulate high-dimensional spatial-
mode entanglement in up to seven dimensions, demonstrating their application
as fully programmable quantum gates. Furthermore, we show how their
programmability allows us to turn the multi-mode fibre itself into a
generalised multi-outcome measurement device, allowing us to both transport
and certify entanglement within the transmission channel. Finally, we discuss
the scalability of our approach, numerically showing how a high circuit
fidelity can be achieved with a low circuit depth by harnessing the resource
of a high-dimensional mode-mixer. Our work serves as an alternative yet
powerful approach for realising precise control over high-dimensional quantum
states of light, with clear applications in next-generation quantum
communication and computing technologies.

A programmable optical circuit is an essential element for applications in
fields as diverse as sensing, communication, neuromorphic computing,
artificial intelligence, and quantum information processing Shastri  _et al._
(2021); Bogaerts  _et al._ (2020); Wetzstein  _et al._ (2020). The production
of large, reprogrammable circuits is of paramount importance for coherently
processing information encoded in light. However, there remain many challenges
associated with the design, manufacture, and control of such circuits, which
normally require a sophisticated mesh of interferometers constructed with bulk
or integrated optics Harris  _et al._ (2018); Bogaerts  _et al._ (2020).
Conventional construction of these circuits exploits universal programmability
on two-dimensional unitary spaces to construct arbitrary high-dimensional
unitary transformations Reck  _et al._ (1994); Miller (2013); Clements  _et
al._ (2016); Kumar and Dhand (2021), herein referred to as the “bottom-up”
technique (Fig.1a). Over the past two decades, the technological development
of integrated programmable circuits has enabled universal programmability in
up to 20 path-encoded modes, containing a few hundreds of optical components
on the same chip Carolan  _et al._ (2015); Wang  _et al._ (2020); Tang  _et
al._ (2021); Taballione  _et al._ (2022).

Figure 1: Designing programmable optical circuits: A general linear
transformation $\mathbb{T}$ can be implemented via (a) the conventional
“bottom-up” approach, where the circuit is constructed from units consisting
of beamsplitters (BS) and phase shifters (P), or (b) the herein proposed “top-
down” approach, where a target $d$-dimensional linear circuit is implemented
within a large ambient mode-mixer with dimension $n>d$, where $n-d$ auxiliary
modes serve as an additional resource. The technique harnesses random
unitaries $U_{j}$ (such as a complex scattering system) interspersed with
controllable phase planes $P_{j}$ implemented via spatial light modulators
(SLMs), which provide programmability over the target circuit. A similar
approach is used in (c) multi-plane light converters, where the random
unitaries are replaced with free-space propagation $F$.

Imperfections in optical circuits such as scattering loss, unbalanced mode-
mixing, and undesired cross-talk between modes are problematic as they reduce
the accuracy and success probability of the implemented circuit Miller (2015);
Burgwal  _et al._ (2017); Pai  _et al._ (2018); Fang  _et al._ (2019); Hamerly
_et al._ (2021). These issues become increasingly challenging in large
dimensions, as the number of optical elements grows quadratically with the
size of the circuit Harris  _et al._ (2018); Bogaerts  _et al._ (2020). Such
imperfections can be addressed to some extent by increasing the depth of the
circuit through the introduction of additional phase shifters and
beamsplitters Miller (2015); Burgwal  _et al._ (2017); Pai  _et al._ (2018);
Fldzhyan  _et al._ (2020); Tanomura  _et al._ (2022). However, these
additional components necessitate additional control, further increasing the
demands associated with circuit complexity. In this work, we present an
alternative solution where the optical circuit is embedded in a higher-
dimensional space of a large ambient mode-mixer such as a random scattering
medium, placed between reprogrammable phase planes (Fig.1b). This “top-down”
approach harnesses the complicated scattering process within a large mode-
mixer to forgo control over each individual circuit element. Instead, an
inverse-design approach is used that employs algorithmic techniques to program
an optical circuit with a desired functionality within the random scattering
medium Molesky  _et al._ (2018); Marcucci  _et al._ (2020). Similar approaches
based on inverse-design have been used in multi-plane light converters (MPLC)
for spatial-mode manipulation Morizur  _et al._ (2010); Labroille  _et al._
(2014); Fontaine  _et al._ (2019), where free-space propagation is commonly
used in place of a random scattering medium (Fig.1c). Furthermore, inverse-
design techniques have also enabled a variety of optical circuits tailored
towards specific functionalities, ranging from designs of nanoscale photonic
devices Hashimoto  _et al._ (2005) to arrangements of bulk optical elements
for fundamental quantum experiments Erhard  _et al._ (2018); Krenn  _et al._
(2016); Melnikov  _et al._ (2018); Krenn  _et al._ (2020).

The capability to manipulate quantum states of light using large-scale
programmable circuits promises a myriad of applications in quantum information
science, ranging from the demonstration of computational advantage Zhong  _et
al._ (2020) to the realisation of quantum networks Llewellyn  _et al._ (2020).
In this regard, high-dimensional quantum systems offer significant advantages
in terms of increased information capacity and noise-resistance in quantum
communication Hu  _et al._ (2018); Ecker  _et al._ (2019); Zhu  _et al._
(2021), while also enabling more practical tests of quantum nonlocality
Vertesi  _et al._ (2010); Srivastav  _et al._ (2022). While methods for the
transport Valencia  _et al._ (2020); Cao  _et al._ (2020) and certification
Bavaresco  _et al._ (2018a); Friis  _et al._ (2019); Herrera Valencia  _et
al._ (2020) of high-dimensional entanglement have seen rapid progress over the
past few years, scalable techniques for its precise manipulation and
measurement are still lacking. As an alternative to the bottom-up approach
normally implemented on integrated platforms Wang  _et al._ (2020), inverse-
design techniques have been used for realising quantum gates in dimensions up
to $d=8$ using bulk optical interferometers Babazadeh  _et al._ (2017); Wang
_et al._ (2017); Kong  _et al._ (2019) and in $d=5$ with multi-plane light
conversion Brandt  _et al._ (2020); Lib  _et al._ (2021). In parallel, recent
advances in control over light scattering in complex media Rotter and Gigan
(2017); Cao and Eliezer (2022) have enabled linear optical circuits for
classical light Huisman  _et al._ (2015); Matthès  _et al._ (2019) and
demonstrations of programmable two-photon quantum interference Wolterink  _et
al._ (2015); Defienne  _et al._ (2016); Leedumrongwatthanakun  _et al._
(2020), showing their clear potential to serve as a high-dimensional quantum
photonics platform.

In this article, we harness light scattering through an off-the-shelf multi-
mode fibre to program generalised quantum circuits for transverse spatial
photonic modes in dimensions up to seven. We apply these circuits for the
manipulation of high-dimensional entangled states of light in multiple
spatial-mode bases, demonstrating high-dimensional Pauli-$\mathbb{Z}$ and
$\mathbb{X}$ gates, discrete Fourier transforms, and random unitaries in the
macro-pixel and OAM spatial-mode bases Herrera Valencia  _et al._ (2020);
Valencia  _et al._ (2021a). Furthermore, in contrast with single-outcome
projective measurements that are inherently inefficient Bouchard  _et al._
(2018), our technique realises generalised transformations to a spatially
localised “pixel” basis, effectively turning the channel itself into a
generalised multi-outcome measurement device. By harnessing this
functionality, we show how the on-demand programmability of our gates enables
us to both transport and certify entanglement within the same complex medium.
Such multi-outcome measurements can be easily integrated with next-generation
single-photon-detector arrays Allmaras  _et al._ (2020) and provide a key
functionality in many quantum information applications, such as allowing one
to overcome fair-sampling assumptions Designolle  _et al._ (2021).

Figure 2: Experimental setup: A high-dimensional spatially entangled two-
photon state is generated via Type-II spontaneous parametric downconversion
(SPDC) in a periodically poled Potassium Titanyl Phosphate (ppKTP) crystal.
The two photons are spatially separated by a polarising beamsplitter (PBS) and
sent to two parties, Alice and Bob. Alice performs single-outcome projective
measurements $\hat{\Pi}^{\mu}_{a}$ that measure whether a photon is carrying
spatial mode $a$ from modal basis $\mu$. These are performed by a combination
of a spatial light modulator (SLM3), single-mode fibre (SMF), and a single-
photon avalanche photodiode (APD). Bob implements a top-down programmable
circuit that is constructed from a multi-mode optical fibre (MMF) placed
between two programmable spatial light modulators (SLM1,2). The circuit is
used to program a variety of high-dimensional quantum gates and serves as a
generalised multi-outcome device. (Circular insert) A coincidence image
depicting a five-outcome measurement in basis $\mu=1$ performed with the
Fourier $\mathbb{F}$ gate at Bob. The image is obtained by scanning a detector
across the output of the circuit, conditioned on a measurement of
$\hat{\Pi}^{\mu=1}_{a=0}$ at Alice, and shows a large intensity in mode 0 due
to strong spatial-mode correlations. Coincidence detection events between
Alice and Bob are registered by time-tagging electronics. (L: lens, F: filter,
HWP: half-wave plate)

##  I Top-Down Programmable Circuits: Concept and Experimental Implementation

An optical circuit is described by a linear transformation $\mathbb{T}$, which
maps a set of input optical modes onto a set of output modes Miller (2012,
2019). The linear circuit $\mathbb{T}$ of dimension $d$ is built from a
cascade of optical mode mixers $U$, and phase shifters $P$. A deterministic
construction can be based on a cascade of reconfigurable Mach–Zehnder
interferometers, wherein $U_{j}$ represents the embedded balanced two-mode
mixer, i.e. a 50:50 beam splitter, and the $P_{j}$ are phase shifters (Fig.1a)
Reck  _et al._ (1994); Clements  _et al._ (2016). As an alternative to this
deterministic bottom-up construction, the top-down design presented here
relies on the capability to harness large, complex, inter-modal mode mixers
$U_{j}$ of dimension $n$ $(U_{j}\in\mathcal{U}(\mathbf{n}))$ and
reconfigurable phase planes $P_{j}=\text{diag}(e^{i\boldsymbol{\theta}})$ to
construct a programmable target circuit $\mathbb{T}$ of a smaller size
($d\leqslant n$) embedded within the larger mode-mixers (Fig.1b). The
decomposition of a top-down programmable circuit is represented as

$\mathbf{T}\approx\prod_{j=1}^{L\leqslant\mathcal{O}(\mathbf{d})}U_{j}P_{j},$
(1)

where $L$ is the depth of the circuit (the number of layers), and the target
circuit $\mathbb{T}$ is embedded in the total transfer matrix of the system
$\mathbf{T}$. Optimal choices for the large mode-mixer dimension ($n$) and the
circuit depth ($L$) for a given target circuit dimension ($d$) are discussed
in Section III.

We experimentally construct the programmable optical circuit with a 2-metre-
long multi-mode fibre (MMF, Thorlabs) positioned between two programmable
phase planes, $P_{1}$ and $P_{2}$, implemented on spatial light modulators
(SLMs) as depicted in Fig. 2. The MMF serves as a large, complex mode-mixer
that provides complicated inter-modal coupling Carpenter  _et al._ (2014);
Plöschner  _et al._ (2015); Xiong  _et al._ (2018), while the SLMs provide
programmability over the circuit to be implemented. The circuit can be
decomposed as $\mathbf{T}=U_{2}P_{2}U_{1}P_{1}$, where $U_{1}$ represents the
transfer matrix of the optical system consisting of the MMF and the associated
coupling optics and $U_{2}$ is the $2f$ lens system. To construct the circuit,
we begin by characterising $U_{1}$ in a referenceless manner via our developed
technique. Random phase patterns are displayed on the planes $P_{1}$ and
$P_{2}$ and the resulting intensity speckle images are measured at the output.
The data set is then used to optimise the machine learning model that
describes the optical system of our experiment using the gradient descent
method (see Supplementary Information S.2). Once we have the complete
knowledge of the mode-mixer $U_{1}$, a given target circuit is then programmed
using a solution of phase patterns obtained from the inverse-design
optimisation known as the wavefront-matching (WFM) technique Hashimoto  _et
al._ (2005); Sakamaki  _et al._ (2007); Fontaine  _et al._ (2017). The WFM
technique maximises the overlap of a set of target input optical fields to the
corresponding output fields (see S.5 for the detailed procedure).

Figure 3: Manipulation and certification of high-dimensional entanglement:
Normalised two-photon coincidence counts (top row) and reconstructed density
matrices (bottom row) corresponding to the output state obtained after local
operation of the Identity $\mathbb{I}$, Pauli-$\mathbb{Z}$,
Pauli-$\mathbb{X}$, Fourier $\mathbb{F}$, and random unitary $\mathbb{R}$
gates on an input two-photon, five-dimensional entangled state in the macro-
pixel basis. The two-photon coincidences are measured in all six mutually
unbiased bases (MUBs $\mu\in\\{0...5\\}$) via projective measurements at Alice
and Bob. Due to state-channel duality, tomography of the output two-photon
state is equivalent to performing ancilla-assisted process tomography of the
gates themselves Valencia  _et al._ (2020); Altepeter  _et al._ (2003). The
fidelities of the reconstructed density matrices are reported in Table II. The
Identity and Fourier gates enable our circuit to be used as a multi-outcome
measurement device in MUBs $\mu\in\\{0,1\\}$ (red squares). By applying a two-
basis entanglement witness on these data Bavaresco  _et al._ (2018a), we are
able to certify four-dimensional entanglement using the channel itself as a
measurement device.

##  II Applications of Quantum Gates: Manipulation and Certification of High-
Dimensional Entanglement

We utilise the programmable circuit to manipulate spatially entangled two-
photon states in a range of dimensions, $d\in\\{2,3,5,7\\}$ (see S.1 for
details of the generated states). As shown in Fig. 2, the two photons are
generated via the process of spontaneous parametric down-conversion (SPDC) and
sent to two parties, Alice and Bob. Bob’s photon is locally manipulated by the
programmable circuit $\mathbb{T}$, while Alice’s photon is detected via
single-outcome projective measurements $\hat{\Pi}^{\mu}_{a}$. These
measurements project the photon in a particular mode $a$ in basis $\mu$ via
the combination of a holographic spatial light modulator (SLM3) and single
mode fibre Bouchard  _et al._ (2018); Qassim  _et al._ (2014). These single-
outcome measurements require one to perform $d$ projections to realise a
complete measurement, giving them a maximum effective efficiency of $1/d$,
which is normally lower due to loss. In contrast, our programmable circuit
$\mathbb{T}$ performs generalised basis transformations to a localised “pixel”
basis with a maximum theoretical efficiency of unity (see Section III),
enabling multi-outcome measurements in any given basis. The circuit is
programmed to operate on two different input bases, the macro-pixel basis
Herrera Valencia  _et al._ (2020) and the orbital-angular-momentum (OAM) basis
Valencia  _et al._ (2021a), while the target output modes are randomly
selected from the set of all possible foci at the output of the circuit. We
then implement a variety of different target gates including the
identity-$\mathbb{I}$, Pauli-$\mathbb{Z}$, Pauli-$\mathbb{X}$,
Fourier-$\mathbb{F}$, and random unitaries-$\mathbb{R}$ by programming the
circuit using the wavefront-matching algorithm.

In order to verify that these gates preserve quantum coherence, we apply them
on the input high-dimensionally entangled states and reconstruct the resulting
output state via quantum state tomography (S.4). Due to state-channel duality,
tomography of the output two-photon state is equivalent to performing ancilla-
assisted process tomography of the gates themselves Valencia  _et al._ (2020);
Altepeter  _et al._ (2003). In this manner, we can quantify how close to ideal
these gates are, while also verifying that they preserve high-dimensional
entanglement. To showcase the versatility of our platform, we program 296
instances of all gates, sampling from different output foci in different
dimensions and input bases. Fig. 3 (top row) shows examples of normalised two-
photon coincidence count data in all mutually unbiased bases (MUBs) for five-
dimensional $\mathbb{I}$, $\mathbb{Z}$, $\mathbb{X}$, $\mathbb{F}$, and
$\mathbb{R}$ gates programmed for the macro-pixel basis. Fig. 3 (bottom row)
shows density matrices of the manipulated two-photon states reconstructed from
these data, presenting a clear agreement with theoretical prediction (insets).
This can be quantified via their fidelity (S.6) to the ideal output states,
which is reported in Table II for all dimensions in the macro-pixel basis. Our
fidelity calculation takes into account the non-maximally entangled nature of
the input entangled state. Results for gates implemented in the LG basis are
presented in S.7. It is noteworthy that the five-dimensional reconstructed
state after the identity gate $\mathbb{I}$ has a fidelity of
$\mathcal{F}(\rho_{o},|{\Phi^{+}}\rangle\langle{\Phi^{+}}|)=83.8\pm 1.5\%$ to
the maximally entangled state, which exceeds the bound necessary to certify
five-dimensional entanglement.

While we have verified that these gates are able to manipulate and preserve
high-dimensional entanglement, we now demonstrate how they can be used for the
certification of entanglement using the channel itself. Entanglement
certification requires correlation measurements in at least two MUBs Bavaresco
_et al._ (2018a), which are normally performed with SLM-based projective
single-outcome measurements (as done at Alice). Our programmable circuit
functions as a generalised multi-outcome measurement device, allowing
measurements to be made both in the pixel basis $\mu=0$ (via the identity gate
$\mathbb{I}$), as well as the first MUB $\mu=1$ (via the Fourier gate
$\mathbb{F}$) with an appropriate single-photon detector array. An example of
the five-outcome MUB measurement is shown in Fig. 2 (insert) that depicts the
output of the $\mathbb{F}$ gate, conditioned on a MUB measurement
$\hat{\Pi}^{\mu=1}_{a=0}$ at Alice. The image is obtained by tilting
wavefronts using SLM2, which is equivalent to scanning a detector across the
output (as shown in the illustration). The increased coincidence counts
observed in mode 0 are due to the strong two-photon spatial-mode correlations
exhibited by the entangled state. The coincidence count data corresponding to
a two-basis measurement obtained by programming the circuit in this manner are
highlighted in Fig. 3 (red squares). Using these data, we obtain a fidelity of
$68.9\pm 3.2\%$ to a five-dimensional maximally entangled state, certifying
the presence of four-dimensional entanglement. In this manner, the multi-mode
optical fibre can be used to both transport as well as certify high-
dimensional entanglement. It is important to note that while we have used two
MUBs for entanglement certification, the programmability of our circuit in
general allows for measurements in multiple or even “tilted” MUBs Bavaresco
_et al._ (2018a), which would lead to increased fidelities and robustness to
noise.

The coincidence image in Fig. 2 also provides information about scattering
loss outside the output modes of interest. This allows us to measure the
success probability of the gate operation, which is defined as the ratio of
coincidence counts in the target output modes over the total coincidence
counts integrated over all outputs in one polarisation channel. We perform
this measurement on three randomly chosen implementations of the $\mathbb{F}$
gates in $2,3$ and $5$ dimensions and measure a success probability of
$0.36\pm 0.01$, $0.27\pm 0.03$, and $0.18\pm 0.04$, respectively. Additional
information about the success probability and optical transmittance of the
device is provided in S.6. It is worth noting that for this proof-of-concept
demonstration, we only control a single polarisation channel of the multi-mode
fibre, thus reducing the success probability by about half. Controlling both
polarisation channels of the multi-mode fibre can increase the success
probability by almost a factor two as well as improve the fidelity of the
implemented circuits. In addition, the results in Table II report the circuits
with the highest achieved fidelities. While in theory using random-unitary as
a mode-mixer, this is statistically expected to be the same for all types of
implemented circuits at a given dimension, experimental imperfections in the
characterisation and properties of $U_{1}$ result in a spread of fidelities
with a lower average (please see Supplementary Information S.7 for details).

[tb]  : Quantum process fidelities of inverse-designed gates in the macro-pixel basis. Due to state-channel duality, these are equivalent to the fidelities of the two-photon entangled states manipulated by these gates. Gate | $d=2$ | $d=3$ | $d=5$ | $d=7$
---|---|---|---|---
$\mathbb{I}$ | $97.3\pm 0.3\%$ | $94.4\pm 0.2\%$ | $84.7\pm 0.4\%$ | $73.1\pm 0.4\%$
$\mathbb{Z}$ | $97.7\pm 0.4\%$ | $93.5\pm 0.3\%$ | $77.7\pm 0.4\%$ | $61.4\pm 0.4\%$
$\mathbb{X}$ | $97.1\pm 0.4\%$ | $92.6\pm 0.2\%$ | $78.8\pm 0.5\%$ | $58.8\pm 0.5\%$
$\mathbb{F}$ | $96.0\pm 0.6\%$ | $89.4\pm 0.4\%$ | $75.9\pm 0.4\%$ | $57.5\pm 0.4\%$
$\mathbb{R}$ | $96.5\pm 0.5\%$ | $90.2\pm 0.2\%$ | $81.1\pm 0.4\%$ | $63.6\pm 0.4\%$

Figure 4: Programmability and Scalability of top-down optical circuits: (a-b)
Fidelity ($\mathcal{F}$) and success probability ($\mathcal{S}$) as a function
of the dimension of mode-mixers ($n$) for a circuit depth of $L=2$. (c-d)
$\mathcal{F}$ and $\mathcal{S}$ as a function of $L$ for $n=200$. (e) A plot
of Fidelity versus the parameter $nL/d^{2}$ in the regime where $d/n<0.1$. The
plot shows a converging trend towards unit Fidelity ($\mathcal{F}=1$),
demonstrating that full programmability can be achieved by increasing either
the mode-mixer dimension $n$ or the circuit depth $L$. (Insert) A plot of
Success probability versus the parameter $L/d$ shows convergence to unity when
the number of phase planes approaches $L\approx\mathcal{O}(d)$.

##  III Programmability and Scalability

We have successfully demonstrated the ability to perform various gates in
multiple spatial-mode bases in dimensions $2,3,5$ and $7$. However, as the
dimension of the target gate increases, maintaining high fidelities and
success probabilities becomes increasingly challenging. It is thus imperative
to examine the programmability and scalablility of our design and address ways
to improve its performance and target practical experimental regimes to work
in. We investigate these numerically by implementing a circuit based on Eq. 1
and varying three major design parameters—the dimension of the mode mixers,
$n$, the dimension of the target gate, $d$, and the depth of the circuit, $L$.
Multiple implementations of the $\mathbb{I}$, $\mathbb{X}$, $\mathbb{Z}$,
$\mathbb{F}$, and $\mathbb{R}$ gates are simulated for specific values of the
design parameters by changing the random-unitary mode mixers and the sets of
input and output modes for each instance. For each gate, we calculate the
fidelity with respect to the ideal target gate and the success probability.

The key design considerations we address are: what dimension of mode mixers
($n$) should be chosen? And how many layers ($L$) is it practical to use,
given the optical losses usually present at interfaces, and the experimental
overhead involved? Figs. 4a-d depict simulation results showing how the
fidelity and success probability of the top-down design ($n>d$) scale as a
function of either the dimension of mode mixers ($n$) or the depth of circuit
($L$), while keeping other design parameters constant. The first observation
is that increasing the size of the mode mixers ($n$) increases the circuit
fidelity (Fig. 4a). This demonstrates that even when implementing practical
low depth circuits, such as we have presented here, high fidelities can be
reached, with high-dimensional mode mixers serving as a key resource for this
behaviour. Furthermore, for $d/n<0.1$ the success probability is approximately
constant with $n$ (Fig. 4b), allowing high-dimensional mode mixers to be
employed without affecting the success probability.

Alongside this, we observe that increasing the depth of the circuit ($L$)
increases both fidelity and success probability (Figs. 4c-d), generalising
recent results into the $n>d$ regime Saygin  _et al._ (2020); Pereira  _et
al._ (2020). In practise, however, scaling up the circuit depth introduces
experimental overheads in the form of propagation and interface losses and
accumulation of errors. In general, we observe that the fidelity increases and
converges to unity (Fig. 4e for $d/n<0.1$) when the total number of
reconfigurable elements $nL$ exceeds the requirement for parameterising a
$d$-dimensional unitary transform $\mathcal{O}(d^{2})$, thereby showing a high
level of programmability of the top-down design. Furthermore, the convergence
of the success probability to unity occurs when the circuit depth is on the
order of the circuit dimension $L\approx\mathcal{O}(d)$. This is because there
are $d(n-d)$ amplitudes in the transformation which correspond to scattering
from the target input modes, to modes outside of the target output modes, and
to achieve unit success probability these must all vanish requiring at least
this many controllable parameters. The top-down approach thus presents a
powerful route towards realising high-fidelity circuits by harnessing the
resource of a high-dimensional mode-mixing space ($n>d$), while operating in a
practical, low circuit depth regime ($L\leqslant\mathcal{O}(d)$). Full details
of these simulations are presented in Supplementary Information S.8.

##  IV Conclusion and Outlook

We have demonstrated that programmable optical circuits in the transverse-
spatial domain can be reliably implemented using the top-down approach
incorporating complex scattering processes between reconfigurable phase
planes. Using our technique, we programmed high-dimensional quantum gates
within a multi-mode fibre and used them to manipulate high-dimensional
entangled states of light in two different spatial-mode bases. We verified
that these gates preserve quantum coherence by certifying that high-
dimensional entanglement persists after gate operations. We demonstrated how
our gates operate as a generalised multi-outcome measurement device, enabling
the MMF channel to both transport, manipulate and certify high-dimensional
entanglement. Finally, we performed extensive numerical investigations
studying the scalability of our approach, concluding that high circuit
fidelities can be reached by harnessing the resource of a high-dimensional
mode-mixer, while staying within the practical regime of a low circuit depth.
Fundamental aspects of circuit design still present important open challenges,
such as proving that the technique can be used for the universal
implementation of unitary transforms, deterministic calculations for setting
phase shifters, and optimising these circuits for better performance.

Beyond the transverse spatial degree-of-freedom, the method readily generalise
other platforms where phase shifters and mode-mixers can be realised. For
instance, implementations of top-down designs in integrated optics will be
forthcoming as random-mixed waveguides develop and low-loss reconfigurable
phase shifters become available Bruck  _et al._ (2016); Wang  _et al._ (2019);
Dinsdale  _et al._ (2021). Further developments must also address practical
issues including modal dispersion and spatio-temporal mixing that are present
in long multi-mode fibres and thick scattering media. These obstacles,
however, enable the extension of the top-down circuit design into the
spectral-temporal domain Lukens  _et al._ (2016); Mounaix  _et al._ (2016); Lu
_et al._ (2018); Mounaix  _et al._ (2020). By demonstrating the practical
realisation of high-dimensional programmable optical circuits—within the
transmission channel itself—our work overcomes a significant hurdle facing the
adoption of high-dimensional encoding in quantum communication systems, and
paves the way for practical implementations of programmable optical circuits
in various near-term photonic and quantum technologies including sensing and
computation.

###### Acknowledgements.

This work was made possible by financial support from the QuantERA ERA-NET Co-
fund (FWF Project I3773-N36), the UK Engineering and Physical Sciences
Research Council (EPSRC) (EP/P024114/1) and the European Research Council
(ERC) Starting grant PIQUaNT (950402). Colormaps for all the figures in this
article are adopted from Crameri (2021).

## References

  * Shastri  _et al._ (2021) Bhavin J Shastri, Alexander N Tait, T. Ferreira de Lima, Wolfram H P Pernice, Harish Bhaskaran, C D Wright, and Paul R Prucnal,  _Photonics for artificial intelligence and neuromorphic computing,_Nature Photonics 15, 102 (2021).
  * Bogaerts  _et al._ (2020) Wim Bogaerts, Daniel Pérez, José Capmany, David A B Miller, Joyce Poon, Dirk Englund, Francesco Morichetti, and Andrea Melloni,  _Programmable photonic circuits,_Nature 586, 207 (2020).
  * Wetzstein  _et al._ (2020) Gordon Wetzstein, Aydogan Ozcan, Sylvain Gigan, Shanhui Fan, Dirk Englund, Marin Soljačić, Cornelia Denz, David A B Miller, and Demetri Psaltis,  _Inference in artificial intelligence with deep optics and photonics,_Nature 588, 39 (2020).
  * Harris  _et al._ (2018) Nicholas C. Harris, Jacques Carolan, Darius Bunandar, Mihika Prabhu, Michael Hochberg, Tom Baehr-Jones, Michael L. Fanto, A. Matthew Smith, Christopher C. Tison, Paul M. Alsing, and Dirk Englund,  _Linear programmable nanophotonic processors,_Optica 5, 1623 (2018).
  * Reck  _et al._ (1994) Michael Reck, Anton Zeilinger, Herbert J Bernstein, and Philip Bertani,  _Experimental realization of any discrete unitary operator,_Physical Review Letters 73, 58 (1994).
  * Miller (2013) David A B Miller,  _How complicated must an optical component be?_Journal of the Optical Society of America A 30, 238 (2013).
  * Clements  _et al._ (2016) William R. Clements, Peter C. Humphreys, Benjamin J. Metcalf, W. Steven Kolthammer, Ian A. Walsmley, and Ian A. Walmsley,  _Optimal design for universal multiport interferometers,_Optica 3, 1 (2016), arXiv:1603.08788.
  * Kumar and Dhand (2021) Shreya P Kumar and Ish Dhand,  _Unitary matrix decompositions for optimal and modular linear optics architectures,_Journal of Physics A: Mathematical and Theoretical 54, 045301 (2021).
  * Carolan  _et al._ (2015) Jacques Carolan, Christopher Harrold, Chris Sparrow, E. Martin-Lopez, Nicholas J. Russell, Joshua W. Silverstone, Peter J. Shadbolt, Nobuyuki Matsuda, Manabu Oguma, Mikitaka Itoh, Graham D. Marshall, Mark G. Thompson, Jonathan C.F. F. Matthews, Toshikazu Hashimoto, Jeremy L. O’Brien, and Anthony Laing,  _Universal linear optics,_Science 349, 711 (2015), arXiv:1505.01182.
  * Wang  _et al._ (2020) Jianwei Wang, Fabio Sciarrino, Anthony Laing, and Mark G Thompson,  _Integrated photonic quantum technologies,_Nature Photonics 14, 273 (2020).
  * Tang  _et al._ (2021) Rui Tang, Ryota Tanomura, Takuo Tanemura, and Yoshiaki Nakano,  _Ten-Port Unitary Optical Processor on a Silicon Photonic Chip,_ACS Photonics (2021), 10.1021/acsphotonics.1c00419.
  * Taballione  _et al._ (2022) Caterina Taballione, Malaquias Correa Anguita, Michiel de Goede, Pim Venderbosch, Ben Kassenberg, Henk Snijders, Devin Smith, Jörn P Epping, Reinier van der Meer, Pepijn WH Pinkse, _et al._ ,  _20-mode universal quantum photonic processor,_ (2022), arXiv:2203.01801.
  * Miller (2015) David A. B. Miller,  _Perfect optics with imperfect components,_Optica 2, 747 (2015).
  * Burgwal  _et al._ (2017) Roel Burgwal, William R. Clements, Devin H. Smith, James C. Gates, W. Steven Kolthammer, Jelmer J. Renema, and Ian A. Walmsley,  _Using an imperfect photonic network to implement random unitaries,_Optics Express 25, 28236 (2017), arXiv:1612.01199.
  * Pai  _et al._ (2018) Sunil Pai, Ben Bartlett, Olav Solgaard, and David A. B. Miller,  _Matrix optimization on universal unitary photonic devices,_Physical Review Applied 10, 1 (2018), arXiv:1808.00458.
  * Fang  _et al._ (2019) Michael Y.-S. Fang, Sasikanth Manipatruni, Casimir Wierzynski, Amir Khosrowshahi, and Michael R. DeWeese,  _Design of optical neural networks with component imprecisions,_Optics Express 27, 14009 (2019).
  * Hamerly  _et al._ (2021) Ryan Hamerly, Saumil Bandyopadhyay, and Dirk Englund,  _Stability of Self-Configuring Large Multiport Interferometers,_ (2021), arXiv:2106.04363.
  * Fldzhyan  _et al._ (2020) S. A. Fldzhyan, M. Yu. Saygin, and S. P. Kulik,  _Optimal design of error-tolerant reprogrammable multiport interferometers,_Optics Letters 45, 2632 (2020).
  * Tanomura  _et al._ (2022) Ryota Tanomura, Rui Tang, Toshikazu Umezaki, Go Soma, Takuo Tanemura, and Yoshiaki Nakano,  _Scalable and robust photonic integrated unitary converter based on multiplane light conversion,_ Physical Review Applied 17, 024071 (2022), arXiv:2103.14782.
  * Molesky  _et al._ (2018) Sean Molesky, Zin Lin, Alexander Y Piggott, Weiliang Jin, Jelena Vucković, and Alejandro W Rodriguez,  _Inverse design in nanophotonics,_Nature Photonics 12, 659 (2018).
  * Marcucci  _et al._ (2020) Giulia Marcucci, Davide Pierangeli, Pepijn W. H. Pinkse, Mehul Malik, and Claudio Conti,  _Programming multi-level quantum gates in disordered computing reservoirs via machine learning,_Optics Express 28, 14018 (2020), arXiv:1905.05264.
  * Morizur  _et al._ (2010) Jean-François Morizur, Lachlan Nicholls, Pu Jian, Seiji Armstrong, Nicolas Treps, Boris Hage, Magnus Hsu, Warwick Bowen, Jiri Janousek, and Hans-A Bachor,  _Programmable unitary spatial mode manipulation,_Journal of the Optical Society of America A 27, 2524 (2010), arXiv:1005.3366.
  * Labroille  _et al._ (2014) Guillaume Labroille, Bertrand Denolle, Pu Jian, Philippe Genevaux, Nicolas Treps, Jean-François François Morizur, Philippe Genevaux, and Nicolas Treps,  _Efficient and mode selective spatial mode multiplexer based on multi-plane light conversion,_Optics Express 22, 15599 (2014), arXiv:1404.6455v1.
  * Fontaine  _et al._ (2019) Nicolas K Fontaine, Roland Ryf, Haoshuo Chen, David T Neilson, Kwangwoong Kim, and Joel Carpenter,  _Laguerre-Gaussian mode sorter,_Nature Communications 10, 1865 (2019).
  * Hashimoto  _et al._ (2005) T Hashimoto, T Saida, I Ogawa, M Kohtoku, T Shibata, and H Takahashi,  _Optical circuit design based on a wavefront-matching method,_Optics Letters 30, 2620 (2005).
  * Erhard  _et al._ (2018) Manuel Erhard, Mehul Malik, Mario Krenn, and Anton Zeilinger,  _Experimental greenberger–horne–zeilinger entanglement beyond qubits,_Nature Photonics 12, 759–764 (2018).
  * Krenn  _et al._ (2016) Mario Krenn, Mehul Malik, Robert Fickler, Radek Lapkiewicz, and Anton Zeilinger,  _Automated Search for new Quantum Experiments,_Physical Review Letters 116, 1 (2016), arXiv:1509.02749.
  * Melnikov  _et al._ (2018) Alexey A Melnikov, Hendrik Poulsen Nautrup, Mario Krenn, Vedran Dunjko, Markus Tiersch, Anton Zeilinger, and Hans J Briegel,  _Active learning machine learns to create new quantum experiments,_Proceedings of the National Academy of Sciences 115, 1221 (2018).
  * Krenn  _et al._ (2020) Mario Krenn, Manuel Erhard, and Anton Zeilinger,  _Computer-inspired quantum experiments,_Nature Reviews Physics 2, 649 (2020), arXiv:2002.09970.
  * Zhong  _et al._ (2020) Han-Sen Zhong, Hui Wang, Yu-Hao Deng, Ming-Cheng Chen, Li-Chao Peng, Yi-Han Luo, Jian Qin, Dian Wu, Xing Ding, Yi Hu, _et al._ ,  _Quantum computational advantage using photons,_Science 370, 1460 (2020).
  * Llewellyn  _et al._ (2020) Daniel Llewellyn, Yunhong Ding, Imad I Faruque, Stefano Paesani, Davide Bacco, Raffaele Santagati, Yan-Jun Qian, Yan Li, Yun-Feng Xiao, Marcus Huber, and et al.,  _Chip-to-chip quantum teleportation and multi-photon entanglement in silicon,_Nature Physics 16, 148–153 (2020).
  * Hu  _et al._ (2018) Xiao-Min Hu, Yu Guo, Bi-Heng Liu, Yun-Feng Huang, Chuan-Feng Li, and Guang-Can Guo,  _Beating the channel capacity limit for superdense coding with entangled ququarts,_Science Advances 4, eaat9304 (2018).
  * Ecker  _et al._ (2019) Sebastian Ecker, Frédéric Bouchard, Lukas Bulla, Florian Brandt, Oskar Kohout, Fabian Steinlechner, Robert Fickler, Mehul Malik, Yelena Guryanova, Rupert Ursin, and Marcus Huber,  _Overcoming Noise in Entanglement Distribution,_Physical Review X 9, 041042 (2019), arXiv:1904.01552.
  * Zhu  _et al._ (2021) Feng Zhu, Max Tyler, Natalia Herrera Valencia, Mehul Malik, and Jonathan Leach,  _Is high-dimensional photonic entanglement robust to noise?_AVS Quantum Science 3, 011401 (2021), arXiv:1908.08943.
  * Vertesi  _et al._ (2010) Tamás Vertesi, Stefano Pironio, and Nicolas Brunner,  _Closing the Detection Loophole in Bell Experiments Using Qudits,_Phys. Rev. Lett. 104, 60401 (2010), arXiv:0909.3171.
  * Srivastav  _et al._ (2022) Vatshal Srivastav, Natalia Herrera Valencia, Will McCutcheon, Saroch Leedumrongwatthanakun, Sébastien Designolle, Roope Uola, Nicolas Brunner, and Mehul Malik,  _Noise-robust and loss-tolerant quantum steering with qudits,_ (2022), arXiv:2202:09294.
  * Valencia  _et al._ (2020) Natalia Herrera Valencia, Suraj Goel, Will McCutcheon, Hugo Defienne, and Mehul Malik,  _Unscrambling entanglement through a complex medium,_Nature Physics 16, 1112 (2020), arXiv:1910.04490.
  * Cao  _et al._ (2020) Huan Cao, She-Cheng Gao, Chao Zhang, Jian Wang, De-Yong He, Bi-Heng Liu, Zheng-Wei Zhou, Yu-Jie Chen, Zhao-Hui Li, Si-Yuan Yu, and et al.,  _Distribution of high-dimensional orbital angular momentum entanglement over a 1 km few-mode fiber,_Optica 7, 232–237 (2020).
  * Bavaresco  _et al._ (2018a) Jessica Bavaresco, Natalia Herrera Valencia, Claude Klöckl, Matej Pivoluska, Paul Erker, Nicolai Friis, Mehul Malik, and Marcus Huber,  _Measurements in two bases are sufficient for certifying high-dimensional entanglement,_Nat. Phys. 14, 1032 (2018a), arXiv:1709.07344.
  * Friis  _et al._ (2019) Nicolai Friis, Giuseppe Vitagliano, Mehul Malik, and Marcus Huber,  _Entanglement certification from theory to experiment,_Nature Reviews Physics 1, 72 (2019).
  * Herrera Valencia  _et al._ (2020) Natalia Herrera Valencia, Vatshal Srivastav, Matej Pivoluska, Marcus Huber, Nicolai Friis, Will McCutcheon, and Mehul Malik,  _High-Dimensional Pixel Entanglement: Efficient Generation and Certification,_Quantum 4, 376 (2020), arXiv:2004.04994.
  * Babazadeh  _et al._ (2017) Amin Babazadeh, Manuel Erhard, Feiran Wang, Mehul Malik, Rahman Nouroozi, Mario Krenn, and Anton Zeilinger,  _High-Dimensional Single-Photon Quantum Gates: Concepts and Experiments,_Physical Review Letters 119, 180510 (2017), arXiv:1702.07299.
  * Wang  _et al._ (2017) Feiran Wang, Manuel Erhard, Amin Babazadeh, Mehul Malik, Mario Krenn, and Anton Zeilinger,  _Generation of the complete four-dimensional Bell basis,_Optica 4, 1462 (2017), arXiv:1707.05760.
  * Kong  _et al._ (2019) Ling-Jun Kong, Rui Liu, Wen-Rong Qi, Zhou-Xiang Wang, Shuang-Yin Huang, Qiang Wang, Chenghou Tu, Yongnan Li, and Hui-Tian Wang,  _Manipulation of eight-dimensional bell-like states,_Science Advances 5, eaat9206 (2019).
  * Brandt  _et al._ (2020) Florian Brandt, Markus Hiekkamäki, Frédéric Bouchard, Marcus Huber, and Robert Fickler,  _High-dimensional quantum gates using full-field spatial modes of photons,_Optica , 98 (2020), arXiv:1907.13002.
  * Lib  _et al._ (2021) Ohad Lib, Kfir Sulimany, and Yaron Bromberg,  _Reconfigurable synthesizer for quantum information processing of high-dimensional entangled photons,_ (2021), arXiv:2108.02258.
  * Rotter and Gigan (2017) Stefan Rotter and Sylvain Gigan,  _Light fields in complex media: Mesoscopic scattering meets wave control,_Reviews of Modern Physics 89, 015005 (2017), arXiv:1702.05395.
  * Cao and Eliezer (2022) Hui Cao and Yaniv Eliezer,  _Harnessing disorder for photonic device applications,_Applied Physics Reviews 9, 011309 (2022).
  * Huisman  _et al._ (2015) Simon R. Huisman, Thomas J. Huisman, Tom A. W. Wolterink, Allard P. Mosk, and Pepijn W. H. Pinkse,  _Programmable multiport optical circuits in opaque scattering materials,_Optics Express 23, 3102 (2015), arXiv:1408.1856.
  * Matthès  _et al._ (2019) Maxime W. Matthès, Philipp del Hougne, Julien de Rosny, Geoffroy Lerosey, and Sébastien M. Popoff,  _Optical complex media as universal reconfigurable linear operators,_Optica 6, 465 (2019).
  * Wolterink  _et al._ (2015) Tom A. W. Wolterink, Ravitej Uppu, Georgios Ctistis, Willem L. Vos, Klaus J. Boller, and Pepijn W. H. Pinkse,  _Programmable two-photon quantum interference in $10^{3}$ channels in opaque scattering media, _Physical Review A 93, 053817 (2015), arXiv:1511.00897.
  * Defienne  _et al._ (2016) Hugo Defienne, Marco Barbieri, Ian A. Walmsley, Brian J. Smith, and Sylvain Gigan,  _Two-photon quantum walk in a multimode fiber,_Science Advances 2, e1501054 (2016), arXiv:1504.03178.
  * Leedumrongwatthanakun  _et al._ (2020) Saroch Leedumrongwatthanakun, Luca Innocenti, Hugo Defienne, Thomas Juffmann, Alessandro Ferraro, Mauro Paternostro, and Sylvain Gigan,  _Programmable linear quantum networks with a multimode fibre,_Nature Photonics 14, 139 (2020), arXiv:1902.10678.
  * Valencia  _et al._ (2021a) Natalia Herrera Valencia, Vatshal Srivastav, Saroch Leedumrongwatthanakun, Will McCutcheon, and Mehul Malik,  _Entangled ripples and twists of light: radial and azimuthal laguerre–gaussian mode entanglement,_Journal of Optics 23, 104001 (2021a).
  * Bouchard  _et al._ (2018) Frédéric Bouchard, Natalia Herrera Valencia, Florian Brandt, Robert Fickler, Marcus Huber, and Mehul Malik,  _Measuring azimuthal and radial modes of photons,_Opt. Express 26, 31925 (2018), arXiv:1808.03533.
  * Allmaras  _et al._ (2020) Jason P Allmaras, Emma E Wollman, Andrew D Beyer, Ryan M Briggs, Boris A Korzh, Bruce Bumble, and Matthew D Shaw,  _Demonstration of a thermally coupled row-column snspd imaging array,_Nano Letters 20, 2163–2168 (2020).
  * Designolle  _et al._ (2021) Sébastien Designolle, Vatshal Srivastav, Roope Uola, Natalia Herrera Valencia, Will McCutcheon, Mehul Malik, and Nicolas Brunner,  _Genuine high-dimensional quantum steering,_Physical Review Letters 126, 200404 (2021).
  * Miller (2012) David A. B. Miller,  _All linear optical devices are mode converters,_Optics Express 20, 23985 (2012), arXiv:1209.4931.
  * Miller (2019) David A. B. Miller,  _Waves, modes, communications, and optics: a tutorial,_Advances in Optics and Photonics 11, 679 (2019).
  * Carpenter  _et al._ (2014) Joel Carpenter, Benjamin J. Eggleton, and Jochen Schröder,  _110X110 Optical Mode Transfer Matrix Inversion,_Optics Express 22, 96 (2014).
  * Plöschner  _et al._ (2015) Martin Plöschner, Tomáš Tyc, and Tomáš Čižmár,  _Seeing through chaos in multimode fibres,_Nature Photonics 9, 529 (2015).
  * Xiong  _et al._ (2018) Wen Xiong, Chia Wei Hsu, Yaron Bromberg, Jose Enrique Antonio-Lopez, Rodrigo Amezcua Correa, and Hui Cao,  _Complete polarization control in multimode fibers with polarization and mode coupling,_Light: Science & Applications 7, 54 (2018), arXiv:1709.01029.
  * Sakamaki  _et al._ (2007) Y. Sakamaki, T. Saida, T. Hashimoto, and H. Takahashi,  _New Optical Waveguide Design Based on Wavefront Matching Method,_Journal of Lightwave Technology 25, 3511 (2007).
  * Fontaine  _et al._ (2017) Nicolas K. Fontaine, Roland Ryf, Haoshuo Chen, David Neilson, and Joel Carpenter,  _Design of High Order Mode-Multiplexers using Multiplane Light Conversion,_ in  _2017 European Conference on Optical Communication (ECOC)_, Vol. 2017-Septe (IEEE, 2017) pp. 1–3.
  * Altepeter  _et al._ (2003) J B Altepeter, D Branning, E Jeffrey, T C Wei, P G Kwiat, R T Thew, J L O’Brien, M A Nielsen, and A. G. White,  _Ancilla-assisted quantum process tomography,_Physical Review Letters 90, 193601 (2003).
  * Qassim  _et al._ (2014) Hammam Qassim, Filippo M Miatto, Juan P Torres, Miles J Padgett, Ebrahim Karimi, and Robert W Boyd,  _Limitations to the determination of a Laguerre-Gauss spectrum via projective, phase-flattening measurement,_J. Opt. Soc. Am. B 31, A20 (2014), arXiv:1401.3512.
  * Saygin  _et al._ (2020) M. Yu. Saygin, I. V. Kondratyev, I. V. Dyakonov, S. A. Mironov, S. S. Straupe, and S. P. Kulik,  _Robust Architecture for Programmable Universal Unitaries,_Physical Review Letters 124, 010501 (2020), arXiv:1906.06748.
  * Pereira  _et al._ (2020) Luciano Pereira, Alejandro Rojas, Gustavo Cañas, Gustavo Lima, Aldo Delgado, and Adán Cabello,  _Universal multi-port interferometers with minimal optical depth,_ (2020), arXiv:2002.01371.
  * Bruck  _et al._ (2016) Roman Bruck, Kevin Vynck, Philippe Lalanne, Ben Mills, David J. Thomson, Goran Z. Mashanovich, Graham T. Reed, and Otto L. Muskens,  _All-optical spatial light modulator for reconfigurable silicon photonic circuits,_Optica 3, 396 (2016), arXiv:1601.06679.
  * Wang  _et al._ (2019) Zi Wang, Tiantian Li, Anishkumar Soman, Dun Mao, Thomas Kananen, and Tingyi Gu,  _On-chip wavefront shaping with dielectric metasurface,_Nature Communications 10, 3547 (2019).
  * Dinsdale  _et al._ (2021) Nicholas J. Dinsdale, Peter R. Wiecha, Matthew Delaney, Jamie Reynolds, Martin Ebert, Ioannis Zeimpekis, David J. Thomson, Graham T. Reed, Philippe Lalanne, Kevin Vynck, and Otto L. Muskens,  _Deep Learning Enabled Design of Complex Transmission Matrices for Universal Optical Components,_ACS Photonics 8, 283 (2021), arXiv:2009.11810.
  * Lukens  _et al._ (2016) Joseph M. Lukens, Pavel Lougovski, J Oseph M L Ukens, P Avel L Ougovski, Joseph M. Lukens, and Pavel Lougovski,  _Frequency-encoded photonic qubits for scalable quantum information processing,_Optica 4, 2 (2016), arXiv:1612.03131.
  * Mounaix  _et al._ (2016) Mickael Mounaix, Daria Andreoli, Hugo Defienne, Giorgio Volpe, Ori Katz, Samuel Grésillon, and Sylvain Gigan,  _Spatiotemporal coherent control of light through a multiple scattering medium with the multispectral transmission matrix,_Physical review letters 116, 253901 (2016).
  * Lu  _et al._ (2018) Hsuan-hao Lu, Joseph M Lukens, Nicholas A Peters, Ogaga D. Odele, Daniel E Leaird, Andrew M Weiner, and Pavel Lougovski,  _Electro-Optic Frequency Beam Splitters and Tritters for High-Fidelity Photonic Quantum Information Processing,_Physical Review Letters 120, 30502 (2018).
  * Mounaix  _et al._ (2020) Mickael Mounaix, Nicolas K. Fontaine, David T. Neilson, Roland Ryf, Haoshuo Chen, Juan Carlos Alvarado-Zacarias, and Joel Carpenter,  _Time reversed optical waves by arbitrary vector spatiotemporal field generation,_Nature Communications 11, 5813 (2020).
  * Crameri (2021) Fabio Crameri,  _Scientific colour maps,_ (2021).
  * Srivastav  _et al._ (2021) Vatshal Srivastav, Natalia Herrera Valencia, Saroch Leedumrongwatthanakun, Will McCutcheon, and Mehul Malik,  _Characterising and Tailoring Spatial Correlations in Multi-Mode Parametric Downconversion,_ (2021), arXiv:2110.03462.
  * Bavaresco  _et al._ (2018b) Jessica Bavaresco, Natalia Herrera Valencia, Claude Klockl, Matej Pivoluska, Paul Erker, Nicolai Friis, Mehul Malik, and Marcus Huber,  _Measurements in two bases are sufficient for certifying high-dimensional entanglement,_Nature Physics 14, 1032 (2018b).
  * Valencia  _et al._ (2021b) Natalia Herrera Valencia, Vatshal Srivastav, Saroch Leedumrongwatthanakun, Will McCutcheon, and Mehul Malik,  _Entangled ripples and twists of light: radial and azimuthal Laguerre–Gaussian mode entanglement,_Journal of Optics 23, 104001 (2021b), arXiv:2104.04506.
  * Caramazza  _et al._ (2019) Piergiorgio Caramazza, Oisín Moran, Roderick Murray-Smith, and Daniele Faccio,  _Transmission of natural scene images through a multimode fibre,_Nature communications 10, 1 (2019).
  * Arrizon  _et al._ (2007) Victor Arrizon, Ulises Ruiz, Rosibel Carrada, and Luis A Gonzalez,  _Pixelated phase computer holograms for the accurate encoding of scalar complex fields,_J. Opt. Soc. Am. A 24, 3500 (2007).
  * Wootters and Fields (1989) W.K. Wootters and B.D. Fields,  _Optimal state-determination by mutually unbiased measurements,_Ann. Phys. (N. Y). 191, 363 (1989).
  * Giovannini  _et al._ (2013) D. Giovannini, J. Romero, J. Leach, A. Dudley, A. Forbes, and M. J. Padgett,  _Characterization of high-dimensional entangled systems via mutually unbiased measurements,_ Physical Review Letters 110 (2013), arXiv:1212.5825.
  * Goel  _et al._ (2022) Suraj Goel, Saroch Leedumrongwatthanakun, Natalia Herrera Valencia, Will McCutcheon, Claudio Conti, Pepijn W. H. Pinkse, and Mehul Malik,  _Simulation codes for : Inverse-design of high-dimensional quantum optical circuits in a complex medium,_ (2022).
  * Unter  _et al._ (1981) Unter, Z. I. Borevich, and S. L. Krupetskii,  _Subgroups of the unitary group that contain the group of diagonal matrices,_Journal of Soviet Mathematics 17, 1951 (1981).
  * Boucher  _et al._ (2020) Pauline Boucher, Arthur Goetschy, Giacomo Sorelli, Mattia Walschaers, and Nicolas Treps,  _Full characterization of the transmission properties of a multi-plane light converter,_Physical Review Research 3, 1 (2020), arXiv:2005.11982.
  * Schmid  _et al._ (2000) Michael Schmid, Rainer Steinwandt, Jörn Müller-Quade, Martin Rötteler, and Thomas Beth,  _Decomposing a matrix into circulant and diagonal factors,_Linear Algebra and Its Applications 306, 131 (2000).
  * Huhtanen and Perämäki (2015) Marko Huhtanen and Allan Perämäki,  _Factoring Matrices into the Product of Circulant and Diagonal Matrices,_Journal of Fourier Analysis and Applications 21, 1018 (2015).
  * Idel and Wolf (2015) Martin Idel and Michael M. Wolf,  _Sinkhorn normal form for unitary matrices,_Linear Algebra and Its Applications 471, 76 (2015), arXiv:1408.5728.
  * López Pastor  _et al._ (2021) Víctor López Pastor, Jeff Lundeen, and Florian Marquardt,  _Arbitrary optical wave evolution with Fourier transforms and phase masks,_Optics Express 29, 38441 (2021), arXiv:1912.04721.

Supplementary information for: Inverse-design of high-dimensional quantum
optical circuits in a complex medium

The following supplementary information is provided: Details of the high-
dimensionally entangled two-photon source (S.1), acquisition of transfer
matrix (S.2), projective measurements and detection efficiency (S.3), quantum
state tomography (S.4), construction of linear circuits (S.5), and analysis of
fidelity, success probability and optical losses (S.6). The supplementary
results on manipulation of the high-dimensional entangled states using various
types of gates in the macro-pixel and the orbital-angular-momentum (OAM) bases
are presented in (S.7). Finally, numerical results on the programmability and
scalability of our gates are reported in (S.8).

##  Appendix S.1 High-dimensional two-photon entanglement source

The high-dimensional spatially entangled two-photon state is generated via
degenerate Type-II spontaneous parametric downconversion (SPDC) by pumping a
15-mm long periodically poled Potassium Titanyl Phosphate (ppKTP) crystal with
a 405nm continuous-wave laser. After passing through the long-pass dichroic
filter and the band-pass filter, the signal and idler photons are separated
using a polarising-beam-splitter (PBS) and are mapped on to the liquid-
crystal-on-silicon-based spatial light modulators (SLM) ($P_{1}$ and $P_{3}$)
which are placed in the Fourier plane of the ppKTP crystal. The main
characteristics of the entanglement source, i.e., the strength of transverse-
momentum correlation, generated beam waist, and the position of the beams, are
determined by using our developed $2D\pi$-measurement Srivastav  _et al._
(2021) which is the joint coincidence measurement of local $\pi$-phase step
knife-edge scans across the SLMs at each party. The two-photon state is then
characterised via quantum state tomography (S.4) and the entanglement
dimensionality is certified Bavaresco  _et al._ (2018b) using a high-
dimensional entanglement witness in two discrete spatial-mode bases—the Macro-
pixel basis Herrera Valencia  _et al._ (2020) and the orbital-angular-momentum
(OAM) basis Valencia  _et al._ (2021b). We utilise these two bases as the set
of input target modes for constructing the programmable circuits. For the
macro-pixel basis, the size of pixels and their spacing are determined by the
joint transverse momentum amplitude (JTMA) Srivastav  _et al._ (2021). For the
OAM basis, the set of modes are
$\\{\left|\right.\\!{-\ell}\\!\left.\right\rangle,\dots,\left|\right.\\!{0}\\!\left.\right\rangle,\dots,\left|\right.\\!{\ell}\\!\left.\right\rangle\\}$
when the dimension of the circuit $d$ is odd, otherwise
$\\{\left|\right.\\!{-\ell}\\!\left.\right\rangle,\dots,\left|\right.\\!{-1}\\!\left.\right\rangle,\left|\right.\\!{1}\\!\left.\right\rangle,\dots,\left|\right.\\!{\ell}\\!\left.\right\rangle\\}$.
The measured quantifiers of the generated high-dimensionally entangled two-
photon states are reported in Table S.1 and the reconstructed density matrices
are depicted in Fig. S.1 and Fig. S.2 for the macro-pixel and OAM bases,
respectively.

Figure S.1: Generated high-dimensional entangled two-photon states in the
macro-pixel basis. Measured coincidence counts in all mutually unbiased bases
(MUBs) and reconstructed density matrices via quantum state tomography in
dimensions, $d=[2,3,5,7]$. Figure S.2: Generated high-dimensionally entangled
two-photon states in the OAM basis. Measured coincidence counts in all
mutually unbiased bases (MUBs) and reconstructed density matrices via quantum
state tomography in dimensions, $d=[2,3,5,7]$.

[h]  : Generated high-dimensionally entangled two-photon states: State purity $\mathcal{P}$, Entanglement dimensionality $d_{ent}$, Fidelity to maximally entangled state $\mathcal{F}$, Entanglement of Formation ($E_{oF}$). Errors are calculated as 3 standard deviations assuming Poisson statistics in photon counts. Basis | Dimension ($d$) | $\mathcal{P}$ | $d_{ent}$ | $\mathcal{F}(\rho_{i},\left|\right.\\!{\Phi^{+}}\\!\left.\right\rangle\left\langle\right.\\!{\Phi^{+}}\\!\left.\right|)$ |  $E_{oF}$ (ebits)
---|---|---|---|---|---
Macro-Pixel | $2$ |  $96.7\pm 0.7$ % | 2 |  $96.8\pm 0.4$ % | $0.80\pm 0.02$
$3$ |  $92.6\pm 0.4$ % | 3 |  $95.3\pm 0.2$ % | $1.23\pm 0.01$
$5$ |  $88.8\pm 0.3$ % | 5 |  $91.6\pm 0.2$ % | $1.51\pm 0.02$
$7$ |  $75.1\pm 0.3$ % | 6 |  $83.0\pm 0.2$ % | $1.19\pm 0.01$
OAM | $2$ |  $97.7\pm 0.2$ % | 2 |  $97.5\pm 0.1$ % | $0.81\pm 0.01$
$3$ |  $85.9\pm 0.2$ % | 3 |  $90.8\pm 0.1$ % | $1.11\pm 0.01$
$5$ |  $83.2\pm 0.2$ % | 5 |  $86.5\pm 0.1$ % | $1.19\pm 0.01$
$7$ |  $80.0\pm 0.1$ % | 6 |  $80.6\pm 0.1$ % | $1.11\pm 0.01$

##  Appendix S.2 Acquisition of transfer matrix

To construct the circuits, the optical apparatus is described by the transfer
matrix: $\mathbf{T}=U_{2}P_{2}U_{1}P_{1}$, where $U_{2}$ is a $2f$ lens system
and $P_{j}$ is the $j$-th phase plane displayed on the SLMj. The transfer
matrix $U_{1}$ of the multi-mode fiber and associated coupling optics between
the first phase plane $P_{1}$ to the second phase plane $P_{2}$ is measured
without using an external reference field. To do so, we search for the
transfer matrix $U_{1}$ by optimising,

$\text{min}\left|I_{i}-|U_{2}P_{2}U_{1}P_{1}|^{2}\right|^{2}.$ (S.2.1)

The optimisation is based on the gradient descent method fitting the acquired
characterisation data consisting of random phase patterns displayed on SLM1
and SLM2 and the corresponding measured output speckle intensity images
$\\{I_{i}\\}_{i}$. The model of the optical apparatus is implemented in Keras
using Tensorflow2 and complex-number layers developed in Caramazza  _et al._
(2019). The data set is prepared in three parts. In the first part, each input
mode in a given basis that is supported by the fiber is displayed on SLM1.
This data provides accurate information of $|U_{1}|$. In the second part,
random superpositions of these input modes are prepared on SLM1 and sent
through the fibre. The output intensity speckles in this part allow for
recovery of the relative phase and amplitude of transmission coefficient for a
particular output mode. Finally, both SLMs are used for displaying random
superpositions of the input modes and output modes. This final part of the
data set allows for accurate reconstruction of $U_{1}$, including calibration
of the unknown relative phases across the output modes.

##  Appendix S.3 Projective measurements and detection efficiency

The characterisation of the entangled light source both before and after
manipulation by the circuits is performed by local projective measurements.
The computer-generated hologram (CGH) Arrizon  _et al._ (2007) for a
particular spatial mode is displayed on the SLM at each party. If the incident
spatial mode is the complex conjugate of the hologram mode, it is converted
into a Gaussian mode, which couples efficiently into a single-mode fiber (SMF)
positioned in the 1st-order diffraction spot. Coincidence events between the
detection of signal and idler photons in the selected modes is registered by
the coincidence logic within a coincidence window of 0.2 ns. The detection
efficiency $\eta^{\mu}_{a}$ of measuring a particular spatial mode,
$\left|\right.\\!{\psi^{\mu}_{a}}\\!\left.\right\rangle$ (corresponding to the
$a$-th element of the $\mu$-th basis), is estimated and the performed
measurements are then related to ideal projections by
$\hat{\widetilde{\Pi}}^{\mu}_{a}=\eta^{\mu}_{a}\hat{\Pi}^{\mu}_{a}$, where
$\hat{\Pi}^{\mu}_{a}=|{\psi^{\mu}_{a}}\rangle\langle{\psi^{\mu}_{a}}|$ is the
ideal projector.

##  Appendix S.4  Quantum state tomography

Quantum state tomography (QST) is performed through the measurement of an
informationally complete set of measurements and numeric inversion of the
data, subject to physical constraints. It provides full characteristic
information about a state, and via performing QST on both the input and output
states we can characterise the implemented optical circuit. We perform QST via
semidefinite programming (SDP) on both input and output states after
manipulation by the optical circuits. The SDP imposes data fitting of the non-
normalised measurements subject to positive semi-definitness of the state
$\rho$, and unit trace, and reads as

$\displaystyle\min_{\rho,R}$
$\displaystyle|\mathcal{C}^{\mu\nu}_{ab}-R\textnormal{Tr}(\hat{\widetilde{\Pi}}^{\mu}_{a}\otimes{\hat{\widetilde{\Pi}}^{\nu}_{b}}\rho)|^{2}$
(S.4.2) s.t. $\displaystyle\rho\geq 0\,,\,\textnormal{Tr}[\rho]=1,$

where $\mathcal{C}^{\mu\nu}_{ab}$ is the frequency of the outcome (coincidence
count rate) and $R$ is the count rate per integration window. Our local
measurement bases are complete sets of mutually unbiased bases (MUBs) Wootters
and Fields (1989), which are informationally complete for QST Giovannini  _et
al._ (2013), and constructed as :
$\hat{\Pi}^{\mu}_{a}=|{M^{\mu}_{a}}\rangle\langle{M^{\mu}_{a}}|$ and
$\hat{\Pi}^{\nu}_{b}=|{{M^{\nu}_{b}}^{*}}\rangle\langle{{M^{\nu}_{b}}^{*}}|$,
where
$\left|\right.\\!{M^{\mu}_{a}}\\!\left.\right\rangle=\frac{1}{\sqrt{d}}\sum^{d-1}_{m=0}\omega^{am+\mu
m^{2}}_{d}\left|\right.\\!{m}\\!\left.\right\rangle$ on the basis of each
implemented circuit, and $\omega_{d}=\exp(2\pi i/d)$ is a $d$-th root of
unity. All SDPs are implemented in CVX, running the commercial solver MOSEK.

##  Appendix S.5  Construction of linear circuits

Primarily, programming a circuit $\mathbb{T}$ is achieved by calculating the
phase solutions $\\{P_{j}\\}_{j=1}^{L}$ at each phase plane. The wavefront
matching algorithm (WFM) can do so by iteratively matching the wavefronts of
target input and output optical modes propagating through the device across
all phase planes Hashimoto  _et al._ (2005); Sakamaki  _et al._ (2007);
Fontaine  _et al._ (2017). First, input arguments that contain a set of input
spatial modes
$\\{\left|\right.\\!{\psi_{a}(\mathbf{q})}\\!\left.\right\rangle\\}_{a=0}^{d-1}$
labelled in the logical basis by
$\\{\left|\right.\\!{a}\\!\left.\right\rangle_{\text{in}}\\}_{a=0}^{d-1}$, a
corresponding set of output spatial modes
$\\{\left|\right.\\!{\phi_{a}(\mathbf{q})}\\!\left.\right\rangle\\}_{a=0}^{d-1}$
that is related to the inputs via
$\left|\right.\\!{a_{\text{out}}}\\!\left.\right\rangle=\mathbb{T}\left|\right.\\!{a_{\text{in}}}\\!\left.\right\rangle$,
and a set of transfer functions $\\{U_{j}\\}$ between phase planes are
provided to the WFM algorithm.

For each $i$-th iteration, a phase solution at the $p$-th plane is updated in
a cyclic manner starting from the first to the last $L$-th plane and then back
from the last plane to the first. At a particular reconfigurable phase plane
$P_{p}$, the transfer matrix of the optical device $\mathbf{T}$ represented in
the spatial $\mathbf{q}$ basis is decomposed into two sections:

$\mathbf{T}:=\prod_{j=1}^{L}U_{j}P_{j}=B_{p}P_{p}F_{p},$ (S.5.3)

where $B_{p}=\prod_{j=p}^{L}P_{j+1}U_{j}$ and
$F_{p}=\prod_{j=1}^{p-1}U_{j}P_{j}$ such that the forward-propagating input
mode onto the $p$-th phase plane is represented by
$\left|\right.\\!{\psi_{a,(p)}}\\!\left.\right\rangle=F_{p}\left|\right.\\!{\psi_{a}}\\!\left.\right\rangle$
and the backward-propagating output mode onto the $p$-th phase plane is
$\left|\right.\\!{\phi_{a,(p)}}\\!\left.\right\rangle=B_{p}^{\dagger}\left|\right.\\!{\phi_{a}}\\!\left.\right\rangle$.
The phase mismatch between these input and output modes can then be adjusted
by $P_{p}$:

$\left|\right.\\!{\phi_{a}}\\!\left.\right\rangle=B_{p}P_{p}F_{p}\left|\right.\\!{\psi_{a}}\\!\left.\right\rangle\implies\left|\right.\\!{\phi_{a,(p)}}\\!\left.\right\rangle=P_{p}\left|\right.\\!{\psi_{a,(p)}}\\!\left.\right\rangle.$
(S.5.4)

Considering all $d$-target modes of interest, the matching matrix:
$M_{p}:=\sum_{a,a^{\prime}=0}^{d-1}\left\langle\right.\\!{\phi_{a^{\prime},(p)}}\\!\left.\right|P_{p}\left|\right.\\!{\psi_{a,(p)}}\\!\left.\right\rangle\left|\right.\\!{a^{\prime}}\\!\left.\right\rangle\left\langle\right.\\!{a}\\!\left.\right|$
captures the mode mixing at each phase plane. The WFM algorithm maximise
$\textnormal{Tr}\left(M_{p}\right)$ by calculating a phase solution
$P^{[i]}_{p}$ from the weighed average of overlapped fields over all
$d$-target modes as follows:

$P^{[i]}_{p}(\mathbf{q})=\exp\left(i\arg\left(\sum_{a=0}^{d-1}\phi_{a,(p)}^{[\text{latest}]}(\mathbf{q})\odot\psi_{a,(p)}^{*\text{[latest]}}(\mathbf{q})\right)\right),$
(S.5.5)

where $\odot$ is an element-wise multiplication on the $\mathbf{q}$ coordinate
(SLM pixels) and $\phi_{a,(p)}^{\text{[latest]}}(\mathbf{q})$ and
$\psi_{a,(p)}^{*\text{[latest]}}(\mathbf{q})$ is the latest update of output
and input optical fields at the $p$-th phase plane taking into account all
other previous updated phase planes $\\{P^{[i]}_{p}\\}$ in the current
iteration in both forward and backward directions. The algorithm is iterated
until an appropriate value of gate fidelity (Eq. S.6.8) is achieved or
saturated.

In our experiment, the following gates $\mathbb{T}$ are implemented and
defined as:

$\displaystyle\mathbb{I}$
$\displaystyle=\sum_{a=0}^{d-1}\left|\right.\\!{a}\\!\left.\right\rangle\left\langle\right.\\!{a}\\!\left.\right|,\qquad\mathbb{Z}$
$\displaystyle=\sum_{a=0}^{d-1}\left|\right.\\!{a}\\!\left.\right\rangle\omega^{a}_{d}\left\langle\right.\\!{a}\\!\left.\right|,\qquad\mathbb{X}$
$\displaystyle=\sum_{a=0}^{d-1}\left|\right.\\!{a\oplus
1}\\!\left.\right\rangle\left\langle\right.\\!{a}\\!\left.\right|,\qquad\mathbb{F}$
$\displaystyle=\frac{1}{\sqrt{d}}\sum_{a,b=0}^{d-1}\left|\right.\\!{b}\\!\left.\right\rangle\omega^{ab}_{d}\left\langle\right.\\!{a}\\!\left.\right|,$
(S.5.6)

where $\omega_{d}=\exp(2\pi i/d)$ and $a\oplus 1:=(a+1)\mod d$. $\mathbb{R}$
is the random unitary which is sampled from the Haar measure for each
implementation.

##  Appendix S.6 Fidelity, success probability and optical losses

We use two figures of merit to characterise the implemented circuits—fidelity
$\mathcal{F}$ and success probability $\mathcal{S}$. The first is the Uhlmann-
Josza fidelity between two density matrices:

$\mathcal{F}(\rho,\rho_{\text{o}}):=\left(\textnormal{Tr}\left(\sqrt{\sqrt{\rho}\rho_{\text{o}}\sqrt{\rho}}\right)\right)^{2},$
(S.6.7)

where $\rho_{\text{o}}$ is the experimental density matrix of the manipulated
state supported on the space of the circuit and $\rho$ is the output density
matrix of initial state $\rho_{\text{i}}$ manipulated by theoretical ideal
target circuit $\mathbb{T}$:
$\rho=(\mathbb{I}\otimes\mathbb{T})\rho_{\text{i}}(\mathbb{I}\otimes\mathbb{T}^{\dagger})$.
The fidelity thus implies an accuracy of the implemented circuits. Noting
that, in the case that the initial maximally entangled state is pure
$(\mathcal{P}:=\textnormal{Tr}\left(\rho_{\text{i}}^{2}\right)=1)$ and the
implemented circuit can be represented by a rank-one Kraus operator
$\widetilde{\mathbb{T}}$, the fidelity reduces to:

$\mathcal{F}=\frac{\left(\textnormal{Tr}\left(\widetilde{\mathbb{T}}^{\dagger}\mathbb{T}\right)\right)^{2}}{\textnormal{Tr}\left(\widetilde{\mathbb{T}}^{\dagger}\widetilde{\mathbb{T}}\right)\textnormal{Tr}\left(\mathbb{T}^{\dagger}\mathbb{T}\right)},$
(S.6.8)

which is normalised by the transmittance due to the scattering from the
$d$-dimensional space of a circuit into other optical modes. The transmittance
is quantified by the second figure of merit, the success probability,
$\mathcal{S}$, of an implemented circuit:

$\mathcal{S}:=\frac{\textnormal{Tr}\left(\widetilde{\mathbb{T}}^{\dagger}\widetilde{\mathbb{T}}\right)}{\textnormal{Tr}\left(\mathbb{T}^{\dagger}\mathbb{T}\right)},$
(S.6.9)

The implemented $d$-dimensional circuit $\widetilde{\mathbb{T}}$ is embedded
in $\mathbf{T}$ which lives in the $n$-dimensional space of the apparatus such
that:
$\widetilde{\mathbb{T}}=\mathbf{P}_{\text{o}}\mathbf{T}\mathbf{P}_{\text{i}}$,
where $\mathbf{P}_{\text{o}}$ is the output dimensional reduction and
$\mathbf{P}_{\text{i}}$ is the input dimensional expansion, which map the
circuit from $d$ inputs of interest to $n$ inputs of the optical device and
from $n$ outputs of the optical device to the $d$ output modes of circuit,
respectively. We aim to use $\mathcal{S}$ to measure the scattering loss which
stems from the effect of the top-down circuit design, whereas another optical
loss of the apparatus is analysed in the last part of this section.
Experimentally, the success probability $\mathcal{S}$ (Eq. S.6.9) is estimated
on the output $\mathbf{x}$ space as

$\mathcal{S}=\frac{1}{d}\sum_{a=0}^{d-1}\int
d^{2}\mathbf{x}\left|\sum_{b=0}^{d-1}\widetilde{t}_{ab}\phi_{b}(\mathbf{x})\right|^{2}=\frac{1}{d}\sum_{a=0}^{d-1}\int
d^{2}\mathbf{x}\sum_{b=0}^{d-1}\frac{\mathcal{I}_{ab}}{\mathcal{I}_{a}}\left|\phi_{b}(\mathbf{x})\right|^{2},$
(S.6.10)

where $\widetilde{t}_{ab}$ is a transmission coefficient given that
$\widetilde{\mathbb{T}}=\sum_{a,b=0}^{d-1}\widetilde{t}_{ab}\left|\right.\\!{b}\\!\left.\right\rangle\left\langle\right.\\!{a}\\!\left.\right|$
and $\phi_{b}(\mathbf{x})$ is the $b$-th standard output optical field of
circuit on the output $\mathbf{x}$ space. The normalisation of
$\widetilde{t}_{ab}$ is measured by the ratio of optical flux inside the
$b$-th output mode of a circuit,
$\mathcal{I}_{ab}\propto|\widetilde{t}_{ab}|^{2}$, to total output optical
flux transmitting through the system given the $a$-th input mode,
$\mathcal{I}_{a}:=\int d^{2}\mathbf{x}\mathcal{I}_{a}(\mathbf{x})$ where
$\mathcal{I}_{a}(\mathbf{x})\propto|\sum_{b=0}^{n-1}\widetilde{t}_{ab}\phi_{b}(\mathbf{x})|^{2}$.
Noting that the optical flux $\mathcal{I}_{ab}$ can be moved outside the
bracket because the target outputs are foci which are spatially separated and
conveniently detected using a coherent light source. For a two-photon
entangled state, the success probability is then calculated in a similar way
yet using the outcomes of joint measurements between Alice and Bob who has a
circuit and performs the measurements via
$\hat{\widetilde{\Pi}}(\mathbf{x}):=\eta(\mathbf{x})\left|\right.\\!{\mathbf{x}}\\!\left.\right\rangle\left\langle\right.\\!{\mathbf{x}}\\!\left.\right|$
across the output spatial $\mathbf{x}$ space:

$\mathcal{S}^{\mu}=\frac{1}{d}\sum_{a=0}^{d-1}\int
d^{2}\mathbf{x}\sum_{b=0}^{d-1}\frac{\mathcal{C}_{ab}^{\mu,\nu=0}}{\mathcal{C}_{a}^{\mu}(\mathbf{x})}\left|\phi_{b}(\mathbf{x})\right|^{2},$
(S.6.11)

where the coincidence counts ($\mathcal{C}_{ab}^{\mu,\nu=0}$ and
$\mathcal{C}_{a}^{\mu}(\mathbf{x})$) are calibrated by the detection
efficiencies for both parties as described in S.3. And,
$\mathcal{C}_{a}^{\mu}(\mathbf{x})$ is defined as

$\mathcal{C}_{a}^{\mu}(\mathbf{x})=R\frac{1}{\eta^{\mu}_{a}\eta(\mathbf{x})}\textnormal{Tr}(\hat{\widetilde{\Pi}}^{\mu}_{a}\otimes\hat{\widetilde{\Pi}}(\mathbf{x})\rho_{\text{o}}).\\\
$ (S.6.12)

Noting that we perform the experiment on all input bases and the success
probability is thus averaged over all input bases,
$\mathcal{S}=\sum_{\mu=0}^{d}\mathcal{S}^{\mu}/(d+1)$. Moreover, one can show
that Eq. S.6.11 can be reformulated back as Eq. S.6.9 in the case that the
input maximally entangled state and process (circuit) are pure.

Finally, the overall transmittance $\mathcal{T}$ of a circuit is measured
using the two-photon entangled state at the input and output of a circuit,

$\mathcal{T}^{\mu}_{a}=\sum\limits_{b=0}^{d-1}\frac{\mathcal{C}^{\mu,\nu=0}_{ab}}{\mathcal{C^{*}}^{\mu,\nu=0}_{ab}},$
(S.6.13)

where $\mathcal{C^{*}}^{\mu,\nu=0}_{ab}$ is the coincidence counts at the
initial state. The overall transmittance,
$\mathcal{T}=\mathcal{S}\times\mathcal{T}_{o}$, includes the success
probability, $\mathcal{S}$, of a circuit and other optical transmittance of
the apparatus, $\mathcal{T}_{o}$.

In experiment, the measurements of success probability and overall
transmittance are performed in the macro-pixel input basis. The results are
shown in Fig. S.3 where the averaged optical transmittance is $0.051\pm
0.008$, $0.04\pm 0.006$, $0.026\pm 0.004$ and $0.028\pm 0.003$ for 2, 3, 5 and
7-dimensional gates respectively. We performed the measurement of the success
probability for 3 randomly chosen implementations of Fourier-$\mathbb{F}$
gates in $2,3$ and $5$ dimensions and observe $\mathcal{S}$ of $0.36\pm
0.014$, $0.27\pm 0.03$ and $0.18\pm 0.04$, respectively. We thus infer an
average optical transmittance of $\mathcal{T}_{o}=0.14\pm 0.02$ which is
attributed to the optical insertion and propagation losses, diffraction
efficiency of the two SLMs, and other interface losses at the lenses and
mirrors. We note that the main contribution to the loss is due to the success
probability arising from control of only a single polarisation channel of the
multi-mode fiber, which can be further improved when all polarisation-spatial
modes of the optical system are controlled.

Figure S.3: Success probability (left) and optical transmittance (right) in
macro-pixel input basis.

##  Appendix S.7  Manipulation of high-dimensional spatially entangled states

To study the programmabiltiy of our quantum circuits, we program many types of
unitary gates, namely, identity-$\mathbb{I}$, Pauli-$\mathbb{Z}$,
Pauli-$\mathbb{X}$, Fourier-$\mathbb{F}$, and random unitaries-$\mathbb{R}$,
in $2,3,5,$ and $7$ dimensions in both the macro-pixel and OAM input bases.
For each implementation, we randomly appoint a set of target output foci to
encode the circuit with. We then use circuits to locally transform the
$d$-dimensional spatially entangled two-photon state, which is then
characterised by performing quantum state tomography.

Table. S.7 provides the average fidelities and purities of the reconstructed
states for various types of gate and bases sampled over different sets of
output foci. The histogram of fidelities of all the implemented gates are
shown in Fig. S.4. Examples of the best-case measured tomography data and
reconstructed density matrices of these manipulated states are shown in Fig.
S.5 and Fig. S.6 for macro-pixel and OAM bases, respectively whose
corresponding fidelities and purities are tabulated in Table. S.7.

[h]  : Average fidelity $\mathcal{F}$ and purity $\mathcal{P}$ of output
states $\rho_{o}$ manipulated by a gate $\mathbb{T}$ in $d$ dimensions in the
macro-pixel and OAM bases. The standard deviation is calculated from an
ensemble of implemented gates with different output foci, and for many
realisations for the $\mathbb{R}$ gates. Basis $\mathbb{T}$
$\mathcal{F}(\rho,\rho_{o})$ $\mathcal{P}(\rho_{o})$ $d=2$ $d=3$ $d=5$ $d=7$
$d=2$ $d=3$ $d=5$ $d=7$ Macro-Pixel $\mathbb{I}$ $91.6\pm 4.7$ % $87.9\pm 4.7$
% $77.8\pm 5.2$ % $70.2$ %⋆ $95.2\pm 1.4$ % $96.0\pm 3.3$ % $87.7\pm 2.9$ %
$73.3$ %⋆ $\mathbb{Z}$ $92.1\pm 3.8$ % $89.9\pm 3.8$ % $73.7\pm 3.6$ % $61.4$
%⋆ $95.5\pm 2.0$ % $95.9\pm 2.0$ % $87.8\pm 2.5$ % $68.0$ %⋆ $\mathbb{X}$
$91.7\pm 3.5$ % $88.7\pm 4.0$ % $73.3\pm 4.7$ % $57.2$ %⋆ $95.3\pm 2.1$ %
$96.1\pm 2.7$ % $86.6\pm 3.8$ % $72.3$ %⋆ $\mathbb{F}$ $89.1\pm 3.7$ %
$86.9\pm 2.0$ % $69.9\pm 3.6$ % $57.5$ %⋆ $88.9\pm 2.0$ % $85.6\pm 1.8$ %
$78.4\pm 1.5$ % $69.5$ %⋆ $\mathbb{R}$ $89.4\pm 6.2$ % $85.4\pm 2.7$ %
$73.2\pm 4.0$ % $63.6$ %⋆ $92.3\pm 2.2$ % $86.9\pm 1.5$ % $80.8\pm 1.4$ %
$70.8$ %⋆ OAM $\mathbb{I}$ $90.9\pm 2.2$ % $86.7\pm 4.5$ % $71.3\pm 3.7$ %
$60.3\pm 4.8$ % $90.9\pm 0.4$ % $82.2\pm 1.8$ % $75.8\pm 1.9$ % $68.9\pm 1.9$
% $\mathbb{Z}$ $91.6\pm 3.6$ % $87.3\pm 2.9$ % $73.8\pm 7.0$ % $55.7\pm 9.3$ %
$90.1\pm 1.0$ % $82.2\pm 1.1$ % $76.0\pm 2.0$ % $69.6\pm 1.5$ % $\mathbb{X}$
$94.1\pm 2.3$ % $86.0\pm 4.1$ % $74.3\pm 3.0$ % $51.4\pm 6.5$ % $92.6\pm 1.0$
% $81.5\pm 2.3$ % $76.5\pm 1.9$ % $71.1\pm 2.8$ % $\mathbb{F}$ $91.0\pm 2.2$ %
$83.7\pm 4.4$ % $70.7\pm 2.6$ % $59.0\pm 5.8$ % $92.2\pm 1.0$ % $79.0\pm 1.4$
% $75.5\pm 1.9$ % $71.2\pm 0.7$ % $\mathbb{R}$ $91.2\pm 1.9$ % $83.9\pm 3.0$ %
$72.4\pm 2.7$ % $54.4\pm 6.7$ % $91.0\pm 1.1$ % $83.5\pm 4.7$ % $76.3\pm 2.1$
% $73.8\pm 0.9$ % ⋆The standard deviation is not reported.

Figure S.4: Histogram of fidelities of optical circuits implemented in
different dimensions

[h]  : Fidelity $\mathcal{F}$ and purity $\mathcal{P}$ of output states $\rho_{o}$ manipulated a gate $\mathbb{T}$ in $d$ dimensions in the macro-pixel and OAM bases corresponding to the results presented in Fig. S.5 and S.6. The standard deviation is calculated using error propagation assuming Poisson statistics in photon counts. Basis | $\mathbb{T}$ | $\mathcal{F}(\rho,\rho_{o})$ | $\mathcal{P}(\rho_{o})$
---|---|---|---
$d=2$ | $d=3$ | $d=5$ | $d=7$ | $d=2$ | $d=3$ | $d=5$ | $d=7$
Macro-Pixel | $\mathbb{I}$ |  $97.3\pm 0.3$ % |  $94.4\pm 0.2$ % |  $84.7\pm 0.4$ % |  $73.1\pm 0.4$ % |  $96.4\pm 0.8$ % |  $97.8\pm 0.7$ % |  $88.5\pm 0.9$ % |  $70.3\pm 0.5$ %
$\mathbb{Z}$ |  $97.7\pm 0.4$ % |  $93.5\pm 0.3$ % |  $77.7\pm 0.4$ % |  $61.4\pm 0.4$ % |  $97.9\pm 0.9$ % |  $96.3\pm 0.9$ % |  $90.3\pm 0.8$ % |  $68.0\pm 0.6$ %
$\mathbb{X}$ |  $97.1\pm 0.4$ % |  $92.6\pm 0.2$ % |  $78.8\pm 0.5$ % |  $58.8\pm 0.5$ % |  $96.5\pm 0.7$ % |  $97.1\pm 0.7$ % |  $91.3\pm 0.9$ % |  $74.7\pm 0.4$ %
$\mathbb{F}$ |  $96.0\pm 0.6$ % |  $89.4\pm 0.4$ % |  $75.9\pm 0.4$ % |  $57.5\pm 0.4$ % |  $92.2\pm 0.6$ % |  $85.4\pm 0.7$ % |  $80.4\pm 0.7$ % |  $69.5\pm 0.5$ %
$\mathbb{R}$ |  $96.5\pm 0.5$ % |  $90.2\pm 0.2$ % |  $81.1\pm 0.4$ % |  $63.6\pm 0.4$ % |  $92.9\pm 0.7$ % |  $88.7\pm 0.5$ % |  $83.1\pm 0.8$ % |  $70.8\pm 0.6$ %
OAM | $\mathbb{I}$ |  $94.0\pm 0.1$ % |  $94.6\pm 0.2$ % |  $78.4\pm 0.3$ % |  $65.7\pm 0.2$ % |  $91.4\pm 0.3$ % |  $81.5\pm 0.4$ % |  $77.5\pm 0.4$ % |  $70.8\pm 0.3$ %
$\mathbb{Z}$ |  $94.3\pm 0.2$ % |  $92.0\pm 0.1$ % |  $81.2\pm 0.2$ % |  $63.0\pm 0.2$ % |  $89.2\pm 0.3$ % |  $81.1\pm 0.3$ % |  $78.5\pm 0.4$ % |  $68.0\pm 0.3$ %
$\mathbb{X}$ |  $96.8\pm 0.2$ % |  $91.3\pm 0.2$ % |  $77.5\pm 0.2$ % |  $60.6\pm 0.2$ % |  $92.4\pm 0.4$ % |  $84.1\pm 0.3$ % |  $79.1\pm 0.3$ % |  $74.5\pm 0.3$ %
$\mathbb{F}$ |  $93.8\pm 0.3$ % |  $88.9\pm 0.3$ % |  $75.5\pm 0.2$ % |  $67.0\pm 0.2$ % |  $93.5\pm 0.5$ % |  $79.3\pm 0.4$ % |  $77.5\pm 0.4$ % |  $71.6\pm 0.3$ %
$\mathbb{R}$ |  $93.0\pm 0.3$ % |  $87.6\pm 0.2$ % |  $75.4\pm 0.2$ % |  $62.2\pm 0.2$ % |  $91.6\pm 0.5$ % |  $80.8\pm 0.3$ % |  $76.8\pm 0.3$ % |  $74.6\pm 0.3$ %

Figure S.5: Manipulation of 2, 3 and 7-dimensional spatially entangled two-
photon states in the macro-pixel basis using the $\mathbb{I}$,
Pauli-$\mathbb{Z}$, Pauli-$\mathbb{X}$, Fourier $\mathbb{F}$ and random
unitary $\mathbb{R}$ gates. In each panel, the upper part shows the two-photon
coincidence counts in all MUBs and the lower part depicts reconstructed
density matrices.

Figure S.6: Manipulation of 2, 3, 5 and 7-dimensional spatially entangled two-
photon states in the OAM basis using the $\mathbb{I}$, Pauli-$\mathbb{Z}$,
Pauli-$\mathbb{X}$, Fourier $\mathbb{F}$ and random unitary $\mathbb{R}$
gates. In each panel, the upper part shows the two-photon coincidence counts
in all MUBs and the lower part depicts reconstructed density matrices.

##  Appendix S.8  Programmability and scalability of top-down designed
circuits

To investigate the programmability and scalability of our approach, we
numerically construct many instances of the high-dimensional circuits by
varying our design parameters, i.e., dimension of circuit $n$, dimension of
mode mixers $d$, depth of circuit $L$, using the model

$\mathbf{T}:=U_{L+1}\prod_{j=1}^{L}P_{j}U_{j},$ (S.8.14)

where the $n$ reconfigurable phase elements at each $P_{j}$ are found using
the wavefront-matching algorithm as explained in S.5 given a set of $n\times
n$ unitary matrices $\\{U_{j}\\}_{j}$ and a set of $d$ input and output modes
of interest. The codes for these simulations are available in Goel  _et al._
(2022). Once a circuit is implemented, we classify its performance by
measuring fidelity (Eq. S.6.8) and success probability (Eq. S.6.9). For a
given set of design parameters $n$, $L$ and $d$, we implement at least 100
realisations of the Identity $\mathbb{I}$, Pauli-$\mathbb{X}$,
Pauli-$\mathbb{Z}$, Fourier-$\mathbb{F}$, and random unitary $\mathbb{R}$
gates (Eq. S.5.6), by varying the set of $d$ input and output modes of
interest which can be randomly selected or specifically assigned. We simulate
these circuits by treating the mode-mixers $\\{U_{j}\\}_{j}$ as either a set
of random unitaries, or discrete Fourier transforms (DFT).

As presented in the main text, when the dimension of the circuit $d$ is less
than the dimension of mode mixers $n$ ($d/n<0.1$), both fidelity and success
probability reduce as the circuit dimension, $d$, increases. Fig. S.7 conveys
these trends in detail. For all these realisations, all mode mixers
$\\{U_{j}\\}$ correspond to the same random unitary matrix, and the positions
of input/output modes of interest are randomly selected for each
implementation. The behaviour reported in Fig. S.7 is also observed either
when different random mode-mixers are used in each layer, or input/output
modes are specifically assigned to the first $d$ modes of the $U_{j}$.

For a device described by Eq. S.8.14, the total number of degrees of freedom
is given by the number of reconfigurable elements $nL$. On the other hand, the
constraints to program a $d$-dimensional circuit $\mathbb{T}$ is
$\mathcal{O}(d^{2})$ Unter  _et al._ (1981); Miller (2013). A larger $d$ leads
to loss of performance because the number of constraints required to program
the circuit increases. Thus, as $d$ increases, the number of reconfigurable
elements does not change. Improving the figures of merit of a $d$-dimensional
circuit can therefore be addressed in two primary ways: increasing the
dimension of mode mixers, $n$, or the depth of circuit, $L$. As shown in
Fig.S.8a, the fidelity will rise to unity when the total number of
reconfigurable elements exceeds the number required to program a unitary
operation ($\mathcal{O}(d^{2})$). The point at which $\mathcal{F}=1$ depends
on the ratio of $d/n$. In the case where $d=n$, the number of reconfigurable
elements required is optimal, whereas in the cases where $d/n<1$, the number
of reconfigurable elements necessary for the full programmability increases as
$d/n$ decreases.

With respect to the success probability, we observe that it increases as a
function of the circuit depth and reaches unity when $L\approx\mathcal{O}(d)$
in all cases of $d\leq n$ (Fig.S.8b). In this regime, full programmability is
achieved and is seen to be independent of $d/n$.

These results imply that in order to achieve both high fidelity and success
probability, one does not need to solely rely on the number of reconfigurable
elements, but also on their distribution across the circuit. Ideally, one
would want to implement a fully programmable circuit using the full dimension
of mode mixers ($d=n$) constructed from $2\times 2$ beam splitters or $n\times
n$ mode mixers, since this achieves the minimum number of reconfigurable
elements Reck  _et al._ (1994); Clements  _et al._ (2016). However, it is
known that in the presence of imperfections, an increase in the depth of the
circuit is required to improve the fidelity in such schemes Miller (2015);
Burgwal  _et al._ (2017); Pai  _et al._ (2018). Scaling the depth of circuit
in practice may nonetheless not be the most viable option due to a variety of
experimental reasons, namely, propagation and interface losses and
accumulation of errors. Instead of considering errors and scattering losses as
a problem, the top-down approach presents a reasonable alternative ($d<n$ and
$L\lesssim\mathcal{O}(d)$) where randomness is exploited to implement a
circuit with a low depth. Here, both fidelity and success probability are
acceptably high while $n$ can increase to improve the fidelity without
reducing the success probability from unity when $L>2d$, or with a trade-off
on the success probability when $L\leq 2d$. Many optical devices, for
instance, computer-generated holograms and MPLC device Morizur  _et al._
(2010); Boucher  _et al._ (2020), can be considered to be in this category
where mode-mixing can be implemented by free-space propagation, a $2f$ lens
system, or another transformation such as a circulant matrix Schmid  _et al._
(2000); Huhtanen and Perämäki (2015).

Finally, while the deterministic construction of programmable circuits from
discrete Fourier transforms is known for $d=n$ Idel and Wolf (2015); López
Pastor  _et al._ (2021), a proof of universal programmability of unitary
circuits using random-unitary mode mixers remains open to the best of our
knowledge, and the deterministic construction of such circuits is yet to be
discovered.

Figure S.7: Simulated fidelity $\mathcal{F}$ and success probability
$\mathcal{S}$ for all gates implemented in a circuit with random unitary mode
mixers: (a-c) $\mathcal{F}$ and $\mathcal{S}$ as a function of the dimension
of mode-mixers, $n$, with a circuit depth $L=2$ and (d-f) $\mathcal{F}$ and
$\mathcal{S}$ as function of circuit depth $L$ while using mode-mixers with
dimension $n=200$. Figure S.8: Upper bound of trace distance
$\sqrt{1-\mathcal{F}}$ (a) and success probability $\mathcal{S}$ (b) for all
simulated gates implemented in a circuit with random-unitary mode-mixers.