  Preparing thermal and ground states is an essential quantum algorithmic task
for quantum simulation. In this work, we construct the first efficiently
implementable and exactly detailed-balanced Lindbladian for Gibbs states of
arbitrary noncommutative Hamiltonians. Our construction can also be regarded as
a continuous-time quantum analog of the Metropolis-Hastings algorithm. To
prepare the quantum Gibbs state, our algorithm invokes Hamiltonian simulation
for a time proportional to the mixing time and the inverse temperature $\beta$,
up to polylogarithmic factors. Moreover, the gate complexity reduces
significantly for lattice Hamiltonians as the corresponding Lindblad operators
are (quasi-) local (with radius $\sim\beta$) and only depend on local
Hamiltonian patches. Meanwhile, purifying our Lindbladians yields a
temperature-dependent family of frustration-free "parent Hamiltonians",
prescribing an adiabatic path for the canonical purified Gibbs state (i.e., the
Thermal Field Double state). These favorable features suggest that our
construction is the ideal quantum algorithmic counterpart of classical Markov
chain Monte Carlo sampling.
