Quantum Computing: a Computer Scientist's Perspective

Chapter 2

Quantum Computing: a Computer Scientist's Perspective

Many (too many?) introductions to quantum computing have been written, so we will refrain from adding another entry to the collection. Instead, beyond the absolute basics, our focus is on the expressive power and syntax of quantum programs. This demystifies quantum compilation into program transformation problems, amounting to traditional compiler methods that will be very familiar to computer scientists.

In this chapter, we lay the groundwork for this thesis by introducing what programs meant to run on quantum computers look like today, what we expect they will look like in the (near) future, and how quantum compilers have been built to optimise them. We start in section 2.1 with a review of the basic computation primitives of quantum computers and how they are composed to form quantum circuits, the simplest form of quantum programs. This is followed by a review of the leading quantum circuit optimisation techniques in section 2.2. Finally, sections 2.3 and 2.4 introduce and discuss the impact of hybrid quantum computations, and how they challenge existing quantum compiler designs and optimisations.

2.1. Foundations of quantum computing

The most widespread computational model in quantum computing – and arguably its simplest – is built on the qubit abstraction. As its name suggests, it is the quantum analogue of the classical bit, i.e., a value that can take the values 0 or 1.

We will stick to our promise of not delving into the details of the physical realisations of qubits in real-world architectures. Nonetheless, it is important to note one fundamental difference with classical systems. Classical bit values (the famous 0s and 1s of our computers) are typically encoded using two voltages; another way of saying this is that bit values, and hence data, correspond to electrical currents in the wires1 of a chip. Gates, i.e. the lowest level of operations that can be applied to bits, then correspond to barriers that let the electrical current flow through to outgoing wires, or block it.

We can thus picture a classical gate as a black box with n input wires going into the box and m output wires leaving it. For any combination of on and off voltages on the input wires, the box will turn on some of the output wires. The vital point to take away from this classical state of affairs is that we can think of the carriers of input and output data (i.e. the input and output wires) as physically distinct objects that can exist and can be read simultaneously.

Quantum physics rules out such an implementations of qubits. In the case of matter-based qubits, such as ions in traps or Josephson junctions on superconductors, quantum gates are operations that modify – or “mutate”, to borrow a term from programming languages – the physical qubits themselves. An input qubit to a gate is thus submitted to physical interactions that change its internal state. After the gate execution is completed, the qubits that held the input states now contain the operation’s output.

Similarly, photonic systems encode qubits using modes of the electromagnetic field. A gate in this setting acts by transforming these modes – mixing them, shifting their phases, or entangling them with ancillary modes. It is never possible to modify qubit data coherently whilst keeping access to the original input data.

This has several profound implications for quantum computing. First and foremost, every quantum gate must have the same number of inputs as outputs. Most iconic classical gates (AND, OR, XOR, etc.) are thus impossible to implement on a quantum computer without some adjustments2. This also means that the number of qubits must remain unchanged throughout the computation. A computation that starts with n qubits must also end in n qubits – and have n qubits at every point throughout the computation.

At this point, taking the preservation of qubits just described seriously, we should be asking how a quantum computation can even come to be at all, given that no qubit can be created out of thin air. In our attempt to remain blissfully ignorant of physical realities, we suggest adopting the following abstracted mental model of qubits: qubits can neither be created nor deleted3, they simply i) exist at all times, and ii) can be reset to the 0 state.

For our convenience, we can ignore qubits that are unimportant to us. If all we need are n qubits, then we will limit our considerations to these and pretend none other exists. Pushing further our myopic focus on qubits with a direct utility, we can also adjust the window of qubits of interest as we progress through the computation. If, for instance, a new qubit becomes useful halfway through our program execution, we can enlarge the set of qubits we are keeping track of and refer to this as “creating” a qubit. Conversely, qubits often become irrelevant, in which case we move them outside of our field of consideration and say that the qubits were discarded.

A final consequence of mutating qubits that we will highlight is that once a gate has been applied, the input states to the gate no longer exist! In other words, any state that we reach throughout our execution can only be used at most once. Here, your classical intuition might kick in:

Let us just maintain a copy of the original state before modifying it!

This would allow us to do more than one computation from a temporary value. However, copying is a big NO in quantum computing. It is a profound restriction (or property, depending on your point of view) with deep roots in the physics of quantum mechanics. This principle, the no-cloning theorem, is one of three fundamental properties of quantum physics that quantum computing builds upon.

The physical constraints of quantum computation #

No-cloning theorem #

The no-cloning principle Wootte., 1982W. K. Wootters and W. H. Zurek. 1982. A single quantum cannot be cloned. Nature 299, 5886 (October 1982, 802--803). doi: 10.1038/299802a0 provides a formal foundation for the vague statement “qubits live forever” we made earlier. It is a fundamental tenet of quantum information, deserving a more rigorous treatment than we are giving it here. We recommend that the curious reader refers themselves to more respectful references such as Nielsen, 2016Michael A. Nielsen and Isaac L. Chuang. 2016. Quantum Computation and Quantum Information (10th Anniversary edition). Cambridge University Press.

No-cloning theorem: it is impossible to copy an arbitrary unknown state onto another (possibly known) qubit, or to copy a (possibly known) qubit to a qubit with unknown arbitrary state.

If we use ψ\ket{\psi} to denote an arbitrary state and 0\ket{0} to denote a known state, the principle can be restated as: there are no quantum computations mapping ψ0ψψ\ket{\psi}\ket{0} \mapsto \ket{\psi}\ket{\psi}, nor ψ000\ket{\psi}\ket{0} \mapsto \ket{0}\ket{0}. The consequences of this are profound.

A consequence of the first half is what we alluded to in the previous section: any qubit states can only be used once in a computation. This statement also justifies why every quantum gate implementation, no matter the hardware specifics, will mutate its input qubits to produce the output states.

The second half of the statement is often referred to as the “no delete” theorem. Indeed, if we view ψ\ket{\psi} as a state encoding some data, we can interpret it as some amount of information. The state 0\ket{0}, on the other hand, is a fixed state and thus cannot store any information. From the perspective of information theory, the map ψ000\ket{\psi}\ket{0} \mapsto \ket{0}\ket{0} thus destroys information: it turns an information storing left-hand side into a product of 0\ket{0} states, devoid of any information.

We can also revisit the first map ψ0ψψ\ket{\psi}\ket{0} \mapsto \ket{\psi}\ket{\psi} and understand it from an information theoretic perspective as an attempt to create information out of thin air! Using this interpretation, the no-cloning theorem is thus the statement that quantum information is a preserved quantity in quantum computations: its amount will never increase or decrease.

Reversibility #

The fact that the amount of quantum information can never increase by transforming quantum states matches our intuition: if no new information is added from outside the system, then the total information encoded should not be increasing. Why, however, is it impossible to erase some information and thus reduce its total? The answer is reversibility of closed quantum systems: if we exclude the option of discarding parts of the physical system, every quantum of operation is undoable. In other words, a computation must have an inverse operation that recovers the input when applied to the output.

If a quantum operation were thus to erase any information, then an inverse operation would exist that creates information from nothing! The two halves of the no-cloning theorem, as we presented it, thus state the same principle once we consider that every operation must be reversible.

Universality #

Finally, a third distinguishing property of quantum computation is how arbitrarily large computations can be generated from single-qubit gates and pairwise entangling interactions between qubits (two-qubit gates) Barenco, 1995Adriano Barenco, Charles H. Bennett, Richard Cleve, David P. DiVincenzo, Norman Margolus, Peter Shor, Tycho Sleator, John A. Smolin and Harald Weinfurter. 1995. Elementary gates for quantum computation. Physical Review A 52, 5 (November 1995, 3457--3467). doi: 10.1103/PhysRevA.52.3457. It is furthermore the case that the choice of a fixed two-qubit gate, along with single-qubit gates, is sufficient to generate any arbitrary quantum computation. We call a set of gates that can be used to construct any arbitrary quantum computation a universal gate set.

This is a boon for hardware design, as manipulating single-qubit systems is often much more manageable than controlling physical interactions between multiple entities. This decomposition into single-qubit and (a fixed) two-qubit gates means that the architecture i) does not need to support interactions between n>2n > 2 qubits, and ii) can be specialised and hand-tuned to execute the two-qubit interaction of choice as faithfully as possible. Having a two-qubit gate as the entangling operation is not the only choice. Some architectures, such as neutral atoms, choose instead to replace it with a global entangling operation that applies to many qubits simultaneously Evered, 2023Simon J. Evered, Dolev Bluvstein, Marcin Kalinowski, Sepehr Ebadi, Tom Manovitz, Hengyun Zhou, Sophie H. Li, Alexandra A. Geim, Tout T. Wang, Nishad Maskara, Harry Levine, Giulia Semeghini, Markus Greiner, Vladan Vuletić and Mikhail D. Lukin. 2023. High-fidelity parallel entangling gates on a neutral-atom quantum computer. Nature 622, 7982 (October 2023, 268--272). doi: 10.1038/s41586-023-06481-y, resulting in a universal gate set that is more convenient to implement experimentally in their system.

Gate set universality can be generalised further to approximate universality, which is at the centre of the development of error-correcting codes. Indeed, any quantum computations can be approximated to arbitrary precision using only discrete finite sets of one and two-qubit gates Kitaev, 2002Alexei Y. Kitaev, A. H. Shen and Mikhail N. Vyalyi. 2002. Classical and Quantum Computation. American Mathematical Society Dawson, 2006Christopher M. Dawson and Michael A. Nielsen. 2006. The Solovay-Kitaev algorithm. Quantum Information and Computation 6, 1 (January 2006, 81--95). doi: 10.26421/QIC6.1-6. This represents a significant simplification for error correction, as it removes the need for continuously parametrised gates and discretises the problem space.

Leveraging quantum properties for compilation #

We have introduced the universality, reversibility and no-cloning properties of quantum computations for a reason: these laws of physics that govern quantum computations and are absent from classical computer science are an excellent foundation for developing quantum-specific computation optimisations and compilation techniques in general.

As we have just discussed, the wide variety of universal gate sets are degrees of freedom that the compiler can use. Using universality to translate computations between universal gate sets, enabling programmers to seamlessly target different hardware, is one of quantum compiler’s first and most fundamental functions Sivara., 2020Seyon Sivarajah, Silas Dilkes, Alexander Cowtan, Will Simmons, Alec Edgington and Ross Duncan. 2020. t|ket⟩: a retargetable compiler for NISQ devices. Quantum Science and Technology 6, 1 (November 2020, 014003). doi: 10.1088/2058-9565/ab8e92.

Reversibility is also a source of flexibility when expressing quantum programs. Suppose the user wants to execute an operation AA but it is more convenient, or the hardware is only capable of executing a different gate BB. Then, using the inverse B1B^{-1} of BB, it is always possible to rewrite the program as

where these diagrams should be read as operations to be executed from left to right. This is nothing but the mathematical trick of multiplying the left-hand side with the identity operation expressed as BB1B \circ B^{-1}4.

Now, of course, this rewrite is only sensible if the operation B1AB^{-1} \circ A is reasonably cheap to perform. There are plenty of instances where this is indeed the case. Morally, the quantum compiler always has the freedom to execute any quantum operation – at the risk of producing very inefficient code – given that reversibility always guarantees that the operation can be reversed and the competition undone whenever necessary.

Finally, no-cloning is a very useful guarantee that the compiler can use to simplify reasoning about computations5. In chapter 4 we will see that it dramatically simplifies pattern matching, which helps identify all possible optimisations quickly. More generally, no-cloning restricts the set of programs that the compiler must consider, resulting in elegant graph transformation semantics – a topic we explore in chapter 3.

The quantum circuit representation #

We could not conclude our overview of the basics of quantum computing without mentioning the quantum circuit, a representation of quantum computation ubiquitous in the field. With the understanding that we have gained in this section, the two building blocks of the circuit model and the conventions around their graphical representation should be of no surprise to the reader:

  1. Qubits are represented by straight, horizontal lines. Their evolution through time can be followed along the line from left to right: At the leftmost point on the line, the qubit is in its input state; when the qubit reaches its rightmost point, operations have mutated it into the output state of the circuit.
  2. Gates on qubits are boxes placed vertically across one or multiple qubit lines. The qubits it is on represents the set that the gate may act on (and mutate), whereas the left-to-right ordering of the gates reflects their ordering in time.

A simple circuit composed of two qubits and three gates AA, BB and CC could for instance look like this

The previous diagram was in fact also a circuit, in which each arrow pointing to the right was a segment of a qubit line. In this case, AA would be executed before BB and CC; AA would act on both qubits, whereas BB and CC would only modify the first and second qubits, respectively. Note that there is no ordering specified between BB and CC: because they act on disjoint sets of qubits, their relative ordering makes no difference. It is thus common to display them as acting at the same time. We could have equivalently chosen to draw them as:

All these circuits represent the same computation.

Certain quantum gates are particularly useful and appear very regularly in practice. These have standard names that are widely used in the field. The most common single qubit gates are arguably the Hadamard, represented in circuits by a HH box, and the XX, YY and ZZ-axis rotations, drawn as Rx(θ)R_x(\theta), Ry(θ)R_y(\theta) and Rz(θ)R_z(\theta) boxes respectively. Note that rotation gates are parametrised by an angle 0θ<4π0 \leqslant \theta < 4\pi that must be specified to execute the rotation.

There are also commonly used multi-qubit gates. For these, it becomes slightly awkward to draw them as boxes, as they may act on qubits that are not drawn next to each other in the circuit6 or might be applied to qubits in a specified order. As a solution, common gates were given representations that do not spell out their name but mark which qubit they are acting on and in what order. Here are the representations of three of the most famous ones, in order: the CX\mathit{CX} (also known as CNOT) gate, the CZ\mathit{CZ} and the CCX\mathit{CCX} (also known as the three-qubit Toffoli):

You will probably notice that there seems to be a system to this graphical notation. There is, but unfortunately, explaining it would require us to discuss Pauli matrices and commutation relations and quickly lead us astray. The references in section 2.5 are a good starting point for further reading.


  1. In the case of integrated circuits and printed circuits boards, the wires we refer to here would be called “interconnects” or “traces”. ↩︎

  2. The NOT gate is the notable exception to this. It is often found in quantum programs and called X. ↩︎

  3. This is true physically: the carriers of quantum information, typically atoms or photons, live forever in the absence of interactions with their environment. However, we would be seriously deluding ourselves if we believed that the control systems we use to manipulate and keep these particles trapped could do so for any significant amount of time. Instead, experimentalists must constantly devise creative ways to stop the qubits from escaping or interacting with their surroundings (and destroying themselves in the process). ↩︎

  4. The \circ denotes the composition of functions, so unlike the left-to-right diagram, it must be read from right to left. ↩︎

  5. In particular, no-cloning resolves the problem of aliasing once and for all! ↩︎

  6. This becomes immediately apparent if you attempt to draw a gate that should act on the first and third qubit line of a circuit, but leave the second one untouched. ↩︎

2.2. Quantum circuit optimisation: a review

Much of the foundations of classical computer science rely on boolean logic and discrete mathematics Lehman, 2017Eric Lehman, F. Thomson Leighton and Albert R. Meyer. 2017. Mathematics for Computer Science. Samurai Media Limited. In some regards, this is a poor man’s maths, as much of the structure that comes with continuous infinite mathematical objects is lost along the way when discretised.

In contrast, quantum computation, on the other hand, encompasses the whole breadth of (finite dimensional) quantum physical system evolution. Underlying this is a rich mathematical theory steeped in the theory of Hilbert spaces and Lie groups1. A direct consequence of the mathematics of quantum computations is the flourishing of an entire field of research dedicated to quantum circuit optimisations Karupp., 2025Krishnageetha Karuppasamy, Varun Puram, Stevens Johnson and Johnson P. Thomas. 2025. A Comprehensive Review of Quantum Circuit Optimization: Current Trends and Future Directions. Quantum Reports 7, 1 (January 2025, 2). doi: 10.3390/quantum7010002. They leverage the unique structure and symmetries of quantum physics to reduce the noise and resource requirements of quantum computations significantly.

In this section, we will review the main optimisation techniques that established themselves within quantum compilers, focusing on the representation of quantum computations they use and their assumptions about the computations they are optimising.

Cost function #

A key point to settle first when discussing circuit optimisations is the objective of the optimisation – the cost function to be minimised. Unlike much of classical compiler research, which can rely on an established set of hardware targets and benchmarking datasets to profile the empirical, “real world” performance of compiled programs, the quantum world must often contend with simplified noise and architecture models to design proxy metrics, given the limited scale and availability of current quantum devices.

The quantum compilers research community has mostly coalesced around cost functions based on gate count statistics Karupp., 2025Krishnageetha Karuppasamy, Varun Puram, Stevens Johnson and Johnson P. Thomas. 2025. A Comprehensive Review of Quantum Circuit Optimization: Current Trends and Future Directions. Quantum Reports 7, 1 (January 2025, 2). doi: 10.3390/quantum7010002. Counting a type of gate is a simple and popular choice. Making some additional assumptions on the gate parallelism of future hardware, one may also consider cost functions based on gate depth, i.e. the length of the longest chain of gates that cannot be run simultaneously Seling., 2013Peter Selinger. 2013. Quantum circuits of T-depth one. Physical Review A 87, 4 (April 2013, 042302). doi: 10.1103/physreva.87.042302 Basile., 2024Daniel Basilewitsch, Clemens Dlaska and Wolfgang Lechner. 2024. Comparing planar quantum computing platforms at the quantum speed limit. Physical Review Research 6, 2 (April 2024, 023026). doi: 10.1103/physrevresearch.6.023026. In spite (or precisely because) of their simplicity, gate counts serve well as cost functions in many quantum compilation use cases. Most circuit optimisations target one of two hardware regimes.

On most current hardware architectures, the major challenge is achieving high accuracy on entangling operations, i.e. quantum gates that make two or more qubits interact Acharya, 2024Rajeev Acharya, Dmitry A. Abanin, Laleh Aghababaie-Beni, Igor Aleiner, Trond I. Andersen, Markus Ansmann, Frank Arute, Kunal Arya, Abraham Asfaw, Nikita Astrakhantsev, Juan Atalaya, Ryan Babbush, Dave Bacon, Brian Ballard, Joseph C. Bardin, Johannes Bausch, Andreas Bengtsson, Alexander Bilmes, Sam Blackwell, Sergio Boixo, Gina Bortoli, Alexandre Bourassa, Jenna Bovaird, Leon Brill and et al. 2024. Quantum error correction below the surface code threshold. Nature (December 2024). doi: 10.1038/s41586-024-08449-y Pino, 2021J. M. Pino, J. M. Dreiling, C. Figgatt, J. P. Gaebler, S. A. Moses, M. S. Allman, C. H. Baldwin, M. Foss-Feig, D. Hayes, K. Mayer, C. Ryan-Anderson and B. Neyenhuis. 2021. Demonstration of the trapped-ion quantum CCD computer architecture. Nature 592, 7853 (April 2021, 209--213). doi: 10.1038/s41586-021-03318-4 Koch, 2007Jens Koch, Terri M. Yu, Jay Gambetta, A. A. Houck, D. I. Schuster, J. Majer, Alexandre Blais, M. H. Devoret, S. M. Girvin and R. J. Schoelkopf. 2007. Charge-insensitive qubit design derived from the Cooper pair box. Physical Review A 76, 4 (October 2007, 042319). doi: 10.1103/PhysRevA.76.042319 Blais, 2007Alexandre Blais, Jay Gambetta, A. Wallraff, D. I. Schuster, S. M. Girvin, M. H. Devoret and R. J. Schoelkopf. 2007. Quantum-information processing with circuit quantum electrodynamics. Physical Review A 75, 3 (March 2007, 032329). doi: 10.1103/physreva.75.032329. In superconducting qubit and ion trap architectures2, for example, the gate set is typically composed of one and two-qubit gate types, with error rates dominated by an order of magnitude by the latter Steiger, 2018Damian S. Steiger, Thomas Häner and Matthias Troyer. 2018. ProjectQ: an open source software framework for quantum computing. Quantum 2 (January 2018, 49). doi: 10.22331/q-2018-01-31-49 Sivara., 2020Seyon Sivarajah, Silas Dilkes, Alexander Cowtan, Will Simmons, Alec Edgington and Ross Duncan. 2020. t|ket⟩: a retargetable compiler for NISQ devices. Quantum Science and Technology 6, 1 (November 2020, 014003). doi: 10.1088/2058-9565/ab8e92. Circuit optimisations for computations on such noisy hardware thus often define cost functions based on the number of two-qubit gates – typically the CX\mathit{CX} gate, though many other two-qubit gates could be used equivalently.

On the other hand, future generations of hardware for larger scale computations are expected to be more resilient to noise, with the help of error detection and correction techniques. In this regime, the computational power of the hardware is no longer limited by hardware noise but rather by the affordances of the error-correcting code. Depending on how the quantum data is redundantly encoded in the code space, the fault-tolerant execution of specific operations may be anywhere between very straightforward and nigh-impossible. The bottleneck is widely expected to be the execution of single-qubit (non-Clifford) gates, such as the T\mathit{T} gate3. These cases can thus just as well be modelled by cost functions based on gate counts.

Unitary synthesis: the perfect optimisation #

The ne plus ultra of quantum circuit optimisation is unitary synthesis. It leverages the representation of a quantum computation as a square, complex-valued, unitary matrix, which is then re-synthesised as a new, equivalent (and ideally optimised!) quantum circuit. This approach thus breaks down quantum optimisation into two separate sub-problems:

  1. Reduce a nn-qubit quantum circuit into a 2n×2n2^n \times 2^n matrix. This matrix is a unique representation of the computation, meaning that any two equivalent computations will be mapped to the same matrix.
  2. Find the optimal matrix decomposition into primitive quantum gates, thus obtaining a new quantum circuit, equivalent to the original.

The uniqueness of the unitary matrix representation makes it invaluable as a resource for computation optimisation. Not only does it reduce any potentially large collection of equivalent inputs to a single form; it also – crucially – provides a sound distance metric on the space of all circuits, in the form of the Haar measure. This can be used in search-based approaches to measure the distance between synthesised circuits and thus direct a search heuristic towards the optimal solution.

Early work explored general unitary decomposition schemes obtained analytically from linear algebra. These express arbitrary unitaries as a product of unitaries that typically correspond to one and two-qubit gates in the quantum circuit model Iten, 2016Raban Iten, Roger Colbeck, Ivan Kukuljan, Jonathan Home and Matthias Christandl. 2016. Quantum circuits for isometries. Physical Review A 93, 3 (March 2016, 032318). doi: 10.1103/PhysRevA.93.032318 Iten, 2019Raban Iten, Oliver Reardon-Smith, Emanuel Malvetti, Luca Mondada, Gabrielle Pauvert, Ethan Redmond, Ravjot Singh Kohli and Roger Colbeck. 2019. Introduction to UniversalQCompiler. arXiv: 1904.01072 [quant-ph]. Approaches have been proposed using the Cosine-Sine decomposition Mött., 2004Mikko Möttönen, Juha J. Vartiainen, Ville Bergholm and Martti M. Salomaa. 2004. Quantum Circuits for General Multiqubit Gates. Physical Review Letters 93, 13 (Septempter 2004, 130502). doi: 10.1103/PhysRevLett.93.130502, the Quantum Shanon decomposition Krol, 2022Anna M. Krol, Aritra Sarkar, Imran Ashraf, Zaid Al-Ars and Koen Bertels. 2022. Efficient Decomposition of Unitary Matrices in Quantum Circuit Compilers. Applied Sciences 12, 2 (January 2022, 759). doi: 10.3390/app12020759, and the QR decomposition Sedlák, 2008Michal Sedlák and Martin Plesch. 2008. Towards optimization of quantum circuits. Open Physics 6, 1 (March 2008, 128--134). doi: 10.2478/s11534-008-0039-8. While some schemes have been shown to be asymptotically efficient for almost all unitaries Iten, 2016Raban Iten, Roger Colbeck, Ivan Kukuljan, Jonathan Home and Matthias Christandl. 2016. Quantum circuits for isometries. Physical Review A 93, 3 (March 2016, 032318). doi: 10.1103/PhysRevA.93.032318, such strategies typically generate fixed-sized circuits and fail to synthesise short circuits when such circuits exist. The size of synthesised circuits grows exponentially with the number of qubits, making most such schemes impractical beyond three qubits.

Unitary matrix decomposition can also be combined with tools from classical circuit design: in Loke, 2014T. Loke, J. B. Wang and Y. H. Chen. 2014. OptQC : An optimized parallel quantum compiler. Computer Physics Communications 185, 12 (December 2014, 3307--3316). doi: 10.1016/j.cpc.2014.07.022, Loke et al. proposed an approach merging reversible circuit synthesis (see below), a classical compilation problem, with unitary matrix synthesis. They show that searching for decompositions U=PUQU = PU'Q, where PP and QQ are classical reversible circuits can yield shorter circuits when using the Cosine-Sine decomposition for the unitaries UU and UU'.

Search-based approaches have been developed to address the shortcomings of analytical decompositions. Unlike the algebraic approaches, the circuit decomposition problem is viewed as an optimisation problem in search-based circuit synthesis. The space of all possible quantum circuits is explored to find the one that implements the desired unitary whilst minimising the cost function. The major challenge of such methods is the gigantic (typically super-exponential) size of the search space of all possible programs. Without mitigation, most work in this space struggles to scale beyond a handful of qubits.

Up to 3 qubits, T-depth optimal circuits can be found using exhaustive brute force search first proposed in Amy, 2013M. Amy, D. Maslov, M. Mosca and M. Roetteler. 2013. A Meet-in-the-Middle Algorithm for Fast Synthesis of Depth-Optimal Quantum Circuits. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 32, 6 (June 2013, 818--830). doi: 10.1109/TCAD.2013.2244643 and improved in Gheorg., 2022Vlad Gheorghiu, Michele Mosca and Priyanka Mukhopadhyay. 2022. A (quasi-)polynomial time heuristic algorithm for synthesizing T-depth optimal circuits. npj Quantum Information 8, 1 (Septempter 2022). doi: 10.1038/s41534-022-00624-1. Asymptotic bounds on the number of T gates required for general unitary synthesis were recently given in Gosset, 2024David Gosset, Robin Kothari and Kewen Wu. 2024. Quantum state preparation with optimal T-count. arXiv: 2411.04790 [quant-ph].

Scaling to 4 qubits and handling gate sets with continuous parameters, required for non-fault tolerant circuits, an A* search with smart pruning heuristics was proposed in Davis, 2020Marc G. Davis, Ethan Smith, Ana Tudor, Koushik Sen, Irfan Siddiqi and Costin Iancu. 2020. Towards Optimal Topology Aware Quantum Circuit Synthesis. In 2020 IEEE International Conference on Quantum Computing and Engineering (QCE), October 2020. IEEE, 223--234. doi: 10.1109/QCE49297.2020.00036. This approach’s outputs are no longer provably optimal, but the results match optimal decompositions in all known instances. This line of work has subsequently been further refined with heuristics based on pre-defined circuit templates Smith, 2023Ethan Smith, Marc Grau Davis, Jeffrey Larson, Ed Younis, Lindsay Bassman Oftelie, Wim Lavrijsen and Costin Iancu. 2023. LEAP: Scaling Numerical Optimization Based Synthesis Using an Incremental Approach. ACM Transactions on Quantum Computing 4, 1 (February 2023, 1--23). doi: 10.1145/3548693 Madden, 2022Liam Madden and Andrea Simonetto. 2022. Best Approximate Quantum Compiling Problems. ACM Transactions on Quantum Computing 3, 2 (March 2022, 1--29). doi: 10.1145/3505181, parameter instantiation Younis, 2022Ed Younis and Costin Iancu. 2022. Quantum Circuit Optimization and Transpilation via Parameterized Circuit Instantiation. arXiv: 2206.07885 [quant-ph] Younis, 2021Ed Younis, Koushik Sen, Katherine Yelick and Costin Iancu. 2021. QFAST: Conflating Search and Numerical Optimization for Scalable Quantum Circuit Synthesis. In 2021 IEEE International Conference on Quantum Computing and Engineering (QCE), October 2021. IEEE, 232--243. doi: 10.1109/QCE52317.2021.00041 Rakyta, 2022Péter Rakyta and Zoltán Zimborás. 2022. Approaching the theoretical limit in quantum gate decomposition. Quantum 6 (May 2022, 710). doi: 10.22331/q-2022-05-11-710, machine learning Weiden, 2023Mathias Weiden, Ed Younis, Justin Kalloor, John Kubiatowicz and Costin Iancu. 2023. Improving Quantum Circuit Synthesis with Machine Learning. In 2023 IEEE International Conference on Quantum Computing and Engineering (QCE). IEEE. doi: 10.1109/QCE57702.2023.00093 and tensor networks Kuklia., 2023Alon Kukliansky, Ed Younis, Lukasz Cincio and Costin Iancu. 2023. QFactor: A Domain-Specific Optimizer for Quantum Circuit Instantiation. In 2023 IEEE International Conference on Quantum Computing and Engineering (QCE), Septempter 2023. IEEE, 814--824. doi: 10.1109/QCE57702.2023.00096.

Some of these heuristics also make it possible to synthesise circuits with device constraints in mind and can trade off decomposition accuracy for shallower circuit depth and lower noise. In Wu, 2020Xin-Chuan Wu, Marc Grau Davis, Frederic T. Chong and Costin Iancu. 2020. QGo: Scalable Quantum Circuit Optimization Using Automated Synthesis. arXiv: 2012.09835 [quant-ph] Kuklia., 2023Alon Kukliansky, Ed Younis, Lukasz Cincio and Costin Iancu. 2023. QFactor: A Domain-Specific Optimizer for Quantum Circuit Instantiation. In 2023 IEEE International Conference on Quantum Computing and Engineering (QCE), Septempter 2023. IEEE, 814--824. doi: 10.1109/QCE57702.2023.00096, the authors have also explored partitioning the circuit into smaller parts optimised independently to scale these techniques to large circuit sizes. Despite the reduced optimisation performance that the boundaries of the partitioned circuits introduce, the combination of circuit partitioning with the techniques listed above yields some of the best-performing circuit optimisation techniques developed to date Costin., 2025Bert Costin Iancu. 2025. Berkeley Quantum Synthesis Toolkit. Retrieved on 09/01/2025 from https://bqskit.lbl.gov/. Circuit synthesis schemes have also been extended to generate circuits on a more expressive gate set, including elementary classical operations Alam, 2024Faisal Alam and Bryan K. Clark. 2024. Learning dynamic quantum circuits for efficient state preparation. arXiv: 2410.09030 [quant-ph] Niu, 2024Siyuan Niu, Efekan Kokcu, Anupam Mitra, Aaron Szasz, Akel Hashim, Justin Kalloor, Wibe Albert de Jong, Costin Iancu and Ed Younis. 2024. AC/DC: Automated Compilation for Dynamic Circuits. arXiv: 2412.07969 [quant-ph].

However, a fundamental flaw of all unitary synthesis schemes is the 4n4^n-scaling in the number of qubits nn of the unitary representation itself. This means that no matrix-based synthesis method, however efficient, will ever be able to handle computations with much more than a dozen qubits. Circuit partitioning schemes such as Wu, 2020Xin-Chuan Wu, Marc Grau Davis, Frederic T. Chong and Costin Iancu. 2020. QGo: Scalable Quantum Circuit Optimization Using Automated Synthesis. arXiv: 2012.09835 [quant-ph] Kuklia., 2023Alon Kukliansky, Ed Younis, Lukasz Cincio and Costin Iancu. 2023. QFactor: A Domain-Specific Optimizer for Quantum Circuit Instantiation. In 2023 IEEE International Conference on Quantum Computing and Engineering (QCE), Septempter 2023. IEEE, 814--824. doi: 10.1109/QCE57702.2023.00096 effectively circumvent the problem, but they are heavily dependent on the partitioning quality.

The search for scalable representations #

Our study of unitary synthesis introduced us to a convenient two-step approach to quantum computation optimisation. First, the input circuit is transformed into a “global” representation that captures the computation as a whole, abstracting away the precise sequences of gates that compose the original circuit. This representation is then the input for the second half of the problem, which produces a circuit of the desired shape, equivalent to the original input but with reduced cost.

In addition to simplifying the original problem, such global intermediate representations are well-positioned to leverage the quantum-specific structure and symmetries in the computation. They can thus enable more advanced optimisations and are robust to varying circuit representation and local optimisation landscape.

The unitary matrix is the most common representation of quantum computations, but as we have seen, it suffers from severe scaling problems in the number of qubits. The problem is not so much that quantum computations require exponential space to be described in the worst case – after all, the space of all nn-qubit unitaries SU(2n)SU(2^n) is exponentially large. However, the set of unitaries implementable in practice can only be a tiny subset of SU(2n)SU(2^n)4 – the set of unitaries that admit a polynomial-sized circuit representation.

Another fruitful avenue of work for quantum optimisation has thus been the development of alternative representations for quantum computations that can encode polynomially sized quantum programs efficiently whilst enabling novel optimisations.

Phase Polynomials and Pauli Gadgets #

A particularly convenient global representation of many quantum circuits is as products of Pauli exponentials, also known as Pauli gadgets Cowtan, 2019Alexander Cowtan, Silas Dilkes, Ross Duncan, Will Simmons and Seyon Sivarajah. 2019. Phase Gadget Synthesis for Shallow Circuits. In Proceedings 16th International Conference on Quantum Physics and Logic, QPL 2019, Chapman University, Orange, CA, USA, June 10-14, 2019, 213--228. doi: 10.4204/EPTCS.318.13. These unitaries are of the form

U=sPexp(iαss)U = \prod_{s \in P} exp(i \alpha_s \cdot s)

where αs[0,2π)\alpha_s \in \mathbb [0, 2\pi) are real coefficients and sP={I,X,Y,Z}ns \in P = \{I, X, Y, Z\}^n are strings of length nn of the four Pauli matrices – so-called Pauli strings. In this formulation, nn fixes the number of qubits of the computation.

These exponentials are always valid nn-qubit unitaries and can express entangling operations across any number of qubits: the qubits on which an operation exp(iαs)exp(i \alpha \cdot s) acts non-trivially are given by the indices of the characters in ss that are not the identity II. For instance, the exponential

exp(iπ2XIZ)exp(i \frac\pi2 XIZ)

is a valid quantum computation on 3 qubits, entangling the first and third qubits. Beyond useful abstractions for optimisation, such entangling operations appear naturally when simulating quantum systems, for example in quantum chemistry McClean, 2016Jarrod R McClean, Jonathan Romero, Ryan Babbush and Alán Aspuru-Guzik. 2016. The theory of variational hybrid quantum-classical algorithms. New Journal of Physics 18, 2 (February 2016, 023023). doi: 10.1088/1367-2630/18/2/023023.

The use of these primitives for quantum compilation was first explored in Cowtan, 2019Alexander Cowtan, Silas Dilkes, Ross Duncan, Will Simmons and Seyon Sivarajah. 2019. Phase Gadget Synthesis for Shallow Circuits. In Proceedings 16th International Conference on Quantum Physics and Logic, QPL 2019, Chapman University, Orange, CA, USA, June 10-14, 2019, 213--228. doi: 10.4204/EPTCS.318.13, and further generalised in Cowtan, 2020Alexander Cowtan, Will Simmons and Ross Duncan. 2020. A Generic Compilation Strategy for the Unitary Coupled Cluster Ansatz. arXiv: 2007.10515 [quant-ph]. Starting from an (unordered) sequence of Pauli gadgets, the gadgets are clustered into sets of mutually commuting gadgets. These can then be jointly synthesised into a circuit, markedly reducing the number of entangling operations as compared to naively implementing one exponential at a time.

Further improvements to this work have since been presented in Huang, 2024Qunsheng Huang, David Winderl, Arianne Meijer-van de Griend and Richie Yeung. 2024. Redefining Lexicographical Ordering: Optimizing Pauli String Decompositions for Quantum Compiling. CoRR abs/2408.00354. doi: 10.48550/ARXIV.2408.00354 and Schmitz, 2024Albert T. Schmitz, Nicolas P. D. Sawaya, Sonika Johri and A. Y. Matsuura. 2024. Graph Optimization Perspective for Low-Depth Trotter-Suzuki Decomposition. Physical Review A 109, 4 (April 2024, 042418). doi: 10.1103/PhysRevA.109.042418, where new heuristics are introduced to choose the Pauli gadget ordering. In Huang, 2024Qunsheng Huang, David Winderl, Arianne Meijer-van de Griend and Richie Yeung. 2024. Redefining Lexicographical Ordering: Optimizing Pauli String Decompositions for Quantum Compiling. CoRR abs/2408.00354. doi: 10.48550/ARXIV.2408.00354, the hardware-specific connectivity constraints between qubits are also taken into account to produce programs that can be executed on the targeted architecture without overhead.

A close relative of Pauli gadgets – a strictly smaller subset of it, to be precise – are the so-called phase polynomials Amy, 2018Matthew Amy, Parsiad Azimzadeh and Michele Mosca. 2018. On the controlled-NOT complexity of controlled-NOT–phase circuits. Quantum Science and Technology 4, 1 (Septempter 2018, 015002). doi: 10.1088/2058-9565/aad8ca, obtained when restricting the Pauli strings to combinations of Z Pauli matrices and identities: s{I,Z}ns \in \{I, Z\}^n . These are particularly amenable to optimisation as in this case, the ordering of the gadgets becomes irrelevant – all exponential terms commute. This gives the compiler a lot of freedom during circuit synthesis.

The action of phase polynomials on quantum states is quite easy to understand. Instead of the exponentials of II and ZZ-based Pauli string, the computation can equivalently be given by its action on the basis states. A quantum basis state – just like a classical state – is given by a bistring b1bnb_1 \cdots b_n of bits bi{0,1}b_i \in \{0, 1\}. Writing eb1bne_{b_1 \cdots b_n} for the basis state corresponding to the bitstring b1bnb_1 \cdots b_n, the action of a phase polynomial UU on eb1bne_{b_1 \cdots b_n} is given by

eb1bnexp(is{I,Z}nas(s~1b1s~nbn))Reb1bne_{b_1 \cdots b_n} \mapsto \underbrace{\exp(i \cdot \sum_{s \in \{I, Z\}^n} a_s \cdot (\tilde{s}_1 b_1 \oplus \cdots \oplus \tilde{s}_n b_n))}_{\in\,\mathbb{R}} e_{b_1 \cdots b_n}

where s~1s~n\tilde{s}_1 \cdots \tilde{s}_n is now also a bitstring of booleans s~i{0,1}\tilde{s}_i \in \{0, 1\}, and \oplus denotes the boolean XOR operation. The boolean s~i\tilde{s}_i has value 11 if and only if the ii-th character in the Pauli string ss is ZZ,

The exponential expression in (1) is just a real number – indeed each term in the sum simply evaluates to either asa_s or 00. A phase polynomial is thus a diagonal unitary matrix: it maps every basis state b1bn\ket {b_1 \cdots b_n} to itself, multiplied by some phase eiθe^{i \theta}.

Polynomially-sized circuits that implement diagonal matrices correspond to phase polynomials with k=O(np)2nk = \mathcal{O}(n^p) \ll 2^n non-zero terms as0a_s \neq 0, i.e. they can represent quantum computations efficiently and scale well with the number of qubits – thus allowing efficient algorithms that scale polynomially in the number of qubits nn.

The Graysynth algorithm, as presented in Amy, 2018Matthew Amy, Parsiad Azimzadeh and Michele Mosca. 2018. On the controlled-NOT complexity of controlled-NOT–phase circuits. Quantum Science and Technology 4, 1 (Septempter 2018, 015002). doi: 10.1088/2058-9565/aad8ca, has become the reference synthesis method for phase polynomials. The key observation made by its authors is that all terms of the sum within the exponential can be cycled through and obtained following the binary Gray codes Gray, 1953F. Gray. 1953. Pulse code communication. Retrieved from http://www.google.com/patents/US2632058. The Hamming distance of one that separates successive bitstrings in the code translates into a single two-qubit CX\mathit{CX} gate when synthesised to a quantum circuit by Graysynth.

This approach was adapted to work with hardware connectivity constraints in Griend, 2022Arianne Meijer-van de Griend and Ross Duncan. 2022. Architecture-Aware Synthesis of Phase Polynomials for NISQ Devices. In Proceedings 19th International Conference on Quantum Physics and Logic, QPL 2022, Wolfson College, Oxford, UK, 27 June - 1 July 2022, 116--140. doi: 10.4204/EPTCS.394.8, Gogioso, 2022Stefano Gogioso and Richie Yeung. 2022. Annealing Optimisation of Mixed ZX Phase Circuits. In Proceedings 19th International Conference on Quantum Physics and Logic, QPL 2022, Wolfson College, Oxford, UK, 27 June - 1 July 2022, 415--431. doi: 10.4204/EPTCS.394.20 and Vandae., 2022Vivien Vandaele, Simon Martiel and Timothée Goubault de Brugière. 2022. Phase polynomials synthesis algorithms for NISQ architectures and beyond. Quantum Science and Technology 7, 4 (Septempter 2022, 045027). doi: 10.1088/2058-9565/ac5a0e. An up-to-date study of the performance of phase polynomial-based compiler optimisations and comparisons with standard approaches is performed in Meijer., 2025Arianne Meijer - van de Griend. 2025. A comparison of quantum compilers using a DAG-based or phase polynomial-based intermediate representation. Journal of Systems and Software 221 (March 2025, 112224). doi: 10.1016/j.jss.2024.112224.

The study of phase polynomials can also be generalised to arbitrary diagonal operators. Tight asymptotic bounds on the resource requirements for arbitrary diagonal operator synthesis and their implementation were recently given in Sun, 2023Xiaoming Sun, Guojing Tian, Shuai Yang, Pei Yuan and Shengyu Zhang. 2023. Asymptotically Optimal Circuit Depth for Quantum State Preparation and General Unitary Synthesis. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 42, 10 (October 2023, 3301--3314). doi: 10.1109/TCAD.2023.3244885. The authors propose using a smart meshing of different Gray codes in parallel and, where available, additional qubits as ancilla registers to parallelise computations further and minimise circuit depth. The resulting general-purpose decomposition of arbitrary diagonal operators yields circuits of depth O(2nn)\mathcal O(\frac{2^n}{n}) and size O(n2logn)+2n+3\mathcal O(\frac{n^2}{\log n}) + 2^{n+3}, as well as improved bounds in the presence of m2nm \geq 2n ancilla qubits.

Clifford synthesis #

The group of all nn-qubit unitaries SU(2n)SU(2^n) contains a subgroup that has become an object of study across many domains of quantum computing science: the Clifford group. We have already mentioned that it is at the centre of quantum error correction theory Bravyi, 2005Sergey Bravyi and Alexei Kitaev. 2005. Universal quantum computation with ideal Clifford gates and noisy ancillas. Physical Review A 71, 2 (February 2005, 022316). doi: 10.1103/PhysRevA.71.022316; it is also a cornerstone of measurement-based quantum computing Rausse., 2001Robert Raussendorf and Hans J. Briegel. 2001. A One-Way Quantum Computer. Physical Review Letters 86, 22 (May 2001, 5188--5191). doi: 10.1103/PhysRevLett.86.5188 and graph states Hein, 2004M. Hein, J. Eisert and H. J. Briegel. 2004. Multiparty entanglement in graph states. Physical Review A 69, 6 (June 2004, 062311). doi: 10.1103/physreva.69.062311, as well as one of the most promising approaches for fast quantum simulations Gottes., 1999Daniel Gottesman. 1999. The Heisenberg representation of quantum computers. In Group 22: Proceedings of the 12th International Colloquium onGroup Theoretical Methods in Physics,. International Press, 32--43 Bravyi, 2019Sergey Bravyi, Dan Browne, Padraic Calpin, Earl Campbell, David Gosset and Mark Howard. 2019. Simulation of quantum circuits by low-rank stabilizer decompositions. Quantum 3 (Septempter 2019, 181). doi: 10.22331/q-2019-09-02-181 Kissin., 2022Aleks Kissinger and John van de Wetering. 2022. Simulating quantum circuits with ZX-calculus reduced stabiliser decompositions. Quantum Science and Technology 7, 4 (July 2022, 044001). doi: 10.1088/2058-9565/ac5d20.

The Clifford subgroup of quantum circuits admits an efficient Θ(2n2)\Theta(2n^2)-sized program representation known as Clifford tableau Aarons., 2004Scott Aaronson and Daniel Gottesman. 2004. Improved simulation of stabilizer circuits. Physical Review A 70, 5 (November 2004, 052328). doi: 10.1103/PhysRevA.70.052328. This has been used profusely for compiler optimisation. In Aarons., 2004Scott Aaronson and Daniel Gottesman. 2004. Improved simulation of stabilizer circuits. Physical Review A 70, 5 (November 2004, 052328). doi: 10.1103/PhysRevA.70.052328 the first Clifford circuit synthesis procedure is given, using an analytical decomposition of Clifford tableaus into O(n2/logn)O(n^2 /\log n) one and two-qubit gates. An improved, Bruhat-based decomposition that is optimal in the number of Hadamard gates was subsequently proposed in Maslov, 2018Dmitri Maslov and Martin Roetteler. 2018. Shorter Stabilizer Circuits via Bruhat Decomposition and Quantum Circuit Transformations. IEEE Transactions on Information Theory 64, 7 (July 2018, 4729--4738). doi: 10.1109/tit.2018.2825602. In the case of a Clifford fragment directly followed by measurements, the procedure can be further refined to replace gates with classical computation on the measurement outcomes Bravyi, 2021Sergey Bravyi and Dmitri Maslov. 2021. Hadamard-Free Circuits Expose the Structure of the Clifford Group. IEEE Transactions on Information Theory 67, 7 (July 2021, 4546--4563). doi: 10.1109/TIT.2021.3081415. Finally, an alternative normal form that is well-suited to hardware with limited nearest neighbours connectivity was also derived using a diagrammatic approach Maslov, 2023Dmitri Maslov and Willers Yang. 2023. CNOT circuits need little help to implement arbitrary Hadamard-free Clifford transformations they generate. npj Quantum Information 9, 1 (Septempter 2023). doi: 10.1038/s41534-023-00760-2.

Just as in unitary synthesis, circuit decompositions of Clifford operations more efficient than the general analytical expressions can be obtained case-by-case using search and optimisation. The pendant to the provably optimal decompositions of unitaries obtained through brute force search Amy, 2013M. Amy, D. Maslov, M. Mosca and M. Roetteler. 2013. A Meet-in-the-Middle Algorithm for Fast Synthesis of Depth-Optimal Quantum Circuits. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 32, 6 (June 2013, 818--830). doi: 10.1109/TCAD.2013.2244643 also exists for Clifford circuits Kliuch., 2013Vadym Kliuchnikov and Dmitri Maslov. 2013. Optimization of Clifford circuits. Physical Review A 88, 5 (November 2013, 052307). doi: 10.1103/physreva.88.052307. Due to the more efficient representation and smaller search space, all optimal Clifford circuits could be found up to 6 qubits. Using modern SAT solvers, optimal Clifford synthesis has recently been pushed much further, with known optimal circuits beyond 20 qubits Peham, 2023Tom Peham, Nina Brandl, Richard Kueng, Robert Wille and Lukas Burgholzer. 2023. Depth-Optimal Synthesis of Clifford Circuits with SAT Solvers. In IEEE International Conference on Quantum Computing and Engineering, QCE 2023, Bellevue, WA, USA, September 17-22, 2023. IEEE, 802--813. doi: 10.1109/QCE57702.2023.00095 Schnei., 2023Sarah Schneider, Lukas Burgholzer and Robert Wille. 2023. A SAT Encoding for Optimal Clifford Circuit Synthesis. In Proceedings of the 28th Asia and South Pacific Design Automation Conference, January 2023. IEEE. doi: 10.1145/3566097.3567929.

Heuristic optimisation approaches have also been shown to be effective on Clifford optimisation Bravyi, 2021Sergey Bravyi and Dmitri Maslov. 2021. Hadamard-Free Circuits Expose the Structure of the Clifford Group. IEEE Transactions on Information Theory 67, 7 (July 2021, 4546--4563). doi: 10.1109/TIT.2021.3081415 Fagan, 2018Andrew Fagan and Ross Duncan. 2018. Optimising Clifford Circuits with Quantomatic. In Proceedings 15th International Conference on Quantum Physics and Logic, QPL 2018, Halifax, Canada, 3-7th June 2018, 85--105. doi: 10.4204/EPTCS.287.5 and scale to larger systems. For Clifford computations on devices with restricted connectivity, an architecture-aware synthesis method was proposed in Winderl, 2024David Winderl, Qunsheng Huang, Arianne Meijer-van de Griend and Richie Yeung. 2024. Architecture-Aware Synthesis of Stabilizer Circuits from Clifford Tableaus. arXiv: 2309.08972 [quant-ph].

Diagrammatic representations #

Quantum computer science and quantum mechanics have a rich history in diagrammatic representations Feynman, 1949R. P. Feynman. 1949. Space-Time Approach to Quantum Electrodynamics. Physical Review 76, 6 (Septempter 1949, 769--789). doi: 10.1103/physrev.76.769 Coecke, 2017Bob Coecke and Aleks Kissinger. 2017. Picturing Quantum Processes: A First Course in Quantum Theory and Diagrammatic Reasoning. Cambridge University Press. doi: 10.1017/9781316219317 Backens, 2019Miriam Backens and Aleks Kissinger. 2019. ZH: A Complete Graphical Calculus for Quantum Computations Involving Classical Non-linearity. Electronic Proceedings in Theoretical Computer Science 287 (January 2019, 23--42). doi: 10.4204/EPTCS.287.2. These have allowed one to picture complex physical processes as intuitive operations in a graphical language and have – as a nice side effect – led to a plethora of state-of-the-art quantum circuit optimisation techniques!

A diagrammatic representation of quantum computation is obtained by lifting the gates that form a quantum circuit into the nodes of a more abstract graph-based graphical calculus. The most commonly used flavour of calculus for circuit optimisation is the ZX calculus Coecke, 2008Bob Coecke and Ross Duncan. 2008. Interacting Quantum Observables Coecke, 2012Bob Coecke, Ross Duncan, Aleks Kissinger and Quanlong Wang. 2012. Strong Complementarity and Non-locality in Categorical Quantum Mechanics. In 2012 27th Annual IEEE Symposium on Logic in Computer Science, June 2012. IEEE, 245--254. doi: 10.1109/lics.2012.35 Weteri., 2020John van de Wetering. 2020. ZX-calculus for the working quantum computer scientist. arXiv: 2012.13966 [quant-ph] Yeung, 2024Richie Yeung, Konstantinos Meichanetzidis, Alexandre Krajenbrink and François Charton. 2024. Teaching small transformers to rewrite ZX diagrams. MathAI submission.

By breaking up multi-qubit gates into several non-unitary tensors, the ZX calculus and related variants Roy, 2011Shibdas Roy, Dipankar Home, Guruprasad Kar and Archan S. Majumda. 2011. Towards Normal Forms for GHZ∕W Calculus. In AIP Conference Proceedings. AIP, 112--119. doi: 10.1063/1.3635852 Backens, 2019Miriam Backens and Aleks Kissinger. 2019. ZH: A Complete Graphical Calculus for Quantum Computations Involving Classical Non-linearity. Electronic Proceedings in Theoretical Computer Science 287 (January 2019, 23--42). doi: 10.4204/EPTCS.287.2 Felice, 2023Giovanni de Felice and Bob Coecke. 2023. Quantum Linear Optics via String Diagrams. In Proceedings 19th International Conference on Quantum Physics and Logic, Wolfson College, Oxford, UK, 27 June - 1 July 2022. Open Publishing Association, 83-100. doi: 10.4204/EPTCS.394.6 expose some of the symmetry and structure of quantum physics in the form of simple and intuitive graphical rules. This has enabled the discovery of many quantum optimisation techniques (e.g. Duncan, 2019Ross Duncan, Aleks Kissinger, Simon Perdrix and John van de Wetering. 2019. Graph-theoretic Simplification of Quantum Circuits with the ZX-calculus. arXiv: 1902.03178 [quant-ph] Weteri., 2024John van de Wetering, Richie Yeung, Tuomas Laakkonen and Aleks Kissinger. 2024. Optimal compilation of parametrised quantum circuits. arXiv: 2401.12877 [quant-ph]), some of which we have already reviewed Huang, 2024Qunsheng Huang, David Winderl, Arianne Meijer-van de Griend and Richie Yeung. 2024. Redefining Lexicographical Ordering: Optimizing Pauli String Decompositions for Quantum Compiling. CoRR abs/2408.00354. doi: 10.48550/ARXIV.2408.00354 Gogioso, 2022Stefano Gogioso and Richie Yeung. 2022. Annealing Optimisation of Mixed ZX Phase Circuits. In Proceedings 19th International Conference on Quantum Physics and Logic, QPL 2022, Wolfson College, Oxford, UK, 27 June - 1 July 2022, 415--431. doi: 10.4204/EPTCS.394.20 Griend, 2022Arianne Meijer-van de Griend and Ross Duncan. 2022. Architecture-Aware Synthesis of Phase Polynomials for NISQ Devices. In Proceedings 19th International Conference on Quantum Physics and Logic, QPL 2022, Wolfson College, Oxford, UK, 27 June - 1 July 2022, 116--140. doi: 10.4204/EPTCS.394.8 Cowtan, 2019Alexander Cowtan, Silas Dilkes, Ross Duncan, Will Simmons and Seyon Sivarajah. 2019. Phase Gadget Synthesis for Shallow Circuits. In Proceedings 16th International Conference on Quantum Physics and Logic, QPL 2019, Chapman University, Orange, CA, USA, June 10-14, 2019, 213--228. doi: 10.4204/EPTCS.318.13 Cowtan, 2020Alexander Cowtan, Will Simmons and Ross Duncan. 2020. A Generic Compilation Strategy for the Unitary Coupled Cluster Ansatz. arXiv: 2007.10515 [quant-ph]. This selection of papers is not quite exhaustive5 – there are currently over 300 hundred papers on the topic, as indexed by zxcalculus.com.

Aside from being an invaluable tool for research and compiler pass design, a significant contribution of these diagrammatic representations is the introduction of graph transformation systems (GTS) Ehrig, 1973Hartmut Ehrig, Michael Pfender and Hans Jürgen Schneider. 1973. Graph-Grammars: An Algebraic Approach. In 14th Annual Symposium on Switching and Automata Theory, Iowa City, Iowa, USA, October 15-17, 1973. IEEE Computer Society, 167--180. doi: 10.1109/SWAT.1973.11 Rozenb., 1997Grzegorz Rozenberg. 1997. Handbook of Graph Grammars and Computing by Graph Transformations, Volume 1: Foundations. World Scientific König, 2018Barbara König, Dennis Nolte, Julia Padberg and Arend Rensink. 2018. A Tutorial on Graph Transformation. In Graph Transformation, Specifications, and Nets - In Memory of Hartmut Ehrig. Springer, 83--104. doi: 10.1007/978-3-319-75396-6_5 to quantum computing. More on this in chapter 3 (and much of the rest of this thesis)!

Reversible classical circuits #

Many more representations have either been taken over from classical compiler optimisations or were developed for specific purposes. The last we will mention is reversible circuit synthesis, an entirely classical circuit design problem which can draw from the results of decades of research. From a quantum perspective, reversible classical circuits correspond to unitaries (and more generally, isometries) that send basis states to basis states –  and thus do not introduce any complex phase Shende, 2002V.V. Shende, A.K. Prasad, I.L. Markov and J.P. Hayes. 2002. Reversible logic circuit synthesis. In IEEE/ACM International Conference on Computer Aided Design, 2002, November 2002. IEEE, 353--360. doi: 10.1109/iccad.2002.1167558. We highlight a selection of the more recent work in the field and refer the reader to the much more complete, albeit ageing, survey of Saeedi, 2013Mehdi Saeedi and Igor L. Markov. 2013. Synthesis and optimization of reversible circuits—a survey. ACM Computing Surveys 45, 2 (February 2013, 1--34). doi: 10.1145/2431211.2431220.

Up to 4 (qu)bits, all reversible circuits and their optimal synthesis can be generated by brute force Li, 2014Zhiqiang Li, Hanwu Chen, Xiaoyu Song and Marek Perkowski. 2014. A Synthesis Algorithm for 4-Bit Reversible Logic Circuits with Minimum Quantum Cost. ACM Journal on Emerging Technologies in Computing Systems 11, 3 (December 2014, 1--19). doi: 10.1145/2629542. Viewing reversible circuits as a permutation of all 2n2^n bitstrings, Susam et al. pre-compute optimal circuits only for swaps of two bitstrings (transpositions). These can then be used as part of a standard selection sort to synthesise arbitrary permutations. The number of such permutations scales much more favourably compared to arbitrary permutation, allowing fast circuit synthesis of up to 20+ (qu)bits in a fraction of a second, with good performance.

Truth table or matrix representations of reversible circuits suffer from the same exponential scaling as unitaries. To address these, other representations that have been used include exclusive sums of product terms (ESOP) Fazel, 2007K. Fazel, M. A. Thornton and J. E. Rice. 2007. ESOP-based Toffoli Gate Cascade Generation. In 2007 IEEE Pacific Rim Conference on Communications, Computers and Signal Processing, August 2007. IEEE. doi: 10.1109/pacrim.2007.4313212 Bandyo., 2014Chandan Bandyopadhyay, Hafizur Rahaman and Rolf Drechsler. 2014. A Cube Pairing Approach for Synthesis of ESOP-Based Reversible Circuit. In 2014 IEEE 44th International Symposium on Multiple-Valued Logic, May 2014. IEEE, 109--114. doi: 10.1109/ismvl.2014.27, positive polarity Reed-Müller codes (PPRM) Jegier, 2017Jerzy Jegier and Paweł Kerntopf. 2017. PPRM-based approach to synthesis of reversible functions. In Photonics Applications in Astronomy, Communications, Industry, and High Energy Physics Experiments 2017, August 2017. SPIE, 1044523. doi: 10.1117/12.2280943 and decision diagrams Stojko., 2019Suzana Stojković, Radomir Stanković, Claudio Moraga and Milena Stanković. 2019. Reversible Circuits Synthesis from Functional Decision Diagrams by using Node Dependency Matrices. Journal of Circuits, Systems and Computers 29, 05 (August 2019, 2050079). doi: 10.1142/s0218126620500796 Wille, 2010Robert Wille and Rolf Drechsler. 2010. Effect of BDD Optimization on Synthesis of Reversible and Quantum Logic. Electronic Notes in Theoretical Computer Science 253, 6 (March 2010, 57--70). doi: 10.1016/j.entcs.2010.02.006 Pang, 2011Yu Pang, Shaoquan Wang, Zhilong He, Jinzhao Lin, Sayeeda Sultana and Katarzyna Radecka. 2011. Positive Davio-based synthesis algorithm for reversible logic. In 2011 IEEE 29th International Conference on Computer Design (ICCD), October 2011. IEEE, 212--218. doi: 10.1109/iccd.2011.6081399.

The quantum framework is strictly more general than the classical regime in which the problem was studied initially. This affords additional freedom for decomposition schemes, such as decompositions of CCX\textit{CCX} gates on 3 qubits into single and two-qubit gates Shende, 2008Vivek V. Shende and Igor L. Markov. 2008. On the CNOT-cost of TOFFOLI gates. arXiv: 0803.2316 [quant-ph]. Various optimised decompositions for sequences of Toffoli gates have also been similarly developed Scott, 2008Nathan O. Scott and Gerhard W. Dueck. 2008. Pairwise decomposition of toffoli gates in a quantum circuit. In Proceedings of the 18th ACM Great Lakes symposium on VLSI, May 2008. ACM, 231--236. doi: 10.1145/1366110.1366168 Arabza., 2010Mona Arabzadeh, Mehdi Saeedi and Morteza Saheb Zamani. 2010. Rule-based optimization of reversible circuits. In 2010 15th Asia and South Pacific Design Automation Conference (ASP-DAC), January 2010. IEEE, 849--854. doi: 10.1109/aspdac.2010.5419684 Datta, 2013Kamalika Datta, Gaurav Rathi, Robert Wille, Indranil Sengupta, Hafizur Rahaman and Rolf Drechsler. 2013. Exploiting Negative Control Lines in the Optimization of Reversible Circuits Rahman, 2014Md Zamilur Rahman and Jacqueline E. Rice. 2014. Templates for Positive and Negative Control Toffoli Networks Datta, 2015Kamalika Datta, Indranil Sengupta and Hafizur Rahaman. 2015. A Post-Synthesis Optimization Technique for Reversible Circuits Exploiting Negative Control Lines. IEEE Transactions on Computers 64, 4 (April 2015, 1208--1214). doi: 10.1109/tc.2014.2315641 Arpita, 2015Pyreddy Mary Arpita, Kamalika Datta, Rohith Vemula and Indranil Sengupta. 2015. Optimization of reversible circuits using triple-gate templates at quantum gate level. In 2015 International Conference on Electronic Design, Computer Networks & Automated Verification (EDCAV), January 2015. IEEE, 120--124. doi: 10.1109/edcav.2015.7060551 Abdess., 2016Nabila Abdessaied, Matthew Amy, Mathias Soeken and Rolf Drechsler. 2016. Technology Mapping of Reversible Circuits to Clifford+T Quantum Circuits. In 2016 IEEE 46th International Symposium on Multiple-Valued Logic (ISMVL), May 2016. IEEE, 150--155. doi: 10.1109/ismvl.2016.33 Gado, 2021Mariam Gado and Ahmed Younes. 2021. Optimization of Reversible Circuits Using Toffoli Decompositions with Negative Controls. Symmetry 13, 6 (June 2021, 1025). doi: 10.3390/sym13061025. Mohammadi and Eshghi introduced 4-valued truth tables to extend classical circuit synthesis to include X\sqrt{X} (also known as V\mathit{V}) gates Mohamm., 2008Majid Mohammadi and Mohammad Eshghi. 2008. Behavioral description of quantum V and V+ gates to design quantum logic circuits. In 2008 5th International Multi-Conference on Systems, Signals and Devices, July 2008. IEEE, 1--5. doi: 10.1109/ssd.2008.4632850. References Soeken, 2012M. Soeken, Z. Sasanian, R. Wille, D. M. Miller and R. Drechsler. 2012. Optimizing the Mapping of Reversible Circuits to Four-Valued Quantum Gate Circuits. In 2012 IEEE 42nd International Symposium on Multiple-Valued Logic, May 2012. IEEE, 173--178. doi: 10.1109/ismvl.2012.64 as well as Rahman, 2012Md. Mazder Rahman, Gerhard W. Dueck and Anindita Banerjee. 2012. Optimization of Reversible Circuits Using Reconfigured Templates incorporated controlled-V\mathit{V} gates into template matching strategies and showed significant improvements in synthesised gate count . Finally, Maslov, 2016Dmitri Maslov. 2016. Advantages of using relative-phase Toffoli gates with an application to multiple control Toffoli optimization. Physical Review A 93, 2 (February 2016, 022311). doi: 10.1103/physreva.93.022311 proposed decomposing Toffolis only up to relative phase, introducing a lot of freedom in the quantum decompositions that are required compared to the traditional classical decompositions.


In summary, a variety of scalable representations – such as phase polynomials, Pauli gadgets, Clifford tableaus, diagrammatic calculi, and reversible circuits – have been developed to abstract computations and enable highly tailored optimisation methods. These approaches leverage the unique structure and symmetries of quantum computations, achieving significant reductions in circuit size, depth, and hardware-specific overheads. Techniques such as phase polynomial synthesis and Clifford tableau representations are widely applicable and are a cornerstone of modern quantum compilers Amy, 2019Matthew Amy. 2019. Formal methods in Quantum Circuit Design. PhD Thesis. University of Waterloo Meijer., 2025Arianne Meijer - van de Griend. 2025. A comparison of quantum compilers using a DAG-based or phase polynomial-based intermediate representation. Journal of Systems and Software 221 (March 2025, 112224). doi: 10.1016/j.jss.2024.112224. Meanwhile, diagrammatic calculi, such as the ZX calculus, provide a flexible and theoretically robust framework for optimisations, often revealing simplifications invisible in the traditional gate-based model.


  1. If intrigued, look at this nice introduction Kottma., 2024Korbinian Kottmann. 2024. Introducing (dynamical) Lie algebras for quantum practitioners. (February 2024). Retrieved on 08/01/2025 from https://pennylane.ai/qml/demos/tutorial_liealgebra and the references therein. It’s not as scary as it sounds. ↩︎

  2. Experimental realisations of many-qubit interactions have also been demonstrated Erhard, 2019Alexander Erhard, Joel J. Wallman, Lukas Postler, Michael Meth, Roman Stricker, Esteban A. Martinez, Philipp Schindler, Thomas Monz, Joseph Emerson and Rainer Blatt. 2019. Characterizing large-scale quantum computers via cycle benchmarking. Nature Communications 10, 1 (November 2019). doi: 10.1038/s41467-019-13068-7 Bluvst., 2022Dolev Bluvstein, Harry Levine, Giulia Semeghini, Tout T. Wang, Sepehr Ebadi, Marcin Kalinowski, Alexander Keesling, Nishad Maskara, Hannes Pichler, Markus Greiner, Vladan Vuletić and Mikhail D. Lukin. 2022. A quantum processor based on coherent transport of entangled atom arrays. Nature 604, 7906 (April 2022, 451--456). doi: 10.1038/s41586-022-04592-6 Arrazo., 2021J. M. Arrazola, V. Bergholm, K. Brádler, T. R. Bromley, M. J. Collins, I. Dhand, A. Fumagalli, T. Gerrits, A. Goussev, L. G. Helt, J. Hundal, T. Isacsson, R. B. Israel, J. Izaac, S. Jahangiri, R. Janik, N. Killoran, S. P. Kumar, J. Lavoie, A. E. Lita, D. H. Mahler, M. Menotti, B. Morrison, S. W. Nam, L. Neuhaus, H. Y. Qi, N. Quesada, A. Repingon and et al. 2021. Quantum circuits with many photons on a programmable nanophotonic chip. Nature 591, 7848 (March 2021, 54--60). doi: 10.1038/s41586-021-03202-1 Evered, 2023Simon J. Evered, Dolev Bluvstein, Marcin Kalinowski, Sepehr Ebadi, Tom Manovitz, Hengyun Zhou, Sophie H. Li, Alexandra A. Geim, Tout T. Wang, Nishad Maskara, Harry Levine, Giulia Semeghini, Markus Greiner, Vladan Vuletić and Mikhail D. Lukin. 2023. High-fidelity parallel entangling gates on a neutral-atom quantum computer. Nature 622, 7982 (October 2023, 268--272). doi: 10.1038/s41586-023-06481-y and are at the core of other proposed architectures Bartol., 2023Sara Bartolucci, Patrick Birchall, Hector Bombín, Hugo Cable, Chris Dawson, Mercedes Gimeno-Segovia, Eric Johnston, Konrad Kieling, Naomi Nickerson, Mihir Pant, Fernando Pastawski, Terry Rudolph and Chris Sparrow. 2023. Fusion-based quantum computation. Nature Communications 14, 1 (February 2023). doi: 10.1038/s41467-023-36493-1 Bouras., 2021J. Eli Bourassa, Rafael N. Alexander, Michael Vasmer, Ashlesha Patil, Ilan Tzitrin, Takaya Matsuura, Daiqin Su, Ben Q. Baragiola, Saikat Guha, Guillaume Dauphinais, Krishna K. Sabapathy, Nicolas C. Menicucci and Ish Dhand. 2021. Blueprint for a Scalable Photonic Fault-Tolerant Quantum Computer. Quantum 5 (February 2021, 392). doi: 10.22331/q-2021-02-04-392↩︎

  3. Much of quantum error correction theory is built on the Clifford group, a subset of quantum operations that preserve “Pauli errors” and can thus be corrected easily. The flip side of this is that correcting any non-Clifford operation is very hard, something that is resolved by constructing “error-free” magic states ahead of time. For more details, refer to a quantum error correction textbook such as Gottes., 2024Daniel Gottesman. 2024. Surviving as a Quantum Computer in a Classical World. (February 2024). Retrieved on 08/01/2025 (lecture notes) from https://www.cs.umd.edu/class/spring2024/cmsc858G/QECCbook-2024-ch1-15.pdf↩︎

  4. Polynomial-sized quantum circuits constitute a polynomial-dimensional submanifold of the exponential-dimensional SU(2n)SU(2^n) Lie group. They are, hence, a measure zero subset of SU(2n)SU(2^n) with respect to the Haar measure. ↩︎

  5. and totally arbitrary! ↩︎

2.3. Rise of hybrid quantum-classical computation

Quantum measurements #

We have, until now, skipped over a crucial part of the quantum computation process: the role of quantum measurements. Quantum data, in isolation, is inherently inaccessible to us and the broader macroscopic world. A result from a quantum computation is only of value if we can probe it and get some readout value that we can display to the user or return to whoever launched the quantum computation.

Quantum physics measurements fundamentally differ from our classical understanding of just “reading out” data that is already there. This is the famous Schrödinger’s cat thought experiment of quantum mechanics: what data is within the qubits remains undefined until a measurement is performed. The act of observation will transform the quantum data: looking inside the box will, at random, either kill the cat or spare it1.

We thus need to add the measurement operation as a special case to our computer scientist’s model of quantum computing. Unlike purely quantum operations, measurements inherently involve interaction with the environment to produce a readout. Consequently, the no-delete and reversibility principles discussed earlier do not apply. Indeed, measurement is a lossy (and therefore irreversible) operation that projects the quantum state into one of a small subset of classical states. Which state the quantum state is projected into is non-deterministic. If one has access to an infinite supply of the same quantum state, then the whole state can be reconstructed by repeating measurements and analysing the distribution of outcomes2. Given no-cloning, however, this is unlikely to be the case, and so the full quantum result is hardly ever known. Instead, we must rely on well-designed measurement schemes to extract useful information from our partial access to the quantum states.

We model measurement as an operation that takes one qubit and outputs one purely classical bit3. In the circuit formalism, measurements are often implicitly added at the end of every qubit. Suppose we wish to make them explicit or add them elsewhere in the computation. In that case, we must introduce a graphical representation for the classical bit of data the measurement produces. The field has adopted the double-wire for this, even though a “half” wire would arguably have been more appropriate to reflect the reduced information content relative to quantum wires. I present to you the measurement box:

Measurements as first-class citizens #

It is very tempting to our feeble classical brains – and admittedly, we just did it ourselves in the previous paragraphs – to view measurements as merely a readout operation, an auxiliary operation that we are forced to perform at the end of a computation for operative reasons. This could not be further from the truth! In many ways, measurements are just as powerful tools as any other quantum operation – if not more so!

One eye-opening perspective on this is the field of measurement-based quantum computing (MBQC). Raussendorf and Briegel showed indeed Rausse., 2001Robert Raussendorf and Hans J. Briegel. 2001. A One-Way Quantum Computer. Physical Review Letters 86, 22 (May 2001, 5188--5191). doi: 10.1103/PhysRevLett.86.5188 that arbitrary quantum computations can be reproduced in the MBQC framework using only some resource quantum states that can be prepared ahead of time and measurements! In other words, given entangled qubits, measurements are all you need to perform quantum operations.

We will not explore MBQC further in this chapter (nor in this thesis, for that matter). Instead, we will use this as a motivation to explore what we can achieve with measurements. We have so far spared you from any mathematical alphabet soup. As we start discussing more concrete constructions of quantum computations, some introductory linear algebra and conventions around notation will become unavoidable.

Dirac formalism. Quantum states are nearly unanimously written using kets: instead of referring to a quantum state as ψ\psi, we write it wrapped in special brackets as ψ\ket{\psi}. This notation is also used when referring to the 00 and 11 states of qubits, written 0\ket{0} and 1\ket{1}.

Several states can be joined and considered together as one overall state. This is expressed using the tensor \otimes symbol: ψ1ψ2\ket{\psi_1} \otimes \ket{\psi_2} is the joint system of ψ1\ket{\psi_1} and ψ2\ket{\psi_2}. When the states in question are all explicitly qubit states, we use the shorthand binary notation 010=010\ket{0} \otimes \ket{1} \otimes \ket{0} = \ket{010}.

We will introduce more notation along the way.

With this out of the way, let us look in more details at the first smart use of measurements: the block-encoding technique. Consider the following scenario: you would like to perform an operation AA on an arbitrary quantum state ψ\ket{\psi}. Now, there are, unfortunately, many cases where implementing AA as a quantum circuit made of primitive gates that can be executed on hardware is very expensive4.

However, what we can always do is express AA as a matrix of dimensions 2n×2n2^n \times 2^n, where nn is the number of qubits in the state ψ\ket{\psi}. Then, there is a neat trick that we can sometimes apply: instead of trying to execute AA, we enlarge the matrix to a bigger A~\tilde{A}:

A~=(AG1G2G3)\tilde{A} = \begin{pmatrix}A & G_1\\ G_2 & G_3 \end{pmatrix}

where G1,G2G_1, G_2 and G3G_3 are “garbage” matrices that we do not care about, but should combine into a matrix A~\tilde{A} that we know how to execute on a quantum computer. Quantum computations must be matrices with a row and column number that is a power of two; so at a minimum, A~\tilde{A} must be of size 2n+1×2n+12^{n+1} \times 2^{n+1}, i.e. be a computation on n+1n + 1 qubits.

We restrict our considerations in the following to the case on m=n+1m = n + 1 qubits – other cases are similar. We thus need to add a qubit to our ψ\ket\psi state to be able to pass it to our new operation. Such qubits that are added temporarily to facilitate a computation are a recurring feature in quantum computing and have thus earned themselves a name – ancilla qubits.

Let us take a look at the quantum states that result from executing A~\tilde{A}. If we add to ψ\ket \psi a 0\ket 0 ancilla state, our quantum operation acts as5

A~(0ψ)=0Aψ+1G1ψ.\tilde{A} (\ket 0 \otimes \ket \psi) = \ket 0 \otimes A \ket \psi + \ket 1 \otimes G_1 \ket \psi.

The expression AψA \ket \psi means the operation AA applied to ψ\ket \psi – exactly the output state we are seeking. If we input the ancilla qubit in state 1\ket 1, we get garbage:

A~(1ψ)=0G2ψ+1G3ψ.\tilde{A} (\ket 1 \otimes \ket \psi) = \ket 0 \otimes G_2 \ket \psi + \ket 1 \otimes G_3 \ket \psi.

So 0ψ\ket 0 \otimes \ket \psi is definitely the input state we are more interested in.

How can we recover AA from (1)? This is precisely what measurements do! When quantum states are expressed as sum of states, the terms of the sum form the possible measurement outcomes6. If we only measure a subset of the qubits, then the term corresponding to that measurement is isolated and all other terms disappear. Hence, if we measure the first qubit (that we introduced ourselves) in the zero state, then the remaining nn qubits will be precisely in the desired state Aψ.A \ket \psi. Success!

Using this “term isolating” property of measurements, known as state collapse, we can thus effect computations that would have been otherwise difficult or impossible to perform. There is however one important wrinkle that we cannot forget about: measurements are non-deterministic! We cannot assume that all measurements of the ancilla qubit will return the zero state. When 1\ket 1 is measured on the ancilla, the remaining qubits are left in the G1ψG_1 \ket\psi state. The computation has thus failed, and the execution must be aborted and restarted. How often the block-encoding protocol that we have presented fails depends on the details of AA and the choices of G1,G2G_1, G_2 and G3G_3 and is the main disadvantage of an otherwise very powerful quantum technique.

We will now explore two strategies to deal with “fails” in measurements. At the core of them is the idea of hybrid quantum-classical programs.

Who said quantum computers could not fix their mistakes #

Failed computations are an expensive mistake in quantum computing as the no-cloning theorem prevents us from keeping a “backup” of the initial state. The fact that failures are in fact unlucky measurement outputs makes matters worse, given that measurements are the only irreversible quantum operation. It is therefore impossible in general to recover from a “wrong” measurement.

There are, however, prominent cases in which the computation can be corrected based on the measurement outcome, thus yielding deterministic results. Recall equation (1) of the previous section: there is a computation AA on nn qubits, that can be probabilistically computed using m=n+1m = n + 1 qubits using A~\tilde{A}:

A~(0ψ)=0(Aψ)+1(Gψ),\tilde{A} (\ket 0 \otimes \ket \psi) = \ket 0 \otimes (A\ket\psi) + \ket 1 \otimes (G\ket\psi),

for some “garbage” GG. What if GG is a reversible operation, i.e. there is an operation G1G^{-1} to undo GG? Well then, we can still, at least in theory, recover AψA\ket \psi by applying AG1A \circ G^{-1}:

Gψ(AG1)Gψ=Aψ,G \ket \psi \mapsto (A \circ G^{-1}) \circ G \ket \psi = A \ket \psi,

but only if 1 was measured on the ancilla qubit7!

This is the beginning of quantum-classical hybrid computing: we start by performing quantum operations followed by measurements, the outcomes of which dictate what further quantum operations must be applied. We define for this purpose a classically controlled gate: a quantum operation that is only executed if a certain classical bit (the condition) is set. This bit will typically be a value derived from a previous measurement: it could be as simple as the outcome that a previous measurement yield, or a function of multiple past outcomes that must be evaluated on classical hardware (e.g. a CPU).

Mixing classical and quantum operations is a sure way to bring the quantum circuit representation to its knees. We adopt the following representation, in which a quantum gate that has an additional classical bit wire attached to it represents a classically controlled operation that is only executed if the bit value is 1.

Quantum Teleportation #

Quantum teleportation is a simple example of performing classically controlled quantum operations to do circuit corrections based on measurement outcomes. It is also coincidentally one of the most fundamental protocols of quantum theory. Its name is slightly misleading. Think of it as data transfer for quantum data, with a mind-bending twist: at the time of the transfer, only classical data must be communicated between the sending and receiving parties. As a result of this protocol, quantum information can be transferred using plain old-school copper wires (or any other classical communication channels)!

This is predicated on one crucial action being performed before the start of the communication. For every qubit that should be transmitted, the parties must beforehand create and share among themselves a pair of qubits that will serve as the quantum resource during the protocol execution. This resource state is widespread enough that it got its name: the Bell pair state. It is written in Dirac notation as 00+11\ket{00} + \ket{11}. As the notation indicates, it is a state with perfectly correlated measurements: when measured, the two qubits will always yield the same outcome, either both 0 or both 1.

There turns out to be a straightforward circuit that maps the two-qubit 00\ket {00}, which every two-qubit computation starts in, into the Bell pair state:

It is enough for us to think of it as a black box – or a grey box in this case.

We are interested in “teleporting” an arbitrary, single-qubit quantum state. Such a state can always be expressed as ψ=α0+β1\ket \psi = \alpha \ket 0 + \beta \ket 1, i.e. in the most general case, a one-qubit state will be in some superposition of the states 0\ket 0 and 1\ket 1. The paramenters α\alpha and β\beta are complex coefficients that encode the probabilities of measuring 0 or 1 – we can view them as the weights of a weighted sum.

We are now interested in combining a Bell resource state in a joint system with the arbitrary state ψ\ket \psi. The resulting three-qubit state is obtained with the \otimes operation, which distributes over sums just like usual multiplication:

(00+11)first two qubits(α0+β1)third qubit= α000+α110+β001+β111.\begin{aligned} &\underbrace{(\ket {00} + \ket {11})}_{\text{first two qubits}} \otimes \underbrace{(\alpha \ket 0 + \beta \ket 1)}_{\text{third qubit}}\\=\ &\alpha \ket {000} + \alpha \ket {110} + \beta \ket {001} + \beta \ket {111}.\end{aligned}

We chose to place the Bell pair on the first two qubits and the arbitrary state on the third. The goal is to move the data that sits on that last qubit to the first qubit. Looking at the first qubit in the above expression, notice that the desired state ψ=α0+β1\ket \psi = \alpha \ket 0 + \beta \ket 1 appears in the first qubit if we can discard the second and third terms:

α000+(α110+β001)+β111\alpha \ket{\underline{\mathbf{0}}00} + {\color{gray}(\alpha \ket {110} + \beta \ket {001})} + \beta \ket{\underline{\mathbf{1}}11}

This sounds very much like the measurement operations we have used before to isolate terms – but we need to isolate two terms simultaneously. We can resolve this issue by reorganising the expression8

α000+α110+β001+β111= (α0+β1)=ψ(00+11)Bell pair+(β0+α1)(01+10)+(α0β1)(0110)+(β0α1)(0011)\begin{aligned}&\alpha \ket{000} + \alpha \ket{110} + \beta \ket {001} + \beta \ket {111}\\ =\ &\underbrace{(\alpha \ket 0 + \beta \ket 1)}_{= \ket \psi}\otimes \underbrace{( \ket {00} + \ket {11})}_{\text{Bell pair}}\\&+(\beta \ket 0 + \alpha \ket 1) \otimes (\ket {01} + \ket {10})\\&+(\alpha\ket 0 - \beta \ket 1) \otimes (\ket{01} - \ket {10})\\&+(\beta \ket 0 - \alpha \ket 1) \otimes (\ket {00} - \ket {11})\end{aligned}

Obtaining the ψ\ket \psi state on the first qubit is thus as simple as isolating the first of these four terms. We do not know a priori how to measure 00+11\ket {00} + \ket{11} but we do know how to map that state to 00\ket {00}: that’s the inverse of the Bell pair state preparation circuit! This results in the following circuit:

This brings us to the same situation as we had for the block encoding application above: conditioned on the measurement outcome of the second and third qubits being 0, the computation performs a state “teleportation”, moving ψ\ket \psi from the third to the first qubit. We can compute the effect of Bell1\textit{Bell}^{-1} on the overall expression of (2) to find all possible output states:

α000+α110+β001+β111Bell1(α0+β1)00+(β0+α1)01+(α0β1)10+(β0α1)11\begin{aligned}\alpha \ket {000} + \alpha \ket {110} + \beta \ket {001} + \beta \ket {111} \overset{\textit{Bell}^{-1}}{\mapsto}&(\alpha \ket 0 + \beta \ket 1) \otimes \ket {00} \\&+ (\beta \ket 0 + \alpha \ket 1) \otimes \ket {01} \\& + (\alpha \ket 0 - \beta \ket 1) \otimes \ket {10} \\&+ (\beta \ket 0 - \alpha \ket 1) \otimes \ket {11}\end{aligned}

As expected, we do get ψ\ket \psi on the first qubit for the measurement 00 (corresponding to the state 00\ket {00}), but as it stands, this only has a 14\frac{1}{4} probability of success.

You might notice, however, that the other states in which the first qubit can end up look remarkably similar, up to some sign flips and swaps 01\ket 0 \leftrightarrow \ket 1. In particular, all states still have the amplitudes α\alpha and β\beta somewhere, so it does not seem unfathomable that these “wrong” states can be mapped back to ψ\psi.

We can use the measurement outcomes of the second and third qubit to infer which of the “mistakes” occurred, and hence what state the first qubit has ended in. The 01 measurement outcome, for instance, results in the β0+α1\beta \ket 0 + \alpha \ket 1 state – this is just a bit flip away from ψ\ket \psi! This gate is known as XX. Its colleague the ZZ gate on the other hand leaves 0\ket 0 states untouched but flips the sign of 1.\ket 1. This would fix the 10 outcome. Finally, 11 requires both a Z and a X correction.

Putting these observations together, we can leverage classically controlled operations to obtain a fully deterministic protocol! The correct circuit implementing quantum teleportation is given by

In the scenario where a first party (Alice) wants to send a one-qubit quantum state to Bob, they can achieve that by creating a Bell pair state, the first qubit of which is given to Bob and the second to Alice. When Alice then gets in possession of another qubit ψ\ket \psi whose data she wants to transmit to Bob, she can achieve that by executing Bell1\textit{Bell}^{-1}, measuring her two qubits and communicating the (classical) measurement outcomes to Bob. Bob can perform the necessary corrections and will then have state ψ\ket \psi.

It is beautiful and often overlooked how one of the most fundamental protocols of quantum information theory is, in fact, a hybrid classical-quantum computation. Quantum teleportation without classical communication is physically impossible: it would let Alice communicate with Bob instantly, even though he could be light years away – in other words, it would fundamentally break relativity.

Repeat until success: If you fail, retry! #

Classical computer science has a straightforward solution whenever probabilistic computations that can fail are used: probability amplification or boosting Scheid., 2018Christian Scheideler. 2018. Probability amplification. Retrieved lecture notes, online, visited 30/12/2024 from https://cs.uni-paderborn.de/fileadmin-eim/informatik/fg/ti/Lehre/SS_2018/AA/lecture_5.pdf. The idea is so simple that it barely deserves a name: execute several independent runs of the computation and choose the most common outcome. If the probability of failure is below a certain threshold (e.g. 50% for a binary output), then with basic statistics, one can extrapolate the number of runs required to obtain any desired accuracy9.

We have been ignoring this approach so far since no-cloning prohibits us from repeating a procedure more than once on an input state ψ\ket\psi. However, in the scenario that the computation should only be executed on a specific, known input state and the computation that prepares that state is known, we can recover from computation failures by just preparing a new state identically.

Suppose we know how to execute the quantum computation PP mapping

00P00=ψ.\ket{0\cdots 0} \mapsto P \ket {0\cdots0} = \ket \psi.

As before, we would like to compute AA given an implementation of the computation A~\tilde{A} that acts on a nn-qubit state ψ\ket\psi and an ancilla qubit in the 0\ket 0 state. If the measurement of A~(0ψ)\tilde{A}(\ket 0 \otimes \ket \psi) returns 1, then the computation failed. We can then discard all qubits and restart from the 0\ket 0 state, applying PP followed by A~\tilde{A} and an ancilla measurement, repeating until we measure 0. As a pseudo-quantum circuit, we could express this as:

psi_qs = create_qubits(n)
while True:
   ancilla_q = create_qubit()
   obtain measurement m from:



    if m == 0:
        break  # success! we can exit loop and proceed
    else:
        reset_qubits(psi_qs)

At each iteration, we can either exit the loop if the state collapse was successful (m == 0), or reset the qubits to zero and try again. But pseudo circuits do not run on hardware! The only way to express this computation as an actual circuit is to unroll the loop, i.e. repeat the block within the loop as many times as we expect might be necessary10. The first two iterations would look as follows:

It should be obvious why we haven’t unrolled the loop any further – it quickly becomes unweildy. The resulting program is not only hard to display and read, but it also suffers from fundamental issues in practice. For one, the program size becomes hugely bloated, and beyond slowing down the compiler, it will also cause a host of issues on the control hardware in real-time, such as long load times, inefficient execution, and low cache efficiency.

Even more worryingly, when picking the maximum number of iterations, we face an impossible tradeoff: if the number of iterations is small, then the probability of failure will remain non-negligible. As we scale this value up, however, we are introducing more and more gates into the program to cover the odd case of multiple successive repeated failures. We do not intend to execute these gates on most computation runs. They come at a significant cost to the runtime. For each gate listed in the circuit, the condition for the gate’s execution must be checked, whether or not the gate ends up being executed. Furthermore, hardware schedulers might be forced to be pessimistic and schedule a time window for all conditional operations ahead of time. This will significantly delay any operation to be performed after the loop.

We, therefore, argue that the quantum circuit model is ill-suited as the representation for quantum programs that combine classical and quantum data. Such programs, however, are a fundamental building block towards developing meaningful large-scale quantum computations and are bound to become the norm. Beyond the examples discussed above—–including block-encodings, repeat-until-success schemes, distributed quantum computing and measurement-based quantum computing – one application of hybrid quantum-classical operations stands out as critically important for the large-scale deployment of quantum computing: quantum error correction (QEC) schemes. We discuss this use case in the next section.


  1. It is ironic that Schrödinger’s thought experiment Schrö., 1935Erwin Schrödinger. 1935. Die gegenwärtige Situation in der Quantenmechanik. Naturwissenschaftern, intended to highlight the absurdity of quantum mechanics, has become the field’s most famous PR campaign. Sorry to disappoint – you won’t find felines occupying multiple states of existence (though qubits do!) ↩︎

  2. This is known as state tomography Allahv., 2004A. E. Allahverdyan, R. Balian and Th. M. Nieuwenhuizen. 2004. Determining a Quantum State by Means of a Single Apparatus. Physical Review Letters 92, 12 (March 2004, 120402). doi: 10.1103/PhysRevLett.92.120402. One must perform measurements in multiple bases, i.e., different choices of classical states to project to. ↩︎

  3. Where did the qubit go? All the information in a qubit post-measurement is also contained in the classical bit of output data – it is, therefore, redundant and renders the qubit useless. In our model, we, therefore, bundle measurement and qubit discard into one operation. ↩︎

  4. or outright impossible, in cases where AA is not a unitary linear operation, for example. ↩︎

  5. This is obtained by a simple matrix multiplication. The vector representation of the quantum state 0ψ\ket 0 \otimes \psi is obtained using the Kronecker product. You can also just trust me that this works out this way. ↩︎

  6. This is simplifying slightly. There is a necessary condition for this to be a valid measurement: the states in the sum must form a measurement basis, i.e. they must be orthogonal. This is satisfied here. ↩︎

  7. Notice that, informally, we would hope to get a computation GG such that GAG \approx A in the sense that it should somehow be closely related to AA. This way, the resulting correction AG1IdA \circ G^{-1} \approx Id would be close to the identity, and would be cheap to compute. ↩︎

  8. Apologies, it seems at this point that we are conjuring up a complex expression out of nowhere. It is in fact just a change of basis – plain old linear algebra. The formula can be obtained easily by writing out the basis change matrix. ↩︎

  9. This is fiendishly effective: the Hoeffding bounds guarantee that the probability of success will converge to 1 exponentially with the number of runs. ↩︎

  10. In other words, we must pick a constant MM for the maximum number of times we expect the loop to be executed. If a single loop iteration has a failure probability of pp, the failure probability of the program with MM unrolled iteration is then pMp^M↩︎

2.4. Quantum compilers cannot do it alone

We have (hopefully!) by now convinced our readership that quantum programs must interface with our established classical infrastructure and should rather be understood as an interleaved execution of both classical and quantum operations. The obvious question that thus poses itself is

How do we equip quantum compilers to deal with classical operations?

The simplest solution is to adopt the extended quantum circuit formalism with support for classically controlled operations, as we have introduced in the previous section. Using this representation, the basic types available for computation are the qubit and the classical bit. We can also, at that point, introduce purely classical operations on bits, for instance, to compute boolean logic on measurement outcomes, such as “if both the first AND the second measurement outcomes are 1, then …”.

However, the circuit model is inherently designed with the no-cloning principle in mind: specifically, with the assumption that at any one time, there are exactly nn (for some fixed value of nn) resources available for computation. This for example means that in the following program

in which two measurements write to the same classical bit, it would be impossible to append a gate controlled on the first measurement outcome after the ZZ gate, as that value was overwritten on the classical wire by the second measurement. The solution could be to introduce1 a new, fresh classical wire for each measurement and avoid overwriting outcomes. However, there are also many other ways to break this wires-based representation: suppose you have an operation with one input and two outputs, such as a copy operation x(x,x)x \mapsto (x,x). We would need two wires for the output, but the input would only provide us with one… We now have to start creating additional wires ahead of time for this purpose and solve memory allocation problems to decide which wire should be given to which operation.

These are run-of-the-mill classical compiler problems! One might at first hope that the set of overlapping problems between classical and quantum compilers is manageably small. After all, in all the use cases we have covered so far, the amount of classical computation was very minimal, limiting itself to conditionals and loops based on simple boolean expressions. Surely the full-blown powers of a classical compiler are not required!

Unfortunately (and as usual), scientists have shown no lack of imagination in this field – and so have found very compelling use cases for complex classical computations within quantum programs. To drive this point home, let us consider the concrete example of quantum error correction.

The quantum error correction use case #

Error-correcting protocols do as their name suggests: they detect whenever data is subjected to errors and thus modified in an unexpected way. They then attempt to recover the intended valid state. In the classical world, such schemes are employed whenever the hardware is not reliable enough: this is hardly the case for computations themselves but is widespread in communications (e.g. within the TCP/IP protocol for the internet Eddy, 2022Wesley Eddy. 2022. Transmission Control Protocol (TCP). (August 2022). Retrieved as RFC 9293 from https://www.rfc-editor.org/info/rfc9293) or for memory and storage in critical applications.

No one expects to be able to manipulate matter-based qubits without introducing errors for a very long time. Photons, on the other hand, are prone to data losses throuh absorption and can only be entangled using complex and noisy schemes such as the Knill–Laflamme–Milburn protocol Knill, 2001E. Knill, R. Laflamme and G. J. Milburn. 2001. A scheme for efficient quantum computation with linear optics. Nature 409, 6816 (January 2001, 46--52). doi: 10.1038/350510092. Simply put, it is safe to assume that error correction will be found everywhere – as soon as our quantum computers manage to implement such protocols.

A sketch of quantum error correction goes roughly as follows: the data that would be stored on kk qubits is instead encoded in a redundant way on a larger number n>kn > k of qubits. Thus, when errors occur on a subset of the nn qubits, the data can be restored using the qubits that have not been corrupted. Before errors can be corrected, they must be detected. To this end, we first add fresh ancilla qubits to the program. Through smartly designed interactions with the data qubits, the ancilla qubits pick up the errors from the data. When we subsequently perform measurements on the ancilla qubits, these errors result in modified outcomes, called the error syndrome.

The challenging bit comes next: from a run of syndrome measurements, one must infer the most likely errors – a step known as syndrome decoding. This is a purely classical maximum likelihood problem that requires a non-trivial amount of computations to resolve. For small problem instances, all possible input syndromes can be tabled, and the outputs precomputed – in which case the problem at runtime is reduced to fast table lookups. However, the higher the fault tolerance we require, the more qubits must be used in the encodings, and so invariably, the problem quickly becomes very demanding computationally.

Meanwhile, these “cycles” of error detection and correction are under strict latency constraints: idling qubits waiting for corrections to be applied will accumulate new errors that must themselves be corrected – for error correction to be workable, we must be capable of detecting and correcting for errors faster than they are being introduced. The entire error correction cycle just described can be summarised by the following diagram:

q a u n b c i i t l s l a c i r c u i t p r o e p r a r g o a r t i o n m s e y a n s d u r r o e m m e e n t s d y e n t d e r c o t m i e o c n o r r e c t i o n

The decoding time is a crucial factor in determining the overall cycle time and, thus, the clock rate of fault-tolerant quantum hardware. Consider, for example, a 32-qubit Toric code Kitaev, 2003A.Yu. Kitaev. 2003. Fault-tolerant quantum computation by anyons. Annals of Physics 303, 1 (January 2003, 2--30). doi: 10.1016/S0003-4916(02)00018-0, one of the most well-studied quantum error-correcting codes. Without going into the details of the code itself, we can use the C++ implementation made available by the MQT toolkit Burgho., 2021Lukas Burgholzer and Robert Wille. 2021. Advanced Equivalence Checking for Quantum Circuits. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 40, 9 (Septempter 2021, 1810--1824). doi: 10.1109/tcad.2020.3032630 to study the decoder performance for this code.

Consider first a “naive” compilation of the decoder – the kind of program that we could hope to get from a quantum compiler that “understands” classical operations but only implements optimisations directly relevant to quantum computations. Such a compiler does not currently exist, but the decoder being a C++ program, we can approximate what the compiled binary would look like by turning off all optimisations from an established classical compiler3.

The runtime averaged over 1000 runs of the decoder is 0.73±0.06ms0.73\pm0.06\,ms. This is within the latency requirements of certain trapped ion architectures Ryan-A., 2021C. Ryan-Anderson, J. G. Bohnet, K. Lee, D. Gresh, A. Hankin, J. P. Gaebler, D. Francois, A. Chernoguzov, D. Lucchetti, N. C. Brown, T. M. Gatterman, S. K. Halit, K. Gilmore, J. A. Gerber, B. Neyenhuis, D. Hayes and R. P. Stutz. 2021. Realization of Real-Time Fault-Tolerant Quantum Error Correction. Physical Review X 11, 4 (December 2021, 041058). doi: 10.1103/physrevx.11.041058, but far beyond the sub-microsecond regime that will be required to make error correction a reality on superconduction-based quantum computers Carrer., 2024Almudena Carrera Vazquez, Caroline Tornow, Diego Ristè, Stefan Woerner, Maika Takita and Daniel J. Egger. 2024. Combining quantum processors with real-time classical communication. Nature 636, 8041 (November 2024, 75--79). doi: 10.1038/s41586-024-08178-2. this can be contrasted with the program output by the same compiler, but with all compiler optimisations enabled: the average runtime is reduced by a factor close to 10x to 0.078±0.004ms0.078\pm0.004\,ms – still a factor 100x away from the required performance on superconductors, but huge gains nonetheless! The details of the experiment with all build flags, the hardware used and how to reproduce the results are available here.

There is no hope of obtaining these types of speedups without an in-depth understanding of classical hardware and battle-tested implementations for every optimisation pass under the sun – in short, the full thrust of a modern state-of-the-art compiler such as clang or gcc.

To make matters worse, such classical computations are bound to move to dedicated accelerators that require specialised compilation, such as GPUs and FPGAs, for the most time-critical subroutines: quantum error decoding using GPUs is already well-developed Bausch, 2024Johannes Bausch, Andrew W. Senior, Francisco J. H. Heras, Thomas Edlich, Alex Davies, Michael Newman, Cody Jones, Kevin Satzinger, Murphy Yuezhen Niu, Sam Blackwell, George Holland, Dvir Kafri, Juan Atalaya, Craig Gidney, Demis Hassabis, Sergio Boixo, Hartmut Neven and Pushmeet Kohli. 2024. Learning high-accuracy error decoding for quantum processors. Nature 635, 8040 (November 2024, 834--840). doi: 10.1038/s41586-024-08148-8 Cao, 2023Hanyan Cao, Feng Pan, Yijia Wang and Pan Zhang. 2023. qecGPT: decoding Quantum Error-correcting Codes with Generative Pre-trained Transformers. arXiv: 2307.09025 [quant-ph] and more esoteric platforms FPGAs Overwa., 2022Ramon W. J. Overwater, Masoud Babaie and Fabio Sebastiano. 2022. Neural-Network Decoders for Quantum Error Correction Using Surface Codes: A Space Exploration of the Hardware Cost-Performance Tradeoffs. IEEE Transactions on Quantum Engineering 3 (1--19). doi: 10.1109/tqe.2022.3174017 Meinerz, 2022Kai Meinerz, Chae-Yeun Park and Simon Trebst. 2022. Scalable Neural Decoder for Topological Surface Codes. Physical Review Letters 128, 8 (February 2022, 080505). doi: 10.1103/physrevlett.128.080505, superconducting circuits Ueno, 2021Yosuke Ueno, Masaaki Kondo, Masamitsu Tanaka, Yasunari Suzuki and Yutaka Tabuchi. 2021. QECOOL: On-Line Quantum Error Correction with a Superconducting Decoder for Surface Code. In 2021 58th ACM/IEEE Design Automation Conference (DAC), December 2021. IEEE, 451--456. doi: 10.1109/dac18074.2021.9586326 and compute-in-memory architectures Wang, 2024Hao Wang, Erjia Xiao, Songhuan He, Zhongyi Ni, Lingfeng Zhang, Xiaokun Zhan, Yifei Cui, Jinguo Liu, Cheng Wang, Zhongrui Wang and Renjing Xu. 2024. CIM-Based Parallel Fully FFNN Surface Code High-Level Decoder for Quantum Error Correction. arXiv: 2411.18090 [cs.AR] are being actively studied.

These observations should leave the reader convinced that in order to compile and realise the kind of hybrid quantum-classical programs that we expect will become the norm in the field, quantum compilers will need to embrace and encompass the full breadth and depth of classical compilers. This leaves us with no choice but to fully transform and integrate the existing quantum tooling and quantum optimisation research into the established compiler ecosystem. What this means exactly is the subject of the rest of this chapter.

A new quantum programming paradigm? #

We have seen it – quantum circuits are very limited in their expressiveness. They are well suited to presenting sequences of purely quantum operations and how the computation is parallelised across qubits, but they quickly become limiting once both quantum and classical data types are mixed and any type of control flow (conditionals, loops, function calls, etc.) is introduced.

How users express programs in the front end has deep implications for the kind of computations that the compiler must be capable of reasoning about and, hence, for the compiler’s architecture. The great merging of classical and quantum compilers is the perfect opportunity to reconcile program representations and integrate the learnings from decades of classical programming language research into quantum computing.

There have been several trailblazing initiatives to formalise quantum programming and create dedicated languages, such as QCL Ömer, 2000Bernhard Ömer. 2000. Quantum Programming in QCL. (January 2000). Retrieved from http://tph.tuwien.ac.at/ oemer/doc/quprog.pdf, Quipper Green, 2013Alexander S. Green, Peter LeFanu Lumsdaine, Neil J. Ross, Peter Selinger and Benoît Valiron. 2013. Quipper: a scalable quantum programming language. In Proceedings of the 34th ACM SIGPLAN Conference on Programming Language Design and Implementation, June 2013, New York, NY, USA. Association for Computing Machinery, 333--342. doi: 10.1145/2491956.2462177 Rios, 2018Francisco Rios and Peter Selinger. 2018. A Categorical Model for a Quantum Circuit Description Language (Extended Abstract). Electronic Proceedings in Theoretical Computer Science 266 (February 2018, 164--178). doi: 10.4204/eptcs.266.11 Fu, 2023Peng Fu, Kohei Kishida, Neil J. Ross and Peter Selinger. 2023. Proto-Quipper with Dynamic Lifting. Proceedings of the ACM on Programming Languages 7, POPL (January 2023, 309--334). doi: 10.1145/3571204, Q# Micros., 2024 Microsoft. 2024. Introduction to the quantum programming language Q#. Retrieved on 31/12/2024 from https://learn.microsoft.com/en-us/azure/quantum/qsharp-overview and Silq Bichsel, 2020Benjamin Bichsel, Maximilian Baader, Timon Gehr and Martin Vechev. 2020. Silq: a high-level quantum language with safe uncomputation and intuitive semantics. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation, June 2020. ACM, 286--300. doi: 10.1145/3385412.3386007. Their adoption in the quantum ecosystem have so far remained limited, overshadowed by the popularity of python-based APIs for quantum circuit-based representations, as offered by Qiskit Javadi., 2024Ali Javadi-Abhari, Matthew Treinish, Kevin Krsulich, Christopher J. Wood, Jake Lishman, Julien Gacon, Simon Martiel, Paul D. Nation, Lev S. Bishop, Andrew W. Cross, Blake R. Johnson and Jay M. Gambetta. 2024. Quantum computing with Qiskit. arXiv: 2405.08810 [quant-ph], Pennylane Bergho., 2022Ville Bergholm, Josh Izaac, Maria Schuld, Christian Gogolin, Shahnawaz Ahmed, Vishnu Ajith, M. Sohaib Alam, Guillermo Alonso-Linaje, B. AkashNarayanan, Ali Asadi, Juan Miguel Arrazola, Utkarsh Azad, Sam Banning, Carsten Blank, Thomas R Bromley, Benjamin A. Cordier, Jack Ceroni, Alain Delgado, Olivia Di Matteo, Amintor Dusko, Tanya Garg, Diego Guala, Anthony Hayes, Ryan Hill, Aroosa Ijaz, Theodor Isacsson, David Ittah, Soran Jahangiri, Prateek Jain, Edward Jiang, Ankit Khandelwal, Korbinian Kottmann, Robert A. Lang, Christina Lee, Thomas Loke, Angus Lowe, Keri McKiernan, Johannes Jakob Meyer, J. A. Montañez-Barrera, Romain Moyard, Zeyue Niu, Lee James O'Riordan, Steven Oud, Ashish Panigrahi, Chae-Yeun Park, Daniel Polatajko, Nicolás Quesada, Chase Roberts, Nahum , Isidor Schoch, Borun Shi, Shuli Shu, Sukin Sim, Arshpreet Singh, Ingrid Strandberg, Jay Soni, Antal Száva, Slimane Thabet, Rodrigo A. Vargas-Hernández, Trevor Vincent, Nicola Vitucci, Maurice Weber, David Wierichs, Roeland Wiersema, Moritz Willmann, Vincent Wong, Shaoming Zhang and Nathan Killoran. 2022. PennyLane: Automatic differentiation of hybrid quantum-classical computations. arXiv: 1811.04968 [quant-ph] and Cirq Cirq D., 2024 Cirq Developers. 2024. Cirq. There is, as a result, a justified dose of scepticism in the quantum community on how well the ideas from classical programming really translate to quantum.

It is thus all the more notable that we are seeing a new generation of quantum programming tooling being developed Koch, 2024Mark Koch, Alan Lawrence, Kartik Singhal, Seyon Sivarajah and Ross Duncan. 2024. GUPPY: Pythonic Quantum-Classical Programming. (January 2024). Retrieved (talk recording) from https://www.youtube.com/live/D8esZrt7ogk?feature=shared&t=31448 Ittah, 2024David Ittah, Ali Asadi, Erick Ochoa Lopez, Sergei Mironov, Samuel Banning, Romain Moyard, Mai Jacob Peng and Josh Izaac. 2024. Catalyst: a Python JIT compiler for auto-differentiable hybrid quantum programs. Journal of Open Source Software 9, 99 (July 2024, 6720). doi: 10.21105/joss.06720 CUDA-Q., 2024 CUDA-Q Developers. 2024. CUDA-Q Documentation. Retrieved on 31/12/24 from https://nvidia.github.io/cuda-quantum/latest/index.html, driven by the need to write more expressive programs for the improving hardware (as we have been discussing), as well as for performance reasons, to scale quantum compilation to large scale Ittah, 2022David Ittah, Thomas Häner, Vadym Kliuchnikov and Torsten Hoefler. 2022. QIRO: A Static Single Assignment-based Quantum Program Representation for Optimization. ACM Transactions on Quantum Computing 3, 3 (June 2022, 1--32). doi: 10.1145/3491247, accelerate quantum simulations Ittah, 2024David Ittah, Ali Asadi, Erick Ochoa Lopez, Sergei Mironov, Samuel Banning, Romain Moyard, Mai Jacob Peng and Josh Izaac. 2024. Catalyst: a Python JIT compiler for auto-differentiable hybrid quantum programs. Journal of Open Source Software 9, 99 (July 2024, 6720). doi: 10.21105/joss.06720 and integrate with classical high-performance computing (HPC) NVIDIA, 2024 NVIDIA. 2024. NVIDIA Accelerates Quantum Computing Centers Worldwide With CUDA-Q Platform. Retrieved on 31/12/2024 from https://investor.nvidia.com/news/press-release-details/2024/NVIDIA-Accelerates-Quantum-Computing-Centers-Worldwide-With-CUDA-Q-Platform/default.aspx.

The history of programming is, first and foremost, a masterclass in constructing abstractions. Many of the higher-level primitives, that have proven invaluable classically, solve problems that we expect to encounter very soon in our hybrid programs – when we have not already. Examples include

  • structured control flow to simplify reasoning about branching in quantum-classical hybrid programs,
  • type systems to encode program logic and catch errors at compile time – this is particularly important for quantum programs as there is no graceful way of handling runtime errors on quantum hardware: by the time the error has been propagated to the caller, all quantum data stored on qubits is probably corrupted and lost,
  • memory management such as reference counting and data ownership models. Current hardware follows a static memory model, in which the number of available qubits is fixed, and every operation acts on a set of qubits assigned at compile time. This becomes impossible to keep track of in instances such as qubit allocations within loops with an unknown number of iterations at compile time. It thus becomes necessary to manage qubits dynamically, just like classical memory.

To facilitate such a large swath of abstractions, the first step quantum compilers must take is to make a distinction between the language frontend and the intermediate representation (IR) that the compiler uses to reason about the program and perform optimisations. This will be the topic of chapter 3. The graph-based IR that we introduce in that chapter will then form the foundation for the new quantum compilation techniques that will be developed throughout the remainder of the thesis.


  1. Or, as we would say in programming parlance, to allocate↩︎

  2. We should at this point – at the risk of stoking controversy – acknowledge the commendable efforts of scientists chasing the Majorana particle Sau, 2010Jay D. Sau, Roman M. Lutchyn, Sumanta Tewari and S. Das Sarma. 2010. Generic New Platform for Topological Quantum Computation Using Semiconductor Heterostructures. Physical Review Letters 104, 4 (January 2010, 040502). doi: 10.1103/physrevlett.104.040502 Haaf, 2024Sebastiaan L. D. ten Haaf, Qingzhen Wang, A. Mert Bozkurt, Chun-Xiao Liu, Ivan Kulesh, Philip Kim, Di Xiao, Candice Thomas, Michael J. Manfra, Tom Dvir, Michael Wimmer and Srijit Goswami. 2024. A two-site Kitaev chain in a two-dimensional electron gas. Nature 630, 8016 (June 2024, 329--334). doi: 10.1038/s41586-024-07434-9 Mourik, 2012V. Mourik, K. Zuo, S. M. Frolov, S. R. Plissard, E. P. A. M. Bakkers and L. P. Kouwenhoven. 2012. Signatures of Majorana Fermions in Hybrid Superconductor-Semiconductor Nanowire Devices. Science 336, 6084 (May 2012, 1003--1007). doi: 10.1126/science.1222360. The topological quantum computers these would enable are, to our knowledge, the only quantum architecture proposed that could do away with error correction. ↩︎

  3. Here we are using Apple clang v15.0.0, running macOS 14.7 on an Apple M3 Max chip. ↩︎

2.5. Summary and further reading

This introductory chapter covered some of the basic principles of quantum computation and, in doing so, hopefully, made a convincing argument as to why we should expect the programs running on quantum hardware to become more complex in the future, with the intertwining of classical and quantum computations – processes we refer to as hybrid quantum-classical programs. Prior to that, we also presented quantum compilation, an emerging discipline that is introducing many new problems and ideas to the established corpus of work on compiler research.

If this quantum taster has intrigued you or you would like to learn the basics from people who actually know what they are talking about, nothing beats the reference book for quantum information and quantum computing by Nielsen and Chuang Nielsen, 2016Michael A. Nielsen and Isaac L. Chuang. 2016. Quantum Computation and Quantum Information (10th Anniversary edition). Cambridge University Press. A fascinating alternative perspective on quantum theory has also been developed within the programme of categorical quantum mechanics, for which the illustrious “Dodo book” Coecke, 2017Bob Coecke and Aleks Kissinger. 2017. Picturing Quantum Processes: A First Course in Quantum Theory and Diagrammatic Reasoning. Cambridge University Press. doi: 10.1017/9781316219317 would be the go-to introductory material1.

At the risk of turning this thesis into absolutely shameless Oxford self-promotion, guess what else was a product of this university’s world-class research? The quantum circuit itself! These diagrams came from theoretical physicists (no surprise here) interested in capturing thought experiments in quantum information theory Deutsch, 1989David Deutsch. 1989. Quantum Computational Networks. In Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences. Royal Society, 73--90.

The idea caught on, and soon, software tools were created to facilitate building such diagrams. The Quantum Computation Language (QCL) was one of the first Ömer, 2000Bernhard Ömer. 2000. Quantum Programming in QCL. (January 2000). Retrieved from http://tph.tuwien.ac.at/ oemer/doc/quprog.pdf. Quantum software2 has since proliferated, especially as the possibility of actually performing these thought experiments on quantum hardware became more tangible. The result were software packages for quantum computing, designed for the automatic transformation and optimisation of quantum computations for execution on real hardware Javadi., 2024Ali Javadi-Abhari, Matthew Treinish, Kevin Krsulich, Christopher J. Wood, Jake Lishman, Julien Gacon, Simon Martiel, Paul D. Nation, Lev S. Bishop, Andrew W. Cross, Blake R. Johnson and Jay M. Gambetta. 2024. Quantum computing with Qiskit. arXiv: 2405.08810 [quant-ph] Cirq D., 2024 Cirq Developers. 2024. Cirq Steiger, 2018Damian S. Steiger, Thomas Häner and Matthias Troyer. 2018. ProjectQ: an open source software framework for quantum computing. Quantum 2 (January 2018, 49). doi: 10.22331/q-2018-01-31-49 Sivara., 2020Seyon Sivarajah, Silas Dilkes, Alexander Cowtan, Will Simmons, Alec Edgington and Ross Duncan. 2020. t|ket⟩: a retargetable compiler for NISQ devices. Quantum Science and Technology 6, 1 (November 2020, 014003). doi: 10.1088/2058-9565/ab8e92​ – we called them quantum compilers.

A recent development for quantum compilers focuses on scalability and first-class support for hybrid quantum-classical computations. Quantum circuits that include some form of classical control have been variously called “dynamic circuits” (e.g. Córco., 2021A. D. Córcoles, Maika Takita, Ken Inoue, Scott Lekuch, Zlatko K. Minev, Jerry M. Chow and Jay M. Gambetta. 2021. Exploiting Dynamic Quantum Circuits in a Quantum Algorithm with Superconducting Qubits. Physical Review Letters 127, 10 (August 2021, 100501). doi: 10.1103/physrevlett.127.100501), “adaptive circuits” (e.g. Smith, 2024Kevin C. Smith, Abid Khan, Bryan K. Clark, S.M. Girvin and Tzu-Chieh Wei. 2024. Constant-Depth Preparation of Matrix Product States with Adaptive Quantum Circuits. PRX Quantum 5, 3 (Septempter 2024, 030344). doi: 10.1103/prxquantum.5.030344), “circuits with measurements and feedforward” (e.g. Graham, 2023T. M. Graham, L. Phuttitarn, R. Chinnarasu, Y. Song, C. Poole, K. Jooya, J. Scott, A. Scott, P. Eichler and M. Saffman. 2023. Midcircuit Measurements on a Single-Species Neutral Alkali Atom Quantum Processor. Physical Review X 13, 4 (December 2023, 041051). doi: 10.1103/physrevx.13.041051), and “circuits assisted by local operations and classical communication” (e.g. Piroli, 2021Lorenzo Piroli, Georgios Styliaris and J. Ignacio Cirac. 2021. Quantum Circuits Assisted by Local Operations and Classical Communication: Transformations and Phases of Matter. Physical Review Letters 127, 22 (November 2021, 220503). doi: 10.1103/physrevlett.127.220503).

Besides supporting advances in quantum hardware Córco., 2021A. D. Córcoles, Maika Takita, Ken Inoue, Scott Lekuch, Zlatko K. Minev, Jerry M. Chow and Jay M. Gambetta. 2021. Exploiting Dynamic Quantum Circuits in a Quantum Algorithm with Superconducting Qubits. Physical Review Letters 127, 10 (August 2021, 100501). doi: 10.1103/physrevlett.127.100501 Graham, 2023T. M. Graham, L. Phuttitarn, R. Chinnarasu, Y. Song, C. Poole, K. Jooya, J. Scott, A. Scott, P. Eichler and M. Saffman. 2023. Midcircuit Measurements on a Single-Species Neutral Alkali Atom Quantum Processor. Physical Review X 13, 4 (December 2023, 041051). doi: 10.1103/physrevx.13.041051 Pino, 2021J. M. Pino, J. M. Dreiling, C. Figgatt, J. P. Gaebler, S. A. Moses, M. S. Allman, C. H. Baldwin, M. Foss-Feig, D. Hayes, K. Mayer, C. Ryan-Anderson and B. Neyenhuis. 2021. Demonstration of the trapped-ion quantum CCD computer architecture. Nature 592, 7853 (April 2021, 209--213). doi: 10.1038/s41586-021-03318-4, hybrid classical-quantum computations are central to many quantum computing applications. As put recently by Alam and Clark Alam, 2024Faisal Alam and Bryan K. Clark. 2024. Learning dynamic quantum circuits for efficient state preparation. arXiv: 2410.09030 [quant-ph]​:

“[…] dynamic quantum circuits are a crucial milestone on the roadmap to fault-tolerant quantum computers.”

We have covered a small subset of applications of hybrid quantum-classical computations. Quantum teleportation is undoubtedly one of the oldest Bennett, 1993Charles H. Bennett, Gilles Brassard, Claude Crépeau, Richard Jozsa, Asher Peres and William K. Wootters. 1993. Teleporting an unknown quantum state via dual classical and Einstein-Podolsky-Rosen channels. Physical Review Letters 70, 13 (March 1993, 1895--1899). doi: 10.1103/physrevlett.70.1895. The block-encoding technique that we discussed in section 2.3 is the foundation of several algorithms, including the Quantum Singular Value Decomposition (QSVT) Gilyén, 2019András Gilyén, Yuan Su, Guang Hao Low and Nathan Wiebe. 2019. Quantum singular value transformation and beyond: exponential improvements for quantum matrix arithmetics. In Proceedings of the 51st Annual ACM SIGACT Symposium on Theory of Computing, June 2019. ACM, 193--204. doi: 10.1145/3313276.3316366 and the Linear Combination of Unitaries (LCU) Chakra., 2024Shantanav Chakraborty. 2024. Implementing any Linear Combination of Unitaries on Intermediate-term Quantum Computers. Quantum 8 (October 2024, 1496). doi: 10.22331/q-2024-10-10-1496 Sze, 2025Michelle Wynne Sze, Yao Tang, Silas Dilkes, David Muñoz Ramo, Ross Duncan and Nathan Fitzpatrick. 2025. Hamiltonian dynamics simulation using linear combination of unitaries on an ion trap quantum computer. arXiv: 2501.18515 [quant-ph]. Measurement-based quantum computing (MBQC) was introduced in Rausse., 2001Robert Raussendorf and Hans J. Briegel. 2001. A One-Way Quantum Computer. Physical Review Letters 86, 22 (May 2001, 5188--5191). doi: 10.1103/PhysRevLett.86.5188 and is forming the base for some photonic quantum computing architectures Bartol., 2023Sara Bartolucci, Patrick Birchall, Hector Bombín, Hugo Cable, Chris Dawson, Mercedes Gimeno-Segovia, Eric Johnston, Konrad Kieling, Naomi Nickerson, Mihir Pant, Fernando Pastawski, Terry Rudolph and Chris Sparrow. 2023. Fusion-based quantum computation. Nature Communications 14, 1 (February 2023). doi: 10.1038/s41467-023-36493-1 Bouras., 2021J. Eli Bourassa, Rafael N. Alexander, Michael Vasmer, Ashlesha Patil, Ilan Tzitrin, Takaya Matsuura, Daiqin Su, Ben Q. Baragiola, Saikat Guha, Guillaume Dauphinais, Krishna K. Sabapathy, Nicolas C. Menicucci and Ish Dhand. 2021. Blueprint for a Scalable Photonic Fault-Tolerant Quantum Computer. Quantum 5 (February 2021, 392). doi: 10.22331/q-2021-02-04-392. Hybrid programs have also been shown to be useful for implementing the Quantum Fourier Transform (QFT) Bäumer, 2024Elisa Bäumer, Vinay Tripathi, Alireza Seif, Daniel Lidar and Derek S. Wang. 2024. Quantum Fourier Transform Using Dynamic Circuits. Physical Review Letters 133, 15 (October 2024, 150602). doi: 10.1103/physrevlett.133.150602 and the Quantum Phase Estimation (QPE) algorithms Córco., 2021A. D. Córcoles, Maika Takita, Ken Inoue, Scott Lekuch, Zlatko K. Minev, Jerry M. Chow and Jay M. Gambetta. 2021. Exploiting Dynamic Quantum Circuits in a Quantum Algorithm with Superconducting Qubits. Physical Review Letters 127, 10 (August 2021, 100501). doi: 10.1103/physrevlett.127.100501, two of the most fundamental computation primitives for quantum algorithms.

On the other hand, repeat until success schemes Paetzn., 2014Adam Paetznick and Krysta M. Svore. 2014. Repeat-until-success: non-deterministic decomposition of single-qubit unitaries. Quantum Information & Computation 14, 15–16 (November 2014, 1277–1301) are widespread in state preparation routines and will play a key role in fault-tolerant (FT) quantum computing. Arguably, the most well-known scheme for FT is magic state distillation Bravyi, 2005Sergey Bravyi and Alexei Kitaev. 2005. Universal quantum computation with ideal Clifford gates and noisy ancillas. Physical Review A 71, 2 (February 2005, 022316). doi: 10.1103/PhysRevA.71.022316, a procedure expected to be a core building block of many FT architectures. State preparation is generally a ubiquitous problem for FT, as the error-correcting codes that are employed initiate computations starting from a logical zero state, which may be expensive to prepare on the qubits of the hardware Fowler, 2012Austin G. Fowler, Matteo Mariantoni, John M. Martinis and Andrew N. Cleland. 2012. Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 3 (Septempter 2012, 032324). doi: 10.1103/physreva.86.032324.

Finally, quantum error-correcting (QEC) codes themselves must be implemented using hybrid programs. The quantum error correction (QEC) literature is vast and can get very technical very quickly, but diving into it promises bountiful rewards. The field is one of quantum information’s fastest-evolving areas of research. These work-in-progress lecture notes Gottes., 2024Daniel Gottesman. 2024. Surviving as a Quantum Computer in a Classical World. (February 2024). Retrieved on 08/01/2025 (lecture notes) from https://www.cs.umd.edu/class/spring2024/cmsc858G/QECCbook-2024-ch1-15.pdf by a coryphaeus of the field make for excellent introductory material.


  1. And while we’re on the topic of my supervisor’s brilliant work, there is also a very recent textbook, a sort of spiritual successor to Coecke, 2017Bob Coecke and Aleks Kissinger. 2017. Picturing Quantum Processes: A First Course in Quantum Theory and Diagrammatic Reasoning. Cambridge University Press. doi: 10.1017/9781316219317, particularly focused on quantum compilation Kissin., 2024Aleks Kissinger and John van de Wetering. 2024. Picturing Quantum Software: An Introduction to the ZX-Calculus and Quantum Compilation. Preprint. It is just as worth a read and might appeal more to the computer science-y reader. ↩︎

  2. That is classical software written to control and optimise quantum computations. ↩︎