Computational devices based on the laws of quantum mechanics hold promise to speed up many algorithms known to be hard for classical computers.1 The implementation of a full-scale computation with existing technology requires an outstanding ability to maintain quantum coherence (i.e., isolation from the environment) without compromising the ability to control the interactions among the qubits in a scalable way. Among the most successful paradigms of quantum computation, there is the ‘circuit model’, in which the algorithm is decomposed into an universal set of single- and two-qubit gates,2 and, to some extent, the so-called adiabatic quantum computation (AQC),3 in which the output of the algorithm is encoded in the ground state of an interacting many-qubit Hamiltonian. A different approach4 is based on the use of always-on interactions, naturally occurring between physical qubits, to accomplish the computation. Compared with the circuit model, this scheme has the advantage of requiring minimal external control and avoiding the continuous switch off and on of the interactions between all but two qubits, whereas compared with AQC it has the advantage of being faster, being based on the non-equilibrium evolution of the system. Quantum computation with always-on interactions is accomplished by combining the natural couplings with a moderate external control, e.g., with a smooth shifting of Zeeman energies,5 via feed-forward techniques,6 using measurement-based computation7 or quantum control.8,9 Most of these approaches are based on the assumption that the natural couplings are fixed by nature and not tunable, whereas local interactions can be modulated with external fields. However, the amount of external control required can be minimised if the couplings between the qubits can be statically tuned10—e.g., during the creation of the quantum device.

The recent advances in the fabrication of superconducting quantum devices has opened up to the realisation of interacting quantum networks. In a superconducting device, the qubits are built with a Josephson tunnel element, an inductance and a capacitor,11 whereas local operations and measurements are performed by coupling the qubit to a resonator.12 The interactions can be designed using lithographic techniques by jointly coupling two qubits via a capacitor13 or an inductance,14 and can be modelled via an effective two-body Hamiltonian α J α σ α σ α 15,16 where σα are the Pauli matrices. Because of the flexibility in wiring the pairwise interactions among the qubits, it is possible to arrange them in a planar graph structure, namely a collection of vertices and links, in which the vertices correspond to the qubits and the links correspond to the two-body interactions between them. Moreover, thanks to the development of three-dimensional superconducting circuits,17 it may be possible in the near future to wire also non-planar configurations, namely a general qubit network.

Motivated by the above, we ask the following question: is it possible to encode a quantum algorithm into the unmodulated dynamics of a suitably large quantum network of pairwise interacting qubits? This would be extremely interesting, as it would enable quantum computation by simply ‘waiting’, without the need of continuously applying external control pulses or measurements. Even when sequential operations cannot be avoided, our scheme can enable the in-hardware implementation of recurring multi-qubit operations of a quantum algorithm (see e.g., Figure 1), such as quantum arithmetic operations,18 and possibly also the quantum Fourier transform or error-correcting codes.1 We focus on two-body interactions, as they are the most common in physical setups, and we consider an enlarged network in which auxiliary qubits enrich the quantum dynamics. The important question analysed in this paper is as follows: given a target unitary operation UQ on a given set of qubits Q, we consider an extended network QA in which A is a set of auxiliary qubit (ancillae), and we ask whether it is possible to engineer the pairwise interactions in QA, modelled by the time-independent Hamiltonian HQA, such that e i t H Q A = U Q V A after some time t (VA may be an extra unitary operation on the auxiliary space). More generally, the target operation can depend also on the ancillae initial state: if e i t H Q A = n U Q ( n ) | A n A n | , where { | A n } forms a basis of the ancillae Hilbert space and, e.g., U Q = U Q ( 1 ) , then the target operation is implemented when A is initialised in | A 1 . Our method is particularly useful for implementing quantum gates, which requires k-body interactions (k>2), such as the Toffoli or Fredkin gates1,19,20 where U Q e i t H Q for any two-local HQ, and for remote logic, namely for applying a gate to qubits that are not directly connected but are rather interacting via intermediate systems. Our approach is completely different from the simulation of k-local Hamiltonians with pairwise interactions discussed in the AQC literature,21,22 being based on the unmodulated dynamics. Moreover, being based on unmodulated (time-independent) interactions and ancillary qubits, it is significantly different from quantum optimal control.23

Figure 1
figure 1

Schematic transposition of a quantum circuit to a trained quantum network. (a) An example seven-qubit circuit in which the gates G1 and G2 are sequentially applied. Many important circuits can be cast into the scheme a, such as those for quantum arithmetics.18 (b) Quantum network implementation of a: each qubit network in the green boxes implements either G1 or G2 on the input/output qubits (the three qubits in the bottom row). The quantum bus sequentially transfers the state of three qubits from the register, on which the gate G1 or G2 has to be applied, to the input/output qubits of the gate network. After the gate network has implemented its transformations, the state is transferred back to the original three qubits of the register.

Our quantum network design procedure is inspired by supervised learning in feed-forward networks,24 in which the training procedure involves the optimisation of the network couplings (i.e., the weights between different nodes) such that the output corresponding to some input data has a desired functional form (e.g., for data classification). Although there are many recent developments about using a quantum device to speed up machine learning algorithms2529 or storing data,30 our optimisation procedure is entirely classical, but specifically developed for quantum hardware design. Our scheme is completely different from other recent proposals3133 because it avoids measurements or active feedbacks and requires minimal external control.


Supervised quantum network design

Supervised learning is all about function approximation: given a training set {(I1, O1), (I2, O2), …}, namely a collection of inputs Ik and the corresponding known outputs Ok, the goal is to find a function f with two desired properties: (i) Okf(Ik) for any training pair, and (ii) f should be able to infer the unknown output of an input not contained in the training set. In classical feed-forward networks, the function f is approximated with a directed graph organised in layers, where the first layer is the input register and the last one encodes the output. The value s k ( ) of the k-th node in layer ℓ is updated via the equation s k ( ) = A [ j λ k j ( 1 ) s j ( 1 ) ] , where A is an appropriate (typically non-linear) activation function and λ k j ( 1 ) is the weight between node k in layer ℓ and node j in ℓ − 1. The training procedure consists in finding the optimal weights λ by minimising a suitable cost function such as C = k | O k f ( I k ) | 2 .

A quantum network consists, on the other hand, of an undirected graph (V, E) of vertices V and links E described by a two-local Hamiltonian

(1) H = ( n , m ) E α , β J n m α β σ n α σ m β 4 + n V α h n α σ n α 2 ,

where σ n α , α=x, y, z, are the Pauli matrices acting on qubit n and, to simplify the notation, we call λ = { J n m α β , h n α } the set of parameters. The vertices are composed of two disjoints sets V=QA, where Q consists of register qubits and A consists of auxiliary qubits. Given a separable initial state | ψ Q | ψ A , the time evolution according to Hamiltonian (1) generates a quantum channel1 E λ [ | ψ Q ψ Q | ] = Tr A [ e i H t ˜ | ψ Q ψ Q | | ψ A ψ A | e i H t ˜ ] on subsystem Q—as we are interested in a fixed operational time t ˜ for simplicity we set t ˜ = 1 , reabsorbing t ˜ into the definition of the definition of H. Depending on the flexibility of the experimental apparatus in reliably initialising the auxiliary qubits, one can add | ψ A to the set λ. Network design consists in the following procedure: given a target unitary operation UQ that we want to implement, the goal is to find the parameters λ, if they exist, such that E λ [ ρ Q ] = U Q ρ Q U Q for any ρQ. To simplify the notation, we assume that the gate output is encoded in Q but it is straightforward to generalise the formalism when the output sites differ from the input ones.

Motivated by the similarity with classical supervised learning, where the weights λ are tuned to maximise the ability of the network to reproduce a known output given the corresponding input, we create a training set T with a random set of initial input states. For each input | ψ T the expected known output is U Q | ψ , whereas the output of the network evolution is E λ [ | ψ ψ | ] . The ‘learning’ procedure involves the minimisation of the difference between the output of the network and the expected output, and corresponds to the maximisation of the fidelity

(2) F = | ψ T F ψ | T | , F ψ = ψ | U Q E λ [ | ψ ψ | ] U Q | ψ .

If the average is performed over all possible states, then equation (2) can be substituted by the average gate fidelity F ¯ = F ψ d ψ where the formal integration can be explicitly evaluated10,34,35 yielding

(3) F ¯ = 1 D + 1 + 1 D ( D + 1 ) i j k l U i k * E λ i j , k l U j l ,

where E λ i j , k l = q i | E λ [ | q k q l | ] | q j , U i j = q i | U Q | q j and { | q j } form the computational basis of the D-dimensional Hilbert space of qubits Q. The typical value of the fidelity for a random non-optimal evolution of the qubit network is F ¯ = D 1 , obtained using Haar integration techniques.36 This value is independent of the details of the ancillae, as it depends only on the dimension of the target Hilbert space, and provides an estimate for the initial fidelity of an untrained network.

The gate-learning procedure corresponds to a global maximisation of the fidelity (3). However, because of the many parameters in the Hamiltonian (1), F ¯ can have many local maxima, making the global optimisation extremely complicated. As most global optimisation algorithms introduce stochastic strategies, rather than introducing unphysical random jumps, we take advantage of the explicit stochastic nature of the problem ( F ¯ is a uniform average over random states) and we propose the following learning algorithm to design the interactions of the quantum network.

1: Choose an initial parameter set λ (e.g., at random), and choose an initial learning rate ε;

2: Repeat

3: Generate a random | ψ ;

4: Update L times the coupling strengths as

(4) λ λ + ε λ ψ | U Q E λ [ | ψ ψ | ] U Q | ψ ;

5: Decrease ε (see Materials and methods);

6: Until convergence (or maximum number of operations).

Specifically, we combine the above algorithm with the maximisation of the average fidelity (see below) and we observe a drastic speed up of the optimisation process. The parameter L tunes the number of deterministic steps in the learning procedure, and can be set to the minimum value L=1, so that after each interaction the state is changed or to a higher value. In our simulations, we use L=1, for simplicity. Our algorithm is an application of the stochastic gradient descent (SGD) method37 to the maximisation of the function (2). In classical feed-forward networks, SGD is the de facto standard algorithm for network training24,37 and is specifically used for large training data sets, when the evaluation of the cost function and its gradient are computationally intensive. On the other hand, the average in equation (2) can be evaluated explicitly over a uniform distribution of an infinite number of initial states, giving equation (3). Although F ψ is easier than F ¯ to compute, the major advantage of SGD for quantum network design comes from its ability to escape local maxima. The crucial observation to show the latter point is that the statistical variance over random states Var F = F 2 ¯ F ¯ 2 vanishes when F ¯ = 1 (see e.g., refs 34 and 35)—indeed, intuitively, as both F ¯ and F ψ are bounded in [0, 1], F ¯ can achieve its maximum only if F ψ = 1 for all the states, apart from a set of measure zero. On the other hand, if 0 < F ¯ < 1 , then Var F > 0 and the fluctuations can be so high that a local maximum of F ¯ may not correspond to a maximum of F ψ for some state ψ. This is indeed shown in Figure 2 with a real example for the implementation of the Toffoli gate (see the application section below). In Figure 2, the average fidelity F ¯ has three local maxima at λ k loc . (k=1, 2, 3) and a single global maximum at λgl., namely the optimal parameters, whereas the fidelities F ψ for different random states ψ have a more complicated behaviour. In view of the argument discussed above, all the state fidelities F ψ have a global maximum at λgl., whereas, remarkably, at least one fidelity F ψ has no local maximum at λ k loc . . Our stochastic learning algorithm uses a gradient descent technique for locally maximising the function F ψ ( λ ) . Therefore, if we are around the slopes of a local maximum of F ψ ( λ ) (say λ k loc . from the previous example) and the state | ψ is randomly changed to | ϕ , that local maximum may disappear from F ϕ ( λ ) , allowing the algorithm to escape from this non-optimal region when the parameters are updated via equation (4). On the other hand, when the algorithm is probing the neighbourhood of a true optimal point for which F ¯ ( λ ) = 1 (e.g., λgl. in the previous example), then the maximum of F ψ ( λ ) does not disappear when the state ψ is changed, allowing the ‘climbing’ procedure to continue.

Figure 2
figure 2

Average fidelity F ¯ and fidelity F ψ for some random states ψ for implementing the Toffoli gate in a four-qubit network (see discussion in the text). All the parameters are set to the optimal ones, except J 35 x x in the abscissa. The region around the only global peak is filled in green.

The above stochastic algorithm may be combined with a deterministic maximisation of equation (3). In our simulations, we use stochastic learning for the initial global span of the parameter manifold, and if it reaches a suitably high fidelity (e.g., F ¯ > 95% ) then it is reasonable to suppose that the algorithm has found a global maximum. Starting from this point, we perform a local maximisation of equation (3), and if F ¯ 1 is reached the learning has been successful. Otherwise, we repeat the procedure.

It is worth emphasising that given a target gate U it is an open question to understand a priori whether a solution may exist for a graph with a certain set of interactions (e.g., Heisemberg, Ising and so on). Unlike in quantum control, where given a time-dependent Hamiltonian H ( t ) = H 0 + β ( t ) V one can check in advance whether U = T [ exp ( i 0 1 H ( t ) d t ) ] for some control profile β(t): such a profile can exist only if U is contained in the group associated with the algebra generated by the repeated commutators of H 0 and V. Although no complete algebraic characterisation is known for our case (see, however, the Materials and methods for a necessary condition) and we have to study each problem numerically, in the next sections we find some structures that enable the implementation of important quantum gates. All numerical simulations have been obtained in a laptop computer using QuTiP.38

Application: Toffoli gate

The Toffoli gate is a key component for many important quantum algorithms, notably the Shor algorithm,39 quantum error correction,20 fault-tolerant computation40 and quantum arithmetic operations,18 and, together with the Hadamard gate, is universal for quantum computation.41 Experimental implementations of this gate have been obtained with trapped ions,42 superconducting circuits19,43 or photonic architectures.44 Toffoli gate is a controlled-controlled-not (CCNOT) operation acting on three qubits. It can be implemented in a circuit using five two-qubit gates,1 or it can be obtained in coupled systems via quantum control techniques.45,46 Efficient schemes require higher dimensional system (i.e., qudits).44 On the other hand, the direct implementation using natural interactions is complicated, as the Hamiltonian H CCNOT corresponding to the gate, i.e., CCNOT = e i H CCNOT , has three-body interactions, which are unlikely to appear in nature.

By applying our quantum hardware design procedure, we show that the Toffoli gate can be implemented in a four-qubit network using only pairwise interactions and constant control fields. Our findings enable the construction of a device that implements the Toffoli gate with a fidelity F ¯ = 99.98% by simply ‘waiting’ for the natural dynamics to occur, without the need for external control pulses. We consider a four-qubit network as displayed in Figure 3, in which the control qubits are labelled by the indices 1,2, the target is qubit 3 and the ancilla is qubit 4. We start our analysis by considering a fully connected graph in which each qubit interacts with the others using XX- and ZZ-type pairwise interactions, as this kind of interaction can be obtained in superconducting circuits.15 Because of the symmetries of the Toffoli gate (see Materials and methods), we consider the two control qubits to be equally coupled to the target and the ancilla: J 1 m α β = J 2 m α β , for m=3, 4 and similarly we set h 1 α = h 2 α . Moreover, as the Toffoli gate is real, we only consider local fields in the X and Z directions and set | ψ A =cosη | + e i ξ sinη | . By combining SGD with the maximisation of equation (3), we find the following optimal parameters,

(5) J 12 z z = 8.940, J 13 z z = 4.957 , J 14 z z = 5.657, h 1 z = 2.428, h 3 z = J 13 z z , h 4 z = 0.165, h 3 x = 19.08, h 4 x = 4.267, J 34 x x =15.06, η =0.8182, ξ =0.0587,

in which the other XX- and ZZ-type interactions not displayed in equation (5) are found to be zero by the learning algorithm, so the optimal configuration is the one summarised in Figure 3, where the XX coupling is only between qubits 3 and 4. In more physical terms, if the maximal allowed coupling is fixed to J/2π≈40 MHz, then we find a gate time of 60 ns and

(6) J 12 z z = 149.2 MHz , J 13 z z = 82.71 MHz , J 14 z z = 94.39 MHz , h 1 z = 40.52 MHz , h 3 z = J 13 z z , h 4 z = 2.751 MHz , h 3 x = 318.4 MHz , h 4 x = 71.2 MHz , J 34 x x =251.3 MHz .

With the optimal parameters of equations (5) and (6), we obtain an average gate fidelity of 99.98%, above the threshold for topological fault tolerance for single- and two-qubit gates, whereas by avoiding the extra phase fixing ξ=0 we still obtain F ¯ = 99.92% . Moreover, our gate fidelity is above the Toffoli gate accuracy threshold (755/75699.87%) for fault-tolerant computation in the limit in which Clifford gate errors are negligible.47

Figure 3
figure 3

Network implementing the Toffoli gate. The gate acts on the three external qubits (the top ones being the control qudits, and the bottom one being the target), and has an additional auxiliary qubit in the centre.

The optimal parameters (5) and (6) are stable against an imperfect tuning of the interactions. Indeed, we considered a perturbation λ k λ k + ε r k , rk[0. 1] being a random number and ε being the strength of the static perturbation, and found that F ¯ > 99.9% if ε < 0.04 ( ε < 0.7 MHz ) and F ¯ > 99% if ε < 0.18 ( ε < 3 MHz ).

Application: Fredkin gate

Fredkin gate is a controlled-swap (CSWAP) operation acting on three qubits, which is universal for reversible computation.1 We found that this gate can be obtained with perfect fidelity (up to the numerical precision) in a four-qubit network with Hamiltonian (1) where J 12 x x = J 13 x x = 13.60 (227.0 MHz), J 23 α α = 4.712 (−78.62 MHz), J 24 x x = J 34 x x = 8.400 (140.2 MHz), J 12 z z = J 13 z z = 11.15 (186.1 MHz, h 4 x = 1.025 (17.11 MHz), h 1 z = π (54.42 MHz). The values in MHz correspond to a gate time of 60 ns. Moreover, e i H = CSWAP 123 U 4 so the gate is independent of the initial state of the ancilla. As for the Toffoli gate, this optimal configuration has been obtained by starting the training procedure with a fully connected graph with all the interactions, and thus the fact that some interactions are zero is a result of the optimisation process.

Application: remote logic

We study a qubit network that implements a maximally entangling gate between two sites that are not directly coupled. Remote logic has been studied extensively in spin chains for achieving entangling operations between the boundary sites,4,10,48,49 and it is a building block for a proposed architecture for solid-state quantum computation at room temperature.50 For simplicity, we consider a SU(2) invariant four-qubit network, interacting with a Heisenberg Hamiltonian H = i j =1 4 α = x , y , z J i j σ i α σ j α / 4 where there is no direct coupling between qubits 1 and 4 (J14=0). Applying our learning algorithm, we found that the SWAP gate, which is universal for quantum computation when paired with single qubit operations,1 can be achieved between qubits 1 and 4 with unit fidelity with different choices of J12=J24, J13=J34 and J23 when the initial state of ancillae is ( | | ) / 2 . Given this simplification, one can then find a solution analytically: J 12 = α + π ( 2 n ) 2 1 / 8 , J 13 = α π ( 2 n ) 2 1 / 8 , J 23 = α + ( 1 ) n π , where n is an integer. We find analytically that irrespective of α the above choice gives perfect fidelity. Our strategy has not found any three-qubit configurations that implement a remote SWAP gate, and thus the four-qubit network is the minimal non-trivial example. Remarkably, some of our four-qubit configurations are more stable to noise than the direct implementation of the gate in a two-qubit system (namely when J14=π/2 and the other couplings are zero). For instance, if J i j = J i j optimal + ε , J i j optimal being the optimal value for implementing the gate, we found that when ε is randomly distributed in [0, 1/2], then the four-qubit system with n=1 still has, on average, F ¯ 99.1%, whereas the direct two-qubit case has F ¯ 98.8%.

Towards a scalable architecture for quantum computation

Current architectures for quantum computation, e.g., with superconducting qubits51 or ion traps,52 are based on an arrays of interacting qubits that are continuously controlled via external pulses to implement the desired operation. This approach may suffer from scalability issues because, even assuming the ability to maintain quantum coherence for a long time, extremely large (classical) control units will be necessary to generate the sophisticated pulse sequences required to implement a full-scale quantum algorithm. On the other hand, the approach that we have in mind shares more similarities with integrated circuits in present-day electronics, where a set of special-purpose logic units (modules) are wired together to achieve computation (or other tasks). In our vision, different modules can be fabricated with qubit networks designed to produce a specific logic task, namely a quantum gate, automatically without the need of external control. As in Figure 1, the different logic and memory units can be reciprocally connected using a quantum bus, whose purpose is to transfer the qubit states between the quantum registers/memory and the input/output qubits of the modules. In Figure 1, for simplicity the input/output ports of the modules are designed in the same physical qubits, although this can be easily extended to more general cases. The quantum bus can be realised with different technologies, e.g., with microwave resonators,53 or it can also be implemented via quantum-state transfer in a qubit network.54 The modules shown in Figure 1 can be designed to produce either simple basic operations, such as the CNOT or the Toffoli gate, or, in principle, they can directly implement larger components of a quantum algorithm such as the Quantum Fourier Transform or error-correcting codes.1 In this respect, to treat systems with many parameters, one can easily combine our optimisation strategy, based on fidelity statistics, with metaheuristic strategies,55 which simultaneously deals with many candidate solutions and are known to be fast in global optimisation with high-dimensional parameter spaces. Moreover, highly optimised deep learning algorithms are already used to train neural networks with 60 millions of parameters.56 However, given the difficulty in numerically simulating large quantum systems, this approach may be reasonable for networks up to, say, 20–30 qubits.


Inspired by classical supervised learning, we have proposed an optimisation scheme to encode a quantum operation into the unmodulated dynamics of a qubit register, which is part of a bigger network of pairwise interacting qubits. Our strategy is based on the static engineering of the pairwise couplings, and it enables the creation of a quantum device, which implements the desired operation by simply waiting for the natural dynamics to occur, without the need of external control pulses. Our findings show that machine learning-inspired techniques can be combined with quantum mechanics not only for data classification speed up25,26 or quantum black-box certification,57,58 but also for quantum hardware design.

This paper opens up the topic of encoding quantum gates and operations into the unmodulated dynamics of qubit networks. Although we have focused on small systems, larger networks can be considered using more efficient training schemes. These would enable the simulation of larger components of a quantum algorithm, as different multi-qubit gates can be combined into a unique quantum operation, which can be simulated in a large quantum network. Moreover, when combined with a quantum bus as in Figure 1, our strategy can provide an alternative approach to universal quantum computation, which avoids the decomposition of the algorithm into one- and two-qubit gates. Note that most quantum algorithms take classical inputs, and thus the extra control required for initialisation demands the further ability to fully polarise globally the spins. The latter step is, however, typically much easier than the implementation of entangling gates, which has been considered in this paper. Moreover, in view of the recent experimental measures of the average gate fidelity,59 it is tempting to predict an all-quantum version of our learning procedure, where F ¯ is not classically simulated, but rather directly measured. This would require a further highly controlled system to infer the optimal parameters of an uncontrolled quantum network, which can be used to industrialise the production of unmodulated quantum devices implementing the desired algorithm.

Our results demonstrate the efficacy of the proposed scheme in designing four-qubit networks that implement the Toffoli and Fredkin gates or remote logic operations. The proposed Toffoli gate is fast, has high fidelity for fault-tolerant computation and only uses static XX- and ZZ-type interactions, which can be achieved in superconducting systems.15 The key advantage of our method is in exploiting all the permanent interactions in the qubit network without trying to suppress some of them sequentially to implement pairwise gates. Moreover, being based on non-equilibrium dynamics, our gate is fast: if J/2π≈40 MHz, then the total operation time is ~60 ns, which matches the current gate times for single- and two-qubit operations.51

Materials and methods

Learning rate

The choice of the learning rate ε is crucial. If the initial learning rate is too small, it might not escape from the different ‘local maximum’ points, whereas if it is too large it will continue to randomly jump without even seeing the local maxima. To maximise the speed and precision of SDG, the learning rate ε has to decrease as a function of the steps, a common choice being ε m 1/2 where m is the step counter.37 However, when the gradient in equation (4) cannot be performed analytically, one can use more sophisticated techniques60 in which both the learning rate and the finite difference approximation of the gradient change as a function of m.


In the design of the quantum network and its couplings, the number of parameters can be drastically reduced if the target unitary operation UQ has some symmetries, namely if there exists some unitary matrix S such that [UQ, SQ]=0. This condition requires the quantum channel E λ [ ρ ] = Tr A [ e i H ρ ρ A e i H ] to satisfy E λ ( S Q ρ S Q ) = S Q E λ ( ρ ) S Q for each state ρ, e.g., [ H , S Q 1 A ] =0. Conversely, if the interaction type is fixed by nature (for instance, only Ising or Heisenberg interactions are allowed), then one has to check whether the Lie algebra spanned by the operators in H contains the generators of UQ.

Bottom-up construction: Lie algebraic characterisation

All the numerical results presented in the main text are obtained using a top-down approach: after selecting the interaction types (e.g., XX, ZZ, Heisenberg and so on), the algorithm starts with a zero-bias fully connected configuration in which all the qubit pairs of the network interact with all possible interactions, each weighted with a different parameter, and different local fields. As a result of the training procedure, we found numerically that most of these parameters are indeed zero. However, for larger networks it is better to use a bottom-up approach, in which one starts with a minimal set of parameters and then adds other parameters until a solution is found.

To construct a minimal set of parameters, one can use a Lie algebraic characterisation inspired by quantum control. We write the Hamiltonian as H = j λ j O j , where λj is the independent parameter and O j is the operator. If the parameters are time dependent, then there exist suitable pulses λj(t) such that the dynamics implements the target gate G only if log(G) is contained in the algebra generated by the repeated commutators [ O j , [ O k , ] ] . As our scheme is based on the particular choice where λj(t) is constant, the above characterisation still provides a necessary condition. As an example, we consider the Toffoli gate and the solution equation (5) where O 1 = σ 1 z σ 2 z , O 2 = σ 1 z σ 3 z + σ 2 z σ 3 z + 2 σ 3 z , O 3 = σ 1 z σ 4 z + σ 2 z σ 4 z , O 4 = σ 3 x σ 4 x , O 5 = σ 1 z + σ 2 z , O 7 = σ 4 z , O 8 = σ 3 x , O 9 = σ 4 x . It is simple to check that log G (up to an irrelevant constant factor) is contained in the algebra generated by the operators Oj, whereas this is not the case if the operator O 8 is removed from the Hamiltonian. Therefore, no solution is possible if λ8≡0.

Inspired by the above example, the bottom-up approach consists in the following steps: (i) based on the symmetries of the target gate and on the physically allowed interactions, one defines an initial set of operators; (ii) other operators are added to the set until the dynamical algebra contains log(G); (iii) one starts the numerical parameter training to check for convergence (different runs may be required). Until the solution is found, one can either adds new operators or changes the previous ones.