## Abstract

The preparation of thermal equilibrium states is important for the simulation of condensed matter and cosmology systems using a quantum computer. We present a method to prepare such mixed states with unitary operators and demonstrate this technique experimentally using a gate-based quantum processor. Our method targets the generation of thermofield double states using a hybrid quantum-classical variational approach motivated by quantum-approximate optimization algorithms, without prior calculation of optimal variational parameters by numerical simulation. The fidelity of generated states to the thermal-equilibrium state smoothly varies from 99 to 75% between infinite and near-zero simulated temperature, in quantitative agreement with numerical simulations of the noisy quantum processor with error parameters drawn from experiment.

## INTRODUCTION

The potential for quantum computers to simulate other quantum mechanical systems is well known^{1}, and the ability to represent the dynamical evolution of quantum many-body systems has been demonstrated^{2}. However, the accuracy of these simulations depends on efficient initial state preparation within the quantum computer. Much progress has been made on the efficient preparation of non-trivial quantum states, including spin-squeezed states^{3} and entangled cat states^{4}. Studying phenomena like high-temperature superconductivity^{5} requires preparation of thermal equilibrium states, or Gibbs states. Producing mixed states with unitary quantum operations and measurements is not straightforward, and has only recently begun to be explored^{6,7}. In this work, we demonstrate the use of a variational quantum-classical algorithm to realize Gibbs states using (ideally unitary) gate control on a transmon quantum processor.

Our approach is mediated by the generation of thermofield double (TFD) states, which are pure states sharing entanglement between two identical quantum systems with the characteristic that when one of the systems is considered independently (by tracing over the other), the result is a mixed state representing equilibrium at a specific temperature. TFD states are of interest not only in condensed matter physics but also for the study of black holes^{8,9} and traversable wormholes^{10,11}. We use a variational protocol^{12} motivated by quantum-approximate optimization algorithms (QAOA) that relies on alternation of unitary intra- and inter-system operations to control the effective temperature, eliminating the need for a large external heat bath. Other methods have been studied for generation of Gibbs states, such as quantum metropolis sampling^{13} and imaginary time evolution using variational quantum simulation^{14,15}. However, the advantage of QAOA compared to these proposals is that the form of the ansatz is relatively straightforward and low-depth, whereas the metropolis sampling involves phase estimation which leads to a high-depth circuit, and the imaginary time evolution proposal does not have a clear proposal for the form of the ansatz. Recently, verification of TFD state preparation was demonstrated on a trapped-ion quantum computer^{6}. Our work experimentally demonstrates the generation of finite-temperature states in a superconducting quantum computer by variational preparation of TFD states in a hybrid quantum-classical manner.

## RESULTS

### Theory

Consider a quantum system described by Hamiltonian *H* with eigenstates \(\left|j\right\rangle \) and corresponding eigenenergies *E*_{j}:

The Gibbs state *ρ*_{Gibbs} of the system is

where *β* = 1/*k*_{B}*T* is the inverse temperature, *k*_{B} is the Boltzmann constant, and

is the partition function. Except in the limit *β* → *∞*, the Gibbs state is a mixed state and thus impossible to generate strictly through unitary evolution. To circumvent this, we define the TFD state^{12} on two identical systems A and B as

Tracing out either system yields the desired Gibbs state in the other.

To prepare the TFD states, we follow the variational protocol proposed by^{12} and consider two systems each of size *n*. In the first step of the procedure, the TFD state at *β* = 0 is generated by creating Bell pairs \(\left|{{{\Phi }}}_{i}^{+}\right\rangle =\left({\left|0\right\rangle }_{{{{\rm{B}}}}i}{\left|0\right\rangle }_{{{{\rm{A}}}}i}+{\left|1\right\rangle }_{{{{\rm{B}}}}i}{\left|1\right\rangle }_{{{{\rm{A}}}}i}\right)/\sqrt{2}\) between corresponding qubits *i* in the two systems. Tracing out either system yields a maximally mixed state on the other, and vice versa. The next steps to create the TFD state at finite temperature depend on the relevant Hamiltonian. Here, we choose the transverse field Ising model in a one-dimensional chain of *n* spins^{16}, with *n* = 2 [Fig. 1(a)]. We map spin up (down) to the computational state \(\left|0\right\rangle \)\((\left|1\right\rangle )\) of the corresponding transmon. The Hamiltonian describing system A is

where *Z* *Z*_{A} = *Z*_{A2}*Z*_{A1}, *X*_{A} = *X*_{A2} + *X*_{A1}, and *g* is proportional to the transverse magnetic field. The Hamiltonian for system B is the same. We focus on *g* = 1, where a phase transition is expected in the transverse field Ising model at large *n*^{17}. We use a QAOA-motivated variational ansatz^{12,18}, where intra-system evolution is interleaved with a Hamiltonian enforcing interaction between the systems:

where *X* *X*_{BA} = *X*_{B2}*X*_{A2} + *X*_{B1}*X*_{A1}, and analogously for *Z**Z*_{BA}. For single-step state generation, the unitary operation describing the TFD protocol is

where

The variational parameters \({{{\boldsymbol{\gamma }}}}=\left({\gamma }_{1},{\gamma }_{2}\right)\), \({{{\boldsymbol{\alpha }}}}=\left({\alpha }_{1},{\alpha }_{2}\right)\) are optimized by the hybrid classical-quantum algorithm to generate states closest to the ideal TFD states. A single step of intra- and inter-system interaction ideally produces the state \(\left|\psi ({{{\boldsymbol{\alpha }}}},{{{\boldsymbol{\gamma }}}})\right\rangle =U\left({{{\boldsymbol{\alpha }}}},{{{\boldsymbol{\gamma }}}}\right)\left(\left|{{{\Phi }}}_{2}^{+}\right\rangle \otimes \left|{{{\Phi }}}_{1}^{+}\right\rangle \right)\)^{19}.

The variational algorithm extracts the cost function after each state preparation. We engineer a cost function \({{{\mathcal{C}}}}\) to be minimized when the generated state is closest to an ideal TFD state^{19}. Following recent work on the concentration of control parameters for QAOA^{20,21}, we expect engineering the cost function based on the target state for small-sized systems to lead to a general expression for the cost function of an arbitrary-sized system. The engineered cost function is given by:

We compare the performance of this engineered cost function \({{{{\mathcal{C}}}}}_{1.57}\) to that of the non-optimized cost function \({{{{\mathcal{C}}}}}_{1.00}\), using the reduction of infidelity to the Gibbs state as the ultimate metric of success [see Supplementary Note 1]. The engineered cost function achieves an average improvement of 54% across the *β* range covered ([10^{−2}, 10^{2}] in units of 1/*g*), as well as a maximum improvement of up to 98% for intermediate temperatures (*β* ~ 1). Our choice of the class of cost functions to optimize lets us trade off a slight decrease in low-temperature performance with a significant increase in performance at intermediate temperatures. See ref. ^{19} for further details on the theory.

The quantum portion of the algorithm prepares the state according to a given set of angles \(\left({{{\boldsymbol{\alpha }}}},{{{\boldsymbol{\gamma }}}}\right)\), performs the measurements, and returns these values to the classical portion. The classical portion then evaluates the cost function according to the returned measurements, performs classical optimization, generates and returns the next set of variational angles to evaluate the quantum portion.

### Experiment

We implement the algorithm using four of seven transmons in a monolithic quantum processor [Fig. 2(a)]. The four transmons (labeled A_{1}, A_{2}, B_{1}, and B_{2}) have square connectivity provided by coupling bus resonators, and are thus ideally suited for implementing the circuit in Fig. 1(b). Each transmon has a microwave-drive line for single-qubit gating, a flux-bias line for two-qubit controlled-*Z* (CZ) gates, and a dispersively coupled resonator with dedicated Purcell filter^{22,23}. The four transmons can be simultaneously and independently read out by frequency multiplexing, using the common feedline connecting to all Purcell filters. All transmons are biased to their flux-symmetry point (i.e., sweetspot^{24}) using static flux bias to counter residual offsets. Device details and a summary of measured transmon parameters are provided in Supplementary Note 3. Details on the experimental setup can be found in Supplementary Note 4.

In order to realize the theoretical circuit in Fig. 1(b), we first map it to the optimized depth-13 equivalent circuit shown in Fig. 2(b), which conforms to the native gate set in our control architecture. This gate set consists of arbitrary single-qubit rotations about any equatorial axis of the Bloch sphere, and CZ gates between nearest-neighbor transmons. Conveniently, all variational angles are mapped to either the axis or angle of single-qubit rotations. Further details on the compilation steps are reported in Methods and Supplementary Note 2. Bases pre-rotations are added at the end of the circuit to first extract all the terms in the cost function \({{{\mathcal{C}}}}\) and finally to perform two-qubit state tomography of each system.

Prior to implementing any variational optimizer, it is helpful to build a basic understanding of the cost-function landscape. To this end, we investigate the cost function \({{{\mathcal{C}}}}\) at *β* = 0 using two-dimensional cuts Fig. 3: we sweep ** γ** while keeping

**= 0 to study the effect of**

*α**U*

_{intra}and vice versa to study the effect of

*U*

_{inter}. Note that owing to the

*β*

^{−1.57}divergence, the cost function reduces to −〈

*H*

_{BA}〉 in the

*β*= 0 limit. Consider first the landscape for an ideal quantum processor, which is possible to compute for our system size. The

**landscape at**

*γ***= 0 is**

*α**π*-periodic in both directions due to the invariance of \(\left|{{{\rm{TFD}}}}(\beta =0)\right\rangle \) under bit-flip (

*X*) and phase-flip (

*Z*) operations on all qubits. The cost function is minimized to −4 at even multiples of

*π*/2 on

*γ*

_{1}and

*γ*

_{2}: \(\left|{{{\rm{TFD}}}}(\beta =0)\right\rangle \) is a simultaneous eigenstate of

*X*

*X*

_{BA}and

*Z*

*Z*

_{BA}with eigenvalue +2 due to the symmetry of the constituting Bell states \(\left|{{{\Phi }}}_{i}^{+}\right\rangle \). In turn, the cost function is maximized to +4 at odd multiples of

*π*/2, at which the \(\left|{{{\Phi }}}_{i}^{+}\right\rangle \) are transformed to singlets \(\left|{{{\Psi }}}_{i}^{-}\right\rangle =\left({\left|0\right\rangle }_{{{{\rm{B}}}}i}{\left|1\right\rangle }_{{{{\rm{A}}}}i}-{\left|1\right\rangle }_{{{{\rm{B}}}}i}{\left|0\right\rangle }_{{{{\rm{A}}}}i}\right)/\sqrt{2}\). The

**landscape at**

*α***= 0 is constant, reflecting that \(\left|{{{\rm{TFD}}}}(\beta =0)\right\rangle \) is a simultaneous eigenstate of**

*γ**X*

*X*

_{BA}and

*Z*

*Z*

_{BA}and thus also of any exponentiation of these operators. The corresponding experimental landscapes show qualitatively similar behavior. The

**landscape clearly shows the**

*γ**π*periodicity with respect to both angles, albeit with reduced contrast. The

**landscape is not strictly constant, showing weak structure particularly with respect to**

*α**α*

_{2}. These experimental deviations reflect underlying errors in our noisy intermediate-scale quantum (NISQ) processor, which include transmon decoherence, residual

*Z*

*Z*coupling at the bias point, and leakage during CZ gates. We discuss these error sources in detail further below.

The task of the variational algorithm is to balance the mixture of the states at each *β*, in order to generate the corresponding Gibbs state. Although thermal states are well understood, it is challenging to accurately generate them in NISQ devices for studies of finite temperature systems. When working with small systems, it is possible and tempting to predetermine the variational parameters at each *β* by a prior classical simulation and optimization for an ideal or noisy quantum processor. We refer to this common practice^{6,25} as *cheating*, since this approach does not scale to larger problem sizes and skips the main quality of variational algorithms: to arrive at the parameters variationally. Here, we avoid cheating altogether by starting at *β* = 0, with initial guess the obvious optimal variational parameters for an ideal processor (** γ** =

**= 0), and using the experimentally optimized \(\left({{{\boldsymbol{\alpha }}}},{{{\boldsymbol{\gamma }}}}\right)\) at the last**

*α**β*as an initial guess when stepping

*β*in the range \(\left[0,5\right]\) (in units of 1/

*g*). This approach only relies on the assumption that solutions (and their corresponding optimal variational angles) vary smoothly with

*β*. At each

*β*, we use the Gradient-Based Random-Tree optimizer of the

*scikit-optimize*

^{26}Python package to minimize \({{{\mathcal{C}}}}\), using 4096 averages per tomographic pre-rotation necessary for the calculation of \({{{\mathcal{C}}}}\). After 200 iterations, the optimization is stopped. The best point is remeasured two times, each with 16384 averages per tomographic pre-rotation needed to perform two-qubit quantum state tomography of each system. A new optimization is then started for the next

*β*, using the previous solution as the initial guess.

To begin comparing the optimized states \({\rho }_{{{{\rm{Exp}}}}}\) produced in an experiment to the target Gibbs states *ρ*_{Gibbs}, we first visualize their density matrices (in the computational basis) for a sampling of the *β* range covered (Fig. 4). Starting from the maximally-mixed state *I* *I*/4 at *β* = 0, the Gibbs state monotonically develops coherences (off-diagonal terms) between all states as *β* increases. Coherences between states of equal (opposite) parity have 0 (*π*) phase throughout. Populations (diagonal terms) monotonically decrease (increase) for even (odd) parity states. By *β* = 5, the Gibbs state is very close to the pure state \(\left|{{\Upsilon }}\right\rangle \left\langle {{\Upsilon }}\right|\), where \(\left|{{\Upsilon }}\right\rangle \approx \sqrt{0.36}\left(\left|01\right\rangle +\left|10\right\rangle \right)-\sqrt{0.14}\left(\left|00\right\rangle +\left|11\right\rangle \right)\). The noted trends are reproduced in \({\rho }_{{{{\rm{Exp}}}}}\). However, the matching is evidently not perfect, and to address this we proceed to a quantitative analysis.

We employ two metrics to quantify experimental performance: the fidelity *F* of \({\rho }_{{{{\rm{Exp}}}}}\) to *ρ*_{Gibbs} and the purity *P* of \({\rho }_{{{{\rm{Exp}}}}}\), given by

At *β* = 0, *F* = 99% and *P* = 0.262, revealing a very close match to the ideal maximally-mixed state. However, *F* smoothly worsens with increasing *β*, decreasing to 92% at *β* = 1 and 75% by *β* = 5. Simultaneously, *P* does not closely track the increase of purity of the Gibbs state. By *β* = 5, the Gibbs state is nearly pure, but *P* peaks at 0.601.

In an effort to quantitatively explain these discrepancies, we perform a full density-matrix simulation of a four-qutrit system using *quantumsim*^{27}. Our simulation incrementally adds calibrated errors for our NISQ processor, starting from an ideal processor (model 0): transmon relaxation and dephasing times at the bias point (model 1), increased dephasing from flux noise during CZ gates (model 2), crosstalk from residual *Z**Z* coupling at the bias point (model 3), and transmon leakage to the second-excited state during CZ gates (model 4). The experimental input parameters for each increment and details of modeling are described in Methods and Supplementary Notes 5–9. The added curves in Fig. 5 clearly show that model 4 quantitatively matches the observed dependence of *F* and *P* over the full *β* range, and identifies leakage from CZ gates as the dominant error.

## DISCUSSION

The power of variational algorithms relies on their adaptability: the optimizer is meant to find its way through the variational parameter space, adapting to mitigate coherent errors as allowed by the chosen parametrization. For completeness, we compare in Fig. 5 the performance achieved with our variational strategy to that achieved by cheating, i.e., using the pre-calculated optimal \(\left({{{\boldsymbol{\alpha }}}},{{{\boldsymbol{\gamma }}}}\right)\) for an ideal processor. Our variational approach, whose sole input is the obvious initial guess at *β* = 0, achieves comparable performance at all *β*. This aspect is crucial when considering the scaling with problem size, as classical pre-simulations will require prohibitive resources beyond ~50 qubits, but variational optimizers would not. Given the dominant role of leakage as the error source, which cannot be compensated by the chosen parametrization, it is unsurprising in hindsight that both approaches yield nearly identical performance.

In summary, we have presented the generation of finite-temperature Gibbs states in a quantum computer by variational targeting of TFD states in a hybrid quantum-classical manner. The algorithm successfully prepares mixed states for the transverse field Ising model with Gibbs-state fidelity ranging from 99% to 75% as *β* increases from 0 to 5/*g*. The loss of fidelity with decreasing simulated temperature is quantitatively matched by a numerical simulation with incremental error models based on experimental input parameters, which identifies leakage in CZ gates as dominant. This work demonstrates the suitability of variational algorithms on NISQ processors for the study of finite-temperature problems of interest, ranging from condensed-matter physics to cosmology. Our results also highlight the critical importance of continuing to reduce leakage in two-qubit operations when employing weakly-anharmonic multi-level systems such as the transmon.

During the preparation of this manuscript, we became aware of related experimental work^{25} on a trapped-ion system, applying a non-variationally prepared TFD state to the calculation of a critical point.

## METHODS

### Quantum circuit

We map the theoretical circuit in Fig. 1(b) to an equivalent circuit conforming to the native gate set in our control architecture and exploiting virtual *Z*-gate compilation^{28} to minimize circuit depth. Single-qubit rotations *R*_{XY}(*ϕ*, *θ*), by arbitrary angle *θ* around any equatorial axis \(\cos (\phi ){{{\bf{x}}}}+\sin (\phi ){{{\bf{y}}}}\) on the Bloch sphere, are realized using 20ns DRAG pulses^{29,30}. Two-qubit CZ gates are realized by baseband flux pulsing^{31,32} using the Net Zero scheme^{33,34}, completing in 80ns. In the optimized circuit [Fig. 2(b)], CZ gates only appear in pairs. These pairs are simultaneously executed and tuned as one block. Single-qubit rotations *R*_{1}-*R*_{4} are used to change the measurement bases, as required to measure \({{{\mathcal{C}}}}\) during optimization and to perform two-qubit tomography^{35} in each system to extract *F* and *P*. A summary of single- and two-qubit gate performance [see Supplementary Note 5] and a step-by-step derivation of the optimized circuit is provided [see Supplementary Note 2].

### Modeling and simulations

Noiseless simulations were performed prior to experiments, for verification of algorithm convergence. During simulations, experimental conditions were maintained exactly for the algorithm and the control software, while the outcome from readout hardware (Zurich Instruments UHFQC) was replaced with a simulated readout [see Supplementary Note 10 for details].

The models used to simulate the performance of the algorithm are incremental: model *k* contains all the noise mechanisms in model *k* − 1 plus one more, which we use for labeling in Fig. 5. Model 0 corresponds to an ideal quantum processor without any error. Model 1 adds the measured relaxation and dephasing times measured for the four transmons at their bias point. These times are tabulated in Supplementary Table 1. Model 2 adds the increased dephasing that flux-pulsed transmons experience during CZ gates. For this, we extrapolate the echo coherence time \({T}_{2}^{{{{\rm{echo}}}}}\) to the CZ flux-pulse amplitude using a 1/*f* noise model^{36,37} with amplitude \(\sqrt{A}=1\mu {{{\Phi }}}_{0}\). This noise model is implemented following^{38}. Model 3 adds the idling crosstalk due to residual *Z**Z* coupling between transmons. This model expands on the implementation of idling evolution used for coherence times: the circuit gates are simulated to be instantaneous, and the idling evolution of the system is trotterized. In this case, the residual *Z**Z* coupling operator uses the measured residual *Z**Z* coupling strengths at the bias point [see Supplementary Note 6 for details]. Finally, model 4 adds leakage to the CZ gates, based on randomized benchmarking with modifications to quantify leakage^{33,39}, and implemented in simulation using the procedure described in ref. ^{38}.

### Leakage in transmons

Leakage to transmon second-excited states is found essential to quantitatively match the performance of the algorithm by simulation. To reach this conclusion it was necessary to thoroughly understand how leakage affects the two-qubit tomographic reconstruction procedure employed. The readout calibration only considers computational states of the two transmons involved. Moreover, basis pre-rotations only act on the qubit subspace, leaving the population in leaked states unchanged. Using an overcomplete set of basis pre-rotations for state tomography, comprising both positive \(\left(X,Y,Z\right)\) and negative \(\left(-X,-Y,-Z\right)\) bases for each transmon, leads to the misdiagnosis of a leaked state as a maximally mixed state qubit state for that transmon. See Supplementary Note 8 for further details.

## Data availability

The data from experiments and simulations in this work are available at the online repository DiCarloLab-Delft/Gibbs_States_Data^{40}.

## Code availability

The code that is deemed central to the conclusions is available from the corresponding author upon reasonable request.

## References

Feynman, R. P. Simulating physics with computers.

*Int. J. Theor. Phys.***21**, 467–488 (1982).Lloyd, S. Universal quantum simulators.

*Science***273**, 1073 (1996).Hosten, O., Engelsen, N. J., Krishnakumar, R. & Kasevich, M. A. Measurement noise 100 times lower than the quantum-projection limit using entangled atoms.

*Nature***529**, 505–508 (2016).Vlastakis, B. et al. Deterministically encoding quantum information using 100-photon Schrödinger cat states.

*Science***342**, 607–610 (2013).Lee, P. A., Nagaosa, N. & Wen, X.-G. Doping a mott insulator: Physics of high-temperature superconductivity.

*Rev. Mod. Phys.***78**, 17–85 (2006).Zhu, D. et al. Generation of thermofield double states and critical ground states with a quantum computer.

*P. Natl Acad. Sci. USA***117**, 25402–25406 (2020).Chowdhury, A. N., Low, G. H. & Wiebe, N. A variational quantum algorithm for preparing quantum gibbs states (2020). Preprint at https://arxiv.org/abs/2002.00055.

Israel, W. Thermo-field dynamics of black holes.

*Phys. Rev. A***57**, 107 – 110 (1976).Maldacena, J. Eternal black holes in anti-de sitter.

*J. High Energy Phys.***2003**, 021–021 (2003).Maldacena, J., Stanford, D. & Yang, Z. Diving into traversable wormholes.

*Fortschritte der Physik***65**, 1700034 (2017).Gao, P., Jafferis, D. L. & Wall, A. C. Traversable wormholes via a double trace deformation.

*J. High Energy Phys.***2017**, 151 (2017).Wu, J. & Hsieh, T. H. Variational thermal quantum simulation via thermofield double states.

*Phys. Rev. Lett.***123**, 220502 (2019).Temme, K., Osbourne, T., Vollbrecht, K., Poulin, D. & Verstraete, F. Quantum metropolis sampling.

*Nature***471**, 87 (2011).Yuan, X., Endo, S., Zhao, Q., Li, Y. & S.C., B. Theory of variational quantum simulation.

*Quantum***3**, 191 (2019).Motta, M. et al. Determining eigenstates and thermal states on a quantum computer using quantum imaginary time evolution.

*Nat. Phys.***16**, 205–210 (2020).Ho, W. W. & Hsieh, T. H. Efficient variational simulation of non-trivial quantum states.

*SciPost Phys.***6**, 29 (2019).de Alcantara Bonfim, O. F., Boechat, B. & Florencio, J. Ground-state properties of the one-dimensional transverse Ising model in a longitudinal magnetic field.

*Phys. Rev. E***99**, 012122 (2019).Hadfield, S. et al. From the Quantum Approximate Optimization Algorithm to a Quantum Alternating Operator Ansatz.

*Algorithm***12**(2019).Premaratne, S. P. & Matsuura, A. Y. Engineering a cost function for real-world implementation of a variational quantum algorithm. In

*Proc. 2020 IEEE Int. Conf. Quantum Comp. Eng*., 278–285 (2020).Brandão, F. G. S. L., Broughton, M., Farhi, E., Gutmann, S. & Neven, H. For Fixed Control Parameters the Quantum Approximate Optimization Algorithm’s Objective Function Value Concentrates for Typical Instances Preprint at https://arxiv.org/abs/1812.04170v1 (2018).

Streif, M. & Leib, M. Training the Quantum Approximate Optimization Algorithm without access to a Quantum Processing Unit.

*Quantum Sci. Technol.***5**, 034008. Preprint at https://iopscience.iop.org/article/10.1088/2058-9565/ab8c2b (2020).Heinsoo, J. et al. Rapid high-fidelity multiplexed readout of superconducting qubits.

*Phys. Rev. App.***10**, 034040 (2018).Bultink, C. C. et al. Protecting quantum entanglement from leakage and qubit errors via repetitive parity measurements.

*Sci. Adv*.**6**(2020).Schreier, J. A. et al. Suppressing charge noise decoherence in superconducting charge qubits.

*Phys. Rev. B***77**, 180502(R) (2008).Francis, A. et al. Many body thermodynamics on quantum computers via partition function zeros Preprint at https://arxiv.org/abs/2009.04648 (2020).

Head, T., Kumar, M., Nahrstaedt, H., Louppe, G. & Scherbatyi, I. Scikit-optimize. https://doi.org/10.5281/zenodo.4014775 (2020).

Tarasinski, B. M., Ostroukh, V. P., Bonet-Monroig, X., O’Brien, T. E. & Varbanov, B. Quantumsim. https://gitlab.com/quantumsim (2016).

McKay, D. C., Wood, C. J., Sheldon, S., Chow, J. M. & Gambetta, J. M. Efficient

*z*gates for quantum computing.*Phys. Rev. A***96**, 022330 (2017).Motzoi, F., Gambetta, J. M., Rebentrost, P. & Wilhelm, F. K. Simple pulses for elimination of leakage in weakly nonlinear qubits.

*Phys. Rev. Lett.***103**, 110501 (2009).Chow, J. M. et al. Optimized driving of superconducting artificial atoms for improved single-qubit gates.

*Phys. Rev. A***82**, 040305 (2010).Strauch, F. W. et al. Quantum logic gates for coupled superconducting phase qubits.

*Phys. Rev. Lett.***91**, 167005 (2003).DiCarlo, L. et al. Demonstration of two-qubit algorithms with a superconducting quantum processor.

*Nature***460**, 240 (2009).Rol, M. A. et al. Fast, high-fidelity conditional-phase gate exploiting leakage interference in weakly anharmonic superconducting qubits.

*Phys. Rev. Lett.***123**, 120502 (2019).Rol, M. A. et al. Time-domain characterization and correction of on-chip distortion of control pulses in a quantum processor.

*App. Phys. Lett.***116**, 054001 (2020).Sagastizabal, R. et al. Error mitigation by symmetry verification on a variational quantum eigensolver.

*Phys. Rev. A***100**, 010302(R) (2019).Wellstood, F., Urbina, C. & Clarke, J. Excess noise in dc squids from 4.2 k to 0.022 k.

*IEEE Trans. Magn.***23**, 1662–1665 (1987).Paladino, E., Galperin, Y. M., Falci, G. & Altshuler, B. L. 1/

*f*noise: Implications for solid-state quantum information.*Rev. Mod. Phys.***86**, 361–418 (2014).Varbanov, B. M. et al. Leakage detection for a transmon-based surface code.

*npj Quantum Inf.***6**, 102 (2020).Asaad, S. et al. Independent, extensible control of same-frequency superconducting qubits by selective broadcasting.

*npj Quantum Inf.***2**, 16029 (2016).Sagastizabal, R. et al. Gibbs States Data. https://github.com/DiCarloLab-Delft/Gibbs_States_Data (2021).

Nijholt, B., Weston, J., Hoofwijk, J. & Akhmerov, A. Adaptive: parallel active learning of mathematical functions (2019). https://doi.org/10.5281/zenodo.1182437.

## Acknowledgements

We thank L. Janssen, M. Sarsby, and M. Venkatesh for experimental assistance, X. Bonet-Monroig and B. Tarasinski for useful discussions, and G. Calusine and W. Oliver for providing the traveling-wave parametric amplifier used in the readout amplification chain. This research is supported by Intel Corporation, the ERC Synergy Grant QC-lab, and by the Office of the Director of National Intelligence (ODNI), Intelligence Advanced Research Projects Activity (IARPA), via the U.S. Army Research Office grant W911NF-16-1-0071. The views and conclusions contained herein are those of the authors and should not be interpreted as necessarily representing the official policies or endorsements, either expressed or implied, of the ODNI, IARPA, or the U.S. Government.

## Author information

### Authors and Affiliations

### Contributions

M.B, N.H., and L.D.C. designed the device. A.B., N.M., and C.Z. fabricated it. R.S. and B.A.K. performed the measurements and analysed the data with contributions from M.A.R and V.N. M.S.M. designed control electronics. S.P., X.Z., and S.J. developed the algorithm and theory. S.P., B.A.K., V.O., and R.S. performed the numerical simulations. A.M. and L.D.C. supervised theory and experiment, respectively. R.S. and S.P. wrote the manuscript with contributions from A.M. and L.D.C., and feedback from all co-authors. R.S. and S.P. contributed equally to this work as co-first authors.

### Corresponding author

## Ethics declarations

### Competing interests

The authors declare no competing interests.

## Additional information

**Publisher’s note** Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Supplementary information

## Rights and permissions

**Open Access** This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.

## About this article

### Cite this article

Sagastizabal, R., Premaratne, S.P., Klaver, B.A. *et al.* Variational preparation of finite-temperature states on a quantum computer.
*npj Quantum Inf* **7, **130 (2021). https://doi.org/10.1038/s41534-021-00468-1

Received:

Accepted:

Published:

DOI: https://doi.org/10.1038/s41534-021-00468-1