# Quantum Fluctuation Theorem for Arbitrary Measurement and Feedback Schemes

Kacper Prech<EMAIL_ADDRESS>Patrick P. Potts  Department of Physics,
University of Basel, Klingelbergstrasse 82, 4056 Basel, Switzerland

###### Abstract

Fluctuation theorems and the second law of thermodynamics are powerful
relations constraining the behavior of out-of-equilibrium systems. While there
exist generalizations of these relations to feedback controlled quantum
systems, their applicability is limited, in particular when considering strong
and continuous measurements. In this letter, we overcome this shortcoming by
deriving a novel fluctuation theorem, and the associated second law of
information thermodynamics, which remain applicable in arbitrary feedback
control scenarios. In our second law, the entropy production is bounded by the
coarse-grained entropy production which is inferrable from the measurement
outcomes, an experimentally accessible quantity that does not diverge even
under strong continuous measurements. We illustrate our results by a qubit
undergoing discrete and continuous measurement, where our approach provides a
useful bound on the entropy production for all measurement strengths.

_Introduction._ Stochastic thermodynamics [1, 2, 3, 4, 5, 6, 7, 8] aims to
understand the thermodynamic behavior of nanoscale classical and quantum
systems out of equilibrium. In this framework, thermodynamic quantities, such
as entropy, work, and heat are fluctuating quantities defined at a trajectory
level. A crucial result in this field is provided by the Fluctuation Theorem
(FT), $\langle e^{-\sigma}\rangle=1$ [9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23], where $\sigma$ denotes the entropy production and
$\langle\cdot\rangle$ the ensemble average. This relation implies the second
law of thermodynamics, $\langle\sigma\rangle\geq 0$, and therefore, it can be
considered a generalization thereof.

The idea of employing measurement and feedback in thermodynamic processes
dates back to the thought experiments of Maxwell and Szilard [24, 25, 26],
where knowledge about the microscopic degrees of freedom of a system could be
utilized to seemingly overcome the second law of thermodynamics. The FT and
the second law can be generalized to feedback controlled processes by treating
information on an equal footing as entropy production [27], thus resolving
this paradox. Indeed, for many scenarios modified FTs and a corresponding
second law of information thermodynamics may be derived by including a
stochastic information term, $I$, resulting in [28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 40, 42, 43, 44, 45, 46, 47, 48, 49]

$\langle e^{-\sigma-I}\rangle=1\implies\langle\sigma\rangle\geq-\langle
I\rangle,$ (1)

which allows $\langle\sigma\rangle$ to become negative.

Crucially, for a given feedback control protocol there is no unique way to
define the information term $I$ [34]. For classical feedback control
scenarios, at least two approaches have proven to be useful. In the first
approach, the information term $I$ is given by the transfer entropy (see Refs.
[30, 32]). This quantity is applicable to multiple as well as continuous
measurements, and reduces to the mutual information [29] for a single
measurement. This approach was extended to quantum systems for single [28] as
well as, recently, for continuous measurement [42].

While the resulting FT is a powerful relation highlighting the connection
between information and thermodynamics, it also has significant shortcomings,
both in the classical as well as in the quantum regime: i) The information
term $I$ accumulates with consecutive measurements. As a result, $\langle
I\rangle$ can significantly outgrow the entropy production in the case of many
measurements and may even diverge for continuous measurements [50, 48],
causing the second law of information thermodynamics to become trivial. ii)
The information term $I$ for a given trajectory explicitly depends on the
actual trajectory of the system. For this reason, it cannot be directly
accessed from the measurement outcomes alone [31, 43].

In the second approach developed for classical systems [34], the stochastic
information is given by the coarse-grained entropy $I=-\sigma_{\rm cg}$ [51,
30]. This approach circumvents the shortcomings mentioned above. i) The
ensemble average $\langle\sigma_{\rm cg}\rangle$ does not diverge even for
continuous measurements (as long as the entropy production itself remains
finite). ii) The coarse-grained entropy only depends on the measurement
outcomes, making it accessible from the measured data. While this approach is
particularly useful for continuous and potentially strong measurements, it has
not yet been extended to quantum systems.

Here we fill this gap by deriving a detailed FT that holds for open quantum
systems undergoing measurement and feedback

$\frac{P_{\rm B}[\bar{\Gamma}]}{P[\Gamma]}=e^{-(\sigma[\Gamma]-\sigma_{\rm
cg}[Y])},$ (2)

where $\Gamma$ denotes a trajectory that includes both the measurement
outcomes $Y$ as well as additional quantities specifying the time-evolution of
the system. The probability for such a trajectory is denoted by $P[\Gamma]$,
$P_{\rm B}[\bar{\Gamma}]$ is the probability of the reversed trajectory
$\bar{\Gamma}$ in a corresponding backward experiment, and $\sigma[\Gamma]$ is
the entropy production associated with the trajectory. All these quantities
will be introduced in detail below. From Eq. (2), an integral FT

$\langle e^{-(\sigma-\sigma_{\rm cg})}\rangle=1,$ (3)

as well as a generalized second law

$\langle\sigma\rangle\geq\langle\sigma_{\rm cg}\rangle$ (4)

follow. To illustrate our results, we numerically investigate a continuous
measurement of a qubit and we demonstrate that as the strength of the
continuous measurement increases, $\langle\sigma_{\rm cg}\rangle$ provides a
useful bound on $\langle\sigma\rangle$, while the generalization of the
transfer entropy diverges [42]. We note that in contrast to Ref. [42], Eqs.
(3) and (4) do not rely on Markovian dynamics of the reduced system. Our
results thus provide useful FTs and second laws for arbitrary measurement and
feedback schemes.

_General measurement and feedback scheme._ We consider an open quantum system
that may exchange energy with a reservoir at an inverse temperature $\beta$.
At times $t_{n}$, the system is being measured and the outcome $y_{n}$ is
obtained. The system and reservoir together are described by a density matrix
$\hat{\varrho}^{Y_{n}}_{t}$, conditioned on all previous measurement outcomes
$Y_{n}\equiv\\{y_{1},y_{2},...,y_{n}\\}$, with $t_{n}<t<t_{n+1}$. The
measurements are modeled by POVMs [52, 53, 54] and update the state according
to

$\hat{\varrho}^{Y_{n}}_{t_{n}}=\frac{\hat{M}_{n}(y_{n})\hat{\varrho}^{Y_{n-1}}_{t_{n}}\hat{M}^{\dagger}_{n}(y_{n})}{P[y_{n}|Y_{n-1}]},$
(5)

where
$P[y_{n}|Y_{n-1}]=\text{Tr}\\{\hat{M}^{\dagger}_{n}(y_{n})\hat{M}_{n}(y_{n})\hat{\varrho}^{Y_{n-1}}_{t_{n}}\\}$
and $\hat{M}_{n}(y_{n})$ is the Kraus operator corresponding to obtaining
outcome $y_{n}$ in the measurement at $t_{n}$. The set of Kraus operators
fulfils the relation $\sum_{y}\hat{M}^{\dagger}_{n}(y)\hat{M}_{n}(y)=\hat{I}$,
where $\hat{I}$ is the identity operator.

In between measurements, the time-evolution of the system and reservoir
together is unitary and determined by the total Hamiltonian $\hat{H}_{\rm
tot}(\lambda_{t}^{Y_{n}})=\hat{H}(\lambda_{t}^{Y_{n}})+\hat{V}(\lambda_{t}^{Y_{n}})+\hat{H}_{\rm
R}$, where the first term denotes the Hamiltonian of the system, the second
term the system-reservoir coupling, and the last term the Hamiltonian of the
reservoir. The Hamiltonian depends on a control parameter
$\lambda_{t}^{Y_{n}}$, which may depend on both time, as well as the set of
previous measurement outcomes.

At the initial time $t=0$, the joint quantum state is given by
$\hat{\varrho}_{0}=\hat{\rho}_{0}\otimes\hat{\tau}_{\rm R}$, where
$\hat{\rho}_{0}=\sum_{a}p_{a}|a\rangle\langle a|$ is the initial state of the
system, and $\hat{\tau}_{\rm R}=e^{-\beta\hat{H}_{\rm R}}/Z_{\rm R}$ is the
thermal state of the reservoir with the inverse temperature $\beta$ and the
partition function $Z_{\rm R}=\text{Tr}\\{e^{-\beta\hat{H}_{\rm R}}\\}$. At
all times, the reduced state of the system may be obtained by tracing out the
reservoir $\hat{\rho}_{t}^{Y_{n}}=\text{Tr}_{\rm
R}\\{\hat{\varrho}_{t}^{Y_{n}}\\}$. For simplicity, we assume that at the
final time $t=\tau$ the control parameter takes the same value
$\lambda_{\tau}$ for all $Y\equiv Y_{M}$, where $M$ denotes the total number
of measurements. However, our approach can readily be generalized (see [55]).

_Trajectory thermodynamics._ The evolution of the quantum state of the system
and the reservoir can be unravelled into the trajectories
$\Gamma=\\{Y,\gamma\\}$ containing the set of the measurement outcomes $Y$ and
information about the system and the reservoir
$\gamma=\\{a,E_{0},f,E_{\tau}\\}$ at the beginning and the end of the
protocol. Here $E_{0}$ and $E_{\tau}$ are eigenvalues of $\hat{H}_{\rm R}$ and
refer to the energies of the reservoir at the beginning and at the end of the
trajectory. Similarly, $a$ and $f$ denote the system state at the beginning
and end of the trajectory. While $a$ is an eigenvalue of the initial state
$\hat{\rho}_{0}$, $f$ is an eigenvalue of the reference state $\hat{\rho}_{\rm
r}=\sum_{f}p_{f}|f\rangle\langle f|$, which in general may be chosen
arbitrarily. As we will see below, it specifies the initial quantum state of
the system in the backward experiment. Here we restrict ourselves to the case
where $\hat{\rho}_{\rm r}$ is independent of $Y$ (see [55] for a
generalization).

The entropy production corresponding to the trajectory $\Gamma$ is defined as
[21, 56, 41, 57, 4]

$\sigma[\Gamma]=-\ln{p_{f}}+\ln{p_{a}}+\beta Q[\Gamma],$ (6)

where $Q[\Gamma]=E_{\tau}-E_{0}$ is the change of the energy of the reservoir,
which we identify as heat. We denote the probability associated to a
trajectory by $P[\Gamma]$. It can be computed by choosing
$|a\rangle\otimes|E_{0}\rangle$ as the initial state, computing the total
density matrix conditioned on the measurement outcomes $Y$, and projecting
onto the state $|f\rangle\otimes|E_{\tau}\rangle$ [55].

For the reference state, two choices are popular. First, one may choose the
average final state
$\hat{\rho}_{\mathrm{r}}=\sum_{Y}P[Y]\hat{\rho}_{\tau}^{Y}$, such that the
average of $\sigma[\Gamma]$ reduces to the average entropy production in the
measurement and feedback experiment, see for instance [42, 41]. Second, one
may choose a thermal state $\hat{\rho}_{\rm
r}=e^{-\beta\hat{H}(\lambda_{\tau})}/\text{Tr}\\{e^{-\beta\hat{H}(\lambda_{\tau})}\\}$,
such that, when the initial state is also thermal, the FT results in a
generalization of the Jarzynski relation, see for instance [38, 41].

Figure 1: The second law for the qubit model. Entropy production
$\langle\sigma\rangle$ (black), coarse-grained $\langle\sigma_{\rm
cg}\rangle_{\rm c/q}$ (blue/red), (quantum-classical) mutual information
[panel a)] or transfer entropy [panels b) and c)] $\langle I_{\rm
mi/te}\rangle_{\rm c/q}$ (blue-dashed/red-dashed), and extracted work $\langle
W\rangle_{\rm q}$ (green) as a function of the measurement error $\epsilon$.
The subscripts c and q correspond to the classical and quantum protocols,
respectively. The entropy production $\langle\sigma\rangle$ is equal for both
cases but only for the classical protocol can it be related to the extracted
work $\beta\langle W\rangle_{\rm c}=-\langle\sigma\rangle$ . a) Single
measurement. b) Two measurements with $\kappa\Delta t=1$. c) Two measurements
with $\kappa\Delta t=0.2$. In all panels, $\beta\omega=1$.

_FTs and the second law._ In order to derive the detailed FT [see Eq. (2)], we
need to introduce the backward experiment. In the backward experiment,
measurements with corresponding Kraus operators
$\hat{\Theta}\hat{M}^{\dagger}_{n}(y)\hat{\Theta}^{-1}$, where $\hat{\Theta}$
is the time-reversal operator [4], are performed at times $\tau-t_{n}$. Note
that these Kraus operators always define elements of POVMs and thus correspond
to physical measurements [55]. In between measurements, the time-evolution is
determined by the Hamiltonian $\hat{\Theta}\hat{H}_{\rm
tot}(\xi_{t})\hat{\Theta}^{-1}$. In contrast to the forward experiment, no
feedback is performed in the backward experiment. Instead, a fixed protocol
$\\{\xi_{t}\\}$ is applied. The initial state for the backward experiment is
given by the time-reversed reference state $\hat{\Theta}\hat{\rho}_{\rm
r}\otimes\hat{\tau}_{\rm R}\hat{\Theta}^{-1}$. We denote the probability for a
trajectory $\Gamma$ given a fixed protocol as $P_{\rm
tr}[\Gamma|\\{\xi_{t}\\}]$, where the subscript stands for “time-reversed”.
Before introducing the full backward experiment, we note that the following FT
holds

$e^{-\sigma[\Gamma]}=\frac{P_{\rm
tr}[\bar{\Gamma}|\\{{\lambda}_{\tau-t}^{Y}\\}]}{P[\Gamma]},$ (7)

where the overbar signifies time-reversal, i.e.,
$\bar{\Gamma}=\\{\bar{Y},\bar{\gamma}\\}$, with
$\bar{\gamma}=\\{f,E_{\tau},a,E_{0}\\}$ and $\bar{Y}=\\{y_{M},...,y_{1}\\}$.
This is in fact the standard FT [21, 56, 4, 41], since $P[\Gamma]$ also
provides the probability for the trajectory $\Gamma$ in an experiment where
the protocol $\\{{\lambda}_{t}^{Y}\\}$ is determined in advance rather than by
feedback. In addition, it is known that adding measurements (without feedback)
does not alter the FT [58, 59, 60]

Similar to the classical case in Ref. [34], the full backward experiment is
then described by the distribution

$P_{\rm B}[\bar{\Gamma}]=\frac{P_{\rm
tr}[\bar{\Gamma}|\\{{\lambda}_{\tau-t}^{Y}\\}]P[Y]}{P_{\rm
tr}[\bar{Y}|\\{{\lambda}_{\tau-t}^{Y}\\}]},$ (8)

where $P[Y]=\sum_{\gamma}P[\Gamma]$ is the probability that the measurement
outcomes $Y$ are obtained in the forward experiment and $P_{\rm
tr}[\bar{Y}|\\{{\lambda}_{\tau-t}^{Y}\\}]=\sum_{\gamma}P_{\rm
tr}[\bar{\Gamma}|\\{{\lambda}_{\tau-t}^{Y}\\}]$ is the probability of
obtaining $\bar{Y}$ in the time-reversed scenario. The backward experiment
determined by Eq. (8) has a clear experimental interpretation: 1. $Y$ is
sampled from the distribution $P[Y]$. 2. The protocol
$\\{{\lambda}_{\tau-t}^{Y}\\}$ is implemented, together with the time-reversed
measurements. 3. A postselection is performed: if the measurement outcomes
coincide with $\bar{Y}$, the experiment is a success, otherwise, the data is
discarded and the experiment repeated starting from step 2.

We then find the FTs given in Eqs. (2) and (3), our first main result, by
noting that (see [55] for a derivation)

$e^{-\sigma_{\rm cg}[Y]}=\frac{P_{\rm
tr}[\bar{Y}|\\{{\lambda}_{\tau-t}^{Y}\\}]}{P[Y]},$ (9)

where $\sigma_{\rm cg}[Y]$ denotes the entropy production, coarse-grained over
$\gamma$, the experimentally inaccessible part of the trajectory [30, 51, 34].
By comparing the last equation with Eq. (7), we may interpret $\sigma_{\rm
cg}[Y]$ as the entropy production inferable from the measurement outcomes
alone. Using Jensen’s inequality $\langle f(X)\rangle\leq f(\langle X\rangle)$
for a convex function $f(X)$, we obtain the second law of information
thermodynamics given in Eq. (4), which constitutes our second main result.

Figure 2: Fluctuation theorem and second law for continuous feedback control.
a) Conventional FT $\langle e^{-\sigma}\rangle$ (orange) and our FT $\langle
e^{-(\sigma-\sigma_{\rm cg})}\rangle$ (black) as a function of the measurement
rate $\kappa_{\rm m}$. While the conventional FT breaks down, Eq. (3) holds.
b) The entropy production $\langle\sigma\rangle$ (red) is compared to the
bounds provided by the coarse-grained entropy $\langle\sigma_{\rm cg}\rangle$
(blue), and the quantum classical transfer entropy $-\langle I_{\rm
te}\rangle$ (green). The coarse grained entropy provides a useful bound for
all measurement rates, while the transfer entropy becomes uninformative in the
limit of large measurement rates. Parameters: $\tau/\beta=10$,
$\beta\omega=0.3$, $\beta\chi=0.04$, $\beta\epsilon=0.2$,
$\beta\Omega=0.1\pi$, $\kappa/\omega=0.116$. Each data point was obtained
using a quantum jump simulation with $10^{5}$ trajectories.

_Lindblad master equation._ Since open quantum systems are very often modeled
using Lindblad master equations, we now adapt the results of the previous
section to scenarios where the dynamics of the reduced density matrix in
between the measurements ($t_{n}<t<t_{n+1}$) is described by [61, 62, 63, 64]
(we set $\hbar=1$ hereafter)

$\frac{d}{dt}\hat{\rho}_{t}^{Y_{n}}=-i[\hat{H}(\lambda_{t}^{Y_{n}}),\hat{\rho}_{t}^{Y_{n}}]+\sum_{j}\mathcal{D}[\hat{L}_{j}(\lambda_{t}^{Y_{n}})]\hat{\rho}_{t}^{Y_{n}}$
(10)

where
$\mathcal{D}[\hat{O}]\hat{\rho}=\hat{O}\hat{\rho}\hat{O}^{\dagger}-\frac{1}{2}\\{\hat{\rho},\hat{O}^{\dagger}\hat{O}\\}$.
The POVM measurements update the density matrix $\hat{\rho}_{t_{n}}^{Y_{n}}$
according to the rule presented in Eq. (5). The jump operators obey a local
detailed balance, i.e., for each $j$ there is a $\tilde{j}$ such that
$\hat{L}_{\tilde{j}}=\hat{L}_{j}^{\dagger}e^{-\beta q_{j}/2}$, with
$q_{j}=-q_{\tilde{j}}$.

In this scenario, a trajectory is defined as $\Gamma=\\{Y,\gamma\\}$, where
$\gamma=\\{a,(s_{1},j_{1}),...,(s_{k},j_{k}),...,(s_{K},j_{K}),f\\}$. Here
$(s_{k},j_{k})$ implies that at time $s_{k}$, a jump mediated by the operator
$\hat{L}_{j_{k}}$ occurred. The remaining symbols retain their meaning. On the
trajectory level, the heat released to the reservoir reads
$Q[\Gamma]=\sum_{k}q_{j_{k}}(\lambda_{s_{k}}^{Y})$. The expression for
$\sigma[\Gamma]$ given in Eq. (6), as well as the associated ensemble averages
continue to hold [65, 66, 38, 21, 42].

The backward experiment and the probability $P_{\rm tr}[\Gamma|\\{\xi_{t}\\}]$
are analogously to the unitary case (see [55] for details). In the quantum
jump unravelling, the reversed version of $\Gamma$ is given by
$\bar{\Gamma}=\\{\bar{Y},\bar{\gamma}\\}$, where $\bar{\gamma}=\\{f,(\tau-
s_{K},\tilde{j}_{K}),...,(\tau-s_{k},\tilde{j}_{k}),...,(\tau-
s_{1},\tilde{j}_{1}),a\\}$, which results in Eq. (7). By defining the full
backward experiment with Eq. (8), we recover our main results, Eqs. (2), (3),
and (4) for systems described by Lindblad master equations.

_Qubit model._ We illustrate our results by investigating a feedback
controlled qubit with a Hamiltonian
$\hat{H}=\frac{\omega}{2}\hat{\sigma}_{z}$, where $\hat{\sigma}_{x,y,z}$ are
Pauli matrices in the basis $|0\rangle$ (ground) and $|1\rangle$ (excited).
The system is initially in a thermal state with inverse temperature $\beta$,
$\hat{\rho}_{0}=e^{-\beta\hat{H}}/\text{Tr}\\{e^{-\beta\hat{H}}\\}$. We
consider multiple feedback protocols that aim at extracting work from the
qubit. First, we consider a single measurement with Kraus operators that
commute with the Hamiltonian: $\hat{M}_{0}=\sqrt{1-\epsilon}|0\rangle\langle
0|+\sqrt{\epsilon}|1\rangle\langle 1|$ and
$\hat{M}_{1}=\sqrt{1-\epsilon}|1\rangle\langle
1|+\sqrt{\epsilon}|0\rangle\langle 0|$. If the measurement outcome is $0$, the
system is assumed to be in the ground state and no feedback is performed. If
the measurement outcome is equal to $1$, the system is assumed to be in the
excited state and the unitary transformation $\hat{U}_{1}=|0\rangle\langle
1|+|1\rangle\langle 0|$ is applied. This transformation can extract work by
transforming the excited state to the ground state. In this protocol, heat
from the bath is turned into work using information. Since only the
populations of the qubit are relevant, we label this protocol as classical.
Considering as a reference state the thermal state, the first law of
thermodynamics implies that the entropy production is determined by the
extracted work $\langle\sigma\rangle=-\beta\langle W\rangle_{\rm c}$, where
the subscript stands for classical. Equation (4) then provides a bound on the
extracted work. This is illustrated in Fig. 1 a), where we compare our bound
to the mutual information $\langle I_{\rm mi}\rangle_{\rm c}$. Notably, for
small measurement errors, our bound is tighter.

In addition to the classical protocol, we consider a quantum protocol where
the measurement operators do not commute with the Hamiltonian:
$\hat{M}_{+}=\sqrt{1-\epsilon}|+\rangle\langle+|+\sqrt{\epsilon}|-\rangle\langle-|$
and
$\hat{M}_{-}=\sqrt{1-\epsilon}|-\rangle\langle-|+\sqrt{\epsilon}|+\rangle\langle+|$,
where $|\pm\rangle=(|0\rangle+|1\rangle)/\sqrt{2}$. The corresponding unitary
transformations employed to extract work are
$\hat{U}_{+}=|0\rangle\langle+|+|1\rangle\langle-|$ and
$\hat{U}_{-}=|0\rangle\langle-|+|1\rangle\langle+|$. In this protocol, the
measurement provides the energy which is then extracted in the form of work,
in analogy to Ref. [67, 68]. This implies that the extracted work can no
longer be related to the heat exchanged with the bath and generally differs
from the entropy production. As illustrated in Fig. 1 a), more work can be
extracted with the measurement providing an additional source of energy. Due
to the similarity of the classical and the quantum protocol, we find that the
entropy production is equal in the two cases. However, in the quantum protocol
our bound becomes slightly less tight because the measurement outcome provides
less information on heat, which fully determines the entropy production. The
bound provided by the quantum-classical mutual information $\langle I_{\rm
mi}\rangle_{\rm q}$, which generalizes the mutual information to the quantum
regime [28], hardly changes compared to the classical protocol.

Similar observations can be made when measurement and feedback is applied
twice, with a time delay $\Delta t$ in between the measurements. During this
intermediate stage the interaction with the reservoir is described with the
Lindblad jump operators $\hat{L}_{-}=\sqrt{\kappa}\hat{\sigma}_{-}$ and
$\hat{L}_{+}=\sqrt{\kappa}e^{-\beta\omega/2}\hat{\sigma}_{+}$, where
$\hat{\sigma}_{\pm}=\hat{\sigma}_{x}\pm i\hat{\sigma}_{y}$. The second law is
shown in Fig. 1 b) and c) for $\kappa\Delta t=1$ and $\kappa\Delta t=0.2$,
respectively. In this case, $\langle I_{\rm te}\rangle_{\rm c}$ denotes the
transfer entropy, and $\langle I_{\rm te}\rangle_{\rm q}$ denotes the quantum
classical transfer entropy [42]. For large $\Delta t$, this scenario
corresponds to performing the single-measurement scenario discussed above
twice. For small $\Delta t$, the classical protocol does not benefit from the
second measurement. In contrast, the extracted work in the quantum protocol
can be increased already for small $\Delta t$ since the energy source is the
measurement rather than the environment.

_Continuous feedback control._ Finally, we illustrate our FT and the second
law in a continuous feedback protocol. We consider a qubit with a Hamiltonian
$\hat{H}(t)=\frac{\omega}{2}\hat{\sigma}_{z}+\chi\hat{\sigma}_{x}\cos{(\Omega
t)}$. The effect of the environment is characterized by the same jump
operators as above, $\hat{L}_{\pm}$. The continuous quantum measurement is
realised with the measurement operator $\hat{M}_{1}$ from the classical
scenario at a rate $\kappa_{\rm m}$. In each infinitesimal time-step of
duration $\delta t$, the measurement operator is applied with probability
$\kappa_{\rm m}\delta t$. The time-evolution will thus be interrupted by
measurements of the excited state occurring with rate $\kappa_{\rm m}$ and
error probability $\epsilon$. Upon the detection of the excited state, a
unitary transformation given by $\hat{\sigma}_{x}$ is applied to extract
energy from the system. We note that an analogous example was investigated in
Ref. [42]. The ensemble averages $\langle e^{-\sigma}\rangle$ and $\langle
e^{-(\sigma-\sigma_{\rm cg})}\rangle$ are presented in Fig. 2 a), and the
second law of thermodynamics is illustrated in Fig. 2 b), where the plots are
obtained using numerical simulations (as above, the reference state is the
thermal state of the final Hamiltonian). Our results are consistent with the
FT given in Eq. (3), whereas the ordinary FT breaks down. Furthermore, as the
strength of the measurement $\kappa_{\rm m}$ grows, the coarse grained entropy
provides an increasingly tighter bound in comparison with the quantum-
classical transfer entropy. This demonstrates that our second law of
information thermodynamics (4) is suitable to bound the entropy production in
quantum systems, even in the limit of continuous and strong measurements.

_Conclusions._ We have derived a FT and a second law of information
thermodynamics for quantum system under feedback control. Our results hold for
arbitrary open quantum systems and do not rely on any weak coupling or
Markovian approximations. The information term appearing in the FT is provided
by the coarse-grained entropy, which can be understood as the entropy
production inferable from the measurement outcomes. In contrast to the
quantum-classical transfer entropy, it can thus be computed from the
measurement outcomes alone. We have illustrated our findings on a feedback
controlled qubit and we found that our second law applies even to the limit of
continuous and strong measurements, where the quantum-classical transfer
entropy does no longer provide a useful bound on the entropy production. Our
work thus fills an important gap for deriving quantum FTs and second laws for
arbitrary measurement and feedback schemes.

_Acknowledgements._ P.P.P. and K.P. acknowledge funding from the Swiss
National Science Foundation (Eccellenza Professorial Fellowship
PCEFP2_194268).

## References

  * Seifert [2012] U. Seifert, Stochastic thermodynamics, fluctuation theorems and molecular machines, Rep. Prog. Phys. 75, 126001 (2012).
  * Harris and Schütz [2007] R. J. Harris and G. M. Schütz, Fluctuation theorems for stochastic dynamics, J. Stat. Mech.: Theory Exp. 2007 (07), P07020.
  * Jarzynski [2011] C. Jarzynski, Equalities and inequalities: Irreversibility and the second law of thermodynamics at the nanoscale, Annu. Rev. Condens. Matter Phys. 2, 329 (2011).
  * Campisi  _et al._ [2011a] M. Campisi, P. Hänggi, and P. Talkner, Colloquium: Quantum fluctuation relations: Foundations and applications, Rev. Mod. Phys. 83, 771 (2011a).
  * Esposito  _et al._ [2009] M. Esposito, U. Harbola, and S. Mukamel, Nonequilibrium fluctuations, fluctuation theorems, and counting statistics in quantum systems, Rev. Mod. Phys. 81, 1665 (2009).
  * Manzano and Zambrini [2022] G. Manzano and R. Zambrini, Quantum thermodynamics under continuous monitoring: A general framework, AVS Quantum Science 4, 025302 (2022).
  * Strasberg [2022] P. Strasberg,  _Quantum Stochastic Thermodynamics: Foundations and Selected Applications_ (Oxford University Press, Oxford, 2022).
  * Ciliberto [2017] S. Ciliberto, Experiments in stochastic thermodynamics: Short history and perspectives, Phys. Rev. X 7, 021051 (2017).
  * Jarzynski [1997a] C. Jarzynski, Nonequilibrium equality for free energy differences, Phys. Rev. Lett. 78, 2690 (1997a).
  * Jarzynski [1997b] C. Jarzynski, Equilibrium free-energy differences from nonequilibrium measurements: A master-equation approach, Phys. Rev. E 56, 5018 (1997b).
  * Jarzynski [1999] C. Jarzynski, Hamiltonian derivation of a detailed fluctuation theorem, J. Stat. Phys. 98, 77 (1999).
  * Crooks [1998] G. E. Crooks, Nonequilibrium measurements of free energy differences for microscopically reversible markovian systems, J. Stat. Phys. 90, 1481 (1998).
  * Crooks [1999] G. E. Crooks, Entropy production fluctuation theorem and the nonequilibrium work relation for free energy differences, Phys. Rev. E 60, 2721 (1999).
  * Crooks [2000] G. E. Crooks, Path-ensemble averages in systems driven far from equilibrium, Phys. Rev. E 61, 2361 (2000).
  * Seifert [2005] U. Seifert, Entropy production along a stochastic trajectory and an integral fluctuation theorem, Phys. Rev. Lett. 95, 040602 (2005).
  * [16] H. Tasaki, Jarzynski relations for quantum systems and some applications, arXiv:cond-mat/0009244 [cond-mat.stat-mech] .
  * [17] J. Kurchan, A quantum fluctuation theorem, arXiv:cond-mat/0007360 [cond-mat.stat-mech] .
  * Bochkov and Kuzovlev [1977] G. N. Bochkov and I. E. Kuzovlev, General theory of thermal fluctuations in nonlinear systems, Zh. Eksp. Teor. Fiz. 72, 238 (1977).
  * Bochkov and Kuzovlev [1981a] G. Bochkov and Y. Kuzovlev, Nonlinear fluctuation-dissipation relations and stochastic models in nonequilibrium thermodynamics: I. generalized fluctuation-dissipation theorem, Physica A: Statistical Mechanics and its Applications 106, 443 (1981a).
  * Bochkov and Kuzovlev [1981b] G. Bochkov and Y. Kuzovlev, Nonlinear fluctuation-dissipation relations and stochastic models in nonequilibrium thermodynamics: Ii. kinetic potential and variational principles for nonlinear irreversible processes, Physica A: Statistical Mechanics and its Applications 106, 480 (1981b).
  * Manzano  _et al._ [2018] G. Manzano, J. M. Horowitz, and J. M. R. Parrondo, Quantum fluctuation theorems for arbitrary environments: Adiabatic and nonadiabatic entropy production, Phys. Rev. X 8, 031037 (2018).
  * Talkner  _et al._ [2007] P. Talkner, E. Lutz, and P. Hänggi, Fluctuation theorems: Work is not an observable, Phys. Rev. E 75, 050102 (2007).
  * [23] F. L. S. Rodrigues and E. Lutz, Nonequilibrium thermodynamics of quantum coherence beyond linear response, arXiv:2301.13529 [quant-ph] .
  * Maxwell [1872] J. Maxwell,  _Theory of Heat_ (Longmans, Green, and Company, London, 1872).
  * Szilard [1929] L. Szilard, über die entropieverminderung in einem thermodynamischen system bei eingriffen intelligenter wesen, Z. Phys. 53, 840 (1929).
  * Rex [2017] A. Rex, Maxwell’s demon—a historical review, Entropy 19, 240 (2017).
  * Parrondo  _et al._ [2015] J. M. Parrondo, J. Horowitz, and T. Sagawa, Thermodynamics of information, Nat. Phys. 11, 131 (2015).
  * Sagawa and Ueda [2008] T. Sagawa and M. Ueda, Second law of thermodynamics with discrete quantum feedback control, Phys. Rev. Lett. 100, 080403 (2008).
  * Sagawa and Ueda [2010] T. Sagawa and M. Ueda, Generalized jarzynski equality under nonequilibrium feedback control, Phys. Rev. Lett. 104, 090602 (2010).
  * Sagawa and Ueda [2012a] T. Sagawa and M. Ueda, Nonequilibrium thermodynamics of feedback control, Phys. Rev. E 85, 021104 (2012a).
  * Sagawa and Ueda [2012b] T. Sagawa and M. Ueda, Fluctuation theorem with information exchange: Role of correlations in stochastic thermodynamics, Phys. Rev. Lett. 109, 180602 (2012b).
  * Horowitz and Vaikuntanathan [2010] J. M. Horowitz and S. Vaikuntanathan, Nonequilibrium detailed fluctuation theorem for repeated discrete feedback, Phys. Rev. E 82, 061120 (2010).
  * Ito and Sagawa [2013] S. Ito and T. Sagawa, Information thermodynamics on causal networks, Phys. Rev. Lett. 111, 180603 (2013).
  * Potts and Samuelsson [2018] P. P. Potts and P. Samuelsson, Detailed fluctuation relation for arbitrary measurement and feedback schemes, Phys. Rev. Lett. 121, 210603 (2018).
  * Ponmurugan [2010] M. Ponmurugan, Generalized detailed fluctuation theorem under nonequilibrium feedback control, Phys. Rev. E 82, 031129 (2010).
  * Morikuni and Tasaki [2010] Y. Morikuni and H. Tasaki, Quantum jarzynski-sagawa-ueda relations, J. Stat. Phys. 143, 1 (2010).
  * Funo  _et al._ [2013] K. Funo, Y. Watanabe, and M. Ueda, Integral quantum fluctuation theorems under measurement and feedback control, Phys. Rev. E 88, 052121 (2013).
  * Gong  _et al._ [2016] Z. Gong, Y. Ashida, and M. Ueda, Quantum-trajectory thermodynamics with discrete feedback control, Phys. Rev. A 94, 012107 (2016).
  * Murashita  _et al._ [2017] Y. Murashita, Z. Gong, Y. Ashida, and M. Ueda, Fluctuation theorems in feedback-controlled open quantum systems: Quantum coherence and absolute irreversibility, Phys. Rev. A 96, 043840 (2017).
  * Ashida  _et al._ [2014] Y. Ashida, K. Funo, Y. Murashita, and M. Ueda, General achievable bound of extractable work under feedback control, Phys. Rev. E 90, 052125 (2014).
  * Funo  _et al._ [2015] K. Funo, Y. Murashita, and M. Ueda, Quantum nonequilibrium equalities with absolute irreversibility, New J. Phys. 17, 075005 (2015).
  * Yada  _et al._ [2022] T. Yada, N. Yoshioka, and T. Sagawa, Quantum fluctuation theorem under quantum jumps with continuous measurement and feedback, Phys. Rev. Lett. 128, 170601 (2022).
  * Sagawa and Ueda [2013] T. Sagawa and M. Ueda, Role of mutual information in entropy production under information exchanges, New J. Phys. 15, 125012 (2013).
  * Abreu and Seifert [2012] D. Abreu and U. Seifert, Thermodynamics of genuine nonequilibrium states under feedback control, Phys. Rev. Lett. 108, 030601 (2012).
  * Lahiri  _et al._ [2012] S. Lahiri, S. Rana, and A. M. Jayannavar, Fluctuation theorems in the presence of information gain and feedback, J. Phys. A: Math. Theor. 45, 065002 (2012).
  * Wächtler  _et al._ [2016] C. W. Wächtler, P. Strasberg, and T. Brandes, Stochastic thermodynamics based on incomplete information: generalized jarzynski equality with measurement errors with or without feedback, New J. Phys. 18, 113042 (2016).
  * Shiraishi and Sagawa [2015] N. Shiraishi and T. Sagawa, Fluctuation theorem for partially masked nonequilibrium dynamics, Phys. Rev. E 91, 012130 (2015).
  * Schmitt  _et al._ [2023] R. K. Schmitt, P. P. Potts, H. Linke, J. Johansson, P. Samuelsson, M. Rico-Pasto, and F. Ritort, Information-to-work conversion in single-molecule experiments: From discrete to continuous feedback, Phys. Rev. E 107, L052104 (2023).
  * Horowitz and Esposito [2014] J. M. Horowitz and M. Esposito, Thermodynamics with continuous information flow, Phys. Rev. X 4, 031015 (2014).
  * Horowitz and Sandberg [2014] J. M. Horowitz and H. Sandberg, Second-law-like inequalities with information and their interpretations, New J. Phys. 16, 125007 (2014).
  * Kawai  _et al._ [2007] R. Kawai, J. M. R. Parrondo, and C. V. den Broeck, Dissipation: The phase-space perspective, Phys. Rev. Lett. 98, 080602 (2007).
  * Nielsen and Chuang [2010] M. Nielsen and I. Chuang,  _Quantum Computation and Quantum Information: 10th Anniversary Edition_ (Cambridge University Press, Cambridge, 2010).
  * Wiseman and Milburn [2010] H. Wiseman and G. Milburn,  _Quantum Measurement and Control_ (Cambridge University Press, Cambridge, 2010).
  * Jacobs and Steck [2006] K. Jacobs and D. A. Steck, A straightforward introduction to continuous quantum measurement, Contemp. Phys. 47, 279 (2006).
  * [55] See supplementary material below.
  * Manzano  _et al._ [2015] G. Manzano, J. M. Horowitz, and J. M. R. Parrondo, Nonequilibrium potential and fluctuation theorems for quantum maps, Phys. Rev. E 92, 032129 (2015).
  * Landi and Paternostro [2021] G. T. Landi and M. Paternostro, Irreversible entropy production: From classical to quantum, Rev. Mod. Phys. 93, 035008 (2021).
  * Watanabe  _et al._ [2014] G. Watanabe, B. P. Venkatesh, P. Talkner, M. Campisi, and P. Hänggi, Quantum fluctuation theorems and generalized measurements during the force protocol, Phys. Rev. E 89, 032114 (2014).
  * Campisi  _et al._ [2010] M. Campisi, P. Talkner, and P. Hänggi, Fluctuation theorems for continuously monitored quantum fluxes, Phys. Rev. Lett. 105, 140601 (2010).
  * Campisi  _et al._ [2011b] M. Campisi, P. Talkner, and P. Hänggi, Influence of measurements on the statistics of work performed on a quantum system, Phys. Rev. E 83, 041114 (2011b).
  * Breuer and Petruccione [2003] H.-P. Breuer and F. Petruccione,  _The theory of open quantum systems_ (Oxford University Press, Oxford, 2003).
  * Potts  _et al._ [2021] P. P. Potts, A. A. S. Kalaee, and A. Wacker, A thermodynamically consistent markovian master equation beyond the secular approximation, New J. Phys. 23, 123013 (2021).
  * Albash  _et al._ [2012] T. Albash, S. Boixo, D. A. Lidar, and P. Zanardi, Quantum adiabatic markovian master equations, New J. Phys. 14, 123016 (2012).
  * [64] G. T. Landi, M. J. Kewming, M. T. Mitchison, and P. P. Potts, Current fluctuations in open quantum systems: Bridging the gap between quantum continuous measurements and full counting statistics, arXiv:2303.04270 [quant-ph] .
  * Horowitz [2012] J. M. Horowitz, Quantum-trajectory approach to the stochastic thermodynamics of a forced harmonic oscillator, Phys. Rev. E 85, 031110 (2012).
  * Horowitz and Parrondo [2013] J. M. Horowitz and J. M. R. Parrondo, Entropy production along nonequilibrium quantum jump trajectories, New J. Phys. 15, 085028 (2013).
  * Elouard  _et al._ [2017] C. Elouard, D. Herrera-Martí, B. Huard, and A. Auffèves, Extracting work from quantum measurement in maxwell’s demon engines, Phys. Rev. Lett. 118, 260603 (2017).
  * Elouard  _et al._ [2016] C. Elouard, D. Herrera Marti, M. Clusel, and A. Auffèves, The role of quantum measurement in stochastic thermodynamics, npj Quantum Inf. 3 (2016).

Supplementary Material: Quantum Fluctuation Theorem for Arbitrary Measurement
and Feedback Schemes

In this supplementary material we provide derivations of the detailed
fluctuation theorem (FT) (2), the integral FT (3), and the second law of
information thermodynamics (4) presented in the main text. We also provide
supplementary calculations on the examples used to illustrate our findings in
the main text. The supplementary material is structured as follows. In Sec. I
we provide derivations of our main results for the general scenario, where the
joint quantum state of system and environment is modeled by unitary time-
evolution interrupted by measurements. In Sec. II we focus on scenarios where
the reduced system is modeled with a Lindblad master equation. In Sec. III we
discuss the qubit model with discrete measurement and feedback, as well as the
quantum classical transfer entropy. The continuous measurement and the
corresponding qubit model are discussed in Sec. IV. Finally, in Sec. V we
provide details about the measurements in the backward experiment.

##  I I. Unitary evolution

###  I.1 Forward experiment

The total Hamiltonian of the system and the reservoir has already been
introduced in the main text of the letter, but we restate it here for
convenience. It is given by

$\hat{H}_{\rm
tot}(\lambda_{t}^{Y_{n}})=\hat{H}(\lambda_{t}^{Y_{n}})+\hat{H}_{\rm
R}+\hat{V}(\lambda_{t}^{Y_{n}}),$ (S1)

where $\hat{H}(\lambda_{t}^{Y_{n}})$ is the Hamiltonian of the system,
$\hat{H}_{\rm R}=\sum_{E}E|E\rangle\langle E|$ is the Hamiltonian of the
reservoir, and $\hat{V}(\lambda_{t}^{Y_{n}})$ is the coupling Hamiltonian. At
the beginning of the experiment, the joint quantum state is assumed to be of
the form

$\hat{\varrho}_{0}=\hat{\rho}_{0}\otimes\hat{\tau}_{\rm R},$ (S2)

where $\hat{\rho}_{0}=\sum_{a}p_{a}|a\rangle\langle a|$ is the initial state
of the system, and $\hat{\tau}_{\rm R}=e^{-\beta\hat{H}_{\rm R}}/Z_{\rm R}$ is
the thermal state of the reservoir. The probability of the trajectory
$\Gamma=\\{Y,\gamma\\}$, where $\gamma=\\{a,E_{0},f_{Y},E_{\tau}\\}$, is given
by

$P[\Gamma]=p_{a}p_{E_{0}}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\otimes|E_{\tau}\rangle\langle
E_{\tau}|\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}|a\rangle\langle
a|\otimes|E_{0}\rangle\langle E_{0}|\right\\},$ (S3)

where $p_{E}=e^{-\beta E}/Z_{\rm R}$ and $|f_{Y}\rangle$ is an eigenstate of
the reference state $\hat{\rho}_{\rm
r}^{Y}=\sum_{f_{Y}}p_{f_{Y}}|f_{Y}\rangle\langle f_{Y}|$. The reference state
may in general be different for each $Y$(generalizing the scenario considered
in the main text). We have also introduced a measurement superoperator

$\mathcal{M}_{n}(y_{n})\hat{\varrho}=\hat{M}_{n}(y_{n})\otimes\hat{I}_{\rm
R}\hat{\varrho}\hat{M}_{n}^{\dagger}(y_{n})\otimes\hat{I}_{\rm R}$ (S4)

and a unitary superoperator

$\mathcal{U}_{n}(Y_{n})\hat{\varrho}=\hat{U}_{n}(Y_{n})\hat{\varrho}\hat{U}_{n}^{\dagger}(Y_{n}),$
(S5)

where the unitary evolution in between the measurements is described by an
operator

$\hat{U}_{n}(Y_{n})=\mathcal{T}e^{-i\int_{t_{n}}^{t_{n+1}}dt\hat{H}_{\rm
tot}\left(\lambda_{t}^{Y_{n}}\right)},$ (S6)

where $t_{0}=0$, $t_{M+1}=\tau$, and $\mathcal{T}$ is the time ordering
operator.

###  I.2 Entropy production

The entropy production corresponding to the trajectory $\Gamma$ may be written
as [21, 56, 41, 57, 4]

$\sigma[\Gamma]=-\ln{p_{f_{Y}}}+\ln{p_{a}}-\ln{p_{E_{\tau}}}+\ln{p_{E_{0}}}=\Delta
S[\Gamma]+\beta Q[\Gamma],$ (S7)

where $\Delta S[\Gamma]=-\ln{p_{f_{Y}}}+\ln{p_{a}}$ and
$Q[\Gamma]=E_{\tau}-E_{0}$ is the stochastic heat transferred to the
reservoir. The expectation value of the stochastic heat is equal to the
average energy change of the reservoir

$\begin{split}\langle Q\rangle&=\sum_{\Gamma}P[\Gamma]Q[\Gamma]\\\
&=\sum_{a,E_{0},f_{Y},E_{\tau},Y}(E_{\tau}-E_{0})p_{a}p_{E_{0}}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\otimes|E_{\tau}\rangle\langle
E_{\tau}|\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}|a\rangle\langle
a|\otimes|E_{0}\rangle\langle E_{0}|\right\\}\\\
&=\sum_{Y,E_{\tau}}P[Y]E_{\tau}\text{Tr}\\{\hat{I}_{S}\otimes|E_{\tau}\rangle\langle
E_{\tau}|\hat{\varrho}_{\tau}^{Y}\\}-\sum_{E_{0}}E_{0}p_{E_{0}}\\\
&=\sum_{Y}P[Y]\text{Tr}\\{\hat{I}_{S}\otimes\hat{H}_{\rm
R}\hat{\varrho}_{\tau}^{Y}\\}-\text{Tr}\\{\hat{H}_{\rm R}\hat{\tau}_{\rm
R}\\}.\end{split}$ (S8)

In the calculation we have used the measurement update rule

$\hat{\varrho}_{t_{n}}^{Y_{n}}=\frac{\mathcal{M}_{n}(y_{n})\hat{\varrho}_{t_{n}}^{Y_{n-1}}}{P[y_{n}|Y_{n-1}]},$
(S9)

where
$P[y_{n+1}|Y_{n}]=\text{Tr}\\{\mathcal{M}_{n+1}(y_{n+1})\hat{\varrho}_{t_{n+1}}^{Y_{n}}\\}$.
After performing a similar calculation, we find that the ensemble average of
$\Delta S[\Gamma]$ is given by

$\langle\Delta
S\rangle=\sum_{\Gamma}P[\Gamma](-\ln{p_{f_{Y}}}+\ln{p_{a}})=-\sum_{f_{Y},Y}P[Y]\langle
f_{Y}|\hat{\rho}_{\tau}^{Y}|f_{Y}\rangle\ln{p_{f_{Y}}}+\sum_{a}p_{a}\ln{p_{a}}.$
(S10)

The first choice for the reference state is the average state of the system at
the end of the experiment

$\hat{\rho}_{\rm r}=\hat{\rho}_{\tau}\equiv\sum_{Y}P[Y]\hat{\rho}_{\tau}^{Y}.$
(S11)

In this case, $\Delta S[\Gamma]$ corresponds to the change of the stochastic
von Neumann entropy between the final and the initial states. The average
entropy production becomes

$\langle\sigma\rangle=S_{\rm vn}\left(\hat{\rho}_{\tau}\right)-S_{\rm
vn}\left(\hat{\rho}_{0}\right)+\beta\langle Q\rangle,$ (S12)

where $S_{\rm vn}(\hat{\rho})=-\text{Tr}(\hat{\rho}\ln{\hat{\rho}})$ is the
von Neumann entropy [52]. Alternatively, we may chose the reference state

$\hat{\rho}_{\rm
r}^{Y}=e^{-\beta\hat{H}(\lambda_{\tau}^{Y})}/Z(\lambda_{\tau}^{Y}),$ (S13)

where
$Z(\lambda_{\tau}^{Y})=\text{Tr}\\{e^{-\beta\hat{H}(\lambda_{\tau}^{Y})}\\}$.
We also assume that the initial state of the system is given by a thermal
state $\hat{\rho}_{0}=e^{-\beta\hat{H}(\lambda_{0})}/Z(\lambda_{0})$, where
$Z(\lambda_{0})=\text{Tr}\\{e^{-\beta\hat{H}(\lambda_{0})}\\}$. In this
scenario, the expectation value of the entropy production is given by

$\langle\sigma\rangle=\sum_{Y}P[Y]\beta\left(\text{Tr}\\{\hat{H}(\lambda_{\tau}^{Y})\hat{\rho}_{\tau}^{Y}\\}-F(\lambda_{\tau}^{Y})\right)-\beta\left(\text{Tr}\\{\hat{H}(\lambda_{0})\hat{\rho}_{0}\\}-F(\lambda_{0})\right)+\beta\langle
Q\rangle,$ (S14)

where $F(\lambda)=-\frac{1}{\beta}\ln{Z(\lambda)}$. If the Kraus operators
commute with the Hamiltonian of the system, measurements do not affect the
energy of the system. In this case, when the energy stored in the interaction
Hamiltonian is small [41], the entropy production in Eq. (S14) can be
connected to the work $\langle W\rangle$ extracted in the feedback driving,
$\langle\sigma\rangle=-\beta\langle
W\rangle-\sum_{Y}P[Y]\beta\left(F(\lambda_{\tau}^{Y})-F(\lambda_{0})\right)$.
In the general case, measurements may change the energy of the system, and
$\langle\sigma\rangle$ will include an additional contribution from the energy
change due to the measurement. This energy injection has been referred to as
quantum heat [68], and provides the basis for measurement driven heat engines
[67].

###  I.3 Backward experiment

In the backward experiment, a fixed protocol $\\{\xi_{t}\\}$ is applied to the
the initial state $\hat{\Theta}\hat{\rho}_{\rm r}^{Y}\otimes\hat{\tau}_{\rm
R}\hat{\Theta}^{-1}$. Unlike in the forward experiment, this protocol is not
determined by measurement outcomes but it is fixed from the start of the
backward experiment. In addition, measurements are performed. The probability
of the inverse trajectory $\bar{\Gamma}=\\{\bar{\gamma},\bar{Y}\\}$, where
$\bar{\gamma}=\\{f_{Y},E_{\tau},a,E_{0}\\}$, given the protocol
$\\{\xi_{t}\\}$ is then given by

$P_{\rm
tr}[\bar{\Gamma}|\\{\xi_{t}\\}]=p_{f_{Y}}p_{E_{\tau}}\text{Tr}\left\\{\Theta|a\rangle\langle
a|\otimes|E_{0}\rangle\langle
E_{0}|\Theta^{-1}\bar{\mathcal{U}}_{0}(\\{\xi_{t}\\})\left(\prod_{n=M}^{1}\bar{\mathcal{M}}_{n}(y_{n})\bar{\mathcal{U}}_{n}(\\{\xi_{t}\\})\right)\Theta|f_{Y}\rangle\langle
f_{Y}|\otimes|E_{\tau}\rangle\langle E_{\tau}|\Theta^{-1}\right\\}.$ (S15)

Here we have introduced

$\bar{\mathcal{U}}_{n}(\\{\xi_{t}\\})\hat{\varrho}=\bar{U}_{n}(\\{\xi_{t}\\})\hat{\varrho}\bar{U}_{n}^{\dagger}(\\{\xi_{t}\\}),$
(S16) $\bar{U}_{n}(\\{\xi_{t}\\})=\mathcal{T}e^{-i\int_{\tau-t_{n+1}}^{\tau-
t_{n}}dt\hat{\Theta}\hat{H}_{\rm tot}\left(\xi_{t}\right)\hat{\Theta}^{-1}},$
(S17)

and

$\bar{\mathcal{M}}_{n}(y_{n})\hat{\varrho}=\hat{\Theta}\hat{M}^{\dagger}_{n}(y_{n})\otimes\hat{I}_{\rm
R}\hat{\Theta}^{-1}\hat{\varrho}\hat{\Theta}\hat{M}_{n}(y_{n})\otimes\hat{I}_{\rm
R}\hat{\Theta}^{-1}.$ (S18)

In contrast to the forward experiment, we kept the explicit $\\{\xi_{t}\\}$
dependence in the unitary steps, since the protocol is not determined by the
measurement outcomes. In order to obtain Eq. (7), we use the principle of
microreversibility for driven quantum systems [4]

$\hat{\Theta}^{-1}\bar{U}_{n}(\\{\lambda_{\tau-t}^{Y}\\})\hat{\Theta}=\hat{U}_{n}^{\dagger}(Y_{n}).$
(S19)

This relation can be derived by diving the interval $t_{n+1}-t_{n}$ into $N$
steps of duration $\delta t$ and using a trotterization

$\bar{U}_{n}(\\{\lambda_{\tau-t}^{Y}\\})=e^{-i\delta t\hat{\Theta}\hat{H}_{\rm
tot}\left(\lambda^{Y}_{\tau-(\tau-
t_{n})}\right)\hat{\Theta}^{-1}}\cdot\cdot\cdot e^{-i\delta
t\hat{\Theta}\hat{H}_{\rm tot}\left(\lambda^{Y}_{\tau-(\tau-
t_{n+1})}\right)\hat{\Theta}^{-1}}=e^{-i\delta t\hat{\Theta}\hat{H}_{\rm
tot}\left(\lambda^{Y}_{t_{n}}\right)\hat{\Theta}^{-1}}\cdot\cdot\cdot
e^{-i\delta t\hat{\Theta}\hat{H}_{\rm
tot}\left(\lambda^{Y}_{t_{n+1}}\right)\hat{\Theta}^{-1}}.$ (S20)

The time reversal operator is antiunitary, $\hat{\Theta}i=-i\hat{\Theta}$,
which leads to $e^{-i\delta t\hat{\Theta}\hat{H}_{\rm
tot}\left(\lambda^{Y}_{t}\right)\hat{\Theta}^{-1}}=\hat{\Theta}e^{i\delta
t\hat{H}_{\rm tot}\left(\lambda^{Y}_{t}\right)}\hat{\Theta}^{-1}$. Upon
trotterizing $\hat{U}_{n}$ and taking its Hermitian conjugate, we obtain Eq.
(S19). The principle of microreversibility, together with the cyclic property
of the trace, results in

$P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=p_{f_{Y}}p_{E_{\tau}}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\otimes|E_{\tau}\rangle\langle
E_{\tau}|\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}|a\rangle\langle
a|\otimes|E_{0}\rangle\langle E_{0}|\right\\},$ (S21)

which, together with Eq. (S7), yields Eq. (7).

###  I.4 Fluctuation theorems and the second law

The coarse-grained entropy is defined as [51, 30, 34]

$e^{-\sigma_{\rm cg}[Y]}\equiv\sum_{\gamma}e^{-\sigma[\Gamma]}P[\gamma|Y],$
(S22)

where $P[\gamma|Y]=P[\Gamma]/P[Y]$ is the conditional probability for the part
of the trajectory that is not accessible by the measurements. The probability
to obtain the set of the measurement outcomes $Y$ is given by

$\begin{split}P[Y]&=\sum_{\gamma}P[\Gamma]\\\
&=\sum_{a,E_{0},f_{Y},E_{\tau}}p_{a}p_{E_{0}}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\otimes|E_{\tau}\rangle\langle
E_{\tau}|\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}|a\rangle\langle
a|\otimes|E_{0}\rangle\langle E_{0}|\right\\}\\\
&=\text{Tr}\left\\{\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}\hat{\varrho}_{0}\right\\}.\end{split}$
(S23)

The coarse-grained entropy may then be expressed as

$e^{-\sigma_{\rm
cg}[Y]}=\frac{1}{P[Y]}\sum_{\gamma}e^{-\sigma[\Gamma]}P[\Gamma]=\frac{1}{P[Y]}\sum_{\bar{\gamma}}P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=\frac{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}{P[Y]},$ (S24)

recovering Eq. (9) in the main text, where to obtain the second equality we
used Eq. (7), and in the third equality we used the definition of $P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]$. The last quantity can be found from

$P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]=\text{Tr}\left\\{\left(\prod_{n=M}^{1}\bar{\mathcal{M}}_{n}(y_{n})\bar{\mathcal{U}}_{n}\right)\Theta\hat{\rho}_{\rm
r}^{Y}\otimes\hat{\tau}_{\rm R}\Theta^{-1}\right\\}.$ (S25)

The detailed FT (2) can then be obtained by combining the full backward
probability (8) with Eqs. (7) and (9). The integral FT (3) follows from

$\begin{split}\langle e^{-(\sigma-\sigma_{\rm
cg})}\rangle&=\sum_{\Gamma}P[\Gamma]e^{-(\sigma[\Gamma]-\sigma_{\rm
cg}[Y])}=\sum_{\Gamma}P_{\rm B}[\bar{\Gamma}]=\sum_{Y}\frac{P[Y]}{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}\sum_{\gamma}P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]\\\ &=\sum_{Y}\frac{P[Y]}{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]=\sum_{Y}P[Y]\\\
&=\sum_{Y}\text{Tr}\left\\{\left(\prod_{n=1}^{M}\mathcal{U}_{n}(Y_{n})\mathcal{M}_{n}(y_{n})\right)\mathcal{U}_{0}\hat{\varrho}_{0}\right\\}=\text{Tr}\\{\hat{\varrho}_{0}\\}=1,\\\
\end{split}$ (S26)

where in the second equality we used the detailed FT (2), in the third
equality we used Eq. (8), in the fourth inequality we applied the definition
of $P_{\rm tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]$, and in the sixth in
equality we used Eq. (S23).

The second law of information thermodynamics (4) follows from Jensen’s
inequality, $\langle f(X)\rangle\leq f(\langle X\rangle)$ for a convex
function $f(X)$, applied to the integral FT (3). The ensemble average of the
coarse-grained entropy can be computed using

$\langle\sigma_{\rm cg}\rangle=\sum_{Y}P[Y]\ln{\frac{P[Y]}{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}}.$ (S27)

##  II II. Lindblad master equation

###  II.1 Forward experiment

In many situations, the time-evolution of the density matrix of the system
$\hat{\rho}_{t}^{Y_{n}}$ in between the measurements $n$ and $n+1$ may be
described using the Lindblad master equation (10), which is restated here for
convenience

$\frac{d}{dt}\hat{\rho}_{t}^{Y_{n}}=-i[\hat{H}(\lambda_{t}^{Y_{n}}),\hat{\rho}_{t}^{Y_{n}}]+\sum_{j}\mathcal{D}[\hat{L}_{j}(\lambda_{t}^{Y_{n}})]\hat{\rho}_{t}^{Y_{n}}=\mathcal{L}(\lambda_{t}^{Y_{n}})\hat{\rho}_{t}^{Y_{n}}.$
(S28)

In the small time interval $dt$, the change in the quantum state may be
expressed as

$\hat{\rho}_{t+dt}^{Y_{n}}=\hat{\rho}_{t}^{Y_{n}}-i[\hat{H}_{\rm
eff}(\lambda_{t}^{Y_{n}}),\hat{\rho}_{t}^{Y_{n}}]dt+\sum_{j}\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{t}^{Y_{n}}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})dt,$
(S29)

where we have introduced an effective non-Hermitian Hamiltonian

$\hat{H}_{\rm
eff}(\lambda_{t}^{Y_{n}})=\hat{H}(\lambda_{t}^{Y_{n}})-\frac{i}{2}\sum_{j}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\hat{L}_{j}(\lambda_{t}^{Y_{n}}).$
(S30)

Equation (S29) may be unravelled into trajectories. Along a single trajectory,
the conditional quantum state $\hat{\rho}_{\rm c}$ follows a stochastic master
equation

$d\hat{\rho}_{\rm c}=-i[\hat{H}_{\rm eff}(\lambda_{t}^{Y_{n}}),\hat{\rho}_{\rm
c}]dt+\sum_{j}\text{Tr}\\{\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{\rm
c}\\}\hat{\rho}_{\rm
c}dt+\sum_{j}\left(\frac{\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{\rm
c}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})}{\text{Tr}\\{\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{\rm
c}\\}}-\hat{\rho}_{\rm c}\right)dN_{j},$ (S31)

where $dN_{j}$ are random variables taking a value $1$ if the jump $j$ occurs
and $0$ otherwise, obeying the relation
$dN_{j}dN_{j^{\prime}}=\delta_{j,j^{\prime}}dN_{j}$. The probability for a
jump to occur is given by
$p_{c}^{j}=\text{Tr}\\{\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{\rm
c}\\}dt$.

The probability density of the trajectory $\Gamma$ corresponding to the
unravelling (S31) reads

$P[\Gamma]=p_{a}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\mathcal{T}\left\\{\mathcal{U}_{\rm
eff}(\tau,0)\prod_{n=1}^{M}\mathcal{M}_{n}(y_{n})\prod_{k=1}^{K}\mathcal{J}_{k}(j_{k},s_{k})\right\\}|a\rangle\langle
a|\right\\},$ (S32)

where

$\mathcal{M}_{n}(y_{n})\hat{\rho}=\hat{M}_{n}(y_{n})\hat{\rho}\hat{M}^{\dagger}_{n}(y_{n})$
(S33)

is the superoperator corresponding to the measurement at the time $t_{n}$,

$\mathcal{J}_{k}(j_{k},s_{k})\hat{\rho}=\hat{L}_{j_{k}}(\lambda^{Y_{n}}_{s_{k}})\hat{\rho}\hat{L}_{j_{k}}^{\dagger}(\lambda^{Y_{n}}_{s_{k}})$
(S34)

is a superoperator describing the $k$-th jump $j_{k}$ at the time $s_{k}$, and
$\mathcal{U}_{\rm eff}(\tau,0)$ an effective nonunitary superoperator that
governs the time-evolution of the system from $t=0$ to $t=\tau$ in between
measurements and jumps. It is given by

$\mathcal{U}_{\rm eff}(t^{\prime\prime},t^{\prime})\hat{\rho}=\hat{U}_{\rm
eff}(t^{\prime\prime},t^{\prime})\hat{\rho}\hat{U}_{\rm
eff}^{\dagger}(t^{\prime\prime},t^{\prime}),$ (S35)

where

$\hat{U}_{\rm
eff}(t^{\prime\prime},t^{\prime})=\mathcal{T}e^{-i\int_{t^{\prime}}^{t^{\prime\prime}}dt\hat{H}_{\rm
eff}(\lambda_{t}^{Y_{n}})}.$ (S36)

Note that $P[\Gamma]$ is a probability density. To obtain the probability that
each jump in the trajectory $\Gamma$ occurs within the time-window $ds$ around
the times $s_{k}$, it needs to be multiplied by $(ds_{k})^{K}$. The time
ordering superoperator $\mathcal{T}\\{\cdot\\}$ in Eq. (S32) ensures that all
the superoperators act in the correct order. We use this notation instead of
explicitly writing all the effective nonunitary superoperators in between
jumps and measurements to simplify the notation. For example, in the case of a
single measurement and for a trajectory with a single jump occurring after the
measurement,

$\mathcal{T}\left\\{\mathcal{U}_{\rm
eff}(\tau,0)\mathcal{M}_{1}(y_{1})\mathcal{J}_{1}(j_{1},s_{1})\right\\}|a\rangle\langle
a|=\mathcal{U}_{\rm
eff}(\tau,s_{1})\mathcal{J}_{1}(j_{1},s_{1})\mathcal{U}_{\rm
eff}(s_{1},t_{1})\mathcal{M}_{1}(y_{1})\mathcal{U}_{\rm
eff}(t_{1},0)|a\rangle\langle a|.$ (S37)

The entropy production along the trajectory reads [21]

$\sigma[\Gamma]=\Delta S[\Gamma]+\beta Q[\Gamma],$ (S38)

where $\Delta S[\Gamma]=-\ln{p_{f_{Y}}}+\ln{p_{a}}$ and
$Q[\Gamma]=\sum_{k=1}^{K}q_{j_{k}}(\lambda^{Y_{n}}_{s_{k}})=\sum_{j}\int_{0}^{\tau}dN_{j}q_{j}(\lambda_{t}^{Y_{n}})$
is the stochastic heat. For the expectation value of the change in the system
entropy we recover Eq. (S10) as expected. The ensemble average of the heat
transferred to the bath is given by

$\langle
Q\rangle=\sum_{\Gamma}P[\Gamma]\sum_{j}\int_{0}^{\tau}dN_{j}q_{j}(\lambda_{t}^{Y_{n}})=\sum_{Y}P[Y]\int_{0}^{\tau}\sum_{j}q_{j}(\lambda_{t}^{Y_{n}})\text{Tr}\\{\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{t}^{Y_{n}}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\\}dt.$
(S39)

This equation is obtained by using that the probability for a jump $j$ at time
$t$, averaged over all previous quantum jumps (but not measurement outcomes)
is given by
$\text{Tr}\\{\hat{L}_{j}(\lambda_{t}^{Y_{n}})\hat{\rho}_{t}^{Y_{n}}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{n}})\\}dt$.

###  II.2 Backward experiment

In the backward experiment, a fixed protocol $\\{\xi_{t}\\}$ is applied
starting from an initial state $\hat{\Theta}\hat{\rho}_{\rm
r}^{Y}\hat{\Theta}^{-1}$. The probability density for the trajectory
$\bar{\Gamma}$ is given by

$P_{\rm
tr}[\bar{\Gamma}|\\{\xi_{t}\\}]=p_{f_{Y}}\text{Tr}\left\\{\hat{\Theta}|a\rangle\langle
a|\hat{\Theta}^{-1}\mathcal{T}\left\\{\bar{\mathcal{U}}_{\rm
eff}(\tau,0)\prod_{n=1}^{M}\bar{\mathcal{M}}_{n}(y_{n})\prod_{k=1}^{K}\bar{\mathcal{J}}_{k}(\bar{s}_{k},\bar{j}_{k})\right\\}\hat{\Theta}|f_{Y}\rangle\langle
f_{Y}|\hat{\Theta}^{-1}\right\\},$ (S40)

where

$\bar{\mathcal{M}}_{n}(y_{n})\hat{\rho}=\hat{\Theta}\hat{M}^{\dagger}_{n}(y_{n})\hat{\Theta}^{-1}\hat{\rho}\hat{\Theta}\hat{M}_{n}(y_{n})\hat{\Theta}^{-1}$
(S41)

is the measurement superoperator of the measurement performed at the time
$\tau-t_{n}$,

$\bar{\mathcal{J}}_{k}(\bar{s}_{k},\bar{j}_{k})\hat{\rho}=\hat{\Theta}\hat{L}_{\bar{j}_{k}}(\xi_{\bar{s}_{k}})\hat{\Theta}^{-1}\hat{\rho}\hat{\Theta}\hat{L}_{\bar{j}_{k}}^{\dagger}(\xi_{\bar{s}_{k}})\hat{\Theta}^{-1},$
(S42)

is the superoperator of the $k$-th jump occurring at the time
$\bar{s}_{k}=\tau-s_{k}$ with $\bar{j}_{k}=\tilde{j}_{k}$, and
$\bar{\mathcal{U}}_{\rm eff}(\tau,0)$ is an effective nonunitary superoperator
describing the time-evolution in between measurements and jumps. Its action is
implemented according to Eq. (S35), but with a nonunitary operator
$\bar{U}_{\rm eff}(t^{\prime\prime},t^{\prime})$ generated with the non-
Hermitian Hamiltonian $\hat{\Theta}\hat{H}_{\rm
eff}^{\dagger}(\xi_{t})\hat{\Theta}^{-1}=\hat{\Theta}\hat{H}(\xi_{t})\hat{\Theta}^{-1}-\frac{i}{2}\sum_{j}\hat{\Theta}\hat{L}_{j}^{\dagger}(\xi_{t})\hat{L}_{j}(\xi_{t})\hat{\Theta}^{-1}$in
a complete analogy to Eq. (S36). This results in the microreversibility
condition $\hat{\Theta}^{-1}\bar{U}_{\rm
eff}(t^{\prime\prime},t^{\prime})\hat{\Theta}=\hat{U}_{\rm
eff}^{\dagger}(\tau-t^{\prime},\tau-t^{\prime\prime})$ [38, 66]. Moreover, we
have $L_{\bar{j}_{k}}=L_{\tilde{j}_{k}}=e^{-\beta
q_{k}/2}L_{j_{k}}^{\dagger}$. Using these relations together with the cyclic
property of the trace yields

$P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=p_{f_{Y}}\prod_{k=1}^{K}e^{-\beta
q_{j_{k}}(\lambda^{Y}_{s_{k}})}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\mathcal{T}\left\\{\mathcal{U}_{\rm
eff}(\tau,0)\prod_{n=1}^{M}\mathcal{M}_{n}(y_{n})\prod_{k=1}^{K}\mathcal{J}_{k}(j_{k},s_{k})\right\\}|a\rangle\langle
a|\right\\},$ (S43)

which leads to Eq. (7).

###  II.3 Fluctuation Theorems

The coarse-grained entropy can still be expressed by Eq. (9)

$e^{-\sigma_{\rm
cg}[Y]}=\int\mathfrak{D}[\gamma]e^{-\sigma[\Gamma]}P[\gamma|Y]=\frac{1}{P[Y]}\int\mathfrak{D}[\gamma]e^{-\sigma[\Gamma]}P[\Gamma]=\frac{1}{P[Y]}\int\mathfrak{D}[\bar{\gamma}]P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=\frac{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}{P[Y]},$ (S44)

where in place of $\sum_{\gamma}$ we have introduced a path integral

$\int\mathfrak{D}[\gamma]=\sum_{f_{Y},a}\sum_{K=0}^{\infty}\prod_{k=1}^{K}\sum_{\\{j_{k}\\}}\int_{0}^{s_{k+1}}ds_{k}.$
(S45)

The probability of obtaining the set of the measurement outcomes $Y$ can be
expressed as

$P[Y]=\int\mathfrak{D}[\gamma]P[\Gamma]=\text{Tr}\left\\{\prod_{n=1}^{M}\left(\mathcal{M}_{n}(y_{n})\mathcal{T}e^{\int_{t_{n-1}}^{t_{n}}\mathcal{L}(\lambda_{t}^{Y_{n}})dt}\right)\hat{\rho}_{0}\right\\},$
(S46)

and $P_{\rm tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]$ can be computed
analogously. As is the previous section, the detailed FT [see Eq. (2)] follows
from Eqs. (8), (7), and (S44). The integral FT, given in Eq. (3), is obtained
as follows:

$\begin{split}\langle e^{-(\sigma-\sigma_{\rm
cg})}\rangle=&\sum_{Y}\int\mathfrak{D}[\gamma]P[\Gamma]e^{-(\sigma[\Gamma]-\sigma_{\rm
cg}[Y])}=\sum_{Y}\int\mathfrak{D}[\bar{\gamma}]P_{\rm
B}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]\\\ =&\sum_{Y}\frac{P[Y]}{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}\int\mathfrak{D}[\bar{\gamma}]P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=\sum_{Y}\frac{P[Y]}{P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]}P_{\rm
tr}[\bar{Y}|\\{\lambda_{\tau-t}^{Y}\\}]=1,\end{split}$ (S47)

where to obtain the second equality and the third equality, we have used Eqs.
(2) and (8), respectively.

##  III III. Qubit model

###  III.1 Single measurement and feedback

The system with the Hamiltonian $\hat{H}=\frac{\omega}{2}\hat{\sigma}_{z}$ is
initially in the quantum state

$\hat{\rho}_{0}=p_{1}|1\rangle\langle 1|+p_{0}|0\rangle\langle 0|,$ (S48)

where $p_{1}=e^{-\beta\omega}/(1+e^{-\beta\omega})$ and
$p_{0}=1/(1+e^{-\beta\omega})$. In the classical protocol, the state is
measured in the computational basis, with corresponding probabilities

$\begin{split}P[0]=&(1-\epsilon)p_{0}+\epsilon p_{1},\\\
P[1]=&(1-\epsilon)p_{1}+\epsilon p_{0}.\\\ \end{split}$ (S49)

After the measurement, the density matrix of the system conditioned on the
outcome is given by

$\begin{split}\hat{\rho}^{0}=&\left(p_{1}\epsilon|1\rangle\langle
1|+p_{0}(1-\epsilon)|0\rangle\langle 0|\right)/P[0],\\\
\hat{\rho}^{1}=&\left(p_{0}\epsilon|0\rangle\langle
0|+p_{1}(1-\epsilon)|1\rangle\langle 1|\right)/P[1].\\\ \end{split}$ (S50)

After the measurement, a unitary operator $\hat{U}_{Y}$ is applied to
$\hat{\rho}^{Y}$. For $Y=1$, this swaps the states while for $Y=0$, it does
nothing (see main text). Then, the system thermalizes again and reaches
$\hat{\rho}_{\tau}=\hat{\rho}_{0}$.

In the backward experiment, $Y$ is chosen randomly from the distribution given
in Eq. (S49). For a given $Y$, the unitary operator $\hat{U}_{Y}^{\dagger}$ is
applied to the state $\hat{\rho}_{\tau}$ and subsequently, the the state is
measured in the computational basis with corresponding probabilities

$P_{\rm tr}[0|\hat{U}_{0}^{\dagger}]=P_{\rm
tr}[1|\hat{U}_{1}^{\dagger}]=(1-\epsilon)p_{0}+\epsilon p_{1}.$ (S51)

The coarse-grained entropy can be computed as

$\sigma_{\rm cg}[Y]=\ln{\left(P[Y]/P_{\rm
tr}[Y|\hat{U}_{Y}^{\dagger}]\right)}.$ (S52)

$a$ | $Y$ | $f$ | $q$ | $P[\Gamma]$ | $e^{-\sigma}$ | $P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]$
---|---|---|---|---|---|---
0 | 0 | 0 | 0 | $p_{0}(1-\epsilon)p_{0}$ | $1$ | $p_{0}p_{0}(1-\epsilon)$
1 | 0 | 0 | $\omega$ | $p_{1}\epsilon p_{0}$ | $\frac{p_{0}}{p_{1}}e^{-\beta\omega}$ | $p_{0}p_{1}\epsilon$
0 | 0 | 1 | $-\omega$ | $p_{0}(1-\epsilon)p_{1}$ | $\frac{p_{1}}{p_{0}}e^{\beta\omega}$ | $p_{1}p_{0}(1-\epsilon)$
1 | 0 | 1 | 0 | $p_{1}\epsilon p_{1}$ | $1$ | $p_{1}p_{1}\epsilon$
0 | 1 | 0 | $\omega$ | $p_{0}\epsilon p_{0}$ | $e^{-\beta\omega}$ | $p_{0}p_{1}\epsilon$
1 | 1 | 0 | 0 | $p_{1}(1-\epsilon)p_{0}$ | $\frac{p_{0}}{p_{1}}$ | $p_{0}p_{0}(1-\epsilon)$
0 | 1 | 1 | 0 | $p_{0}\epsilon p_{1}$ | $\frac{p_{1}}{p_{0}}$ | $p_{1}p_{1}\epsilon$
1 | 1 | 1 | $-\omega$ | $p_{1}(1-\epsilon)p_{1}$ | $e^{\beta\omega}$ | $p_{1}p_{0}(1-\epsilon)$
Table S1: The qubit model with a single classical measurement. Table shows all
the combinations of $\Gamma=\\{a,Y,f\\}$, corresponding stochastic heat $q$,
probability $P[\Gamma]$, corresponding stochastic entropy production $\sigma$,
and probability $P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]$.

The trajectories discussed in the main text either involve the energies of the
environment at the beginning and the end of the protocol (for unitary
evolution) or the jumps induced by the environment (for Lindblad master
equations). Here, we are not interested in the details of the final
thermalization step and we thus group together all trajectories that result in
the same heat ($q$) exchanged with the environment. In this case, the
trajectory is fully determined by $\Gamma=\\{a,Y,f\\}$. In Tab. S1 we list all
different trajectories, providing the corresponding probabilities as well as
the stochastic entropy production. The probability of the trajectory $\Gamma$
can be computed as

$P[\Gamma]=p_{a}p_{f}\text{Tr}\left\\{\hat{M}_{Y}|a\rangle\langle
a|\hat{M}_{Y}^{\dagger}\right\\}=p_{a}p_{f}\left(\delta_{Y,a}(1-\epsilon)+\epsilon(1-\delta_{Y,a})\right).$
(S53)

From Tab. S1, we can verify our integral FT $\langle e^{-(\sigma-\sigma_{\rm
cg})}\rangle=1$. In addition, we provide the probability of the inverse
trajectory $\Gamma$ when we apply the inverse protocol, which can be found
using

$P_{\rm
tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]=p_{f}\text{Tr}\left\\{|a\rangle\langle
a|\hat{M}_{Y}^{\dagger}\hat{U}_{Y}^{\dagger}\hat{\rho}_{\tau}\hat{U}_{Y}\hat{M}_{Y}\right\\}=p_{f}\left(\delta_{a,Y}p_{0}(1-\epsilon)+(1-\delta_{a,Y})p_{1}\epsilon\right).$
(S54)

The full backward probability can be computed as $P_{\rm
B}[\bar{\Gamma}]=P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]P[Y]/P_{\rm
tr}[Y|\hat{U}_{Y}^{\dagger}]$ [cf. Eq. (8)].

The average entropy production is given by

$\langle\sigma\rangle=\beta\omega\left(\epsilon-p_{1}\right),$ (S55)

implying that work can be extracted as long as the measurement error is small
enough, $\epsilon<p_{1}$. The average coarse-grained entropy reads

$\langle\sigma_{\rm
cg}\rangle=-H\left(P[0]\right)-\ln{\left((1-\epsilon)p_{0}+\epsilon
p_{1}\right)},$ (S56)

where $H(x)\equiv-x\ln{x}-(1-x)\ln{(1-x)}$. The ensemble average of the mutual
information [28, 29], which provides another second law of information
thermodynamics [see Eq. (1)], is given by the expression

$\langle I_{\rm mi}\rangle_{\rm c}\equiv
S(\hat{\rho}_{0})-\sum_{Y}P[Y]S(\hat{\rho}^{Y})=-H(\epsilon)+H\left(P[0]\right).$
(S57)

The extracted work, which we define as the average change in the energy
resulting from the feedback unitary

$\langle
W\rangle=\sum_{Y}P[Y]\left(\text{Tr}\\{\hat{H}\hat{\rho}^{Y}\\}-\text{Tr}\\{\hat{H}\hat{U}_{Y}\hat{\rho}^{Y}\hat{U}_{Y}^{\dagger}\\}\right),$
(S58)

coincides with $-\langle\sigma\rangle/\beta$. This is due to the fact the the
measurement Kraus operators commute with the Hamiltonian and do not change the
internal energy of the system.

Calculations for the quantum protocol are performed in a similar way, with the
same initial state given in Eq. (S48). The probabilities of the measurement
outcomes are given by $P[+]=P[-]=1/2$. The post-measured quantum states,
conditioned on the outcomes are given by

$\begin{split}\hat{\rho}^{+}=&(1-\epsilon)|+\rangle\langle+|+\epsilon|-\rangle\langle-|+\sqrt{\epsilon(1-\epsilon)}(p_{0}-p_{1})\left(|+\rangle\langle-|+|-\rangle\langle+|\right),\\\
\hat{\rho}^{-}=&(1-\epsilon)|-\rangle\langle-|+\epsilon|+\rangle\langle+|+\sqrt{\epsilon(1-\epsilon)}(p_{0}-p_{1})\left(|+\rangle\langle-|+|-\rangle\langle+|\right).\\\
\end{split}$ (S59)

Application of the feedback results in

$\hat{U}_{+}\hat{\rho}^{+}\hat{U}_{+}^{\dagger}=\hat{U}_{-}\hat{\rho}^{-}\hat{U}_{-}^{\dagger}=(1-\epsilon)|0\rangle\langle
0|+\epsilon|1\rangle\langle
1|+\sqrt{\epsilon(1-\epsilon)}(p_{0}-p_{1})\left(|0\rangle\langle
1|+|1\rangle\langle 0|\right).$ (S60)

Following the feedback, the system relaxes to
$\hat{\rho}_{\tau}=\hat{\rho}_{0}$.

In the backward experiment, the probability of obtaining the outcome $Y$,
given that $\hat{U}_{Y}^{\dagger}$ was applied to the state
$\hat{\rho}_{\tau}$ is given by

$P_{\rm tr}[-|\hat{U}_{-}^{\dagger}]=P_{\rm
tr}[+|\hat{U}_{+}^{\dagger}]=(1-\epsilon)p_{0}+\epsilon p_{1}.$ (S61)

The coarse grained entropy can be obtained with Eq. (S52). Its average is
given by the expression

$\langle\sigma_{\rm cg}\rangle=\ln{(1/2)}-\ln{\left((1-\epsilon)p_{0}+\epsilon
p_{1}\right)},$ (S62)

whereas the quantum classical mutual information [28] reads

$\langle I_{\rm mi}\rangle_{\rm q}\equiv
S(\hat{\rho}_{0})-\sum_{Y}P[Y]S(\hat{\rho}^{Y})=H(p_{0})-H\left(\frac{1+\sqrt{1-4\epsilon(1-\epsilon)(1-(p_{0}-p_{1})^{2})}}{2}\right).$
(S63)

$a$ | $Y$ | $f$ | $q$ | $P[\Gamma]$ | $e^{-\sigma}$ | $P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]$ | $a$ | $Y$ | $f$ | q | $P[\Gamma]$ | $e^{-\sigma}$ | $P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]$
---|---|---|---|---|---|---|---|---|---|---|---|---|---
0 | + | 0 | 0 | $p_{0}(1-\epsilon)p_{0}/2$ | $1$ | $p_{0}(1-\epsilon)p_{0}/2$ | 0 | + | 0 | $\omega$ | $p_{0}\epsilon p_{0}/2$ | $e^{-\beta\omega}$ | $p_{0}\epsilon p_{1}/2$
1 | + | 0 | 0 | $p_{1}(1-\epsilon)p_{0}/2$ | $\frac{p_{0}}{p_{1}}$ | $p_{0}(1-\epsilon)p_{0}/2$ | 1 | + | 0 | $\omega$ | $p_{1}\epsilon p_{0}/2$ | $\frac{p_{0}}{p_{1}}e^{-\beta\omega}$ | $p_{0}\epsilon p_{1}/2$
0 | + | 1 | $-\omega$ | $p_{0}(1-\epsilon)p_{1}/2$ | $\frac{p_{1}}{p_{0}}e^{\beta\omega}$ | $p_{1}(1-\epsilon)p_{0}/2$ | 0 | + | 1 | 0 | $p_{0}\epsilon p_{1}/2$ | $\frac{p_{1}}{p_{0}}$ | $p_{1}\epsilon p_{1}/2$
1 | + | 1 | $-\omega$ | $p_{1}(1-\epsilon)p_{1}/2$ | $e^{\beta\omega}$ | $p_{1}(1-\epsilon)p_{0}/2$ | 1 | + | 1 | 0 | $p_{1}\epsilon p_{1}/2$ | $1$ | $p_{1}\epsilon p_{1}/2$
0 | - | 0 | 0 | $p_{0}(1-\epsilon)p_{0}/2$ | $1$ | $p_{0}(1-\epsilon)p_{0}/2$ | 0 | - | 0 | $\omega$ | $p_{0}\epsilon p_{0}/2$ | $e^{-\beta\omega}$ | $p_{0}\epsilon p_{1}/2$
1 | - | 0 | 0 | $p_{1}(1-\epsilon)p_{0}/2$ | $\frac{p_{0}}{p_{1}}$ | $p_{0}(1-\epsilon)p_{0}/2$ | 1 | - | 0 | $\omega$ | $p_{1}\epsilon p_{0}/2$ | $\frac{p_{0}}{p_{1}}e^{-\beta\omega}$ | $p_{0}\epsilon p_{1}/2$
0 | - | 1 | $-\omega$ | $p_{0}(1-\epsilon)p_{1}/2$ | $\frac{p_{1}}{p_{0}}e^{\beta\omega}$ | $p_{1}(1-\epsilon)p_{0}/2$ | 0 | - | 1 | 0 | $p_{0}\epsilon p_{1}/2$ | $\frac{p_{1}}{p_{0}}$ | $p_{1}\epsilon p_{1}/2$
1 | - | 1 | $-\omega$ | $p_{1}(1-\epsilon)p_{1}/2$ | $e^{\beta\omega}$ | $p_{1}(1-\epsilon)p_{0}/2$ | 1 | - | 1 | 0 | $p_{1}\epsilon p_{1}/2$ | 1 | $p_{1}\epsilon p_{1}/2$
Table S2: The qubit model with a single quantum measurement. Table shows all
the combinations of $\Gamma=\\{a,Y,f,q\\}$, probability $P[\Gamma]$,
corresponding stochastic entropy production $\sigma$, and probability $P_{\rm
tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]$. Here $q$ in $\Gamma$ corresponds to
$-q$ in $\bar{\Gamma}$.

Similarly to the classical case, we group together all quantum jump
trajectories with the same net stochastic heat $q=\omega,0,-\omega$. After
this grouping, a trajectory is then defined by $\Gamma=\\{a,Y,f,q\\}$. Note
that in contrast to the classical case, $q$ is not uniquely identified by $a$,
$Y$, and $f$. In Tab. S2, we list all different trajectories providing the
corresponding probabilities and entropy productions. The probability for a
trajectory is given by

$P[\Gamma]=p_{a}p_{f}|\langle
b|\hat{U}_{Y}\hat{M}_{Y}|a\rangle|^{2}=\frac{p_{a}p_{f}}{2}\left((\delta_{f,0}\delta_{q,0}+\delta_{f,1}\delta_{q,-\omega})(1-\epsilon)+(\delta_{f,1}\delta_{q,0}+\delta_{f,0}\delta_{q,\omega})\epsilon\right),$
(S64)

where $b=q/\omega+f$. From Tab. S2, one may verify $\langle
e^{-(\sigma-\sigma_{\rm cg})}\rangle=1$ For the ensemble average of the
entropy production we find the same value as for the classical model, given in
Eq. (S55). Unlike in the classical case, the extracted work [see Eq. (S58)] is
not equal to $-\langle\sigma\rangle/\beta$. Instead, we obtain

$\langle W\rangle=\left(\frac{1}{2}-\epsilon\right)\omega.$ (S65)

The discrepancy between $-\langle\sigma\rangle$ and $\beta\langle W\rangle$
arises due to noncommutativity of the measurement Kraus operators and the
Hamiltonian. The measurement changes the energy of the quantum state, an
effect that has been referred to as quantum heat [68, 67]. Finally, the
backward probability can be found from $P_{\rm B}[\bar{\Gamma}]=P_{\rm
tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]P[Y]/P_{\rm
tr}[Y|\hat{U}_{Y}^{\dagger}]$ [cf. Eq. (8)], where

$P_{\rm tr}[\bar{\Gamma}|\hat{U}_{Y}^{\dagger}]=p_{f}\text{Tr}\langle
b|\hat{\rho}_{\tau}|b\rangle|\langle
b|\hat{U}_{Y}\hat{M}_{Y}|a\rangle|^{2}=P[\Gamma]\frac{\langle
b|\hat{\rho}_{\tau}|b\rangle}{p_{a}},$ (S66)

and $b=f+q/\omega$.

###  III.2 Two measurements

We now turn to the scenario, where measurement and feedback are performed
twice. The protocol is similar to the single measurement case. First, a
measurement with Kraus operator $\hat{M}_{y_{1}}$ is performed. Then, a
unitary depending on the measurement outcome, $\hat{U}_{y_{1}}$. is applied.
After this first feedback round, the system is interacting with a thermal bath
for a time $\Delta t$. This is modeled by the Lindblad master equation
described in the main text with Liouvillian $\mathcal{L}$. After this partial
thermalization, another round of measurement ($\hat{M}_{y_{2}}$) and feedback
($\hat{U}_{y_{2}}$) is applied. Finally, the system thermalizes, returning to
the thermal state.

In this case, we describe trajectories by the variables
$\Gamma=\\{a,y_{1},y_{2},f,q_{1},q_{2}\\}$, where $q_{j}$ denotes the heat
exchanged with the environment after measurement $j$. The probabilities can be
calculated similarly to the single measurement case

$\displaystyle P[\Gamma|_{q_{1}=\omega}]=p_{a}p_{f}|\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|0\rangle|^{2}|\langle
1|\hat{U}_{y_{1}}\hat{M}_{y_{1}}|a\rangle|^{2}\langle 0|e^{\mathcal{L}\Delta
t}\left\\{|1\rangle\langle 1|\right\\}|0\rangle,$ (S67) $\displaystyle
P[\Gamma|_{q_{1}=-\omega}]=p_{a}p_{f}|\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|1\rangle|^{2}|\langle
0|\hat{U}_{y_{1}}\hat{M}_{y_{1}}|a\rangle|^{2}\langle 1|e^{\mathcal{L}\Delta
t}\left\\{|0\rangle\langle 0|\right\\}|1\rangle,$ $\displaystyle
P[\Gamma|_{q_{1}=0}]=p_{a}p_{f}\sum_{c,d=0,1}\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|c\rangle\langle
c|\hat{U}_{y_{1}}\hat{M}_{y_{1}}|a\rangle\langle
a|\hat{M}^{\dagger}_{y_{1}}\hat{U}^{\dagger}_{y_{1}}|d\rangle\langle
c|e^{\mathcal{L}\Delta t}\left\\{|c\rangle\langle d|\right\\}|d\rangle\langle
d|\hat{M}^{\dagger}_{y_{2}}\hat{U}^{\dagger}_{y_{2}}|b\rangle,$

where again $b=q_{2}/\omega+f$. In total, this results in 96 possible
trajectories. We refrain from providing a table with all probabilities. They
can be evaluated in a straightforward manner using the identities:

$\begin{split}&\langle\ell^{\prime}|\hat{U}_{y}\hat{M}_{y}|\ell\rangle=\left(\delta_{y,\ell}\sqrt{1-\epsilon}+(1-\delta_{y,\ell})\sqrt{\epsilon}\right)\left(\delta_{y,0}\delta_{\ell^{\prime},\ell}+\delta_{y,1}(1-\delta_{\ell^{\prime},\ell})\right)\text{
(classical case)}\\\
&\langle\ell^{\prime}|\hat{U}_{y}\hat{M}_{y}|\ell\rangle=\left(\delta_{y,+}+\delta_{y,-}(-1)^{\ell}\right)\left(\delta_{\ell^{\prime},0}\sqrt{(1-\epsilon)/2}+(-1)^{\ell}\delta_{\ell^{\prime},1}\sqrt{\epsilon/2}\right)\text{
(quantum case)}\\\ &\langle 0|e^{\mathcal{L}\Delta t}\left\\{|0\rangle\langle
0|\right\\}|0\rangle=\frac{e^{-\beta\omega}e^{-\kappa(1+e^{-\beta\omega})t}+1}{1+e^{-\beta\omega}}\\\
&\langle 1|e^{\mathcal{L}\Delta t}\left\\{|0\rangle\langle
0|\right\\}|1\rangle=\frac{e^{-\beta\omega}\left(1-e^{-\kappa(1+e^{-\beta\omega})t}\right)}{1+e^{-\beta\omega}}\\\
&\langle 0|e^{\mathcal{L}\Delta t}\left\\{|1\rangle\langle
1|\right\\}|0\rangle=\frac{\left(1-e^{-\kappa(1+e^{-\beta\omega})t}\right)}{1+e^{-\beta\omega}}\\\
&\langle 1|e^{\mathcal{L}\Delta t}\left\\{|1\rangle\langle
1|\right\\}|1\rangle=\frac{e^{-\kappa(1+e^{-\beta\omega})t}+e^{-\beta\omega}}{1+e^{-\beta\omega}}\\\
&\langle 0|e^{\mathcal{L}\Delta t}\left\\{|0\rangle\langle
1|\right\\}|1\rangle=e^{i\omega t}e^{-\kappa(1+e^{-\beta\omega})/2}\\\
&\langle 1|e^{\mathcal{L}\Delta t}\left\\{|1\rangle\langle
0|\right\\}|0\rangle=e^{i\omega t}e^{-\kappa(1+e^{-\beta\omega})/2},\\\
\end{split}$ (S68)

where $\ell,\ell^{\prime}=0,1$. The probability for obtaining the measurement
outcomes $Y=\\{y_{2},y_{1}\\}$ can be found from the expression

$P[Y]=\text{Tr}\left\\{\hat{M}_{y_{2}}e^{\mathcal{L}\Delta
t}\left\\{\hat{U}_{y_{1}}\hat{M}_{y_{1}}\hat{\rho}_{0}\hat{M}_{y_{1}}^{\dagger}\hat{U}_{y_{1}}^{\dagger}\right\\}\hat{M}_{y_{2}}^{\dagger}\right\\}.$
(S69)

Similarly, the probability of obtaining $\bar{Y}=\\{y_{1},y_{2}\\}$ when we
reverse the feedback unitary operations is given by

$P_{\rm
tr}[\bar{Y}|U_{Y}^{\dagger}]=\text{Tr}\left\\{\hat{M}_{y_{2}}^{\dagger}e^{\mathcal{L}\Delta
t}\left\\{\hat{U}_{y_{2}}^{\dagger}\hat{M}_{y_{2}}^{\dagger}\hat{\rho}_{\tau}\hat{M}_{y_{2}}\hat{U}_{y_{2}}\right\\}\hat{M}_{y_{1}}\right\\}.$
(S70)

These quantities allow to compute the coarse-grained entropy $\sigma_{\rm
cg}[Y]$. Our calculations are consistent with our integral FT $\langle
e^{-(\sigma-\sigma_{[}\rm cg])}\rangle=1$. Full backward probability $P_{\rm
B}[\bar{\Gamma}]$ [cf. Eq. (8)] can be obtained using

$\displaystyle P[\bar{\Gamma}|_{q_{1}=\omega}|U_{Y}^{\dagger}]=p_{f}\langle
b|\hat{\rho}_{\tau}|b\rangle|\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|0\rangle|^{2}\langle 1|e^{\mathcal{L}\Delta
t}\left\\{|0\rangle\langle 0|\right\\}|1\rangle|\langle
1|\hat{U}_{y_{1}}\hat{M}_{y_{1}}|a\rangle|^{2},$ (S71) $\displaystyle
P[\bar{\Gamma}|_{q_{1}=-\omega}|U_{Y}^{\dagger}]=p_{f}\langle
b|\hat{\rho}_{\tau}|b\rangle|\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|1\rangle|^{2}\langle 0|e^{\mathcal{L}\Delta
t}\left\\{|1\rangle\langle 1|\right\\}|0\rangle|\langle
0|\hat{U}_{y_{1}}\hat{M}_{y_{1}}|a\rangle|^{2},$ $\displaystyle
P[\bar{\Gamma}|_{q_{1}=0}|U_{Y}^{\dagger}]=p_{f}\langle
b|\hat{\rho}_{\tau}|b\rangle\sum_{c,d=0,1}\langle
a|\hat{M}_{y_{1}}^{\dagger}\hat{U}_{y_{1}}^{\dagger}|c\rangle\langle
c|\hat{M}_{y_{2}}^{\dagger}\hat{U}_{y_{2}}^{\dagger}|b\rangle\langle
b|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|d\rangle\langle
d|\hat{U}_{y_{2}}\hat{M}_{y_{2}}|a\rangle\langle c|e^{\mathcal{L}\Delta
t}\left\\{|c\rangle\langle d|\right\\}|d\rangle,$

where $b=f+q_{2}/\omega$. The average extracted work $\langle W\rangle$, which
is given by the generalization of Eq. (S58) to the two measurements case, is
equal to $-\langle\sigma\rangle/\beta$ in the classical case. In the quantum
case, these two quantities cannot be equated, which was already discussed for
the single measurement scenario. The (quantum classical) transfer entropy
$\langle I_{\rm te}\rangle$, which givens another bound on the entropy
production, is introduced below.

###  III.3 Quantum classical transfer entropy

The quantum classical transfer entropy $\langle I_{\rm te}\rangle$, which was
recently introduced in Ref. [42], provides another second law of information
thermodynamics for multiple and continuous measurement [cf. Eq. (1)]. This
quantity is defined as

$\langle I_{\rm
te}\rangle\equiv\sum_{n=0}^{M-1}\sum_{Y_{n}}P[Y_{n}]\mathcal{I}(\hat{\rho}_{t_{n+1}}^{Y_{n}}),$
(S72)

where

$\mathcal{I}(\hat{\rho}_{t_{n+1}}^{Y_{n}})=\left(S_{\rm
vn}\left(\hat{\rho}_{t_{n+1}}^{Y_{n}}\right)-\sum_{y_{n+1}}P[y_{n+1}|Y_{n}]S_{\rm
vn}\left(\hat{\rho}_{t_{n+1}}^{Y_{n+1}}\right)\right),$ (S73)

and

$\hat{\rho}_{t_{n}}^{Y_{n}}=\frac{\mathcal{M}_{n}(y_{n})\hat{\rho}_{t_{n}}^{Y_{n-1}}}{P[y_{n}|Y_{n-1}]},$
(S74)

is the post measurement updated quantum state, and $P[y_{n}|Y_{n-1}]=\text{
Tr}\\{\mathcal{M}_{n}(y_{n})\hat{\rho}_{t_{n}}^{Y_{n-1}}\\}$. In classical
systems, the quantum classical transfer entropy reduces to the transfer
entropy [30].

In the qubit model considered above, the density matrix
$\hat{\rho}_{t_{1}}^{Y_{0}}$corresponds to $\hat{\rho}_{0}$. Similarly,
$\hat{\rho}_{t_{1}}^{Y_{1}}$ corresponds to $\hat{\rho}^{y_{1}}$ [see Eqs.
(S50) and (S59)], $\hat{\rho}_{t_{2}}^{Y_{1}}$ corresponds to
$e^{\mathcal{L}t}\left\\{\hat{U}_{y_{1}}\hat{\rho}^{y_{1}}\hat{U}_{y_{1}}^{\dagger}\right\\}/\text{Tr}\left\\{e^{\mathcal{L}t}\left\\{\hat{U}_{y_{1}}\hat{\rho}^{y_{1}}\hat{U}_{y_{1}}^{\dagger}\right\\}\right\\}$,
and $\hat{\rho}_{t_{2}}^{Y_{2}}$ corresponds to
$\hat{M}_{y_{2}}\hat{\rho}_{t_{2}}^{Y_{1}}\hat{M}_{y_{2}}^{\dagger}/\text{Tr}\left\\{\hat{M}_{y_{2}}\hat{\rho}_{t_{2}}^{Y_{1}}\hat{M}_{y_{2}}^{\dagger}\right\\}$.

##  IV IV. Continuous measurement

Continuous measurements of two types may be considered: First, we may consider
the limit where measurements are performed repeatedly, with a fixed time
$\delta t$ in between measurements. Then, the limit $\delta t\rightarrow 0$ is
taken. To avoid the Zeno effect, the strength of the measurement is usually
taken to go to zero at the same time, such that the rate of acquiring
information remains finite. The POVM elements are usually taken to be
Gaussian, which can be motivated from the central limit theorem. See Ref. [54]
for more information for this type of continuous measurement. Our FT holds for
this type of continuous measurements as they are a special case of the
multiple measurement scenario discussed in Secs. I and II above.

Alternatively, we may continuously monitor the jumps in a Lindblad master
equation [42, 64]. In this section, we focus on this type of measurement. The
time-evolution of the system may then be described by a Lindblad master
equation, where feedback is applied depending on the observed jumps. This
scenario may be described by an unravelled master equation that describes the
evolution of the conditional quantum state

$\begin{split}d\hat{\rho}_{\rm c}=&-i[\hat{H}_{\rm
eff}(\lambda_{t}^{Y_{t}}),\hat{\rho}_{\rm
c}]dt+\sum_{j}\text{Tr}\\{\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{t}})\hat{L}_{j}(\lambda_{t}^{Y_{t}})\hat{\rho}_{\rm
c}\\}\hat{\rho}_{\rm
c}dt+\sum_{y}\text{Tr}\\{\hat{M}_{y}^{\dagger}\hat{M}_{y}\hat{\rho}_{\rm
c}\\}\hat{\rho}_{\rm c}dt\\\
+&\sum_{j}\left(\frac{\hat{L}_{j}(\lambda_{t}^{Y_{t}})\hat{\rho}_{\rm
c}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{t}})}{\text{Tr}\\{\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{t}})\hat{L}_{j}(\lambda_{t}^{Y_{t}})\hat{\rho}_{\rm
c}\\}}-\hat{\rho}_{\rm
c}\right)dN_{j}+\sum_{y}\left(\frac{\hat{V}_{y}({Y_{t}})\hat{M}_{y}\hat{\rho}_{\rm
c}\hat{M}_{y}^{\dagger}\hat{V}_{y}^{\dagger}(Y_{t})}{\text{Tr}\\{\hat{M}^{\dagger}_{y}\hat{M}_{y}\hat{\rho}_{\rm
c}\\}}-\hat{\rho}_{\rm c}\right)dM_{y},\end{split}$ (S75)

where we introduced two types of jumps: those which are observed, described by
the operators $\hat{M}_{y}$, and those that are not observed, described by the
operators $\hat{L}_{j}$. The random variable $dN_{j}$ ($dM_{y}$) takes the
value $1$ if the jump $j$ (measurement jump with outcome $y$) occurs and $0$
otherwise. These random variables obey
$dM_{y}dM_{y^{\prime}}=dM_{y}\delta_{y,y^{\prime}}$,
$dN_{j}dN_{j^{\prime}}=dN_{j}\delta_{j,j^{\prime}}$, and $dM_{y}dN_{j}=0$.
Here, the effective non-Hermitian Hamiltonian is given by

$\hat{H}_{\rm
eff}(\lambda_{t}^{Y_{t}})=\hat{H}(\lambda_{t}^{Y_{t}})-\frac{i}{2}\sum_{j}\hat{L}_{j}^{\dagger}(\lambda_{t}^{Y_{t}})\hat{L}_{j}(\lambda_{t}^{Y_{t}})-\frac{i}{2}\sum_{y}\hat{M}_{y}^{\dagger}\hat{M}_{y}.$
(S76)

Quantum jump detections now happen at random times $t_{n}$, resulting in
outcomes $y_{n}$. The measurement outcomes up to time $t$ can then be
described by all jumps that happen before this time, i.e.,
$Y_{t}=\\{(t_{1},y_{1}),(t_{2},y_{2}),\cdots(t_{n},y_{n})|t_{n}<t\leq
t_{n+1}\\}$. As above, feedback is mediated by the protocol
$\lambda_{t}(Y_{t})$, which may alter both the Hamiltonian and the unobserved
jump operators. In addition, a unitary $\hat{V}_{y_{n}}(Y_{t_{n}})$ may be
applied directly after observing the jump at time $t_{n}$ corresponding to
outcome $y_{n}$. In addition to the very last outcome, this unitary may also
depend on the previous measurement outcomes through $Y_{t_{n}}$.

In this framework, the trajectory in the forward experiment may be defined as
$\Gamma=\\{Y,\gamma\\}$, where $\gamma$ is defined analogously to the quantum
jump unravelling of the Lindblad master equation, and $Y\equiv Y_{\tau}$ where
(as above), $\tau$ denotes the total time of the trajectory. The probability
density of the trajectory can then be expressed as

$P[\Gamma]=p_{a}\text{Tr}\left\\{|f_{Y}\rangle\langle
f_{Y}|\mathcal{T}\left\\{\mathcal{U}_{\rm
eff}(\tau,0)\prod_{n=1}^{M}\mathcal{M}_{n}(y_{n},t_{n})\prod_{k=1}^{K}\mathcal{J}_{k}(j_{k},s_{k})\right\\}|a\rangle\langle
a|\right\\},$ (S77)

where

$\mathcal{M}_{n}(y_{n},t_{n})\hat{\rho}=\hat{V}_{y_{n}}({Y_{t_{n}}})\hat{M}_{y_{n}}\hat{\rho}\hat{M}_{y_{n}}^{\dagger}\hat{V}^{\dagger}_{y_{n}}({Y_{t_{n}}}),$
(S78)

$\mathcal{J}_{k}(j_{k},s_{k})$ is given by Eq. (S34), $\mathcal{U}_{\rm
eff}(\tau,0)$ by Eqs. (S35) and (S36) with the non-Hermitian Hamiltonian in
Eq. (S76). We note that Eqs. (S32) and (S77) have the same form. In the
backward experiment, the probability density of the inverse trajectory is
given by

$P_{\rm
tr}[\bar{\Gamma}|\\{\lambda_{\tau-t}^{Y}\\}]=p_{f_{Y}}\text{Tr}\left\\{\hat{\Theta}|a\rangle\langle
a|\hat{\Theta}^{-1}\mathcal{T}\left\\{\bar{\mathcal{U}}_{\rm
eff}(\tau,0)\prod_{n=1}^{M}\bar{\mathcal{M}}_{n}(y_{n},\tau-
t_{n})\prod_{k=1}^{K}\bar{\mathcal{J}}_{k}(\bar{s}_{k},\bar{j}_{k})\right\\}\hat{\Theta}|f_{Y}\rangle\langle
f_{Y}|\hat{\Theta}^{-1}\right\\},$ (S79)

where

$\bar{\mathcal{M}}_{n}(y_{n},\tau-
t_{n})\hat{\rho}=\hat{\Theta}\hat{M}^{\dagger}_{y_{n}}\hat{V}_{y_{n}}^{\dagger}({Y_{t_{n}}})\hat{\Theta}^{-1}\hat{\rho}\hat{\Theta}\hat{V}_{y_{n}}({Y_{t_{n}}})\hat{M}_{y_{n}}\hat{\Theta}^{-1}$
(S80)

is applied at the time $\tau-t_{n}$,
$\bar{\mathcal{J}}_{k}(\bar{s}_{k},\bar{j}_{k})$ is given by Eq. (S42), and
$\bar{\mathcal{U}}_{\rm eff}$ describes time-evolution with the non-Hermitian
Hamiltonian is given by $\hat{\Theta}\hat{H}_{\rm
eff}^{\dagger}(\lambda^{Y}_{\tau-t})\hat{\Theta}^{-1}$ [cf. Eq. (S76)], which
as above ensures a microreversibility condition. Eq. (S79) has again the same
form as Eq. (S40). These imply that the detailed FT [see Eq. (7)] holds, where
the stochastic entropy production $\sigma[\Gamma]$ is given by Eq. (S38) as in
the case of the Lindblad master equation. Likewise, for a given $Y$, the
derivation of Eq. (9) for the coarse grained entropy follows the same lines as
in the case of a Lindblad master equation with discrete measurements. The
integral FT follows from a calculation analogous to Eq. (S47), where the
summation over $Y$ now involves summation over all $M$ from $0$ to $\infty$ as
well as integration over all possible times of the measurement.

Our results for the time evolution described in Eq. (S75) could be
alternatively derived by dividing the duration of the experiment $\tau$ into
intervals $\delta t$. At each time point $t_{n}=n\delta t$, either a jump $j$
happens with probability
$\text{Tr}\\{\hat{L}_{j}^{\dagger}\hat{L}_{j}\hat{\rho}_{\rm c}\\}\delta t$,
or measurement jump $y$ happens with the probability
$\text{Tr}\\{\hat{M}_{j}^{\dagger}\hat{M}_{j}\hat{\rho}_{\rm c}\\}\delta t$,
or neither of them occur. The latter corresponds to application of the Kraus
operator $\hat{I}-i\delta t\hat{H}_{\rm eff}$ [cf. Eq. (S76)]. We note that in
order to obtain the quantum classical transfer entropy $\langle I_{\rm
te}\rangle$ [cf. Eq. (S72)], it is necessary to use an unraveling where jumps
$j$ and jumps $y$ occur sequentially in each time step, thus allowing for both
types of jumps in a single interval $\delta t$ (see Ref. [42] for details).
This approach is equivalent to the standard unravelling up to the order of
$\delta t$, and could be also applied to derive our results. For the details
about computing $\langle I_{\rm te}\rangle$ we refer the reader to Ref. [42].

###  IV.1 Qubit Model

The Hamiltonian of the system is given by
$\hat{H}_{t}=\frac{\omega}{2}\hat{\sigma}_{z}+\chi\cos{(\Omega t)}$. The jump
operators $\hat{L}_{-}=\kappa\hat{\sigma}_{-}$ and
$\hat{L}_{+}=e^{-\beta\omega}\kappa\hat{\sigma}_{+}$ are ladder operators of
$\frac{\omega}{2}\hat{\sigma}_{z}$. The continuous measurement is performed by
monitoring a single jump operator $\hat{M}=\sqrt{\kappa_{\rm
m}}(\sqrt{1-\epsilon}|1\rangle\langle 1|+\sqrt{\epsilon}|0\rangle\langle 0|)$
corresponding to detection of the excited state with error probability
$\epsilon$. When a jump is observed, a unitary rotation $\hat{\sigma}_{x}$ is
applied to bring the system to the ground state. The numerical results are
performed using a quantum jump simulation, where the duration of the protocol
is divided into $\tau/\delta{t}=1000$ steps. The number of randomly sampled
trajectories for each data point in Fig. 2 is $10^{5}$.

##  V V. Time-reversed measurement

The POVM measurement in the forward protocol is described with the set of the
Kraus operators $\\{\mathcal{M}(y)\\}$. The simplest kind of the measurement
is a projective measurement, when the Kraus operators fulfil
$\mathcal{M}(y)=\mathcal{M}^{\dagger}(y)$ and
$\mathcal{M}(y)\mathcal{M}(y^{\prime})=\delta_{y,y^{\prime}}\mathcal{M}(y)$.
In this case, in the backward measurement we simply perform the same
measurement as in the forward protocol, with the set of the Kraus operators
$\\{\hat{\Theta}\mathcal{M}(y)\hat{\Theta}^{-1}\\}$. If the measurement is not
projective, but it is unital, i.e., it obeys
$\sum_{y}\mathcal{M}(y)\mathcal{M}^{\dagger}(y)=\hat{I}$ (not to be confused
with $\sum_{y}\mathcal{M}^{\dagger}(y)\mathcal{M}(y)=\hat{I}$ which is obeyed
for all measurements), then in the backward experiment we perform a
measurement with the set of the Kraus operators
$\\{\hat{\Theta}\mathcal{M}^{\dagger}(y)\hat{\Theta}^{-1}\\}$.

In the general case, when the measurement is neither projective, nor unital,
we follow [38]. The action of each Kraus operator can be modeled as a
projective measurement on an ancilla A that is correlated with the measured
system S. Suppose that before the measurement, the ancilla is in the state
$|\alpha\rangle\langle\alpha|$ and the system in $\hat{\rho}$. The measurement
with the outcome $y$ consists of correlating the ancilla with the system using
the joint unitary $U$ and collapsing the state of the ancilla onto
$|\alpha_{y}\rangle\langle\alpha_{y}|$. The corresponding Kraus operator is
given by $\mathcal{M}(y)=\langle\alpha_{y}|U|\alpha\rangle$. In the backward
measurement, the Kraus operator
$\hat{\Theta}\mathcal{M}^{\dagger}(y)\hat{\Theta}^{-1}$ results from preparing
the ancilla in the state
$\hat{\Theta}|\alpha_{y}\rangle\langle\alpha_{y}|\hat{\Theta}^{-1}$, acting
with $\hat{\Theta}U^{\dagger}\hat{\Theta}^{-1}$ onto the joint state of the
ancilla and the state, and making a projective measurement onto the ancilla,
such that its state collapses to
$\hat{\Theta}|\alpha\rangle\langle\alpha|\hat{\Theta}^{-1}$. Thus, in the
backward experiment $y$ is no longer a measurement outcome. Instead, for each
$y$ a different measurement is performed and only one of the outcomes
(resulting in the ancilla being in the state $\alpha$) is relevant. For any
other outcome, the result needs to be discarded. In our FT, this does not
result in an additional overhead since in any case, measurement outcomes that
do not agree with what is observed in the corresponding forward trajectory
need to be discarded.