Enhanced Photonic Maxwell’s Demon with Correlated Baths

Maxwell’s Demon is at the heart of the inter-relation between quantum information processing and thermodynamics. In this thought experiment, a demon generates a temperature gradient between two thermal baths initially at equilibrium by gaining information at the single-particle level and applying classical feed-forward operations, allowing for the extraction of work. Here we implement a photonic version of Maxwell’s Demon with active feed-forward in a ﬁbre-based system using ultrafast optical switches. We experimentally show that, if correlations exist be-tween the two thermal baths, the Demon can generate a temperature diﬀerence over an order of magnitude larger than without correlations, and so extract more work. Our work demonstrates the great potential of photonic experiments – which provide a unique degree of con-trol on the system – to access new regimes in quantum thermodynamics.

Maxwell's Demon is at the heart of the interrelation between quantum information processing and thermodynamics. In this thought experiment, a demon generates a temperature gradient between two thermal baths initially at equilibrium by gaining information at the single-particle level and applying classical feed-forward operations, allowing for the extraction of work. Here we implement a photonic version of Maxwell's Demon with active feed-forward in a fibre-based system using ultrafast optical switches. We experimentally show that, if correlations exist between the two thermal baths, the Demon can generate a temperature difference over an order of magnitude larger than without correlations, and so extract more work. Our work demonstrates the great potential of photonic experiments -which provide a unique degree of control on the system -to access new regimes in quantum thermodynamics.

Introduction
Thermodynamics was conceived as a phenomenological theory for the equilibrium properties of macroscopic systems ranging from gas (ensembles of 'many' small systems) to black holes. For these systems, theories like that of Maxwell's for heat [1] provide a complete description of quantities such as temperature or work, and the manipulation of thermal states -as well as their emergence from fluctuations at the smallest scalecan be described in terms of (quantum) information processing [2][3][4]. Reciprocally, thermodynamic considerations ought to limit quantum information processing itself [5][6][7]. This interrelation is perhaps best manifested in the pro-tocol known as 'Maxwell's demon' (MD) [1,[8][9][10][11][12][13][14][15]. As illustrated in Fig. 1 (a), the MD monitors the motion of gas particles inside a partitioned box. Based on its previous knowledge of the particle's velocity [16,17], the MD can sort fast particles from slow particles by opening an aperture in the partition such that all fast particles eventually end up on one side of the partition and all slow particles on the other. So the MD brings the system out of equilibrium, and one can then exploit the engineered temperature differential to extract work. In modern experiments [18][19][20][21][22][23][24][25][26][27][28][29], we say that the MD generates work by measuring individual particles to gain information [16,17], and depending on these measurement results, it applies different operations to the bath (i.e. opening the door, or leaving it closed). These measurement-dependent operations are called feed-forward operations. Here, work and energy are bound to the available information, and are ultimately physically limited by it [17,30].
The 'power' of the MD, the temperature imbalance it can generate per measurement, can be greatly enhanced by operating with correlated particles: Consider a situation where, for every particle moving in a certain direction in the left bath, there is a twin particle moving in the same direction in the right bath (see Fig. 1 (c)). If the MD observes a particle in the left bath it also learns something about an (unobserved) particle in the right bath. Because of this additional information, the MD can generate a larger temperature difference per measurement [31] by simply modifying its feed-forward protocol to make use of the new information.
While correlations are difficult to engineer in Accepted in Quantum 2022-09-08, click title to verify. Published under CC-BY 4.0. most systems, doing so is very easy in photonics. Here, we present the first experimental realisation of a photonic MD operating with correlations and active feed-forward. The photonic MD was first proposed and a proof-of-principle experiment was demonstrated in [32], and the idea to enhance the MD's power was proposed in [31].
The working principle of an uncorrelated photonic MD is depicted in Fig. 1 (e). In a photonic MD, the baths are realised with optical modes, each containing a thermal state of photons whose average photon number directly sets the temperature of the bath. These two optical modes are then sent to individual detectors, D A and D B . When the two optical modes have an equal photon number (the baths have an equal temperature), the detectors register the same counts and no work can be extracted. When a photon is subtracted from this state at a beamsplitter and detected in the reflection port with detector Dem A or Dem B , bunching will occur, meaning that the photon number in the transmitted beam will be temporarily doubled (as depicted in red in Fig. 1 (e)). This photon extraction provides information about the average photon number in the beam, based on which a classical feedforward operation may then be applied to create an imbalance in the photon number between the two beams. This energy imbalance can in turn be used to extract work. The gain of information and the generation of a temperature difference through classical feed-forward is precisely the functioning of an MD -a photonic MD is thus a device that can generate a photon number imbalance between two thermal states that initially have the same photon number. The power of a photonic MD is simply quantified by the photon number difference that can be generated to extract work.
The working principle of the photonic MD was demonstrated only recently in a proof-ofprinciple experiment [32].
There, the feedforward at the core of the extraction of work was not applied, instead the operation of the MD was shown by post-processing the data. Detectors D A and D B were replaced by photodiodes connected to a capacitor. In the case where the photon number at D A and D B was balanced, the photo-currents generated by the photodiodes cancelled out, creating a zero net charge on the capacitor. If, however, there were more pho-tons in one beam, the capacitor's polarity could have been flipped (classical feed-forward operation) such that the photo-currents would no longer cancel out and the capacitor would always be charged positively, allowing the extraction of work. In [32], instead of flipping the capacitor's polarity, the operation of the photonic MD was quantified by recording the charge across the capacitor in real time. It was found that a positive (negative) charge of the capacitor would correspond to a click at Dem A (Dem B ). Hence, no work was extracted.
In our photonic MD, we implement active feed-forward to physically swap the paths of the beams dependent on detection events at Dem A and Dem B using an ultra-fast optical switch (methods adapted from [33]). While our active feed-forward would allow for the extraction of work, we do not extract work here. We instead monitor the photon number imbalance directly using single-photon detectors, as this characterises the maximum work that could be extracted. This detection scheme is also more compatible with the quantum states of light that we use to generate correlations to increase the power of the MD.
Correlations in quantum thermodynamics have been used in numerous experiments in quantum thermodynamics [34][35][36][37][38][39][40][41][42][43][44], but not in terms of information processing by the MD. Here, we compare the statistics obtained with uncorrelated thermal states (produced classically) and split thermal states to those obtained with correlated and anticorrelated thermal states produced by spontaneous parametric down-conversion and a path-entangled (so-called N00N [45]) state, respectively. We show that the choice of correlations is essential in enabling the MD to extract work. Our experiments evidence that particular correlations allow for an order of magnitude increase of the power of the MD, while others prevent the MD from extracting any work at all. Furthermore, we derive a figure of merit for the power of the MD in the regime of low photon-numbers and demonstrate that information processing with correlations and anticorrelations vastly outperforms operation with the other states.
Although we generate some of these correlations using quantum states of light, the enhancement of the power of the MD does not rely on the quantum nature of the correlations. It remains an open question if quantum correlations could further enhance the power of the MD. Nevertheless, correlations are ubiquitous in quantum information processing, and so our photonic implementation settles Maxwell's demon therein.

The power of Maxwell's Demon
In our experiment, the MD consists of a logic that monitors photon arrival events at two detectors and conditionally controls the path light takes. Specifically, the experiment ( Fig. 2 (d)) is based on two separate spatial modes for light propagation, corresponding to two paths (labelled In A and In B in Fig. 1 (e)) in the setup, in which we send states with various statistics. The MD consists of two single-photon detectors (Dem A and Dem B ), two variable-reflectivity beamsplitters (implemented with tunable directional couplers, labelled TDC), the ultra-fast optical switches (UFOS), and the logic (labelled TTM) used to control the UFOS. The detectors monitor photon arrival events in the reflected port of the TDCs, and send signals to the coincidence logic which then sets the state of the UFOS to route the light.
The feed-forward protocol functions as follows: The thermal states (generated by either of the sources Fig. 2 (a), (b) or (b)+(c)) enter the setup ( Fig. 2 (d)) in modes In A and In B . First, the temperature of the thermal baths are set equal by fixing the UFOS in the 'bar state' (to transmit mode A to D A and B to D B ), and equalising the photon rates N A and N B measured by single-photon detectors in modes D A and D B . Second, we make the MD's feedforward active. Microscopic knowledge about incoming photons in modes In A and In B is acquired via the detector clicks in the reflected arms Dem A and Dem B . Based on this information, the MD operates the UFOS (or not) in order to route the beam with a higher photon number in mode A or B to D A , thus creating a photon-number imbalance at the output. The exact details of this routing depend on the states considered and we discuss them below.
To characterise the temperature gradient generated by the MD, we directly measure the photon rates N A and N B in the two beams exiting the experiment with single-photon detectors in modes D A and D B when the feed-forward is ac-tive. We then measure ∆N = N A − N B , the photon number difference between these detectors. Although we do not extract any work here, work could in principle be extracted from this photon-number difference for example by charging a capacitor as proposed in [32], or by moving a particle via the differential in radiation pressure thus engineered. We consider ∆N /N -the change in photon number per incident photon -as our figure of merit for the 'power' of the MD. Here, N is the number of photons incident in mode In A which we will always set equal to the number of photons in mode In B . We estimate N by making the feed-forward inactive, measuring the photon number with the detectors in modes D A and D B , and then dividing by the beamsplitter reflectivity. We begin by presenting our derivations of this figure of merit for the different input states in the regime of low photon-numbers, which we define as one-and two-photon detection events.
Uncorrelated thermal states.
-We first consider two uncorrelated thermal states with the same photon number, as in Fig. 1 (e). The density matrix of a single-mode thermal state of temperature where P (n) = n n (1 + n) n+1 −1 and n = (e β ω − 1) −1 is the average photon number in this state ( and k B are the Planck and Boltzmann constant, respectively and ω is the angular frequency of the photon). This state is sent into mode In A towards the beamsplitter, with vacuum incident into the other unlabelled mode. At the beamsplitter, some of the light is reflected towards detector Dem A while the rest is transmitted into mode A. The probability to detect n photons at detector Dem A and m photons in mode A is where R is the reflection amplitude of the beamsplitter [46]. The subtraction of one photon from a thermal state leads to a two-fold increase in the average photon number left in mode A, n = 2n [47] (hence the two red photons in Fig. 1 (e)). Moreover, if the initial thermal state is a single-mode thermal state, the remaining state is a multimode thermal state [48]. The same is true for the lower B modes. Importantly, neglecting this detection event results in a thermal state with a lower average photon number n = (1 − |R| 2 )n in mode A or B [46]; hence, the MD's measurement does not inject any energy into either mode. As a result, if the MD detects a photon at detector Dem A the remaining photon number in mode A is higher. Since the MD will attempt to increase the photon number in mode D A , it will set the UFOS in the 'bar state' so that light incident in mode A (B) is transmitted to mode D A (D B ). However, detection of a photon at detector Dem B means that there are more photons in mode B, so the MD will swap modes A and B by setting the UFOS to the 'cross state'. When no photons are detected, or a photon is detected in each mode, the MD sets the UFOS to the 'bar state'. Thus a photon number imbalance can be generated based on the MD's information (click/no-click), which depends on the beamsplitter's reflection amplitude R. In Appendix C, we derive the power of the MD when using uncorrelated thermal states for low photon-numbers, obtaining (1) Note that here n is the expectation value of the photon number per mode (i.e., the number of photons per coherence time, which is τ c = 5.42µs for our uncorrelated thermal photons and τ c ≈ 2 ps for the photons generated by spontaneous parametric down-conversion). In contrast, N is the total number of photons sent into mode In A (and equally into mode In B ) during the experiment. Hence, n = τ C T N , where T is the total measurement time. From Eq. 1, we see that the power of the MD increases with n (in the limit of n 1), indicating that this effect is driven by the thermal nature of the beams. Since Eq. 1 also depends on the reflection amplitude R, we will tune this parameter to optimise the power of the MD.
Split thermal states.
-Now, if instead of two statistically uncorrelated thermal states we send two classically correlated thermal states (created by splitting a single thermal state at a balanced beamsplitter) into the setup, the state in modes In A and In B is ρ Split = ∞ n,m=0 P (n, m) |n, m n, m| In A ,In B , with P (n, m) as defined above Since the thermal states in each mode originated from the same source, a detection at Dem A (or equivalently Dem B ) affects the state in both modes A and B: this amounts to effectively increasing the photon number in both arms simultaneously ( Fig. 1 (f )), as in [49].
Therefore, when operating with split thermal states, the MD cannot possibly know in which arm the bunching effect will be stronger -its power in this case is zero: ∆N /N = 0, for all values of the reflectivity of the MD's beamsplitter (see Appendix C). This result holds in general, not just in the regime of low photon-numbers [31]. In terms of the partitioned box example, we can imagine a hole in the partition through which particles can freely escape to either side such that, when the MD measures one particle, the temperature is increased on both sides of the partition ( Fig. 1 (b)). This is not a perfect analogy, as in our photonic implementation, particles are not exchanged after the MD's measurement. Rather, the thermal state is distributed among two optical modes and photon subtraction in either of these modes increases the average photon number equally in both modes, as in [49] for example.
Correlated thermal states. -Unlike the above correlations, which effectively make the MD powerless, the correlations generated by type-II spontaneous parametric down conversion (SPDC) increase its power [31]. Ideally, for this state whenever there is a photon in mode In A , a twin photon is found in mode In B (correlated particles are denoted as the red and blue particles in Fig. 1 (c) and (g)). In particular, the ideal where s specifies the brightness of the source. Although photons are always emitted in pairs, tracing over photons in mode In A (In B ) leaves photons in mode In B (In A ) in a thermal state [46], which means that the power of the MD could be enhanced as with uncorrelated thermal states. However, we will now see that the correlations generated by SPDC have a much larger effect, and in fact counteract the thermal bunching.
The key resource for this state are the correlations which provide the MD with more informa-tion than it can obtain from the thermal bunching. For example, if exactly one photon is detected at Dem A , the MD has removed one photon from mode A, and it now knows that there will be one more photon in mode B (and viceversa). This is illustrated Fig. 1 (g), where the photons come in pairs. For every red photon in mode Dem A there is a correlated blue photon in mode B. Hence, when the MD detects a photon in Dem A there are now zero photons in mode A, and exactly one photon in mode B. Therefore, the MD will move the remaining photon from B to mode D A by putting the UFOS in the cross state. Similarly, it will set the UFOS to the bar state when it detects a photon in mode B. As before, the UFOS remain in bar for all other detection events In the partitioned box analogy, Fig. 1 (c) shows the MD gaining information about particles on both sides of the partition, by measuring a particle on only one side. Here the colour denotes correlated pairs of particles. For every red (blue) particle on the left there is a corresponding blue (red) particle on the right moving in a mirrored direction. Thus, if the MD finds a particle impinging on the aperture from one side, it measures (and destroys) that particle leaving its twin to arrive alone from the other side.
Notice that now the MD's logic is reversed compared to the uncorrelated thermal states. Previously, finding a particle on one side implied that there were more particles on that side. Now the opposite is true. This also introduces a new experimental issue: the power of the MD critically depends on the ratio between correlated photons (which experimentally correspond to coincidence events) and uncorrelated photons (by which we mean photons that have lost their partner due to experimental loss). In practice that means that the coupling efficiency 2 , defined as the ratio between the singles rate the coincidence rate, is essential to create a powerful demon.
In Appendix C, we derive the power of the MD using correlated thermal states in the regime of low photon numbers in the presence of experimental loss. We obtain This equation resembles Eq. (1). Here, however, the power of the MD does not depend on n, since the correlations are the driving force of the power of the demon in this regime. In fact the correlations counteract the thermal bunching effect. Moreover, notice that the power of the MD is scaled by the coupling efficiency 2 . For a perfect source 2 = 1. Interestingly, we can experimentally probe this, by simply computing the power of the MD per photon pair (by normalising ∆N by the total number of coincidences C). As we show in Appendix C, this results in: Anti-correlated thermal states. Finally, we consider the operation of the MD with anticorrelated N00N states (here we set N = 2) [50]. We refer to this state as anti-correlated because whenever there is a photon in mode In A , there are none in mode In B (see Fig. 1h). In Ref. [31], a specific two-mode state was proposed with two important properties. First, for every N-photon event, the two modes are in a N00N statewhere there are N photons mode A and zero in mode B, and vice-versa. Second, tracing out either mode, leaves the remaining mode in a thermal state. Experimentally, we do not create this state, but we note that some experimentallyrealised N00N state sources may come close to these conditions [51,52]. Instead, here we perform Hong-Ou-Mandel (HOM) interference between the two photons from the SPDC source to create a 2-photon N00N state. The higherorder modes will not be in a N00N state; rather, they will be in so-called Holland-Burnett states [53]. Nevertheless, as we show in Appendix C for low-photon numbers, the demon effect is driven by the two-photon component and in this regime our source behaves almost exactly as the state proposed in [31]. Ideally, our state has only the vacuum component and the two-photon terms . Starting from this state, in Appendix C we derive the power of the MD in the presence of loss (coupling efficiency 2 ) and for imperfect Hong-Ou-Mandel visibility (v 2 ), finding This differs from operation with correlated states (Eq. (2)) by a factor depending on the visibility 2v 2 − 1. Here, the key resource are the anticorrelations: In Fig. 1 (g) photons come from the source in pairs, denoted by red and blue. If the MD detects, say, exactly one photon at Dem A , then it knows that a second photon is left in mode A, and there are no photons in mode B. In analogy, Fig. 1 (d) shows the MD gaining information about both particles by measuring only one of them: if the MD detects, say, the red particle then it knows that another one is also arriving from the same side. Here, as with the quantum correlated states above, the power of MD depends on the coupling efficiency, but also on the visibility (i.e. the quality of the N00N state source). Again, if we instead normalise our results by the average coincidence rate C, we get closer to the ideal performance but this does not remove the visibility dependence.
Finally, we remark that in the regime of low photon numbers and for optimal visibility v 2 = 1, operation with correlated and anti-correlated states would provide the same power of the MD. However, for anti-correlated states, the demon switches particles in the same manner as for the thermal bunching. This is why at higher temperatures (photon numbers) Ref. [31] found that the anti-correlated states greatly out perform the correlated states.

Experiment
Our photonic MD experiment, shown in Fig. 2, is built around a 2x2 UFOS (BATi 2x2 Nanona fibre switch). This optical switch can route light from two input modes into two output modes with a variable splitting ratio. The response time of the UFOS is below 60 ns, with a maximal duty-cycle of 1 MHz, and a cross-channel isolation greater than 20 dB for any polarisation, see Ref. [33] for more details. The reflectivity R of the variable beamspliter, implemented by a TDC, sets the amount of information gained by the MD about the input state. After the BS, photons go through a 152 m fibre delay line 1 before entering the UFOS, where the path they take (towards either detector D A or D B ) is conditionally controlled by the MD. All detectors are superconducting nanowire single-photon detectors (SNSPD) from PhotonSpot Inc. (deadtime 50 ns, average system detection efficiency 90%, and timing jitter of ≈ 150 ps). Detection events are recorded and processed by a commercial time tagging module (UQDevices Logic16 TTM). A photon detection event triggers a wave-function generator (Keysight 33500B Series) to generate a 2.5 µs TTL pulse that will make the UFOS switch states.
Before presenting our experimental results, we will explain our measurement procedure which is used for the four different initial states. Our target metric is ∆N , which we then normalise by either the total singles count N or the coincidence count C. However, this is highly sensitive to variations in the imbalance between photon numbers at the input, and thus also to losses in the setup, which can (and do) differ slightly between the upper A modes and B lower modes. In order to account for these unbalanced losses, we first balance the count rates of the two arms when the UFOS is fixed in the bar state and then measure the counts at the output. This ensures refers to the total number of photons detected in mode D A (D B ). Second, we measure the intrinsic imbalance of the setup by fixing the UFOS to the cross state, and preventing the MD from controlling the path by feed-forward. In this configuration we measure ∆N cross = N A − N B , which represents the maximum imbalance the MD could 'accidentally' achieve without properly using information from either thermal bunching or the correlations between the states. We then measure the photon number difference with the MD being active, i.e. we turn on the feed-forward logic (which differs depending on the input state), yielding ∆N FF = N A −N B . Given these measurements, we construct the unnormalised power of the MD as Finally, we need to normalise this by either the number of input single photons N or the number of incident photon pairs C. To estimate the N, we simply measure the total number of counts at the end of the experiment at the detectors in modes D A and D B for each reflectivity of the TDC. We then divide these rates by the reflectivity to obtain the singles rates arriving at the beamsplitter, and average over the counts in modes A and B. To estimate the incoming coincidence counts, we perform a similar protocol. However, due to limitations in the counting logic, we only measured the coincidence rates between detectors D A and Dem A (C D A ,Dem A ) and detectors D A and Dem B (C D A ,Dem B ) for a reflectivity of 50%. From these measurements we compute the input coincidence rates for both the correlated and anti-correlated input states (note that this calculation differs slightly for the N00N state and SPDC state).
Uncorrelated thermal state. -To generate uncorrelated thermal baths we make two independent thermal states of light, using a rotating ground glass wheel (see Appendix A). We verify the thermal nature of the source by measuring g (2) (τ = 0), which is typically ≈ 1.95. A representative measurement is presented in Fig.  3 (a). Since g (2) (τ = 0) > 1 is only a necessary condition for a thermal state, we further verify that without the rotating ground glass g (2) (τ = 0) ≈ 1. With these measurements, and knowledge of our experiment, we can be confident that we have generated a thermal state. By fitting to the g (2) (τ ), assuming a Gaussian thermal beam of the form g (2) (τ ) = 1+e −π( τ /τc) 2 [46], we obtain a coherence time of τ c = 5.42 µs.
We then proceed as described above, setting ∆N bar = 0 and measuring ∆N cross and ∆N F F as we tune the MD's reflectivity from 0% to 50%. For every reflectivity we reconstruct the power of the MD, defined above. The result is plotted in Fig. 4 as red stars. For these measurements, we set the average incident photon number in modes In A and In B to 27, 800 ± 500 cps. We fit the experimental data with a single parameter, the average photon number per mode n. Given the 5.42µs coherence time of the pseudo thermal light and the photon rate, we expect n = 0.151 ± 0.002 (the error bars are the standard deviation of the measured singles rates for different reflectivities). However, we find a much better fit with a value of n = 0.05.
The discrepancy in n is likely due to experimental limitations in our switching logic. We set the switching time to 2.5µs, which is less than the photon coherence time. However, setting it higher limits our maximum count rate, since the wave-function generator cannot respond between time it is triggered and the output pulse is being generated. Because of our reduced switching time, some bunched events may be missed, thus limiting the power of the MD. We use this value in our theoretical calculation shown in Fig. 4 (a) (solid red curve). Note, we also plot this data in Fig. 4 (b). Although it is experimentally possible for us to increase the average photon number, the long coherence time of our thermal distribution would then take us out of the regime of low photon numbers, which is the basis of the fair comparison of the power of the MD with other input states.
Split thermal state. -We produce this input state by simply splitting one of the thermal states at a balanced beamsplitter after the ground glass wheel. We first verify that this still results in a thermal state in each mode by measuring the g (2) (τ ) after the beamsplitter, a representative g (2) (τ ) is plotted in Fig. 3 (b), displaying a g (2) (τ = 0) close to 2.
After this, we balance the count rates and measure the power of the MD as before. The result is plotted in Fig. 4 (a) as the violet diamonds. For these data, n ≈ 0.7 in each spatial mode at the input. Although for this n, our low-photon approximation no longer applies, Ref. [31] showed that our result is independent of n. Experimentally, this corresponds to incident singles rates in modes In A and In B of 293, 000 ± 3000 cps. The resulting experimentally measured ∆N /N is very close to zero, as expected. The small deviation from zero is likely caused by slightly imbalanced losses in the setup, such that although ∆N OF F is close to 0 the real photon number before the UFOS is not exactly balanced.
Correlated thermal states. -We produce correlated thermal states by SPDC. In this source (described in Appendix A) the coherence time is ≈ 2 ps (which we verify by a Hong-Ou-Mandel experiment in Fig. 3 (c)). This is much smaller than both the minimum resolution of our time tagger (which is 156 ps), and the timing jitter of our detectors (≈ 200 ps). Hence, we cannot measure the g (2) (τ = 0) as the width of the expected peak is below the minimum resolution of our detection system. However, it is now well established that in such sources the signal (idler) beam is indeed thermal when the idler (signal) beam is traced out [54,55].
For this state, we operate with a balanced average photon rate of 168, 000 ± 1000 cps in modes In A and In B . Although this is a higher count rate than for the uncorrelated states, the shorter 2 ps coherence time means the average photon number per mode is much smaller n ≈ 10 −7 . We measure the power of the MD per incident photon by varying R (green circles in Fig. 4 (a)). In this case, the theoretical curve (Eq. (2)) depends only on the coupling efficiency 2 . This is calculated by measuring the coincidence rate between the detectors and correcting for the reflectivity of each BS loss and dividing by the singles rate, yielding 2 = 0.14. The resulting solid green curve fits the data very well.
In Fig. 4 (b), we also plot the power of the MD per incident photon pair, by normalising ∆N by the coincidence rate (green circles). This removes the effect of almost all experimental imperfections, and our experimentally measured power of the MD almost reaches the theoretical maximum value of 0.5 (see Eq. (3)). Moreover, the experimentally measured data is in good agreement with the full theoretical curve (solid green line).
Anti-correlated thermal states. -We generate the input 2-photon N00N state by HOM interference between the two photons of our SPDC source. The details are described in Appendix A.
We estimate the quality of the N00N state by The mutual information between the MD's measurement outcomes and the photon number a) for our experimental parameters, and b) for the ideal situation. The parameters used to evaluate these curves are the same as those used in the fits to the data presented in Fig. 4. In all cases, as the MD's beamsplitters reflectively increases, it gains more information about the photon number. Moreover, for all of the parameter regimes investigated in this work the correlated and anti-correlated states out perform the uncorrelated thermal states.
scanning the relative delay and measuring the visibility of the HOM dip -we measure v 2 = 0.87 ± 0.02. To ensure that our state is classically anti-correlated in the Fock basis, we observe the absence of correlations (coincidences) at a time delay of zero (Fig. 3 (c)), which implies that the two photons incident on the fiber beamsplitter in Fig. 2 (c) bunch and exit in the same mode. As mentioned above, this does not result in thermal states in modes A and B, but we show in Appendix C that the behaviour is almost identical in the low-photon number regime.
For this state, we operate with balanced singles rates of 141, 000±3000 cps, and, again, n ≈ 10 −7 . Proceeding as before, we obtain the power of the MD and plot the result normalised by singles as turquoise pentagons in Fig. 4 (a). For the corresponding theory curve (Eq. (4)), we use our measured HOM visibility of v 2 = 0.87 and take 2 = 0.14 (as above). In Fig. 4 (b), we normalise ∆N by the measured coincidence rate. The theory curve, Eq. (5), only requires the visibility which we take as above, and plot as the solid turquoise line. Although ideally the correlated and anti-correlated states behave identically for low photon numbers, the anti-correlated states suffer an additional imperfection arising from the HOM interference.

Discussion
Firstly, we note that the agreement between the experimental data and the theory is very good for all states, with a slight deviation at high reflectivity. This deviation comes from our simplified theory, which does not include the MD's detection efficiency. Indeed, in the theory of [31] it can be observed that changes in the relative detection efficiency between detectors Dem A and Dem B can shift the dependence of ∆N on reflectivity. Moreover, we stress that only one data set, that of the uncorrelated thermal states normalised by singles, required a fitting parameter. All other curves presented in Fig. 4 agree with experimental data using only independently measured experimental parameters, such as the coupling efficiency and HOM visibility. This demonstrates the great potential of relatively simple optical experiments to investigate information processing scenarios characteristic of thermodynamics using pseudo-thermal beams, which moreover give access to a wealth of exotic correlations readily obtained with photons.
We have experimentally demonstrated that the power of the MD with correlated and anticorrelated baths (which we produce with entangled quantum states) vastly outperforms operation with classical states (uncorrelated and split thermal states), as predicted in [31]. For example, when considering the power of the MD per photon (i.e. the data normalised to the incident single-photon rate, plotted in Fig. 4 (a)), the power of the MD is a factor of ≈ 5 higher with correlated baths than with uncorrelated baths (green curve compared to the red curve in panel (a). Moreover, the enhancement is even more striking when considering the power of the MD per photon pair, plotted in Fig. 4 (b). This analysis serves to essentially filter out the single photons that have lost their partner, and allows us to reach the theoretical limits for the correlated baths. In particular, although operating with uncorrelated thermal states does yield a finite power, this is outperformed by a factor 16 when operating with anti-correlations (blue curve compared to the red curve in panel (b)), and by a factor 28 when operating with correlated states (green curve compared to the red curve in panel (b)). Here we are comparing to the power of the MD with uncorrelated thermal baths normalised by the singles rate (plotted in red in both panels (a) and (b)), since the thermal state is robust to loss.
The MD's ability to extract work is limited by the amount of information it can extract. While this was originally formalized by Landauer's erasure principle [2,17], applying this concept in a quantitative manner to our system would require a generalized Jarzynski equality such as that derived in [56]. Nonetheless, the mutual information I between the MD's measurement outcomes in modes Dem A and Dem B and the photon number in mode A and mode B can be used to qualitatively explain the enhancement of the power of the MD in the presence of the correlated input states. In Appendix D, we derive I for each input state, and we plot the results in Fig. 5. Note that MD has 4 measurement outcomes so the maximum possible entropy is 2. In panel (a) we have used the coupling efficiency and N00N state visibility used to fit to our experimental data normalized by the singles, while in panel (b) we used the parameters used to fit to the data normalized by the coincidence rate. In both panels n = 0.05 for the uncorrelated and split thermal cases. These plots demonstrate that, for the both the correlated and anti-correlated states, the MD has access to more information, which is consistent with our observation that it can generate a larger ∆N for these data. Interestingly, for the split thermal state the MD only has marginally less informa-tion than it does for the uncorrelated states. It is hence possible that, for an operation that is more complex than simply the swapping the modes, the MD could still operate with this state.
In our analysis we have not considered the absolute efficiency of the MD, but rather focused on the enhancement provided by correlations in the baths. In the original thought experiment, the cost of both the demon's measurement of the particle's velocity and its cost to open the aperture was assumed to be negligible. This was later formalized by Landauer, who showed that if a reversible process is used for the measurement and sorting, then the cost (i.e. entropy increase) from this step is zero. He then famously showed that at some point the MD must erase its measurement results, which will increase the entropy [2,17]. In our experiment, we used irreversible measurements, and hence we are not in the idealized regime. In principle, however, a photonic platform could reach this regime. For example, the photon that the demon subtracts could be used to trigger a unitary (and hence reversible) controlled-path gate [57] that operates on multiparticle input states. Nevertheless, the measurement and switching in our experiment do not inject any external energy into the baths. Note that the MD's beamsplitters do extract energy from the baths, but since this extraction is balanced in Mode A and Mode B this is not the source of the power of the MD. Thus the enhancement we observed here would also be present in the ideal scenario.
Our work is valid for low photon numbers (i.e. low temperature of the thermal beams). For higher photon numbers, we expect the anticorrelated baths to perform the best, since the anti-correlations act in the same 'direction' as the thermal correlations. Thus a natural extension of our work would be to create a superposition of N00N states for various N [31]. To fully take advantage of this effect, one would need to create such states with a higher n, which would likely require the use of a pulsed laser when generating the photon pairs by SPDC.
To conclude, we have implemented the first photonic Maxwell's Demon without postprocessing, and verified that operating with correlations enhances the power of the MD to process the information it gains and generate a temperature difference (which enables the extrac-tion of work) through classical feed-forward by over an order of magnitude. Our work lays the foundations for future investigations of the interrelation between quantum information processing and thermodynamics at the microscopic scale. For example our work calls for a theoretical derivation of the fluctuation relations [56] that could describe the 'experimental information' obtained by the MD in each round of our feed-forward experiment. Finally, although we used entangled states to generate correlations, our MD protocol only required classical correlations. It would be interesting to develop MD protocols that exploit the quantum entanglement that is readily available in our system.

Data Availability
All of the data that are necessary to replicate, verify, falsify and/or reuse this research is available online at [58].

Acknowledgements
We are thankful to Beate Asenbeck and Giulia Rubino for their valuable comments on the manuscript.
We also thank Michele Spagnolo for work on the SPDC source, and Irati Alonso Calafell for help with the operation of the SNSPDs. The authors acknowledge the excellent comments given by the reviewers. This work was supported by Austrian Science Fund (FWF): F 7113-N38 (Be-yondC),

A Experimental setup
In this section, we detail the arrangement of the experimental setup and provide all technical information needed to reproduce it.

A.1 Source of uncorrelated thermal light
We produce two single-mode pseudo-thermal states with the Arecchi's wheel [59][60][61] setup shown in Fig. 2 (a). A laser beam of λ =1550 nm is divided into two spatial modes by a fibre beamsplitter (FBS). These modes are focused (lens L1, f=75mm) on two separate spots on the spinning ground glass (grit size 220). The rotation frequency of the step-motor (SM) is 20Hz. A bare fibre after the ground glass collects thermal light in each mode. We measure the second-order correlation g (2) (τ ) by the Brown and Twiss method [62,63], and obtain g (2) (τ ) ≈ 1.95 (to be compared with g (2) (τ ) = 2 for thermal light) and a coherence time τ ≈ 5.42 µs.

A.3 Generation of anti-correlated thermal states
The Hong-Ou-Mandel (HOM) interferometer presented in Fig. 2 (c) takes photons from the SPDC source ( Fig. 2 (b)) and produces anti-correlated photons by spatially and temporally overlapping the modes with a delay line (DL) and a FBS, respectively. The active MD is shown in Fig. 2 (d). The input statistics are fed in the setup simply by connecting the fibres from either of the sources (Fig. 2 (a), (a)+BS, (b), (b)+(c)). At the TDC's, the reflected arm goes to the Demon detectors (Dem A,B ), the transmitted arm goes to a fibre delay (FD) and then goes to the UFOS, whose configuration ('cross' or 'bar' state) is decided conditionally on the MD's information. We can adapt the switching logic according to the statistics of the MD's states. After the UFOS, photons are sent to detectors D A,B and the output statistics are recorded with the time tagging module (TTM) The photons' polarisation state is maintained with fibre paddles (PD) before and after the UFOS.

B Switching logic for the feed-forward
Here we detail the switching logic used in the feed-forward control of the UFOS state. When this logic is applied, the difference (power of the MD) ∆N = N A − N B is improved by using the MD's information (Dem (A,B) ).

C Derivation of the power of the MD
Here we will present our simple calculations for our photonic Maxwell's Demon in the low-photon number regime. In all cases, we define this low-photon regime to be events with two or less photons. Note that although some intermediate equations in the following derivations contain contributions from higher-order terms, all of our final results depend only on one-and two-photon detection events.

C.1 Uncorrelated Thermal States
A thermal state of light is described by: where P (n) = n n (1 + n) n+1 .
here n is the average photon number per mode. Sending this state to a beamsplitter (with vacuum incident in the second input port) that reflects the light into mode Dem A , and transmits it into mode A (as sketched in Fig. 1e, where mode A refers to the mode before and after the beamsplitter), results in the following probabilities to detect n photons in mode Dem A and m photons in mode A [46]: where R is the reflection amplitude of the beamsplitter. Then after the beamsplitter, we will approximate the state to be: In this expression we have ignored all off-diagonal terms, and terms with more than two photons. Furthermore, we have left out the terms P (2, 0) |0, 2 0, 2| Dem A ,A and P (0, 2) |2, 0 2, 0| Dem A ,A since P (2, 0) << P (1, 0) for low photon numbers. This condition is valid when the probability of populating terms with photon numbers of three or higher is negligible compared to the one and two-photon contributions. In practice this holds for n 0.2. Then for our experiment we have one such state in modes A and Dem A , and one in modes B and Dem B . Thus the total input state is σ Dem A ,A ⊗ σ Dem B ,B , with σ i,j defined above. The overall expression is straight-forward but rather lengthy, so we do not include it here. The next step is to include the action of the demon. For uncorrelated thermal states, when the demon detects a photon in mode Dem A (Dem B ), the photon number in mode A, (B) is increased. Since the demon's goal is to increase the temperature (photon number) of mode A, this means that when it detects a photon in Dem A it does nothing. On the other hand, when it detects a photon in mode Dem B there are more photons in mode B, so it should swap modes A and B. If the demon detects a photon in both mode Dem A and mode Dem B it gains no information; hence, it does nothing. To represent this mathematically we simply make the following substitutions: Since we do not use number resolving detectors, we do not swap modes A and B in situations such as |n, m, 1, 2 , as this will register as a detection event at both Dem A and Dem B . With this operation, the low-photon number state after the demon is approximated as ρ out = P 2 (0, 0) |0000 0000| + P (0, 0)P (0, 1) |0001 0001| + P (0, 0)P (1, 0) |0100 0100| + P (0, 0)P (1, 1) |1001 1001| + P (0, 1)P (0, 0) |0010 0010| + P 2 (0, 1) |0011 0011| + P (0, 1)P (1, 0) |0110 0110| + P (0, 1)P (1, 1) |0111 0111| + P (1, 0)P (0, 0) |1000 1000| + P (1, 0)P (0, 1) |0101 0101| + P 2 (1, 0) |1100 1100| + P (1, 0)P (1, 1) |1101 1101| + P (1, 1)P (0, 0) |1010 1010| + P (1, 1)P (0, 1) |1011 1011| + In Eq. 12, the mode labels are left off, but they run D A , D B , Dem A , Dem B ; i.e. |ijkl is labelled as |ijkl D A ,D B ,Dem A ,Dem B . In our experiments, we always measure the singles rates in modes D A and D B to observe the power of the demon. From Eq. 12, we can extract the probability for a detector in mode D A or mode D B to click. P A = 2P (0, 0)P (1, 1) + 2P (1, 0)P (1, 1) + P (0, 0)P (1, 0) + P (0, 1)P (1, 1) + P 2 (1, 0) + P 2 (1, 1) (13) P B = P (0, 0)P (1, 0) + 2P (1, 0)P (0, 1) + 2P (1, 0)P (1, 1) + P (0, 1)P (1, 1) + P 2 (1, 0) + P 2 (1, 1). (14) Now experimentally, we run this setup many times, observing average singles rates at both detectors. In general, these rates will be given by ΓP A and ΓP B , where Γ is the total number of repetitions of the experiment. Thus the measured photon number difference is given by ∆N = Γ(P A − P B ). Finally, using our expressions for P A , P B we arrive at: where we have substituted P (n, m) from Eq. 9 to arrive at the last line. As a last step, we construct our figure of merit for the power of the MD ∆N /N. Here N is the number of input photons in mode In A , which we constrain to be equal to the number of input photons in mode In B . This figure or merit can be interpreted as the demon power per photon. In the low-photon limit, the probability for one photon to be in mode In A is given by P (1) = n /(1+n). Then the number of single-photon events detected per second is N = ΓP (1), and thus Thus we see that, even in the low photon number limit, the demon effect depends on the effective temperature of the thermal state via n. As we will see in the next sections, this is not the case for correlated and anti-correlated states in this regime.

C.2 Split Thermal States
In this case, the input to the experiment is a single thermal state, which has been split at a beamsplitter. Thus, a thermal state is still input into both mode A and B; however, correlations will now exist between the two modes. Roughly speaking, now when the demon detects a photon at (say) detector Dem A , it can no longer know if the bunching effect will be stronger in mode A or B.
In more detail, the state in modes In A and In B is now: where P (n, m) is defined above, with R = 1 / √ 2. As above, we will keep only up to the two-photon terms and consider only the diagonal elements: ρ split ≈P (0, 0) |0, 0 0, 0| In A ,In B + P (0, 1) |0, 1 0, 1| In A ,In B + P (1, 0) |1, 0 1, 0| In A ,In B + P (2, 0) |2, 0 2, 0| In A ,In B + P (0, 2) |0, 2 0, 2| In A ,In B + P (1, 1) |1, 1 1, 1| In A ,In B + . . . (18) Next, we will add in the two beamsplitters. The beamsplitters enact the following transformations: Again, here we have not included the off-diagonal terms. This will not affect our final result since we never recombine two modes, i.e. we never interfere modes after splitting them. The demon will now attempt to increase the photon number at the detector in mode D A by swapping modes A and B on detecting a photon at detector Dem B , as in Eq. 11. However, it was pointed out in Ref. [31] that the result is the same if the demon instead swaps the modes upon detection of a photon at detector Dem A . Substituting in these transformations, and using the fact that P (n, m) = P (m, n) when R = 1 / √ 2 we arrive at the following expression for the output state: where the mode labels are D A , D B , Dem A , Dem B . From here, we compute the probability for detector D A and D B to click: Then, we calculate the photon number difference ∆N = Γ(P A − P B ).
where 0 is obtained after substituting in the explicit expressions for P (0, 2) and P (1, 1 Hence, for all values of the reflectivity of the demon's beamsplitter. Moreover, in Ref. [31] it was shown that this result holds in general, not just in the low-photon number regime.

C.3 Correlated Thermal States
To generate our correlated thermal states, we use a type-II SPDC source. In such a source, photons are always emitted in pairs. However, when the idler (signal) beam is traced out, the idler (signal) beam is left in a thermal state [46]. The general input state is given by but for our purposes we will only consider up to the two photon term Here, s is the so-called squeezing parameter related to the brightness of the SPDC source,and thus to the temperature of the thermal states in each mode: sinh 2 (s) = n. Since the SPDC source is pumped with a continuous-wave laser, the terms of order higher than 2 (|2, 2 + |3, 3 . . . ) in Eqs. (25) and (26) have low probability and can be neglected. I.e. we are in the 'low photon-number' regime. For the uncorrelated thermal states, we did not need to consider loss, since a thermal state remains a thermal state upon losing a photon. However, here, the correlations are essential so loss will play a large roll in the power of the demon (the information need to extract work). We model loss as a beamsplitter, which takes |1 A → |1, 0 In A ,l A + √ 1 − 2 |0, 1 In A ,l A . In words, the photon remains in the mode with probability 2 . thermal light and normalise by the input singles rate. In this case, the probability for a photon to be incident in mode In A (or in mode In B ) is s 2 /(1− s 2 /2) 2 2 , coming directly from Eq. 27. Thus, the incoming photon rate is N = Γ s 2 /(1− s 2 /2) 2 2 , and our figure of merit when normalising by singles is After a closer look at Eq. 27, one can see that 2 can be understood as the coupling efficiency. In other words, it is the ratio of the measured coincidence rate to the singles rate before the demon acts.
We thus see that in this case the demon effect is scaled down by the coupling efficiency, which makes sense since a lower coupling efficiency degrades the correlations, making the demon less effective. The other point to note is that, in this regime, the demon is no longer driven by the thermal statistics of the light, but the correlations from the SPDC dominate. This is even more apparent when we instead compute the demon effect per photon pair. Examining Eq. 27 again, we see that the probability for a correlated pair to be incident in mode In A and In B is given by P AB = s 2 /(1− s 2 /2) 2 4 , and thus the coincidence rate is C = ΓP AB , so Now the coupling efficiency drops of altogether, and we are left with the ideal demon effect for correlated thermal states. We also see that when the demon uses a 50:50 beamsplitter (R = 1 / Here, again, s is the squeezing parameter. We have also modeled the imperfect HOM visibility by the parameter v, whereby the photons bunch into a N00N state with probability v 2 . We then proceed as before, modeling loss as |1 In A ,l A on the two-photon terms. With the same definitions for mode B. Similarly, the demon's beamsplitters enact the following transformations: In this case, the demon's strategy will be the same as for uncorrelated thermal states. This is because when the demon detects a photon in mode Dem B , it is now more likely that there are more photons in mode B (unless both photons of the N00N state are reflected). Thus the demon will swap the modes. On the other hand, the demon will not do anything when a photon is detected in mode Dem A . Working through all of these transformations, one arrives at the following state: The mode labels are |i, j, k, l, m, n D A ,D B ,Dem A ,Dem B ,l A ,l B . It is then straightforward to compute the probability for the detectors in mode A and B to click then. For that we can obtain the photon number difference as before This expression is very similar to that of the SPDC light, simply with an additional factor of (2v 2 − 1). So we see in the low photon-number regime, for an ideal source both the correlated and anti-correlated states behave identically. But in practice, the correlated state should perform better, since they do not require the additional experimental step of Hong-Ou-Mandel As a last step, we again compute our two figures of merit, by normalising ∆N by both the singles and the coincidence counts, yielding and ∆N C = 2(2v 2 − 1)R 2 (1 − R 2 ).
Similar to the correlated states, we see that normalising by coincidences removes the effect of the imperfect coupling efficiency. However, the visibility factor remains.

D The Maxwell's Demon's Information
In order to quantify the information accessible to the MD we compute the mutual information between the MD's measurement outcomes (detector clicks at detectors Dem A and Dem B ) and the photon numbers distribution in mode A and B after MD's two beamsplitters. As discussed in the main text, this quantity imposes an upper limit on the amount of work that the MD can extract. The mutual information between the detector outcomes and the photon number quantifies the common information between these systems, and, hence, how much the MD can learn about the photon number from its measurements. Following Ref. [32], the mutual information between the demons measurement clicks (M a and M b ) and the photon number in mode A and B after the beamsplitter (N a and N p(m A , m B , n A , n B ) is the probability to detect m A photons at detector Dem A , m B photons at detector Dem B , while having n A photons remaining in mode A and n B photons remaining in mode B. Similarly, p(m A , m B ) is the probability for the demon to detect m A and m B photons at detectors Dem A and Dem B , respectively. We obtain p(m A , m B ) by marginalizing p(m A , m B , n A , n B ) over n A and n B . The joint probability p(m A , m B , n A , n B ) will depend on the input state, and can be taken almost directly from the output states computed in Appendix C. In particular, they are obtained from the coefficients of the various terms in Eq. (12) for the uncorrelated case, Eq. (20) for the split thermal state, Eq. (29) for the correlated state, and Eq. (37) for the anti-correlated state. However, the MD's operation given in Eq. (11) must first be undone. Furthermore, for the correlated and anti-correlated states, we ignore the vacuum component from the state preparation (i.e. we set |ψ = |1, 1 A,B in Eq. (26), and similarly in Eq. (36)) to reflect our normalization by the singles rate.
The remaining quantity in Eq. (D) is the conditional probability p(m A , m B |n A , n B ) which is the probability that the MD will detect m A and m B photons at detectors Dem A and Dem B , respectively, given that n A and n B photon are incident in modes In A and In B , respectively. Since the modes do not interact before the MD's beamsplitter this probability factorizes p(m A , m B |n A , n B ) = p(m A |n A )p(m B |n B ). These individual probabilities for mode A and B can be readily computed by assuming a Fock state |n is input to a beamsplitter of reflection amplitude R where the coupling efficiency is 2 (as defined above). Notice that the conditional probabilities are the same for every input state, as they are related just to the MD's apparatus. The effect of the input states on the mutual information arises through the joint probabilities coming from the calculations presented in Appendix C, and these introduce dependence the average photon number (for the uncorrelated and split thermal states) and the visibility (for the anti-correlated state).