View on GitHub
Open this notebook in GitHub to run it yourself
Fermionic Gaussian states are ground states of quadratic fermionic Hamiltonians [1]. They are widely used as initial states for simulations of electronic systems and as mean-field ansatz states, including Hartree-Fock states, BCS superconductors, and filled Fermi seas. This notebook prepares such states on a quantum register from the matrices defining the underlying quadratic Hamiltonian
where are the (particle) fermionic creation / annihilation operators (also termed Dirac operators) and are the coupling frequencies ( notation throughout the notebook). The algorithm treats the problem in the following way:Complexity: For fermionic modes, the classical pre-processing costs (diagonalization of an matrix) and the state preparation quantum circuit requires two-qubit Givens rotations. When , the circuit depth satisfies (preparation of a Slater determinant). In general, ( case) the depth is upper bounded by .
- Input: A Hermitian one-body matrix () and a antisymmetric pairing matrix (), where is the number of fermionic modes. For number-conserving Slater determinants (), a target particle number is also specified.
- Output: An -qubit register (under the Jordan-Wigner mapping) prepared in the ground state of , up to a global phase.
Keywords: Fermionic Gaussian state, Slater determinant, Bogoliubov-de Gennes, Givens rotations, Jordan-Wigner, mean-field
Overview
Gaussian fermionic states are widely used as initial states of simulations of electronic systems and as mean field ansatz states [2]. The presented algorithm was introduced by Jiang et al. [1]. It includes two stages:- Classical pre-processing. The quadratic Hamiltonian of fermionic modes is diagonalized to obtain a basis transformation matrix.
- Quantum state preparation. Apply the resulting two-qubit gates (encoded under the Jordan-Wigner mapping) in reverse order to the vacuum , yielding the desired ground state with circuit depth .
- Number-conserving (Slater determinants): Ground states of Hamiltonians of the form: .
- Ground state of General quadratic Hamiltonian: In addition to the particle conserving terms, also contains pairing terms , which break particle-number conservation. Here, are frequencies.
Introduction
Fermionic Gaussian States (FGS) are a class of many-body quantum states of fermions, which are completely characterized by their “second moments” (two-point correlation functions). They underpin many approximate techniques in condensed matter physics and quantum chemistry. In these approaches, the interacting many-electron problem is treated by determining the optimal set of effective non-interacting orbitals that best approximate the full system [3]. The structure of FGSs is governed by the anticommutation relations of the Dirac operators where , while and annihilate and create a fermion in the ‘th fermionic mode, respectively. Important fermionic gaussian states include,- The vacuum state (defined as the state for which for all ).
- Slater Determinants: , where are linear combinations of .
- BCS states:
- Ground states of quadratic Hamiltonians (see overview). As ground states of such Hamiltonians, they have an important role in quantum simulations of fermionic systems.
- can be represented (or defined) as the exponential of a quadratic form in the fermionic operators:
- All higher order correlation functions (i.e. ) are determined by Wick’s theorem from the two-point correlators.
- They maximise the von-Neumann entropy given the second order expectation values.
- Alternatively, their properties can be fully described by the covariance matrix, which is related to the correlation matrix, , where is a transformation to the fermionic Majorana operators, defined below.
Classiq Implementation
We will next describe the classical calculation involved in deriving the state preparation circuit, and implement the circuit with Classiq. Throughout this notebook, we will use the Jordan–Wigner transformation, which maps fermionic creation and annihilation operators to qubit operators suitable for quantum computing. Under this encoding, Fock states are represented directly as computational basis states: each occupation state maps to the same bitstring. Therefore, particle number and particle conservation have the same meaning in the qubit representation. In addition, we can define certain unitaries directly by their action on the encoded Fock space. For example, a unitary that maps to , corresponds to moving a particle from the second mode to the first, i.e., annihilating it in one mode and creating it in the other. We begin by importing the required software packages and defining global constantsOutput:
Preparation of a Slater Determinant State
A Slater-Determinant is the ground state of a quadratic Fermionic Hamiltonian which conserves the number of particles. In the following section, we define such an Hamiltonian and prepare its ground state. We begin, by demonstrating a simple example utilizing only numpy data structures. Following, we introduce Classiq quantum functions which prepare the desired fermionic gaussian state. The form of general number conserving quadratic fermionic Hamiltonian is ( in Eq. (1)) where is known as the one-body Hamiltonian. Remarkably, this implies that the diagonalization of , (an by matrix) allows us to prepare the ground state. The idea is the following: We assume that the number of particles is known. The Hamiltonian conserves the number of particles, that is, it commutes the number operator Diagonalizing the single particle Hamiltonian , where is an -by- unitary matrix and , where , we obtain , where Then since each is a linear combination of the Dirac operators , it excites only a single particle, and the number conservation ( particles) implies that the ground state can be written as The basis transformation can also be expressed in terms of the single-particle transformation, where we collected the creation operators to form an operator valued vector. Each element of the vector corresponds to a transformation by a unitary operator , . Crucially, the cost of evaluating and diagonalizing of scales only polynomially with the number of fermionic modes, and can be efficiently done on a classical computer. In order to prepare the desired ground state we focus on a part of which corresponds to the occupied modes, and denote the by matrix describing these modes by . This identification leads to an alternative form for Eq. (3), for the occupied modes we have An efficient quantum circuit for the ground state preparation can be obtained by a modified QR decomposition of , using a product of elementary two-mode rotations, called Givens rotations. Each rotation can be expressed as \begin{pmatrix} \mathcal{G}c_j^\dagger\mathcal{G}\\ \mathcal{G}c_k^\dagger\mathcal{G} \end{pmatrix} = G_{jk}(\theta,\varphi)\, \begin{pmatrix} c_j^\dagger\\ c_k^\dagger \end{pmatrix}~~, $ and the form of a Givens rotation is $$G_\{jk\}(\theta,\varphi) = \begin\{pmatrix\} \cos(\theta) & -e^\{i\varphi\}\sin(\theta)\\ \sin(\theta) & e^\{i\varphi\}\cos(\theta) \end\{pmatrix\}~~. \tag\{4\} Within the algorithm, the Givens rotations operate on the subspace with a defined number of excitations, therefore, they conserve the number of particles. To simplify the decomposition we begin by utilizing the invariance of the Slater determinant (up to a global phase) under the mapping , where is a unitary transformation. For the transformation of basis to be valid we require that the first rows of are equal to , or alternatively Each Givens transformation operates only on two columns, and its parameters, and , are set so as to nullify elements in the upper right part of the matrix. Due to the orthogonality of the rows of , some transformations nullify more than a single matrix element. As a result, the total number of required Givens transformations is , where is the number of electrons and is the number of fermionic modes. The diagonalization procedure results in a product of Givens rotations After the Jordan-Wigner transformation, each two-mode () rotations correspond to a rotation in the single particle subspace of the two qubits and ( and ). This completely defines the state preparation circuit in terms of a sequence of two-qubit rotations. The gate complexity is (worst case achieved for ), and parallelization leads to a circuit depth of .Summary of the Algorithmic Steps:
- Evaluate the diagonalizing matrix , and filter the non-occupied states by calculating .
- Zero out the upper-right matrix elements of , applying the transformation .
- Diagonalize applying a sequence of Givens rotations.
- Map the Givens rotations to corresponding quantum gates, to obtain the quantum circuit.
Givens Rotations Example
In order to understand the state preparation algorithm, we first show how Givens rotations are utilized to diagonalize a simple one-body Hamiltonian. Consider a simple -by- Hermitian matrix, representing a one-body Hamiltonian: h = \begin\{pmatrix\} \varepsilon_0 & t_\{01\} & 0 & t_\{03\} \\ t_\{01\} & \varepsilon_1 & t_\{12\} & 0 \\ 0 & t_\{12\} & \varepsilon_2 & t_\{23\} \\ t_\{03\} & 0 & t_\{23\} & \varepsilon_3 \end\{pmatrix\} $numpy.linalg.eigh; the rows of are the diagonal-basis modes, and the matrix describing the Slater determinant is the subset of those rows corresponding to the occupied orbitals (here, the modes with negative single-particle energy).
givens_decomposition, returning a list of tuples: [(G_1,G_2),(G_3,),...]. Each tuple includes the Givens rotations which can be operated in parallel. The Givens rotations are encoded as a tuple: , where and are the columns of which the Givens rotation is operated on from the right (see calculation below).
build_U_from_rotations reassembles the unitary as a product of Givens rotations, and build_state_from_rotations applies the Givens rotations in single-particle space starting from a reference vector with the first entries equal to .
Output:
Preparation of an electronic state ground state
We now prepare the ground state of a fermionic lattice model. This is a Slater determinant state of the form: where are linear combinations of . First, we define the model, introduce global parameters, and define utility quantum functions. The model considers nearest neighbor interaction with periodic boundary conditions. Each fermionic mode has two degrees of freedom- The lattice site number,
- Spin,
- - number of lattice sites
- - total number of fermionic modes
OpenFermion convention).
The Jordan-Wigner transformation maps the states and operations of the fermionic Fock space to corresponding operators and states in the qubit Hilbert space.
The particle conserving property of the Givens rotation maps to an operation on states of fixed particle number. For example, for a single excitation on two modes, the subspace is spanned by and . Hence, a rotation within this space corresponds to annihilation/creation of a particle in the second state and creation/annihilation of one in the first.
Next, we introduce quantum functions that convert the sequence of Givens rotations to a corresponding state preparation quantum circuit . We utilize OpenFermion’s givens_decomposition to obtain the sequence of rotations. The decomposition includes a list of sets, where each set includes the rotations which can be operated in parallel, and each rotation operates on adjacent qubits.
Each entry returned by openfermion’s givens_decomposition (and likewise fermionic_gaussian_decomposition) corresponds to the operator
i.e. a Givens rotation in the single-particle subspace (Eq. 4) followed by a phase on mode . In the four-dimensional Fock subspace spanned by modes , , this acts as
Two observations:
- The central block (acting on ) is the transpose of Eq. (4). The transpose appears because Eq. (4) is written in the Heisenberg picture (transformation of ), whereas the matrix above acts on states.
- The corner element on comes from . For a Slater determinant whose pair is never doubly occupied during the circuit, this factor is invisible and a plain Givens would suffice; for a non-particle-conserving (BCS-style) state the doubly-occupied corner does get amplitude, and dropping the phase produces wrong relative signs.
phased_givens qfunc implements exactly the matrix above. We invoke it via phased_givens(theta, phi, [qba[i], qba[j]]): in Classiq’s qubit-ordering convention the first qubit in the list is the least-significant bit, so the basis index seen by the unitary gate is , which lines up with the Fock ordering .
Output:
Output:

Output:
General Quadratic Hamiltonian
In the general case the number of particles is not conserved under the dynamics of (Eq. (1)). This scenario is more involved than the particle-conserving case. Here, we will employ several classical transformations that will effectively diagonalize the Hamiltonian. Following, similarly to the simpler particle conserving case, we construct a unitary transformation that excites the ground state from the vacuum. The general quadratic fermionic Hamiltonian can be written in a concise form where and matrices are hermitian and anti-symmetric, correspondingly. For numerical diagonalization it is convenient to introduce the Majorana operators: for . The Majorana operators satisfy the anticommutation relations A unitary mapping relates between the two representations [1] where . Expressing the Hamiltonian in terms of the Majorana fermion operators, we have where is a real antisymmetric matrix. To simplify the solution, we perform another basis transformation with the orthogonal matrix , , casting into its real Schur form: where is a diagonal matrix of size with positive increasing eigenvalues. The transformation splits the operators into two distinct pairs, where the dynamics of each pair of operators is decoupled from the rest. Finally, we transform back to fermionic operators which is concisely expressed in terms of the unitary matrix , known as the Bogoliubov–de Gennes (BdG) matrix. The operator basis transformation brings the Hamiltonian to the desired diagonal form The transformation matrix has a block form, therefore it suffices to treat only the lower half . By applying Givens rotations on adjacent fermionic modes (encoded by the Jordan Wigner transformation) and particle-hole Bogoliubov transformations on the last fermionic mode. Crucially, the later transformations modify the particle number (unlike the Givens rotations), allowing to prepare ground states of non-particle conserving Hamiltonians. The Givens rotation for the general case is given by the 4 by 4 matrix where the two mode Givens rotation is defined in Eq. (4). The Bogoliubov transformation modifies only the last fermionic mode , while the rest of the modes remain unchanged , for . In the qubit representation this corresponds to application of an gate on the last qubit. We next introduce the matrix , satisfying , where is an arbitrary unitary matrix. By employing a modified QR decomposition equation we can decompose into a sequence of Givens and particle-hole transformations The corresponding gates can be performed in parallel leading to a circuit depth which is at most .Algorithmic Steps
The state preparation algorithm includes the following steps:- Constructs
- Evaluates transformation , bringing to the real Schur form, and constructs BdG matrix, .
- Decomposes into a sequence of Givens rotations and particle-hole Bogoliubov transformations.
Preparation of a Fermionic Ground State
Output:
prepare_fermionic_gaussian to prepare the ground state, the amplitudes match up to a global phase.
Technical Notes
Heisenberg dynamics of the Dirac operators under a number-conserving quadratic Hamiltonian
Referenced from the Preparation of a Slater Determinant State section. We show why diagonalizing the one-body matrix is enough to capture the dynamics generated by in the full -dimensional Fock space. Using the anti-commutation relations and the Heisenberg equation (), we have where the time-dependence is suppressed for conciseness. The dynamics in the Heisenberg representation can therefore be expressed as where and is the total number of fermionic modes. Remarkably, this implies that the diagonalization of , (an by matrix) provides the dynamics in the Hilbert space.Heisenberg dynamics of the Dirac operators for a general quadratic fermion Hamiltonian
Substituting Eq. (5) into the Heisenberg equation, we obtain where the last equality stems from being antisymmetric. This leads to a vector equation describing the Heisenberg dynamics of the Majorana operators Thus, the system dynamics under , can be represented in terms of a simple linear relation, involving the Majorana operators.Simple Example for a General Hamiltonian (Particle non-Conserving)
We consider a quadratic Hamiltonian of the form Two by matrices, and , are considered, where is hermitian and is antisymmetric, corresponding to one-body terms in the Hamiltonian. Following, we construct the matrix , associated with the Majorana fermion representation of the Hamiltonian, evaluate the BdG matrix , decompose it into Givens rotations and Bogoliubov transformations and verify the decomposition.Output:
OpenFermion’s fermionic_gaussian_decomposition method which receives the lower half of , and outputs four objects describing the canonical decomposition
where is an unitary, is a unitary, and is an diagonal matrix of unit-modulus phases, where is the number of fermionic modes.
decomposition: the description of as a sequence of two-mode operations applied to the columns of .
'pht', indicating a particle-hole Bogoliubov transformation on the last fermionic mode, or a tuple specifying a “double” Givens rotation on adjacent fermionic modes, acting on the upper columns of and as its complex conjugate on the lower columns.
left_decompositionandleft_diagonal: are utilized to compose auxiliary unitarydiagonal: a length- array of unit-modulus complex numbers — the diagonal entries of in the identity above. It is utilized to evaluate .