We present a framework for differentiable quantum transforms. Such transforms are metaprograms capable of manipulating quantum programs in a way that preserves their differentiability. We highlight their potential with a set of relevant examples across quantum computing (gradient computation, circuit compilation, and error mitigation), and implement them using the transform framework of PennyLane, a software library for differentiable quantum programming. In this framework, the transforms themselves are differentiable and can be parametrized and optimized, which opens up the possibility of improved quantum resource requirements across a spectrum of tasks.
I. INTRODUCTIONQuantum machine learning (QML) is a rapidly-growing area of research with great potential. Tools for designing QML algorithms and applications are increasingly being incorporated into open-source quantum software [1][2][3][4][5]. Some of these integrate with classical machine learning tools such as Autograd [6], PyTorch [7], TensorFlow [8], and JAX [9]. The core functionality provided by all of these libraries is automatic differentiation (autodifferentiation) of mathematical functions, which is used to compute the gradients required for model training. The capabilities provided by these libraries have enabled significant advances to be made in classical machine learning, allowing developers and practitioners to focus more on architectures, data, and algorithms, rather than on the technical implementation of computing derivatives.Differentiation is a process that maps a function f (x) to another function, g(x) = ∇f (x), which computes its derivative. Differentiation can thus be viewed as a function transform. Some classical frameworks, such as JAX [9], Dex [10], and functorch [11] make this notion explicit. For example, JAX is branded as a library for transforming numerical functions, and its built-in transforms include just-in-time compilation and automatic vectorization (vmap) in addition to autodifferentiation. The system is extensible and allows users to write their own transforms. Furthermore, these transforms preserve differentiability of whatever they act upon.There are many processes in quantum computing that rely on the idea of transforming a quantum function, most often represented by a quantum circuit. Such quantum transforms take a circuit as input, and return a new, modified circuit as output. This idea, and the underlying functional programming elements, is perhaps most explicit in the Haskell-based language Quipper [12], which contains a built-in, user-extensible system for monad transformers that can be applied to quantum circuits. Such transforms are used most often in the context of quantum compilation or transpilation, wherein gates in a circuit are rewritten in terms of other gates, reordered, or otherwise optimized. Many multipurpose quantum software libraries such as Qiskit [2] and Cirq [13], and the compiler t|ket [14], expose such optimization transforms to the user. However, the concept of quantum transforms extends beyond...