` .. figure:: ../_static/variational_rough.png :align: center :width: 40% :target: javascript:void(0); The principle of a *variational circuit*. :html:`

` Typically, variational circuits are trained by a classical optimization algorithm that makes queries to the quantum device. The optimization is an iterative scheme that searches out better candidates for the parameters :math:`\theta` with every step. Variational circuits have been proposed for various near-term applications, such as optimization, quantum chemistry, machine learning, data compression, linear algebra, and feature embeddings. Variational circuits have become popular as a way to think about quantum algorithms for near-term quantum devices. Such devices can only run short gate sequences, and have a high error. Usually, a quantum algorithm is decomposed into a set of standard elementary operations, which are in turn implemented by the quantum hardware. The intriguing idea of variational circuit for near-term devices is to merge this two-step procedure into a single step by "learning" the circuit on the noisy device for a given task. This way, the "natural" tunable gates of a device can be used to formulate the algorithm, without the detour via a fixed elementary gate set. Furthermore, systematic errors can automatically be corrected during optmization. Building the circuit -------------------- :html:`

` .. figure:: ../_static/circuit_embedding.svg :align: center :width: 70% :target: javascript:void(0); Example circuit showing how the argument :math:`x` and the variational parameters :math:`\bm{\theta}` enter the quantum circuit. Circuits can also contain gates which have no free parameters (e.g., a CNOT). :html:`

` Both the input :math:`x` and the variational parameters :math:`\bm{\theta}` enter the quantum circuit in the same way: as arguments for the circuit's gates. This allows us to convert *classical information* (the values of :math:`x` and :math:`\bm{\theta}`) into *quantum information* (the quantum state :math:`U(x;\bm{\theta})|0\rangle`). Quantum information is turned *back into classical information* by evaluating the expectation value of the observable :math:`\hat{B}`, .. math:: f(x; \bm{\theta}) = \langle \hat{B} \rangle = \langle 0 | U^\dagger(x;\bm{\theta})\hat{B}U(x;\bm{\theta}) | 0 \rangle. Beyond the basic rule that the inputs and parameters :math:`(x;\bm{\theta})` are used as the arguments of gates, exactly how the gates are arranged, the *circuit architecture*, is essentially arbitrary. .. note:: As shown in the figure above, the circuit can also include additional gates which have no free parameter associated with them. Examples -------- Data-embedding ~~~~~~~~~~~~~~ As explained in :ref:`concept_embeddings`, the first few gates in the circuit can be used to embed the input :math:`x` into a quantum state (which functions as a feature map :cite:`schuld2018quantum`), while the subsequent gates have parameters :math:`\bm{\theta}` as arguments. As an example, consider a photonic quantum computer (similar examples can be constructed for qubits). For simplicity, we temporarily omit the parameters :math:`\bm{\theta}`. We take the initial state to be the *vacuum* state and the measured observable :math:`\hat{B}` to be the position operator :math:`x`. The vacuum state has expectation value :math:`\langle\hat{x}\rangle = \langle 0 | \hat{x} | 0 \rangle = 0`. Suppose we have an input :math:`x`, which has :math:`N` dimensions. We can embed this into a quantum circuit with :math:`N` wires using the `displacement operator

` .. figure:: ../_static/vc_general.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` Block :math:`A` contains single-system gates applied to every subsystem. Block :math:`B` consists of both single-subsystem gates as well as entangling gates. :html:`

` .. figure:: ../_static/vc_gatearchitecture.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` Layered gate architectures can differ in three regards: * Whether only :math:`A`, only :math:`B`, or both :math:`A` and :math:`B` are parametrized * Which types of gates are used in :math:`A` and :math:`B` * Whether the gates in Block :math:`B` are arranged randomly, fixed, or determined by a hyperparameter Such layered architectures appear in both discrete and continuous-variable quantum computing models. A parametrized, B fixed *********************** In the simplest case of qubit-based devices, we can use general SU(2) gates (i.e., rotations) :math:`R` in Block :math:`A` and let :math:`B` be fixed. :html:`

` .. figure:: ../_static/vc_staticent.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` A parametrized, B parametrized ****************************** We can also have both :math:`A` and :math:`B` parametrized and the arrangements of the two-qubit gates depends on a hyperparameter defining the range of two-qubit gates (see also :cite:`romero2017quantum`, :cite:`schuld2018circuit`). :html:`

` .. figure:: ../_static/vc_cc.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` A fully parametrized architecture specific to continuous-variable systems has been proposed in :cite:`schuld2018quantum`. :html:`

` .. figure:: ../_static/vc_cvkernels.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` The entangling layer :math:`B` contains an interferometer, a passive optical circuit made up of individual beamsplitters and phase shifters. Block :math:`A` consists of single-mode gates with consecutively higher order for the quadrature operator :math:`\hat{x}` which generates the gate: the displacement gate :math:`D` is order-1, the quadratic phase gate :math:`Q` is order-2, and the cubic phase gate :math:`V` is order-3. A fixed, B parametrized *********************** An example where the single-qubit gates are fixed is a so-called *Instantaneous Quantum Polynomial (IQP)* circuit, where :math:`A` consists of Hadamard gates and :math:`B` is made up of parametrized diagonal one- and two-qubit gates :cite:`shepherd2009temporally`:cite:`havlicek2018supervised`. :html:`

` .. figure:: ../_static/vc_iqp.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` Analogous circuits can also be considered for continuous-variable systems :cite:`arrazola2017quantum`. :html:`

` .. figure:: ../_static/vc_iqp_cv.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` IQP circuits are structured so that all gates in the :math:`B` block are diagonal in the computational basis. Other structures **************** Generalizing the simple two-block structure allows to build more complex layers, such as this layer of a photonic neural network which emulates how information is processed in classical neural nets :cite:`killoran2018continuous` :cite:`steinbrecher2018quantum`. :html:`

` .. figure:: ../_static/vc_cvqnn.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` Alternating operator architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The alternating operator architecture was first introduced in Farhi and Goldstone's *Quantum Approximate Optimization Algorithm* (QAOA) :cite:`farhi2014quantum` and later used for machine learning :cite:`verdon2017quantum` and other domain-specific applications :cite:`fingerhuth2018quantum`. Again, we use layers of two blocks. The difference is that this time the unitaries representing these blocks are defined via Hamiltonians :math:`A` and :math:`B` which are evolved for a short time :math:`\Delta t`. :html:`

` .. figure:: ../_static/vc_aoa.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` The idea of this ansatz is based on analogies to adiabatic quantum computing, in which the system starts in the ground state of :math:`A` and adiabatically evolves to the ground state of :math:`B`. Quickly alternating (i.e., *stroboscopic*) applications of :math:`A` and :math:`B` for very short times :math:`\Delta t` can be used as a heuristic to approximate this evolution. Tensor network architectures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Amongst the architectures that do not consist of layers, but a single fixed structure, are gate sequences inspired by tensor networks :cite:`huggins2018towards` :cite:`du2018expressive`. The simplest one is a tree architecture that consecutively entangles subsets of qubits. :html:`

` .. figure:: ../_static/vc_tree.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` Another tensor network is based on *matrix product states*. The circuit unitaries can be decomposed in different ways, and their size corresponds to the "bond dimension" of the matrix product state — the higher the bond dimension, the more complex the circuit ansatz. :html:`

` .. figure:: ../_static/vc_mps.svg :align: center :width: 40% :target: javascript:void(0); :html:`

` .. note:: Tensor networks such as matrix product states were invented to simulate certain quantum systems efficiently (though not universally) on classical computers. Hence, tensor network architectures do not necessarily give rise to classically intractable quantum nodes, but have found use as machine learning models :cite:`miles2016supervised`. .. rubric:: Footnotes .. [#] For example, see the following non-exhaustive list: :cite:`shepherd2009temporally` :cite:`farhi2014quantum` :cite:`miles2016supervised` :cite:`romero2017quantum` :cite:`arrazola2017quantum` :cite:`farhi2017quantum` :cite:`benedetti2018generative` :cite:`huggins2018towards` :cite:`schuld2018quantum` :cite:`havlicek2018supervised` :cite:`schuld2018circuit` :cite:`dallaire2018quantum` :cite:`killoran2018continuous` :cite:`steinbrecher2018quantum`.