The Bonsai algorithm: grow your own fermion-to-qubit mapping

Fermion-to-qubit mappings are used to represent fermionic modes on quantum computers, an essential first step in many quantum algorithms for electronic structure calculations. In this work, we present a formalism to design flexible fermion-to-qubit mappings from ternary trees. We discuss in an intuitive manner the connection between the generating trees' structure and certain properties of the resulting mapping, such as Pauli weight and the delocalisation of mode occupation. Moreover, we introduce a recipe that guarantees Fock basis states are mapped to computational basis states in qubit space, a desirable property for many applications in quantum computing. Based on this formalism, we introduce the Bonsai algorithm, which takes as input the potentially limited topology of the qubit connectivity of a quantum device and returns a tailored fermion-to-qubit mapping that reduces the SWAP overhead with respect to other paradigmatic mappings. We illustrate the algorithm by producing mappings for the heavy-hexagon topology widely used in IBM quantum computers. The resulting mappings have a favourable Pauli weight scaling $\mathcal{O}(\sqrt{N})$ on this connectivity, while ensuring that no SWAP gates are necessary for single excitation operations.

Fermion-to-qubit mappings are used to represent fermionic modes on quantum computers, an essential first step in many quantum algorithms for electronic structure calculations. In this work, we present a formalism to design flexible fermion-to-qubit mappings from ternary trees. We intuitively discuss the connection between the generating trees' structure and certain properties of the resulting mapping, such as Pauli weight and the delocalisation of mode occupation. Moreover, we introduce a recipe that guarantees Fock basis states are mapped to computational basis states in qubit space, a desirable property for many applications in quantum computing. Based on this formalism, we introduce the Bonsai algorithm, which takes as input the potentially limited topology of the qubit connectivity of a quantum device and returns a tailored fermion-to-qubit mapping that reduces the SWAP overhead compared to other paradigmatic mappings. We illustrate the algorithm by producing mappings for the heavy-hexagon topology widely used in IBM quantum computers. The resulting mappings have a favourable Pauli weight scaling O( √ N ) on this connectivity while ensuring that no SWAP gates are necessary for single excitation operations.

I. INTRODUCTION
The field of quantum computing has witnessed astounding developments in the last decade. While the technology is improving quickly, so-called fault-tolerant quantum computing still seems a distant milestone. Current devices are limited to relatively few qubits and cannot reliably execute the deep circuits required by many paradigmatic quantum computing algorithms [1]. Yet, near-term computers with a few hundred qubits and low levels of noise can prepare entangled states that cannot be efficiently simulated classically, which can be a computational resource in itself if combined with classical compute appropriately [2][3][4][5], for instance, to mitigate the detrimental effects of noise [6][7][8][9]. This is the reasoning behind most hybrid quantum-classical computing approaches [10]. Within this hybrid framework, it was recognised early on that one application stands out from the rest in terms of suitability: the simulation of manybody fermionic quantum systems.
Solving electronic structure problems with near-term devices is of paramount importance in fields such as computational chemistry [11][12][13], which itself has a crucial impact on many industries ranging from material science [14] to drug discovery [15,16], amongst many others. In many cases, the limitations of classical methods for chemistry stem from the inability to account for the complexity of electronic wave functions, which can easily involve a superposition of a combinatorially large number of electronic configurations. Given that quantum processors can physically exhibit complex superpositions, * aaron.miller@algorithmiq.fi this problem seems particularly appropriate for them to tackle. Indeed, in most near-term approaches, the physical state of the device is taken to represent the state of the many-body fermionic system of interest, and the physical properties of the latter are inferred by appropriately measuring physical properties of the former [17,18]. However, since the fermionic and the many-qubit wavefunctions live in fundamentally different Hilbert spaces, equipped with different algebraic structures, realising this prospect calls for a concrete way to establish connections between them, the so-called fermion-to-qubit mappings. The type of mapping between fermions and qubits used has a direct impact on the quantum simulation. A fermionic wavefunction |Ψ f ⟩ will be encoded into different many-qubit states |Ψ q ⟩ by different mappings, and these different states will generally not be equally easy to prepare on a given quantum processor. Ultimately, the latter point depends on the specifics of the hardware used, e.g., its connectivity, coherence time, etc. Moreover, one is not generally interested in merely simulating state |Ψ f ⟩, but in determining physical properties, ⟨Ψ f | O f |Ψ f ⟩, where O f is some fermionic quantity of interest. The fermion-to-qubit mapping of choice will map said operator into its qubit counterpart, O q , and the evaluation of ⟨Ψ q | O q |Ψ q ⟩ will be carried out via physical measurements on the device. Therefore, in general, the measurement cost incurred will also depend on the choice of mapping. The importance of the encoding has thus motivated considerable research towards designing convenient fermion-to-qubit mappings beyond the paradigmatic ones, such as Jordan-Wigner (JW) [19], Bravyi-Kitaev (BK) [20], and Parity [21]. Much work in relation to the design of fermion-to-qubit mappings is directed toward the reduction of qubit and Pauli weight (the number of qubits that mapped fermionic operations involve) requirements on lattice models [22][23][24][25][26][27]. Some works avoid fermionic encoding of the wave function altogether in an effort to mitigate the associated costs [28,29] Other works have addressed the measurement cost in certain fermionic simulation tasks, which directly depends on the Pauli weight of the mapping when using informationally complete measurements, and thus introduced a mapping with provable optimal Pauli weight [30]. The latter mapping is generated using regular ternary trees and largely inspired the current work. However, the connection between ternary trees and mappings was established earlier. In Ref. [31], it was used to find representations of the Clifford algebras and spin groups, and it was discussed that JW in BK can be generated from ternary trees as linear and binary subgraphs of them with the appropriate pairing of the resulting strings. More recently, a framework to design mappings based on BK was put forward in Ref. [32], but it cannot achieve optimal Pauli weight scaling.
In this paper, we consider the family of mappings generated by identifying Majorana operators with linearly and algebraically independent Pauli strings obeying equivalent anti-commutation relations. In Section II, we give an overview of fermion-to-qubit mappings and present a classification in terms of the number of qubits that the non-trivial overlap (NTO) between strings involves. We then focus on one-qubit-wise anti-commuting (1-NTO) encodings and introduce a ternary-tree-based framework to design mappings within this sub-class. More precisely, we prove that any n-node connected ternary tree yields a valid mapping.
Importantly, this framework presents a number of desirable properties. On the one hand, it is clear and intuitive. It enables understanding, and consequentially the control of many important properties of the mappings, such as their mode locality (that is, on how many qubits fermionic mode occupation is stored, which has been suggested to impact the resilience of quantum simulations to noise [33]) and their Pauli weight, in terms of simple properties of the underlying ternary trees generating them. Part of the discussion in Section II is aimed at explaining these aspects in a pedagogical manner. On the other hand, it contains the aforementioned paradigmatic mappings, as well as the recently discovered optimal-weight fermion-to-qubit mapping [30], as specific instances. Hence, we can regard our framework as being able to interpolate between and combine well-known mappings, as well as generate completely novel ones that bear little resemblance with these. In addition, these two properties together provide, as a byproduct, a clean and transparent perspective on these widely used encodings and their properties.
We also show that with the right assignment between Majorana operators and Pauli strings, for which we provide a recipe, the tree-based mapping design framework introduced here guarantees a crucial property of the sampled encodings: uncorrelated fermionic states, i.e., Fock basis states (including the vacuum state), are mapped to computational basis states in qubit space. This property, which may be easily overlooked, is of utmost importance, as it ensures no additional quantum resources (more precisely, entanglement) are needed to prepare reference wavefunctions, such as the Hartree-Fock Slater determinant often used as a starting point in many quantum simulation algorithms.
In Section IV, we put our framework into use. We exploit its versatility to devise an algorithm, which we name the Bonsai algorithm, that takes a hardware connectivity layout as an input and returns a tailored mapping. The resulting encoding is designed to minimise SWAP overhead required in the implementation of one-and twoelectron excitation operations, which are the building blocks of many adaptive ansatz construction algorithms of the ADAPT-VQE family [34][35][36]. At the same time, the algorithm aims at minimising the spread of fermionic occupancy over qubits. When applied to heavy-hexagon qubit connectivity graphs, the standard layout in current IBM devices, the Bonsai algorithm returns a mapping with no SWAP overhead for single-excitation operations and a quadratically lower Pauli weight than JW. Moreover, the mapping also drastically reduces circuit complexity of the worst-case scenario implementation of single-and double-excitation generated unitaries with respect to the latter mapping.

II. FERMION-TO-QUBIT MAPPINGS
This section is devoted to the discussion of features of general fermion-to-qubit mappings. After setting up the notation for fermionic systems (we refer the reader to Refs. [37][38][39] for detailed reviews), the Jordan-Wigner transformation, general fermion-to-qubit maps, and finally Majorana string mappings are described.

A. Fermionic systems
Consider an N -mode fermionic system in second quantisation described in terms of N creation and annihilation operators, {a † i } i=0,...,N −1 and {a i } i=0,...,N −1 , which fulfil the usual canonical fermionic anti-commutation relations The creation and annihilation operators act on F(C N ), the Fock space belonging to an N -dimensional oneparticle space. This is a 2 N dimensional Hilbert space spanned by the fermionic vacuum |vac f ⟩ and the vectors obtained by applying subsets of fermionic creation operators; this orthonormal basis, also called Fock basis, can be denoted as where n j ∈ {0, 1} are the so-called occupation numbers of mode j and the notation (a † j ) 0 = 1 is used.
The fermion-number operator for mode j is given aŝ n j = a † j a j . It is easy to show that the Fock basis states are eigenstates of these local fermion-number operators with eigenvalue given by the occupation numbers, e.g., n 0 |n 0 , n 1 , . . . n N −1 ⟩ = n 0 |n 0 , n 1 , . . . n N −1 ⟩.
Besides the fermionic creation and annihilation operators, another useful set of generators for the fermion observables are the 2N Majorana operators {m k } k=0,...,2N −1 defined as which are unitary, self-adjoint, and obey the Majorana anticommutation relations Any fermionic observable can be uniquely expressed as a linear combination of Majorana monomials m x0 ... m xj .

B. Jordan-Wigner transformation and general fermion-to-qubit mappings
The fermionic Fock space F(C N ) and the Hilbert space of N qubits (C 2 ) ⊗N are both 2 N dimensional Hilbert spaces, thus one can map one into the other unitarily. A very natural unitary mapping is to map the Fock basis states of F(C N ) to the computational basis states of the qubits such that the occupation number of the j-th fermionic mode matches with the state of the j-th qubit [19]: On the operator level, this correspondence induces a linear mapping between the corresponding observable algebras given by: for j = 0, 1, . . . N − 1. Here and in the rest of the paper, we use the notation P j with P ∈ {X, Y, Z} for an operator that acts as the Pauli operator P on the j-th qubit and as identity on the other qubits. In general, a unitary mapping between the fermionic and qubit Hilbert spaces induces a linear mapping on the corresponding observable algebras such that Conversely, any linear mapping between the fermionic and qubit observable algebras satisfying the properties (i) and (ii) in Eq.(8) defines uniquely (up to a global phase factor) a unitary mapping between F(C N ) and the Hilbert space of N qubits (C 2 ) ⊗N . This unitary mapping between the two Hilbert spaces can be constructed as follows: Since the fermionic vacuum state |vac f ⟩ is the unique vector (up to a scalar factor) satisfying the relations a j |vac f ⟩ = 1 2 (m 2j + im 2j+1 ) |vac f ⟩ = 0 for all j = 0, . . . , N − 1, the vacuum state is mapped to the state |ψ⟩ which satisfies that 1 2 (R 2j + iR 2j+1 ) |ψ⟩ = 0 for all j = 0, . . . , N − 1 (note that such a |ψ⟩ is unique up to a phase factor).
Any other Fock basis vector a † j0 a † j1 . . . a † j ℓ |vac f ⟩ is mapped to

C. Majorana string mappings
When it comes to mapping fermionic systems to qubit systems, the Pauli basis suggests a path: finding a suitable set S of 2N Pauli strings (i.e., products of Pauli operators) S k (k = 0 . . . 2N − 1) fulfilling the anticommutation {S i , S j } = 2δ ij 1. For this approach to result in a proper fermion-to-qubit mapping, the Pauli strings in S must also be linearly and algebraically independent. Linear independence is trivially satisfied if all the strings differ, but algebraic independence is more subtle. This means that it must not be possible to find two different subsets A ⊆ S and B ⊆ S, A ̸ = B, such that Si∈A S i ∝ Sj ∈B S j , given that the corresponding products of Majorana operators in fermion space result in distinct operators. Throughout this work, we will use the term Majorana strings to refer to the Pauli strings within a set S satisfying these conditions. Summarising the above, in this paper we will consider so-called Majorana string fermion-to-qubit mappings, which are linear mappings between the fermionic and qubit system observable algebras that satisfy the following criteria: • Criterion (A): Each Majorana operator is mapped to a Pauli string, m j → S j ∈ S for j = 0, . . . , 2N − 1.
• Criterion (C): For any unequal subsets A ⊆ S and B ⊆ S, A ̸ = B, Si∈A S i ∝ Sj ∈B S j is not fulfilled.
Furthermore, one often considers Majorana string fermion-to-qubit mappings that satisfy an additional criterion: • Criterion (D): Vacuum preservation, the fermionic vacuum is mapped to the all-zero computational basis state, i.e., |vac f ⟩ → |0⟩ ⊗N .
Mappings satisfying also Criterion (D) besides Criteria (A)-(C), will be called vacuum preserving Majorana string fermion-to-qubit mappings. Consider a Majorana string S j which is (up to a phase factor) a product of (non-identity) Pauli operators over a subset of sites A j ⊂ {0, . . . , N − 1}. We call A j the support of S j . Let A j and A k be the supports of S j and S k , respectively. We call A j ∩ A k the overlapping sites of S j and S k . The subset of N j,k ⊆ A j ∩ A k where the local Paulis corresponding of the Majorana strings S j and S k are different is called the non-trivial overlapping sites of S j and S k . As any two Majorana strings anticommute, the number of non-trivial overlapping sites of any pair of Majorana strings must be odd. Given a Majorana string fermion-to-qubit mapping, let k be the maximum of this odd number considering all the pairs of Majorana strings. We call such a mapping a k-non-trivial-overlap (k-NTO) Majorana string fermion-to-qubit mapping. Most of the known fermion-to-qubit mappings (e.g., JW, BK, and Parity) are 1-NTO, but non-1-NTO mappings also exist (see Appendix A).

III. MAPPINGS ORIGINATING FROM GENERAL TERNARY TREES
In this subsection, we explore the correspondence between a certain class of graphs, called ternary trees (TT), and vacuum-preserving fermion-to-qubit mappings. As mentioned previously, the connection between the two has been established before [30,31]. In Ref. [30], the minimum-depth TT is used to find a fermion-to-qubit mapping with optimal Pauli weight. Inspired by that work, we now extend the TT formalism and show that any TT can result in a valid mapping, the properties of which can be directly connected to the graph-theoretical properties of the tree. This connection will be explored more carefully in the next subsection. Moreover, the mapping-generating method introduced here guarantees that, for any sampled mapping, the fermionic vacuum is mapped to the all-zeros qubit state, and Fock basis states are mapped to computational basis states; we refer to this property as product preservation.

A. Ternary trees
It will be useful for this section and the next one to start by reviewing some graph-theoretic concepts. A graph is a pair G = (V, E) where V is a set of vertices or nodes, and E ⊆ (x, y) | (x, y) ∈ V 2 , x ̸ = y are the FIG. 1. Example of a mapping derived from a ternary tree. The black lines represent the edges, which always connect two qubits, while the legs are depicted in red. Throughout this paper, we always represent the Pauli labelling on the links (both edges and legs) by their position: the left-most link below a node is labelled with an X, while the right-most with a Z. Every leg in the tree can be associated with a Pauli string by following the path from the root node (0, in this case) to the leg. Every time a link with label P stemming downwards from a qubit u is crossed, the operator P acting on qubit u is added to the string. The resulting string acts trivially on all qubits not visited along the path. For example, with the tree in the figure, the leg labelled with S0 generates the string S0 = X0Z1, while S1 = Y0Z2Z8Z10. The green lines depict the pairing between Majorana strings that guarantees product preservation. Notice that, following the upward paths starting from the two legs of any such pair, the two paths meet at a qubit u once they both cross their first link not labelled with a Z. In the previous example with strings S0 and S1, this corresponds to the root node 0. edges, or links, which are sets of paired vertices. We consider undirected graphs, meaning that (x, y) ∈ E ⇒ (y, x) ∈ E. A length-ℓ path p in a graph is a length-ℓ ordered sequence of vertices p = {p 0 , p 1 , . . . , p ℓ−1 } such that any pair of consecutive vertices in the sequence are connected in the graph, that is, for every l < ℓ, (p l−1 , p l ) ∈ E. We call a graph G connected if, for any pair of vertices u, v, there exists at least one path p with u and v as endpoints. In any such graph G, the path structure induces a well-defined metric distance d(u, v) between all pairs of vertices, defined as the length ℓ of the shortest path (or paths, as they may not be unique) with the two vertices as endpoints. It can be easily shown that the set of distances d(u, v) define a proper metric space, given that they are positive, symmetric, zero iff u = v, and they fulfil the triangle inequality, The path structure also allows us to define a special kind of graph, the tree. A tree T is a graph that contains no loops, that is, for which there are no paths p containing any node more than once. It is a fact that any connected N -node tree contains exactly N − 1 edges, and that any connected undirected graph with N − 1 edges is a tree. It is also useful to define the degree of a node u as the number of edges reaching u, With these definitions at hand, we can introduce the TT. Essentially, a TT is a tree in which the branching rate is at most three, that is, each node has at most three descendants. To explain this concept more precisely, let us describe a process in which a TT is built by adding nodes sequentially. First, we start with a single node, the root r. Next, we add k r ≤ 3 nodes to the graph and connect each of them to the root r. The root now has degree ∆(r) = k r . Next, for each of these new nodes (descendants of r) u, we add 0 ≤ k u ≤ 3 nodes, which connect to u. The process can be iterated until the graph contains N nodes. Notice that, since each time we add a node we add one link along with it, the total number of edges will be N − 1 (this observation also shows why the resulting graph is a tree: it is not possible to close any loops in the graph by connecting one new node to a single existing one only). Any node without descendants will be denoted leaf throughout this work.

B. From ternary trees to fermion-to-qubit mappings
The starting point of this work is the observation that, following a simple procedure introduced in Refs. [30,31] for specific TTs, any N -node TT can be used to generate valid fermion-to-qubit mappings. We now explain this procedure and show its generality. The scheme is illustrated in Fig. 1 where we present an 11-qubit example.
Suppose we have an N -qubit system that we want to use to simulate an N -mode fermionic system. Without loss of generality, in what follows we label each qubit with an integer number u = 0, . . . , N − 1. To generate a fermion-to-qubit mapping, we first generate an N -node TT, by for instance following the iterative procedure introduced previously. Next, we assign a qubit label u to each node. Different assignments will lead to different mappings (a degree of freedom that can be exploited), but any such labelling is admissible. In the example (Fig. 1), this corresponds to the tree with blue nodes and black edges. The next step in the process is to add 3 − k u legs, that is, edges without a node at the other end of the link, to each node u, where k u is the number of descendants of u. Note that k r = ∆(r) for the root r, while k u = ∆(u) − 1 for all other nodes as ∆(r) ≤ 3 and ∆(u) ≤ 4 . These are the red links in Fig. 1. Importantly, doing this will result in 2N + 1 legs for any tree. To see this, let us denote the number of legs by L. Every node except the root is now reached by four links (a term that we will use in this work to refer to both edges in the original tree and legs), while the root is reached by three. Thus, if we sum all the new degrees (including legs) for all the nodes, we obtain F = 4N − 1. In this sum, we have counted each of the edges in the original tree twice (once per each node at its endpoints), while the legs have been counted only once. Hence, we have F = |E| + L, with |E| = 2(N − 1) (since each edge is contained twice in E), so L = 2N + 1.
Once the legs have been added, and every node has exactly three descending links (either edges or legs), we distribute the labels X, Y , and Z among said three links of each node. In order to ease the graphical depictions of the trees in this work, the left-most link implicitly carries the label X, the central Y , and the right-most one, Z, as in Ref. [30].
With this labelling of nodes, edges, and legs, the tree can be used to generate Pauli strings in the following manner. For every leg, there exists a unique path leading from it to the root r. The path only includes one leg, the starting one, and it may cross some edges as well. To every link in the path, we can associate a unique Pauli matrix, P u , where u is the parent node reaching the link, and P the label X, Y , or Z, corresponding to the link. The Pauli string is therefore formed by taking the tensor product of these Pauli operators, along with identity on nodes not along the path. Since every path results in a different Pauli string, this procedure generates 2N + 1 strings for N qubits.
Importantly, all these Pauli strings anticommute with one another. This can be seen by considering two Pauli strings S i and S j stemming from two different legs in the tree. The two paths corresponding to the legs must meet, that is, when traversing them upwards towards the root, they must have a first node in common (which may be the root itself). If the first common ancestor to both legs is not the root, both paths from that node upwards are equal, and hence both S i and S j contain the same Pauli operators for those qubits. The first common ancestor, on the other hand, must be reached following two different descendants of said node, so the Pauli matrices for that qubit in the strings are distinct, and both different from identity (what we refer to as non-trivial overlap). If the legs are not directly connected to their common ancestor, their paths include other nodes laying below the latter in the tree. However, notice that, by definition of a first common ancestor, those nodes cannot be present in both paths, and hence one of the strings must act trivially on each such qubit. In short, S i and S j have a single-qubit non-trivial overlap, that is, for every qubit different from the aforementioned first common ancestor, the corresponding Pauli matrices are either both equal or at least one of them is equal to the identity.
Since all the 2N +1 resulting Pauli strings are different, they are obviously linearly independent, but they are not algebraically independent. In particular, any two disjoint subsets of strings A and B, A ∩ B = ∅ such that A ∪ B is the whole set of strings fulfil Si∈A S i ∝ Sj ∈B S j . However, as we prove in Appendix B, any subset missing at least one Pauli string is algebraically independent. Therefore, by dropping any of the strings, the remaining 2N ones can be readily identified with the 2N Majorana operators associated with the N -mode fermionic system, thus defining a valid fermion-to-qubit mapping.

C. Majorana string pairing for product preservation
The previous discussion illustrates how any N -node TT can be used to obtain N -mode mappings. While any association between the generated Pauli strings and Majorana operators results in a legitimate mapping, not all are equally useful in practice. Many applications of fermion-to-qubit mappings require that at least some reference state (e.g., the vacuum) be known in qubit space. In near-term quantum computing, for instance, it is also desirable that Fock basis states be mapped to computational basis states. We now provide a simple recipe to enforce this product preservation feature of the map, including guaranteeing that the fermionic vacuum is mapped to the state |0⟩ ⊗N . First, let us introduce the concept of pairing. According to Eq. (3), there are two Majorana operators, m 2j and m 2j+1 , associated to every fermionic mode j. Therefore, after identifying Majorana strings with Majorana operators, every creation and annihilation operator a ( †) j will be associated with two Pauli strings. The key to product preservation lies in how the Pauli strings are paired into fermionic modes.
Let the set of Majorana strings be the set obtained by removing the Pauli string corresponding to the path that only involves links with label Z, and consider the following pairing algorithm. For every node u in the TT, follow its downward link labelled with X. If the link is not a leg, keep travelling downwards taking always the Z-links until a leg is reached. Denote the leg by s (u) x . The same procedure, starting from the link with label Y will lead to a different final leg s (u) y . The two Pauli strings S s (u) x and S s (u) y should then be paired together into some fermionic mode j, that is, one of them should be identified with m 2j and the other one with m 2j+1 . These pairings are illustrated with green lines in Fig. 1. The simplest identification corresponds to the mapping but it is worth mentioning that it is also possible to ensure that the mapped creation and annihilation operators are real in qubit space by associating with m 2j the Pauli string that contains an even number of Y operators and with m 2j+1 the one containing an odd number of them. However, for the sake of simplicity, we will only consider the first type of identification explicitly throughout this work. Importantly, notice that the identification between modes j and qubits u in Eq. (10) implicitly establishes a bijection between the two sets. By inverting Eq. (3), we see that the fermionic creation and annihilation operators are mapped into qubit space according to Algorithm 1: Pairing scheme 1 Choose a bijection f between modes j and qubits u, j = f (u). 2 Let V be the set of qubits in the tree. 3 Define s as the X-labelled downward link stemming from u. 5 while s not a leg do 6 Define v as the qubit reached following s downwards. 7 Define s as the Z-labelled downward link stemming from v. 8 Set s → s (u) x . 9 Define s as the Y -labelled downward link stemming from u. 10 while s not a leg do 11 Define v as the qubit reached following s downwards. 12 Define s as the Z-labelled downward link stemming from v. 13 Set s → s (u) y . 14 Remove the unpaired right-most Z-leg from the tree. 15 Create mode operators aj and a † j using Eq. (11) with j = f (u). 16 Return mapped mode operators.
A similar argument for the creation operator can be used to show that (S s (u) ⊗N , its action is to flip qubit u's state from |0⟩ to |1⟩, as well as possibly to flip any other qubits above u in the tree for which the traversed links are labelled with an X or a Y . In Appendix C, we extend this argument to prove that any Fock basis state is mapped into a computational basis state in qubit space. After application of this pairing scheme, the j-th mode operators take the form, where Z x u and Z y u are sets of qubits that S s (u) x and S s (u) y act non-trivially on below qubit u in the tree, and G u is a common Pauli string we can factor out. The sets Z u x/y may be empty, in which case the operator reduces to a similar form to the Jordan-Wigner mapping, a ( †) i → P ± u G u , where G u enforces fermionic anti-symmetry with other qubits analogous to the Z-chain. This equation is graphically understood as G u being the common path of S (u) x/y from the root to qubit-u, and sets Z x/y u are qubits along the Z-paths bifurcating from the X/Y-legs of qubitu.

D. Properties of the mappings and the effect of labelling
In the construction of a TT mapping, there are two main degrees of freedom: the tree and the labelling. In this subsection, we briefly discuss how the properties of these elements impact the resulting mappings.
An important feature of a fermion-to-qubit mapping is its Pauli weight. The Pauli weight of a Pauli string is defined as the number of qubits on which the string acts non-trivially (that is, with a Pauli operator different from identity). In the case of a mapping, this refers to the Pauli weight of the strings of the mapped fermionic operators. In the case of TT mappings, this can be easily analysed by considering the Majorana strings. More concretely, notice that the Pauli weight of a Majorana string generated from a TT is precisely the length of the corresponding path from root to leg. Thus, there is a straightforward connection between the Pauli weight of the mapping and the average shortest path length to the root in the tree. More generally, the topology of the tree impacts the sets of qubits involved when applying creation or annihilation operators, but not how (i.e., by which Pauli operators).
The labelling, instead, has a more subtle impact on the resulting map. While it cannot affect the average Pauli weight of the resulting Majorana strings, it impacts how the occupation of the fermionic modes is delocalised over qubits. More precisely, consider the number operator n j = a † j a j for a fermionic mode j in qubit space. Using Eq. (11), we see that Since the two Pauli strings S s (u) x and S s (u) y are equal on all qubits above u in the tree, the product on the righthand side results in the identity operator for those. On u, on the other hand, the product yields XY = iZ. For the qubits below u in the strings, however, one string acts with a Z operator while the other one with identity. Therefore, if we define the set Z u of qubits below u on which S s (u) x and S s (u) y act non-trivially, and include u itself too, we have that is, the occupation of a mode j is encoded in the parity of the state of the qubits in Z u . Now, given a qubit u with edges directly below itself, the choice of label for each of these edges will generally affect the structure of sets {Z u } u in the resulting mapping and, with it, its delocalisation structure.
To analyse this in an illustrative manner, let us introduce a convenient definition of mode-specific delocalisation D u in terms of the qubit u the mode is associated with in a mapping, Now, consider a generic example in which a node i, which is not the root, has two descendants j and k (see Fig. 2). Nodes j and k themselves may have descendants. Suppose that we add legs to all qubits and we label all links in the resulting tree except for the three links stemming downwards from i. The question is then how those three links should be labelled. Of course, there are three possibilities (three labels to be distributed among three links), but since swapping X ↔ Y labels between two links stemming from the same node has a simple impact on the mapping (switching the roles of S s (u) x and S s (u) y ), the only two situations to be discussed are whether the Z label should be assigned to an edge or the leg.
In the left figure, we depict the case in which the leg is assigned the Z label, and the two edges, X and Y . In this case, Z i contains i and all the nodes in the Z-strings lying below j and k, which in the example have length L j and L k , respectively. Therefore, the occupation of the mode associated with qubit i is delocalised among D i = L j + L k qubits. In the opposite case, in which the Z label is assigned to one of the edges, on the other hand, one of the two Z-strings no longer contributes to the delocalisation of node i. In the illustration, we have D i = L j , that is, the occupation of the mode is less spread in the second case.
However, notice one important fact: assume we follow the path from i upwards towards the root r until we reach an edge labelled with an X or a Y , and let us call u the node reached by traversing that edge. In the latter case (right-hand side of the figure), the Z-string along qubit k is now part of one of the Z strings directly below qubit u. In other words, while the delocalisation of the mode associated with i has decreased by an amount L k , the delocalisation of the mode associated with u has increased by the same amount. Therefore, under this assumption, the labelling cannot affect the average delocalisation of the mapping, but only its distribution among the qubits. Crucially, if the path from i to r only crosses Z-labelled edges, this is no longer true, and the second labelling does not increase the delocalisation of any other mode.
From the above discussion, we can draw a very useful overall conclusion regarding the delocalisation structure of a mapping: the average delocalisation among nodes is given by where h Z is simply the number of nodes that can reach the root node r by traversing only Z-labelled edges, including the root itself. This can be seen as follows. If a node i cannot be traced back to the root following Z-labelled edges, the path towards r must cross an Xor Y -labelled edge attached to some node u, and thus i contributes one unit to the delocalisation of node u. Therefore, the sum of all delocalisations must be equal to the number of nodes not in the Z-labelled path, that is, u D u = N − h Z . This observation implies that, in order to minimise the delocalisation of the modes, which may be a desirable property of a fermion-to-qubit mapping [33], we must maximise the number of nodes along the Z-only path. Interestingly, since h Z ∈ {1, . . . , N }, the average delocalisation is bounded ⟨D u ⟩ ∈ [0, 1−1/N ], that is, on average, the occupation of the fermionic modes is stored in less than two qubits, ⟨|Z u |⟩ ∈ [1, 2 − 1/N ].

E. The ternary trees of paradigmatic mappings
It is illustrative to analyse paradigmatic fermion-toqubit mappings in this context. In particular, Jordan-Wigner (JW), Bravyi-Kitaev (BK), Parity (P), and obviously the optimal mapping from Ref. [30] (JKMN) are all 1-NTO and can be generated from TT. In Fig. 3 we depict their corresponding trees. By analysing their graph topologies, and following the insights from the previous discussion, we can easily understand their main properties.
Both JW and P are given by linear graphs. Since these are depth-N trees, the Pauli weight of the resulting Majorana strings is O(N ). However, their occupation delocalisation is different. JW is an extreme case, given that all nodes are in the Z-labelled path and thus has average delocalisation ⟨D u ⟩ = 0; this is the only possible TT mapping with no delocalisation. In the case of P, the occupation is maximally delocalised, with each occupation encoded between two consecutive nodes in the chain, except for the last qubit, in which it is fully localised.
BK and JKMN, instead, are generated by trees with constant branching rates 2 and 3, respectively. Therefore, their depths, and hence the resulting Pauli weights, scale as O(log N ), with JKMN having a smaller depth owing to its higher branching rate (in fact, the authors prove the optimality of the Pauli weight of their mapping in Ref. [30]). In both cases, however, the price to pay is the delocalisation of the occupation. More precisely, notice that the higher up the tree the common ancestor of a given pairing is, the more Z-links are involved in the resulting Majorana strings. Thus, only the lowest-lying nodes lead to completely localised modes.

IV. GROWING HARDWARE-EFFICIENT MAPPINGS WITH THE BONSAI ALGORITHM
Ternary tree mappings can be used as a tool for the design of custom fermion to qubit mappings. The framework introduced in Sect. III is general and can help find mappings with specific desired properties by tailoring the trees according to different cost functions. In what follows, we introduce an algorithm to produce mappings aimed at reducing the complexity of fermionic simulations on quantum computers by minimising the impact of limited qubit connectivity in the quantum processor. We start this section by briefly introducing the problem, and we then present the Bonsai algorithm along with an illustrative and important use case: heavy-hexagon qubit lattices, the topology of choice for current IBM quantum computers. FIG. 4. Qubit operators resulting from the product of two even Majorana operators, m2im2j, implemented on a linear and a clustered topology. The operators are mapped to qubit space using JW and a four-qubit TT mapping in which the root has degree three. Each product of Majorana operators yields a Pauli string, which is written explicitly in the leftmost column of each mapping. The red (blue) highlight corresponds to qubits on which the Pauli strings act non-trivially. A highlighted line skipping over qubits denotes ones that are not present in the strings but are involved in the cascade of SWAP gates.

A. Fermionic simulation under limited connectivity constraints
The simulation of fermionic many-body systems is one of the most promising applications of quantum computing, both in the near term and in the fault-tolerant era. Many of the existing algorithms work in second quantisation, and thus typically require mapping the fermionic operators into qubit space. Fermionic operations are then mapped to unitary gates among the qubits in the de-vice. However, many platforms (such as superconducting qubits) have limited connectivity, meaning that many pairs of qubits in the processor cannot physically interact directly. Thus, when a quantum gate involves qubits that are not physically connected, SWAP gates are iteratively applied so that the state of distant qubits are transported to neighbouring ones, and the gate is then applied. While this is always possible in theory, in practice, the additional SWAP gates increase the circuit complexity, which results in longer runtimes and, consequently, the increased detrimental effect of noise.
In order to illustrate how limited connectivity impacts the circuit complexity, let us consider a minimal example with four fermionic modes simulated with four qubits on two different platforms, one with linear connectivity (the physical connectivity graph being a one-dimensional chain), and a second one with star-like connectivity (three of the four qubits connected to the fourth, and no other connections). Both are depicted in Fig. 4. We now map four fermionic modes to these qubits using JW and TT mapping. For the latter, we consider the specific situation in which the ternary tree is congruent with the connectivity graph of the qubits: qubit 0 is the root, and the other three qubits are its descendants.
We now examine the simulation of the even-even Majorana terms, m 2i m 2j for i ̸ = j, arising from single excitation terms, a † i a j . The resulting six Pauli strings are tabulated in the figure. In many applications, these terms must be exponentiated and implemented as rotations, i.e., exp{−iθm 2i m 2j }. This requires entangling gates between the qubits not acted upon by an identity in the corresponding Pauli string. As explained above, if two such qubits are not neighbours in the physical connectivity graph of the device, SWAPs must be applied. Figure  4 highlights the qubits involved in implementing the rotations. The SWAP overhead is indicated by thin lines skipping over the qubits.
In Fig. 4, we observe that with TT and linear connectivity, three operators, m 0 m 6 , m 2 m 6 , m 4 m 6 , involve all four qubits even though the actual Pauli strings only act on three qubits each. The JW mapping, on the other hand, is more congruent with the underlying connectivity. In the large N limit, the regular TT mapping presents an advantage in terms of Pauli weight with respect to JW (the former scales as O(log 3 N ), while the latter as O(N )) so, in principle, each such rotation would involve much fewer qubits. However, the SWAP overhead with limited connectivity reduces the Pauli weight advantage for the regular TT (and similarly for BK) and an amount of CNOTs equivalent to JW may typically be required. In the case of star-graph connectivity, on the other hand, the TT mapping never requires SWAPs, as opposed to JW, and moreover, no operation involves more than three qubits.
This simple example illustrates why limited connectivity can be an issue for the implementation of fermionic operations, and also that the right choice of mapping, in particular one that is congruent with the underlying connectivity, can help mitigate the overhead.

B. The Bonsai algorithm
In this section, we introduce an algorithm to generate custom fermion-to-qubit mappings tailored to devicespecific connectivity graphs. More precisely, the problem is, given a quantum processor, to find a mapping such that: 1) it is product-preserving, 2) the resulting Pauli weight is low, and 3) mode occupancy is local in qubit space. The first condition is satisfied by appropriate pairing as described in Sect. III C. The second and third points are suitably satisfied by finding a ternary tree that is a subgraph of the physical connectivity graph (or close to one) and then exploiting the labelling freedom to define how the mode occupancy is distributed over qubits in a rational manner. In the following, we present this heuristic strategy in detail and illustrate it with an important application: designing mappings for heavy-hexagon quantum computers. The steps of the algorithm are summarised in Algorithm 2, while the specific subroutines are described in detail in Appendix D.
Finding the ternary tree. The input of the Bonsai algorithm is a physical connectivity graph P = (V P , E P ), in which the nodes are the qubits in the processor and the edges represent the pairs of qubits onto which it is possible to physically apply entangling gates. In Fig. 5 a), we depict the physical connectivity graph P of a 37-qubit heavy-hexagon computer. Now, the strategy to minimise the SWAP overhead is to find a TT, T = (V T , E T ), that is congruent with the topology of P. More precisely, suppose that T is a subgraph of P (that is, V T = V P and E T ⊆ E P ). Then, any path from the root to leaf in T is a path in P and, consequently, no SWAPs are required to apply a gate generated by a Majorana string. A similar argument can be used for gates generated by single-excitation operators.
A tree subgraph T that spans all the nodes in a graph P is called a spanning tree (ST). If P is a tree itself, then the choice of ST is unique. A general graph, however, may have several STs. A degree-∆ constrained ST is one such tree that has no vertices with a degree greater than ∆. In our case, since we need the subgraph T to be a ternary tree in order to define a mapping, all nodes but one must be at most degree-4 and the root degree-3. This implies that it is not always possible to find such a tree (for instance, if P is a tree but not degree-∆ constrained with ∆ ≤ 4). Moreover, even if a degree-4 constrained tree subgraph exists, finding it is generally hard (in fact, simply determining whether there is one is an NP-complete problem [40]). For our purposes, if T is not an ST of P, it can nevertheless define a proper fermionto-qubit mapping, although in such case some SWAPs may be needed to implement Majorana-generated unitary gates. Therefore, we propose using a greedy heuristic to find a TT that is close to a spanning tree and is in fact guaranteed to find an ST for some specific topologies. The routine is explained precisely in Appendix D (Algorithm 3).
The idea is to start by defining T = (V T , E T ), with empty V T and E T , and grow the tree iteratively. First, choose a node to be the root r of the TT, and define L 0 = r. The choice of the root has an impact on the resulting Pauli weight and average delocalisation of the mapping, as will be discussed later on; we now choose it to be central in P (that is, such that it minimises the distance to its furthest node, r = argmin u max v d(u, v), where d(u, v) is the topological distance between nodes u and FIG. 6. Mappings resulting from two different labelling strategies applied to the tree in Fig. 5. a) By applying the homogeneous localisation labelling, modes associated with qubits with descendants are delocalised in a rather even fashion: nodes with one and two descendants have delocalisation Du = 1 and Du = 2, respectively. The zoomed-in area involving qubits 4, 7, 13, 19, and 20 further illustrates the occupancy distribution. The modes associated with 4 and 13 involve three qubits, the mode in qubit 7 involves 2, and the ones in 19 and 20, only one. b) The application of the heterogeneous localisation strategy yields a very different delocalisation structure. Nodes with one descendant are completely localised in this case (Du = 0), but nodes with two descendants can be fairly delocalised. For instance, looking again at the four nodes in the shaded area, we see that the modes in qubits 7 and 13 are more localised than in the previous case, while the one in qubit 4 is delocalised among more qubits, with D4 = 3. The particular case of the root node is a clear example, as it now exhibits delocalisation D0 = 14.
v in P). In Fig. 5 b), this is the pale blue central node. Next, define an empty set L 1 , and add to it min(∆(r), 3) neighbours of r in P. For every node u that is added, add the link between r and u to E T . Notice that r may have degree ∆(r) > 3. In that case, the choice is not unique. For simplicity, we suggest choosing three of them randomly. Then, the process is repeated for each node in L 1 : define L 2 = ∅ and add to it up to three neighbours of each node in L 1 that have not yet been added, that is, not in L 0 ∪ L 1 ∪ L 2 , and the corresponding links to E T . By iterating this process, at some point, all neighbours of all nodes in L L for some L have been added to some L i , so the procedure must stop. Now, let V T = i=1,...,L L i . If V T = V P , we have found a degree-4 constrained ST of P.
Notice that this procedure succeeds with heavy-hexagon lattices, as shown in Fig. 5 b) and c).
If the above procedure does not span all the qubits in P, we need to add the remaining nodes in V P \ V T to T according to some criterion. Notice that it is always possible to include these nodes in T through "virtual edges" that connect physically detached nodes at the expense of SWAPs in the compilation. In order to minimise the resulting SWAP overhead, a good strategy is trying to minimise the physical topological distance between qubits connected in T . This can be achieved following a greedy criterion: for every node u in V P \ V T , find amongst the nodes v in V T with a downward degree less than three in T the ones that minimise the distance d(u, v) in P, and connect u to one of them.

Algorithm 2: Bonsai algorithm
Find a ternary tree T congruent with the physical connectivity graph P using Algorithm 3, which consists of the routines: a. Find a degree-constrained tree subgraph T using greedy search throughout P.
b. If the resulting tree does not span all nodes, add the remaining ones connecting them as to minimise the physical distance to nodes already in T .
Add legs and introduce labels to T using Algorithm 4, choosing among a. Homogeneous localisation: occupancy is spread evenly over qubits in the tree.
b. Heterogeneous localisation: a subset of mode operators will act on many qubits while reducing the amount that others act on.
Pair the generated strings using Algorithm 1.
It is worth noting a few aspects of this method. On the one hand, since at each step in the first part of the algorithm we add as many neighbours of each node as the topology allows, we are implicitly minimising the depth of the resulting tree. Indeed, notice that if the physical device is all-to-all connected, then the resulting graph is the TT from Ref. [30] with optimal depth O(log 3 N ). In the case of the heavy-hexagon topology, the greedy algorithm succeeds in finding degree-constrained spanning trees with depth scaling as O( √ N ), i.e., with quadratically lower Pauli weight than Jordan-Wigner. This latter point can be seen through geometric arguments: the number of qubits at a given topological distance smaller than R from a chosen root node r scales as R 2 . On the other hand, if the connectivity graph is a chain, the algorithm, as presented above, would choose as root r a node in the centre of the chain. While this would lead to a mapping with Pauli weight lower than JW, the occupation would be more delocalised than in the latter case. Instead, if one is interested in minimising delocalisation, a better choice of the root is a node that lies on an extreme of a diameter of P (that is, one of its longest shortest paths), so that the edges along the longest shortest path can be later labelled with Z, hence maximising h Z . In such a case, JW would be obtained for a chain. In general, this trade-off between Pauli weight and delocalisation can be easily controlled with the choice of the root node.
Labelling the tree. Once the TT has been identified, the next step is to introduce terminating legs and Pauli labels to the links to create a qubit tree. As discussed in the previous sections, in order to minimise the average delocalisation, we must label with Z all edges from the root to the most distal node from it. In the case of the heavy-hexagon in Fig. 5, we may do so with all the edges between nodes 0 (the root) and 36. Using the different labelling techniques, we can decide to a certain degree how mode occupancy localisation is spread. While these cannot affect the average delocalisation, ⟨D u ⟩, they can determine how heterogeneously distributed among the qubits the occupancy can be. To that end, we introduce two different labelling strategies, which we coin homogeneous and heterogeneous localisation, based on the discussion in Sect. III D.
Homogeneous localisation proceeds by maximising the number of XY branches amongst edges stemming from the same nodes, in a similar fashion as in Fig. 2 (left). Thus, pairs of edges below a node are assigned X and Y labels, while single edges have an X label. Heterogeneous localisation, instead, maximises the number of Z labels amongst edges: if a node has two descendants, one of the edges is assigned a Z and the other one an X. If the node has only one edge, it is assigned a Z. In this way, the heterogeneous localisation assignment tends to localise the occupation of single-edge nodes at the expense of the delocalisation of nodes above them, hence resulting in typically more heterogeneous distributions of localisation.
In Fig. 6, we depict the two labelling outcomes for the heavy-hexagon topology. Homogeneous localisation produces many operators with occupancy depending on at worst case three qubits, giving a typical delocalisation D u = 2 for those. This is reflected also in the fact that the green lines representing the pairings do not span distant qubits. The number of completely local operators, with specific delocalisation D u = 0 is 16 in this case, whereas in the case of heterogeneous localisation, 27 operators are fully localised. This has the side effect of creating fewer operators with higher delocalisation, such as the number operator for the mode associated with the root (qubit 0), with delocalisation D 0 = 14. Table I in appendix E exhibits mode operators generated for both localisation schemes in this heavy-hexagon example.
Choosing one delocalisation scheme or the other is application-specific and will alter the structure of the resulting circuit. This is evident when considering a highly delocalised mode operator. Operations derived from this mode will generally act on more qubits than its localised counterpart, consequently resulting in more expensive circuits. However, since every tree-mapping has a certain level of average delocalisation, careful handling is required. In certain cases, a few modes may hold little importance and can be delocalised without significant detrimental consequences. In such scenarios, employing the heterogeneous localisation strategy to localise the relevant modes can prove beneficial. This will lead to an overall improvement as frequently used modes become less delocalised. Conversely, in cases where assumptions about the structure cannot be made, applying homogeneous localisation may prove a safe option. This strategy uniformly spreads the delocalisation, ensuring a balanced distribution across the modes.
With these mappings, circuit cost is reduced in two ways. Given that Majorana products follow paths along FIG. 7. The highlight indicates qubits involved in application of worst-case excitations, both for one-and two-particle terms. The top (a, c, e), and bottom (b, d, f) rows correspond to single and double excitation terms respectively. For simplicity, we assume that the identification between modes j and qubits u in Eq. (10) is such that j = u. Qubits to which modes are associated are circled in red, blue, and green for the JW, BK, and the custom map. For example, (a) and (b) correspond to qubit operators of modes-(0, 36) and modes-(0, 1, 2, 36) accordingly. In the case of JW (a, b), both excitations result in gates acting on all qubits. For BK (c, d) the resulting gates will act on many disconnected qubits, resulting in a high SWAP cost completely mitigating its logarithmic scaling benefit. The custom mapping (e, f) generated by the Bonsai algorithm, on the other hand, presents much simpler worst-case scenarios. The single-and double-excitation terms involve much fewer qubits than JW, and only two SWAPs are required to connect the separate highlighted regions in the latter case.
the paths in the tree structure, the number of SWAP gates needed for single excitations is zero, and the number is diminished for double excitations due to Majorana products following paths along the tree structure. The number of entangling gates is further mitigated by lessening Pauli weight. This is illustrated in Fig. 7, where we highlight the interaction maps of worst-case single and double excitations for the mapping obtained through homogeneous localisation, compared to the JW and BK mappings. In both cases, JW acts extensively on the whole system. For BK the qubits involved are disconnected and will need many SWAPs to compile, mitigating the circuit benefits of the encoding's logarithmic Pauliweight scaling. This is not the case for our custom encoding, where the reduction is approximately two-thirds of the system for single and one-third for double excitations. For the latter case, two SWAP gates are required to bridge across the disconnected interaction regions.
Another interesting aspect of these custom mappings is that it simplifies the transpilation of the circuits. Since the mapping is designed to be congruent with the hardware, it is not necessary to search for the optimal qubit assignment, but only to solve the Steiner graph problem to determine where SWAP gates are required. In addition, for two-dimensional devices other than the heavyhexagon based connectivity studied here (e.g., Google's Sycamore grid topology [41]), we expect a similar square root scaling.
It is noteworthy that the formalisms presented in this study can be expanded to tackle the difficulties posed by fully connected devices like ion-traps. This could involve exploring modified mappings to minimize the Hamiltonian Pauli weight linked to reduced measurement cost [42], or devising mappings based on the circuit's structure rather than the hardware to mitigate costs. However, such investigations are deferred to future research.

V. CONCLUSIONS
In this work, we have considered fermion-to-qubit mappings relying on the identification of sets of Pauli strings obeying the anti-commutation relations of Majorana operators. Within this context, we have focused on a specific class, arguably the simplest one to work with, in which the Pauli strings have a non-trivial overlap involving just one qubit. We have then presented a framework that enables sampling such mappings while designing many of their resulting properties. An important element of the methodology is the pairing algorithm that ensures the preservation of separability, that is, that uncorrelated fermionic states are mapped to uncorrelated qubit states.
Interestingly, the framework contains paradigmatic mappings as particular instances, which allows us to interpolate between them at will.
With this framework at hand, we have devised an algorithm to design hardware-specific mappings with lower SWAP overhead than other paradigmatic mappings while retaining a fair localisation of the fermionic occupation in qubit space. When applied to the heavy-hexagon architecture, we obtain a mapping with a quadratically lower Pauli weight than JW. Importantly, the mapping enables applying single excitation operations with no SWAP overhead, and double excitations with a minor one. This can result in a significant improvement in circuit complexity with respect to hardware-agnostic mappings.
Currently, JW is the mapping of choice in most simulations on limited connectivity hardware [43][44][45][46], partly due to the fact that its linear generating tree structure (see Fig. 3) makes it easy to find a set of qubits with that connectivity within the device. For other mappings like BK or TT, suitable subgraphs that have tree-like structure are unattainable on limited connectivity, resulting in a SWAP overhead negating the logarithmic advantage. Bonsai encodings, on the other hand, enable leveraging higher dimensions of limited connectivity graphs to reduce simulation cost, as they naturally extend the hardware suitability of JW while reducing the non-locality of the mapping.
The versatility of the approach here presented enables many other possibilities. In terms of designing mappings, the choice of the cost function to be optimised for is not unique, so the Bonsai algorithm can be naturally extended to produce encodings with different desirable properties. In particular, an important application is extracting relevant physical quantities of the system using local informationally complete POVMs [30,42,47]. In this case, the Pauli weight of the observable is the dominant figure of merit, which is why the authors proposed the logarithmic-depth regular ternary tree in Ref. [30]. While that is the optimal mapping in terms of measurement cost for arbitrary fermionic reduced density matrix elements, in practice, one is typically interested in specific observables like the energy. In that case, the mapping may be further optimised to reduce the measurement cost of e.g. the Hamiltonian of the system. Moreover, it would be interesting to do so while limiting the incurred SWAP overhead on specific hardware.
In broader, more theoretical terms, we emphasise that the bulk of the work here presented is devoted to a specific subset of all the possible mappings, the 1-NTO class, which includes all the widely used encodings. As we have proved, with the pairing we introduced, any rootcontaining connected ternary tree yields a valid, productpreserving fermion-to-qubit mapping. However, we have also shown with a counter-example that not all 1-NTO maps can be generated in this fashion, so the question of how to characterise and represent the space of 1-NTO encodings remains open. In addition, as noted in Section II, k-NTO maps with k > 1 do exist. This opens the interesting prospect of studying these somewhat exotic mappings. Additional information. The Bonsai algorithm is part of Aurora's suite of algorithms for chemistry simulation.
Appendix A: Examples of exotic fermion-to-qubit mappings The most used fermion-to-qubit mappings, such as the JW, BK, and Parity mappings are all 1-NTO mappings, and can even be generated from ternary trees. In this Appendix, we provide a toy example of a fermion-to-qubit mapping that is not 1-NTO and another one that is 1-NTO but cannot be generated from ternary trees.
Consider the following mapping of a four-mode fermion system to a 4-qubit system: One can easily check that the mapping satisfies Criteria (A)-(C) of Subsection II C, thus it is a valid Majorana string mapping. The non-trivial overlap between the Majorana strings X 1 X 2 X 3 and is 3, thus this cannot be a 1-NTO mapping, but is instead 3-NTO. An example of a 1-NTO Majorana string mapping (for 3 fermionic modes), which cannot be generated from a ternary tree is the following: Appendix B: Algebraic independence of subsets of TT-generated Pauli strings The aim of this section is to prove that any subset S ′ ⊂ S (|S ′ | < |S|) of the set S of 2N + 1 Pauli strings generated by an N -node TT is algebraically independent, that is, that there are no two different subsets A ⊆ S ′ and B ⊆ S ′ , A ̸ = B, such that Si∈A S i ∝ Sj ∈B S j .
First, notice that it is enough to prove that no two disjoint subsets A and B leading to equal products exist, given that The above implication stems from the fact that both products on the left-hand side can be multiplied by the Pauli strings in A ∩ B. Since these Pauli stings appear twice in each resulting product and they anticommute with any Pauli string different from themselves, they cancel out to identity incurring at most a change of sign.
Following a similar reasoning as above, if there are two distinct and disjoint subsets A ⊂ S ′ and B ⊂ S ′ such that where 1 N is the identity operator in the Hilbert space of N qubits. In short, it is enough to prove that there is no subset I ⊆ S ′ ⊂ S fulfilling Si∈I S i ∝ 1 N . In what follows, we will prove this by showing that so no such I ⊆ S ′ exists for any incomplete subset S ′ of S.
Given a TT and a subset of its legs I ⊆ S, we can define a set of link multiplicities {φ l }, where φ l is an integer defined for every link l in the tree (be it an edge or a leg) and counts the number of paths from the root node to each of the legs in I that traverse link l. Now, if we assume that Si∈I S i ∝ 1 N , we can make the following observations: 1. For any node u in the tree, the link multiplicities φ l (u) x , φ l (u) y , and φ l (u) z of the three links stemming downwards from u must either be all even or all odd. This is a consequence of the fact that the product of Pauli strings in I results in a product of Pauli operators X u , Y u , and Z u on qubit u. Since these operators anticommute with one another, and their product must be proportional to identity according to our assumption above, which can only be fulfilled if all three link multiplicities have equal parity.
2. Consider a node u different from the root, and let us refer to its upward edge multiplicity by φ l (u) up . The downward link multiplicities are φ l (u) x , φ l (u) y , and φ l (u) z , like above. If the assumption Si∈I S i ∝ 1 N holds, then φ l (u) up must have the same parity as the three downward links. This is a direct consequence of the fact that edge multiplicity is conserved, since every path that traverses l (u) up must traverse one of the three downward links, and of observation 1. Indeed, the sum of an odd number of odd numbers is odd, and no odd number can be obtained by adding even numbers.
These two observations imply that the parity of the link multiplicities is conserved at each node, that is, all links reaching a node must have equal multiplicity parity if the assumption Si∈I S i ∝ 1 N is true. Since the tree is connected, it follows that the multiplicity of all links in the graph must have the same parity. Given that the legs in I have multiplicity one, all links in the graph must have odd multiplicity. Thus, all legs in S must have multiplicity one and hence be in I, which proves Eq. (B3).

Appendix C: From Fock basis states to computational basis states
In the main text, we showed that, with the pairing introduced in Sect. III C, the fermionic vacuum is mapped to |0⟩ ⊗N , and that states of the form a † i |vac f ⟩ lead to computational basis states in qubit space. We now show that this is also true for any Fock basis state.
Consider an arbitrary Fock basis state |ψ⟩ in which the fermionic modes in the subset F ⊆ {0, 1, . . . , N − 1} are occupied, that is, |ψ⟩ = k∈F a † k |vac f ⟩. Since all the creation operators in the expression are different, they anticommute, so |ψ⟩ can be written, up to a sign, by applying them in an arbitrary order.
Recall that, given a TT mapping, every fermionic mode j can be associated with a qubit u j according to the pairing strategy (see Eq. (10)). This identification allows us to associate an integer h j to every mode in F indicating how deep u j lies down the tree. More precisely, h j is the topological distance between mode j's associated qubit u j and the root node. Now, consider a sequence (R 0 , . . . , R |F |−1 ) of the elements in F (that is, R i ∈ F for all i ∈ {0, . . . , |F| − 1} and R i = R j ⇔ i = j) following a top-down order, h Ri ≤ h Ri+1 ∀i ∈ {0, . . . , |F| − 1}. We can then construct |ψ⟩ by applying the sequence of creation operators starting from the highest modes up in the tree, and following downwards, , which only differ on qubit u j (on which they act with X uj and Y uj , respectively), and on all qubits in the X and Y branches lying below u j in the tree; each of the two Majorana strings acts with a Z operator on the qubits on one of the branches, but trivially on the qubits in the other branch. Therefore, if |ϕ⟩ is a computational basis state in which u j and all the qubits below it are in the |0⟩ state, (S ) |ϕ⟩, where the Z Pauli operators on the qubits below u j have substituted with identities in the primed Pauli strings, as in Sect. III C. Importantly, in the output vector, the state of u j and possibly of other qubits above u j in the tree are flipped, but not the state of qubits below u j . In addition, the vector remains a computational basis one.
With this setup, we can proceed in an inductive way. First, it is clear from the above discussion (and the one in the main text) that the state a † R0 |vac f ⟩ in qubit space, let us denote it by |ϕ 0 ⟩, is a computational basis state. Second, it can be seen that if the mapped state i=0,...,n a † Ri |vac f ⟩, |ϕ n ⟩, is a computational basis state, then so is |ϕ n+1 ⟩. This follows from where u n+1 is the qubit associated with the fermionic mode R n+1 . Since all the Majorana strings that must be applied to prepare |ϕ n ⟩ from |0⟩ ⊗N act on u n+1 and all qubits below it with either identity or with Z (again, given that h Ri ≤ h Rn+1 ∀i ∈ {0, . . . , n}), the state of each of those qubits must be |0⟩. As we have shown above, along with the condition that |ϕ n ⟩ be a computational basis state (which here is true by assumption) guarantees that |ϕ n+1 ⟩ is a computational basis state as well.
Appendix D: Algorithms and routines in more detail Algorithm 3: Qubit spanning tree subroutine 1 Define physical connectivity graph P = (VP , EP ). 2 Determine root node r = argmin u maxv d(u, v; P), where d(u, v; P) is the topological distance between u and v in P. 3 Define initial layer, L0 = r, height h = 0, and tree T = (VT , ET ) with VT = ET = ∅. 4 while L h ̸ = ∅ do 5 Define L h+1 = ∅. 6 for v ∈ L h do 7 Define the set of unassigned neighbours of v, Nv = {w ∈ VP : (v, w) ∈ EP ∧ w / ∈ VT }. 8 if |Nv| > 3 then 9 Define N ′ v ⊂ Nv containing three nodes randomly chosen from Nv. 10 Set N ′ v → Nv.
14 Set h + 1 → h. 15 for u ∈ VP \ VT do 16 Determine set A ⊆ VT of nodes in T available to connect, A = {u ∈ VT : |{v ∈ VT : (u, v) ∈ ET }| + δu,r < 4}. 17 Find set C ⊆ A of closest nodes to u, C = {v ∈ A : d(u, v; P) = minw({d(u, w; P) : w ∈ A})}. 18 if |C| > 1 then 19 Define C ′ ⊂ C containing one node randomly chosen from C. 20 Set C ′ → C. 21 Set VT ∪ C → VT . Find the longest path ℓ in T . 3 Associate a Z label to every edge along ℓ. 4 Procedure Homogeneous localisation: 5 For every node in the tree, add labels to each of its unlabelled descending edges with priority 1) X, 2) Y , and 3) Z (that is, single edges are labelled with X and double edges with XY ). 6 Add labels to all legs. 7 Procedure Heterogeneous localisation: 8 For every node in the tree, add labels to each of its unlabelled descending edges with priority 1) Z (if available), 2) X, and 3) Y (that is, single edges are labelled with Z and double edges with ZX). 9 Add labels to all legs.
Appendix E: The heavy-hexagon mappings explicitly  Fig. 6. Localised operators are ones which ones with raising/lowering P ± operators acting on the i-th qubit. Specific delocalisation is clear from the number of Pauli Z operators in the brackets. [1] J. Preskill, Quantum computing in the nisq era and beyond, Quantum 2, 79 (2018).