Searching for Dark Matter with a Superconducting Qubit

The gravitational evidence for the existence of dark matter is extensive, yet thus far, dark matter has evaded direct detection in terrestrial experiments. Detection mechanisms for low mass dark matter candidates such as the axion or hidden photon leverage potential interactions with electromagnetic fields, whereby the dark matter (of unknown mass) on rare occasion converts into a single photon. Current dark matter searches operating at microwave frequencies, use a resonant cavity to coherently accumulate the field sourced by the dark matter and use a quantum limited linear amplifier to read out the cavity signal. Here, we report the development of a novel microwave photon counting technique and use it to set a new exclusion limit on hidden photon dark matter. We constrain the kinetic mixing angle to $\epsilon \leq 1.82 \times 10^{-15}$ in a narrow band around 6.011 GHz (24.86 $\mu$eV) with an integration time of 8.33 s. We operate a superconducting qubit to make repeated quantum non-demolition measurements of cavity photons and apply a hidden Markov model analysis to reduce the noise to 15.7 dB below the quantum limit, with performance limited by the residual population of the system. The techniques presented here will dramatically improve the sensitivity of future dark matter searches in the range of 3-30 GHz and are generally applicable to measurements that require high sensitivity to inherently low signal photon rates.

The nature of dark matter is an enduring mystery of our universe. Dark matter comprises 26.5% of the energy-matter content in the universe and is five times more abundant than visible matter 12 . Observations of galaxy rotation curves, gravitational lensing, and the presence of structure in the cosmos all inform our understanding of dark matter, but provide little insight into its intrinsic properties 1 . We are interested in testing the hypothesis that dark matter is composed of waves of low mass bosons, which due to their high galactic phase space density, arrive as coherent waves with macroscopic occupation number. Well known dark matter candidates include the axion and hidden sector photon, which both have compelling cosmological origin stories 2-6 .
One method for detecting these dark matter waves exploits their interactions with the electromagnetic field 7,6 . The dark matter candidate forms an effective oscillating current density that sources Maxwell's equations. For axions, the effective current density is j axion = g aγγ √ 2ρB 0 e imat , where g aγγ is the predicted coupling of the axion field to electromagnetism, ρ is the local dark matter density, B 0 is a DC magnetic field applied in the laboratory, and m a is the mass of the axion. For hidden photons, the effective current is j HP = m γ √ 2ρe im γ tn , where is a postulated kinetic angle of mixing between standard electromagnetism and hidden sector electromagnetism,n is the polarization of the hidden photon field, and m γ is the hidden photon mass. Via Faraday's law, the electric field of a microwave cavity is sourced by the effective current formed by the dark matter ∇ × B − ∂E ∂t = j DM . A microwave cavity with resonance frequency tuned to the mass of the hypothetical particle is then used to coherently accumulate the electromagnetic response.
There are specified targets in the parameter space of coupling and dark matter mass in the case of the axion of quantum chromodynamics. The expected signal photon occupation number is ∼10 −2 for searches like the Axion Dark Matter eXperiment operating at 650 MHz 8 . However, the microwave cavity volume must shrink at higher frequencies to maintain the resonance condition. The signal photon rate scales with the volume of the cavity, making detection of smaller signals increasingly challenging at higher frequencies. For an axion search with the microwave cavity (6.011 GHz) used in the present work and given the experimental parameters in typical axion search experiments [9][10][11]13 , the axion models (DFSZ and KSVZ) 14-17 predict a signal with mean photon number ofn axion ∼10 −8 − 10 −5 per measurement. For hidden photons, the parameter space is less constrained, 5,18 and the mean photon number per measurement could ben HP ≤ 10 −1 . Currently, these searches employ linear amplification operating near the standard quantum limit (SQL) 19 to read out the built up signal in the microwave cavity, where the noise variance is equivalent to fluctuations of an effective background ofn noise = 1. At GHz frequencies and above, the noise inherent to quantum limited linear amplification overwhelms the signal, making the search untenable (n noise n axion ,n HP ).

Counting photons to detect dark matter
We use single photon resolving detectors to avoid quantum noise by measuring only field amplitude resulting in insensitivity to the conjugate phase observable. The noise is then dominated by the Poisson fluctuations of the background counts and ultimately limited by the shot noise of the signal itself 20 . Technologies such as superconducting nanowire single-photon detectors or photo- Storage n =2 n =0 n =1 Fig. 1: Superconducting transmon qubit dispersively coupled to high Q storage cavity. a, Schematic of photon counting device consisting of storage and readout cavities bridged by a transmon qubit 26 . The interaction between the dark matter and electromagnetic field results in a photon being deposited in the storage cavity. b, Qubit spectroscopy reveals that the storage cavity population is imprinted as a shift of the qubit transition frequency. The photon number dependent shift is 2χ per photon. multipier tubes can readily count photons with virtually no background counts for terahertz frequency photons. However, these technologies are not well suited to detect single low energy microwave photons 21 . We aim to develop a detector that is sensitive in the microwave regime and has a low dark count probability commensurate with the small signal rates expected in a dark matter experiment.
In order to construct such a single photon counter, we build from the work of Haroche et. al. in coupling atomic systems to electromagnetic fields 22,23 . Here, we utilize the interaction between a superconducting transmon qubit 24 and the field in a microwave cavity to count photons. In the dispersive limit (qubit-cavity coupling qubit, cavity detuning), the Jaynes-Cummings Hamiltonian 25 describes the interactions between a qubit and cavity, and is expressed as H/h = ω c a † a + 1 2 ω q σ z + 2χa † a 1 2 σ z . The Hamiltonian can be recast to elucidate a key feature: a photon number dependent frequency shift (2χ) of the qubit transition (Fig. 1b).
We use an interferometric Ramsey measurement of the qubit frequency to infer the cavity state 27 . Qubit decay, dephasing, heating, cavity decay, and readout infidelity are the main sources of errors in this measurement. The qubit-cavity interaction (2χa † a 1 2 σ z ) is composed solely of number operators and commutes with the bare Hamiltonian of the cavity (ω c a † a) and qubit ( 1 2 ω q σ z ). Thus, the cavity photon state collapses to a Fock state (|0 or |1 in the n 1 limit) upon measurement, rather than being absorbed and destroyed [28][29][30][31] . Crucially, this allows us to repeat the photon number measurement multiple times. We devise a counting protocol insensitive to any individual measurement error [32][33][34] , dramatically reducing the probability of false positives.
Instead of producing amplitude noise like a SQL am-plifier, the backaction associated with quantum nondemolition (QND) counting of single photons is the complete randomization of the phase of the electromagnetic field in the cavity, due to the number phase uncertainty relation. However, the phase information is not necessary to determine if the dark matter wave has successfully deposited a photon in the cavity. This QND technique provides the means necessary to achieve the sub-SQL noise required to detect dark matter.
In this work, we use a device composed of a high quality factor (Q s = 2.06 × 10 7 ) 3D cavity used to accumulate and store the signal induced by the dark matter (storage, ω s = 2π × 6.011 GHz), a superconducting transmon qubit (ω q = 2π × 4.479 GHz), and a 3D cavity strongly coupled to a transmission line (Q r = 1.5 × 10 4 ) used to quickly read out the state of qubit (readout, ω r = 2π × 8.051 GHz) (Fig. 1a). We mount the device to the base stage of a dilution refrigerator at 8 mK (see Supplementary Information sections A, B, C).
To count photons, we map the cavity population onto the qubit state by performing a cavity number parity measurement with Ramsey interferometry. This is accomplished by placing the qubit, initialized either in |g or |e , in a superposition state 1 √ 2 (|g ± |e ) with a π/2 pulse. The qubit state precesses at a rate of |2χ| = 2π × 1.13 MHz when there is one photon in the storage cavity due to the photon dependent shift of the qubit frequency. Waiting for a time t p = π/|2χ| results in the qubit state accumulating a π phase if there is one photon in the cavity. We project the qubit back onto the z-axis with a −π/2 pulse completing the mapping of the storage cavity photon number onto the qubit state. If there were zero photons in the cavity, the qubit remains in its initial state. If there were one photon in the cavity the qubit state is flipped (|g ↔ |e ) (see Supplementary Information section D). We then determine the qubit state using it's standard dispersive coupling to the readout resonator. The parity measurement is depicted in Fig. 2a. For weak cavity displacements (n 1), this protocol functions as a qubit π pulse conditioned on the presence of a single cavity photon 27 . Qubit and readout errors during the parity measurement introduce inefficiencies or worse, false positive detections. For contemporary transmon qubits, these errors occur with much greater probability (1-10%) than the appearance of a dark matter induced photon, resulting in a measurement that is limited by detector errors. To suppress the detector errors, we make repeated QND measurements of the cavity population, as shown in Fig. 2a [32][33][34] .

Hidden Markov model analysis
In order to account for all possible error mechanisms during the measurement protocol, we model the evolution of the cavity, qubit, and readout as a hidden Markov process where the cavity and qubit states are hidden variables that emit as a readout signal (see Fig. 2b). The Markov chain is characterized by the transition matrix (T) (Equation 2) that governs how the joint cavity, qubit  |0e |1g |1e       P 00 P gg P 00 P ge P 01 P ge P 01 P gg |0g P 00 P eg P 00 P ee P 01 P ee P 01 P eg |0e P 10 P gg P 10 P ge P 11 P ge P 11 P gg |1g P 10 P eg P 10 P ee P 11 P ee P 11 P eg |1e We determine the elements of the transition matrix using independently measured qubit coherences (T q 1 = 108 ± 18 µs, T q 2 = 61 ± 4 µs), cavity lifetime (T s 1 = 546 ± 23 µs), qubit spurious excited state population (n q = 5.1 ± 0.3 × 10 −2 ), the length of the parity measurement (t p = 380 ns) (see Supplementary Information section F.1), and the time between parity measurements (t m = 10 µs). The repetition rate of the experiment is constrained primarily by the readout time (3 µs) and time for the readout resonator to relax back to the ground state. Qubit (cavity) relaxation |e → |g (|1 → |0 ) occurs with a probability P ↓ eg = 1 − e −tm/T q 1 (P 10 = 1 − e −tm/T s 1 ). The probability of spontaneous heating |g → |e (|0 → |1 ) of the qubit (cavity) towards its steady state population is given by .n c is set to zero in the model in order to penalize events in which a photon appears in the cavity after the measurement sequence has begun (see Supplementary Information section G.2). This makes the detector insensitive to cavity heating events. Dephasing during the parity measurement occurs with probability P φ = 1 − e −tp/T q 2 , leading to outcomes indistinguishable from qubit heating or decay. The transition matrix contains all qubit errors: P ge = P ↑ ge + P φ and P eg = P ↓ eg + P φ . P gg , P ee , P 00 , and P 11 correspond to events where no error occurs, such that probabilities pairwise sum to unity (e.g. P gg + P ge = 1).
The elements of the emission matrix are composed of the independently measured readout fidelities of the ground and excited states of the qubit (F gG = 95.8 ± 0.4 %, F eE = 95.3 ± 0.5 %). Noise from the first stage cryogenic HEMT amplifier sets the readout fidelity (see Supplementary Information section F.2).
Given a set of N+1 measured readout signals (R 0 , R 1 , ..., R N ), we reconstruct the initial cavity state probabilities P (n 0 = 0) and P (n 0 = 1) by using the backward algorithm 32,33 and summing over all possible initial qubit states, as shown in Equation 4.
This reconstruction includes terms corresponding to all the possible processes that could occur. For example, a readout measurement of G followed by E could occur due the correct detection of a photon in the cavity (with probability P 11 P gg F eE /2). Alternatively, this measurement could be produced by a qubit heating event (P 00 P ge F eE /2) or a readout error (P 00 P gg F gE /2). Fig. 2c displays the measured readout signals and reconstructed initial cavity probabilities of two events. The top panels correspond to the absence of a cavity photon and the bottom panels indicate the presence of a photon.
We apply a likelihood ratio test (λ = P (n0=1) P (n0=0) ) to the reconstructed cavity state probabilities to determine if the cavity contained zero or one photons. If the likelihood ratio is greater than (less than) a threshold, λ > λ thresh (λ ≤ λ thresh ), we determine the cavity to contain one (zero) photon. The probability of a false positive detection due to detector errors is therefore less than 1 λ thresh +1 . As the threshold for detection increases, so too does the number of repeated parity measurements needed to confirm the presence of a photon. This protocol and analysis exacts a cost to detection efficiency that is linear in the number of measurements (see Supplementary Information section G.1). More importantly for the detection of rare events, false positives are exponentially suppressed with more repeated measurements, as evident in Fig. 2c.

Detector characterization
To characterize the detector, we populate the cavity by applying a weak drive (n 1) (see Supplementary Information section E). We map out the relationship between the probability of injected and measured photons ( Fig. 3a) by varying the injected mean photon population (n = α 2 ), performing 30 repeated parity measurements, and applying λ thresh to discriminate between one and zero photon events. We fit this relationship to obtain the efficiency of detection (η) and the false positive probability (δ). False positives occur when the detector determines that a photon is present in the cavity even when no photon is injected. Fig. 3b shows that as we increase the likelihood threshold λ thresh , the efficiency corrected false positive probability (δ/η) initially decreases, but eventually asymptotes. The initial decrease for low thresholds indicates a suppression of false positives due to detector errors. Leveling off at larger thresholds indicates that the dominant source of false positives is no longer detector errors, but rather a background of real photons.
False positives that occur when qubit errors are highly suppressed (at large λ thresh ) are due to a photon background in the storage cavity. We measure the cavity occupation to ben c = 7.3 ± 2.9 × 10 −4 , corresponding to a temperature of 39.9 ± 2.2 mK. In experiments with no photons injected into the cavity, we observe events with likelihood ratios comparable with those seen in experiments with injected photons (Fig. 3c). The detector thus correctly identifies real photons which, in the regime of highly suppressed detector errors, set the background for dark matter searches.
The cavity photon temperature (39.9 ± 2.2 mK) is greater than the physical temperature of the device (8 mK) indicating coupling to extraneous baths. One contribution, arising from coupling to quasiparticles via qubit dressing of the cavity 35 , results in a photon population ofn q c = 1.8 ± 0.1 × 10 −4 (see Supplementary Information section H). Suppression of quasiparticle production could be achieved by enhanced infrared filtering, extensive radiation shielding, gap engineering, and quasiparticle trapping [36][37][38] . Other sources of background photons could include blackbody radiation from higher temperature stages of the dilution refrigerator, poorly thermalized or insufficiently attenuated microwave lines, or  Fig. 3: Detector characterization. a, After a variable initial cavity displacement, 30 repeated parity measurements of cavity photon state are performed and a threshold λ thresh is applied to determine the cavity population. Detector efficiency (η) and false positive probability (δ) are determined from the fit (in orange). The dashed red line corresponds to the standard quantum limit, which results in the noise-equivalent of one photon occupation. b, The efficiency corrected false positive probability (δ/η) vs threshold (λ thresh ) curve asymptotes at high thresholds, indicating qubit errors are now a sub dominant contribution to the total detector false positive probability. c, Histograms of log likelihood ratios of all events for two different injected mean photon numbers. The histogram y-axis is cut off at 4 counts to view the rare events at high log likelihood ratios. We observe unexpected photon events when very small photon numbers are injected with log likelihood ratios similar to that expected from real injected photon events. The dashed grey line corresponds to λ thresh = 10 5 used in a. These events are interpreted as real background photons occupying the storage cavity rather than detector error based false positives.
amplifier noise 39,40 . With further reduction of the background population down to the physical temperature of 8 mK, we can achieve a background free search for dark matter.
Hidden photon dark matter exclusion By counting photons with repeated parity measurements and applying a Markov model based analysis, we demonstrate single photon detection with amplitude noise equivalent to −10 log 10 √n c = 15.7 ± 0.9 dB below the quantum limit. We use this detector to conduct a narrow band hidden photon search. We collect 15,141 measurements where the injectedn is well below the background populationn c . Each measurement consists of integrating the signal (for the cavity lifetime, T s 1 = 546 µs) and counting the number of photons in the cavity with 30 repeated parity measurements (30 × t m = 300 µs). The total search time is 15,141 × (546 + 300)µs = 12.81 s with a duty cycle of 546µs 846µs = 65%. We apply a detection threshold of λ thresh = 10 5 , such that the qubit errors are suppressed below the background photon probability (  Fig. 4: Hidden photon dark matter parameter space. Shaded regions in the hidden photon parameter space 5 of coupling ( ) and mass (mγ) are excluded. In the orange band, hidden photon dark matter is naturally produced in models of high scale cosmic inflation 6 . The exclusion set with the qubit based photon counting search presented in this work, is shown in purple. The detector is most sensitive on resonance with the storage cavity (m γ c 2 =hωs) and the hidden photon kinetic mixing angle is constrained to ≤ 1.82 × 10 −15 at 90% confidence. The detection procedure consists of making repeated measurements of the number parity of the cavity state. Therefore, the detector is sensitive to cavity states with number distributions that have odd number populations greater than the measured background. The detector sensitivity is dependent on the mass of the dark matter candidate, giving rise to bands of exclusion (see inset) centered around regions where the cavity number dependent qubit shift 41 is an odd multiple of 2χ. a quantum efficiency of η = 40.9% (Fig. 3a). Accounting for the efficiency of the detector, we count 22 photons. A hidden photon candidate with coupling ( ) and mass (m γ ) that on average produces more than 29.3 photons in 15,141 measurements is therefore excluded at the 90% confidence level (see Supplementary Information section I). Fig. 4 shows the region of hidden photon parameter space excluded by the qubit based search. The detector is maximally sensitive to dark matter candidates with masses within a narrow window around the resonance frequency of the cavity. This window is set by the lineshape of the dark matter (Q DM ∼ 10 6 ) such that the sensitivity falls to half the maximum (-3dB point) 3 kHz away from the cavity resonance. Sensitivity to off resonant candidates occurs in regions where the photon number dependent qubit shift is an odd multiple of the dispersive shift 2χ (see Supplementary Information section J). The hidden photon mixing angle is constrained to ≤ 1.82 × 10 −15 with 90% confidence for hidden photon candidates with mass equal to the resonance frequency of the storage cavity (m γ c 2 =hω s ).

Future dark matter searches
The photon detection technique developed in this work has unprecedented sensitivity to dark matter candidates and enables future cavity based searches for axions and hidden photons in the 3-30 GHz range.
In order to implement a full scale axion search, the photon counting device must be coupled to a microwave cavity bathed in a magnetic field that accumulates the axion deposited signal. To extract the signal, a nonlinear element such as a Josephson parametric converter can be used to transfer the signal photon from the accumulation cavity to the storage cavity 42,43 . When the accumulation cavity frequency is tuned to search for a different axion mass, the converter can be pumped at appropriate frequency to enable photon transfer. The storage cavity and qubit can remain fixed in frequency, which leaves the photon detection protocol unchanged at each tuning. Although novel cavity techniques to achieve high Q in the presence of magnetic fields have been demonstrated 44 , in the most pessimistic scenario the accumulation cavity will be made of copper and limited to a Q ∼ 10 4 at 10 GHz due to the anomalous skin effect. This sets the accumulation time to ∼ 1 µs. To minimize the dead time of the experiment, the time required to measure the storage cavity should ideally be matched to that of a copper accumulation cavity lifetime. Reaching the required detector error probability in this limited time will be challenging. In this work, each parity measurement requires 10 µs because of the large readout signal necessary to overcome the HEMT amplifier noise. We perform 30 repeated measurements in order to reduce the probability of detector errors to a level below the expected signal photon probability for dark matter (n axion ∼ 10 −8 ). Readout of a superconducting qubit with > 99% fidelity in 100 ns has been achieved by using quantum limited parametric amplifiers 45 and appropriate pulse shaping 46 . Both techniques can be applied to this protocol to significantly increase the measurement rate and readout fidelity.
For a hidden photon search, a magnetic field is not required. As demonstrated in this work, the accumulation and storage cavity can be the same device. When the cavity is tuned to search through the parameter space, as long as a sufficiently large dispersive shift to the accumulation/storage is maintained and the qubit is still far detuned, the fundamental QND interaction between the qubit and photon is maintained. Additionally, by using extremely high Q cavities (Q Q DM ) to sample the dark matter energy distribution once or twice per dark matter linewidth, only Q DM ∼ 10 6 cavity frequency tunings are required to test each mass hypothesis in a frequency octave.

Application in quantum computing
Counting photons will also be a useful tool for quantum computing architectures which utilize long lived storage cavities 47,48 that are sensitive to residual cavity population. Though qubit dephasing is typically used to calibrate the background photon population of the system, this technique is only sensitive to the low Q readout cavity and not the storage cavity which has a much longer lifetime than the qubit. Alternatively, the storage cavity population can be extracted by driving Rabi oscillations of the 2χ shifted qubit transition, but this yields only the average cavity photon number over multiple experimental runs. Counting photons with repeated measurements to assess the cavity population independently of the qubit errors allows for both single shot and real time monitoring of the storage cavity, crucial when preparing states whose fidelity is sensitive to the initial conditions.

Conclusions
Photon number measurements allow us to gain unprecedented sensitivity to dark matter signals. The single photon counting protocol demonstrated in this work constitutes a 15.7 dB improvement in amplitude, relative to the zero point noise added by a quantum limited amplifier. This improvement is currently limited by background photonsn c = 7.3 × 10 −4 whose suppression will further increase the sensitivity of the detector. Dark matter searches in the mass range of 3-30 GHz can be performed by a series of tuned narrow band measurements with the detector sensitivities achieved in this work. We demonstrate that qubit based photon counting technology is readily applicable to current narrow band experiments by performing a hidden photon dark matter search which excludes candidates with mixing angle > 1.82 × 10 −15 in a band around 6.011 GHz. To extend the detection scheme presented in this work to searches beyond 30 GHz, a nonlinear element with a higher plasma frequency than that of Aluminium, such as Tantalum 49 , Niobium, or Titanium Nitride, could be used. For dark matter searches in the mass range of 10-100 µeV, qubit based photon counting is the enabling technology.

Data Availability
The experimental data and analysis presented in this manuscript are available from the corresponding author upon request. of Chicago, which receives support from Soft and Hybrid Nanotechnology Experimental (SHyNE) Resource (NSF ECCS-1542205), a node of the National Science Foundations National Nanotechnology Coordinated Infrastructure. This manuscript has been authored by Fermi Research Alliance, LLC under Contract No. DE-AC02-07CH11359 with the U.S. Department of Energy, Office of Science, Office of High Energy Physics, with support from its QuantISED program. We acknowledge support from the Samsung Advanced Institute of Technology Global Research Partnership.

Author Contributions
A.V.D, D.I.S, and A.C. conceived of the experiment. S.C. fabricated the device with assistance from A.V.D. The experiment was designed and conducted by A.V.D. with assistance from S.C., K.H., A.A., and R.K.N. Analysis was performed by A.V.D. All authors contributed to the preparation of the manuscript.

Competing Interests
The authors declare no competing interests.

Additional Information
Correspondence and requests for materials should be addressed to avdixit@uchicago.edu.

A Flute cavity fabrication
The cavities used in this work are fabricated from high purity (99.9999%) Aluminium using a novel flute method illustrated in Fig. S1. This technique involves drilling offset holes from the top and bottom of the stock material, with a region of overlap defining the cavity volume. Making the cavity from a monolithic piece of Aluminium eliminates seam loss by design 50 and results in a high quality factor. The full device consists of two microwave cavities each coupled to the transmon qubit. One cavity has a long lived storage mode and the other is strongly coupled to the line to perform qubit readout.

B Transmon qubit fabrication
The transmon qubits were fabricated on 430 µm thick Cplane (0001) Sapphire wafers with a diameter of 50.8 mm. Wafers were cleaned with organic solvents (Toluene, Acetone, Methanol, Isopropanol, and DI water) in an ultrasonic bath to remove contamination, then were annealed at 1200 • C for 1.5 hours. Prior to film deposition, wafers underwent a second clean with organic solvents (Toluene, Acetone, Methanol, Isopropanol, and DI water) in an ultrasonic bath. The base layer of the device, which includes the capacitor pads for the transmon, consists of 75 mm of Nb deposited via electron-beam evaporation at 1Å/s. The features were defined via optical lithography using AZ MiR 703 photoresist, and exposure with a Heidleberg MLA150 Direct Writer. The resist was developed for 1 minute in AZ MIF 300 1:1. The features were etched in a Plasma-Therm inductively coupled plasma (ICP) etcher using fluorine based ICP etch chemistry with a plasma consisting of 15 sccm SF 6 , 40 sccm CHF 3 , and 10 sccm Ar. The junction mask was defined via electron-beam lithography of a bi-layer resist (MMA-PMMA) in the Manhattan pattern using a Raith EBPG5000 Plus E-Beam Writer, with overlap pads for direct galvanic contact to the optically defined capacitors. The resist stack was developed for 1.5 minutes in a solution of 3 parts IPA and 1 part DI water. Before deposition, the overlap regions on the pre-deposited capacitors were milled in-situ with an Argon ion mill to remove the native oxide. The junctions were then deposited with a three step electron-beam evaporation and oxidation process. First, an initial 35 nm layer of aluminium was deposited at 1 nm/s at an angle of 29 • relative to the normal of the substrate, parallel azimuthally to one of the fingers in the Manhattan pattern for each of the junctions. Next, the junctions were exposed to 20 mbar of a high-purity mixture of Ar and O 2 (ratio of 80:20) for 12 minutes for the first layer to grow a native oxide. Finally, a second 120 nm layer of aluminium was deposited at 1 nm/s at the same angle relative to the normal of the substrate, but orthogonal azimuthally to the first layer of aluminium. After evaporation, the remaining resist was removed via liftoff in N-Methyl-2pyrrolidone (NMP) at 80 • C for 3 hours, leaving only the junctions directly connected to the base layer. After both the evaporation and liftoff, the device was exposed to an ion-producing fan for 15 minutes, in order to avoid electrostatic discharge of the junctions. The room temperature DC resistance of the Josephson junction on each qubit was measured to select the qubit which corresponds to the target Josephson energy 51 (E J ).

C Experimental setup
The cavities and qubit are mounted to the base plate of a dilution fridge (Bluefors LD400) operating at 8 mK. The device is potted in a block of infrared (IR) absorbant material (eccosorb CR-110) to absorb stray radiation and housed in two layers of µ-metal to shield from magnetic fields. Signals sent to the device are attenuated and thermalized at each temperature stage of the cryostat as shown in Fig. S2. The field probing the readout resonator is injected via the weakly coupled port (shorter dipole stub antenna). Control pulses for qubit, storage cavity, and sideband operation are inserted through the strongly coupled readout port (longer dipole stub antenna). This line includes a cryogenic microwave attenuator thermalized to the base stage (Courtesy of B. Palmer) and a weak eccosorb (IR filter). Both control lines also contain an inline copper coated XMA attenuator that is threaded to the base state. The signal from the readout resonator reflects off a Josephson parametric amplifier (not used in this work) before being amplified by a cryogenic HEMT amplifier at the 4 K stage. The output is mixed down to DC before being digitized.  Fig. S2: Wiring diagram inside the dilution refrigerator and the room temperature measurement setup. Qubit readout is performed by injecting a drive into the weakly coupled port. After interacting with the readout cavity, the signal is routed to the amplification chain using non reciprocal circulator and isolator elements. We note, the Josephson parametric amplifier is not in operation for the measurements presented in this work. The signal is then mixed down to DC, further amplified, and finally digitized. Qubit and storage cavity operations are performed via the strongly coupled port. This line is heavily filtered and attenuated 39 to minimize stray radiation from entering the device.

D Calibration of parity measurement
The cavity number parity measurement requires the calibration of the two qubit π/2 pulses as well as the delay between them. To set the π/2 pulse length, we perform qubit Rabi oscillations between the |g and |e levels by driving at the qubit transition frequency. The population transfer is sinusoid and can be fit to determine when the qubit population has inverted (π pulse). By turning on the drive for only half the time required to perform a π pulse gives us the needed π/2 pulse to put the qubit in a clock state ( 1 √ 2 (|g + |e )). The parity measurement is comprised of an initial π/2 pulse followed by a time delay of π/|2χ| and a final −π/2 pulse (constructed by advancing the phase of the π/2 pulse by π).
To calibrate the time delay used in the parity measurement, we perform two Ramsey interferometry exper-iments on the qubit either in the absence or presence of a single photon in the cavity. We chose the Ramsey drive frequency to be on resonance with the qubit transition frequency. In the absence of the photon, the qubit superposition remains unchanged in the frame of the qubit. We use the |f 0 −|g1 sideband [52][53][54][55] to populate the cavity with a single photon. In the presence of the cavity photon, the qubit transition frequency is shifted by 2χ relative to the Ramsey frequency, consequently, the resulting fringe oscillates at a rate of 2χ. The parity measurement delay time (t p ) is chosen such that the qubit superposition state has obtained a phase shift of π. This is also a calibration of the dispersive shift (|2χ| = π/t p ).

E Drive pulse calibration
By applying a weak coherent tone at the storage cavity frequency, we induce a variable displacement α of the cavity state. We calibrate the number of photons injected into the storage cavity by varying the drive amplitude and performing qubit spectroscopy. By fitting the qubit spectrum show in Fig. S3 to a Poisson distribution, we extract the cavity occupation,n = |α| 2 .
Nonlinearities of the signal generator result in a non trivial relationship between drive amplitude (at the software level) and the cavity occupation number. We map the transfer function that describes this relation and use it to apply calibrated cavity displacements (Fig. S4).

F Elements of hidden Markov model
The hidden Markov model relies on independent measurements of the probabilities contained in the transition and emission matrices. The elements of these matricies depend on the parameters of the experiment and the device, including the lifetimes of the qubit and cavity, qubit spurious population, and readout fidelities.

F.1 Transmission matrix elements
The lifetime of the qubit is determined by applying a π pulse and waiting for a variable time before measuring the population. We map out the qubit population as a function of the delay time, fit it with an exponential characterizing the Poissonian nature of the decay process, and obtain T q 1 = 108 ± 18 µs. The dephasing time of the qubit is measured by a Ramsey interferometry experiment with a π/2 pulse, variable delay, and a final π/2 with its phase advanced by ω r t where ω r is the Ramsey frequency. During the variable delay period, a series of π pulses are applied to perform spin echos and reduce sensitivity to low frequency noise. We observe a dephasing time of T q 2 = 61 ± 4 µs. The storage cavity lifetime is calibrated by performing a cavity T 1 experiment. This is accomplished by applying a π ge pulse and a π ef to the transmon. This is followed by driving the |f 0 − |g1 transition, mediated by the Josephson nonliniearity for a time corresponding to a π pulse 52-55 . This populates the cavity with  |n = |1 photons. After a variable time delay, the cavity population is swapped back into the qubit using the same π |f 0 −|g1 pulse. Measuring the qubit population, we infer the cavity population as a function of the time delay. This is fit with a decaying exponential to obtain T s 1 = 546 ± 23 µs (Fig. S5). To measure the cavity dephasing time, the cavity is initialized in a superposition state 1 √ 2 (|0 + |1 ) by first applying a π ge /2 pulse, a π ef , followed by a π |f 0 −|g1 pulse. A Ramsey measurement is performed to obtain a cavity dephasing time of T 2 2 = 774 ± 286 µs.
The qubit spurious population is determined by measuring the relative populations of its ground and excited states 56 . This is done by utilizing the f -level of the transmon. Two Rabi experiments are conducted swapping population between the |e and |f levels. First, we apply a π ge pulse to invert the qubit population followed by the |e − |f Rabi experiment. Second, no π ge pulse is applied before the ef Rabi oscillation. The ratio of the amplitudes of the oscillations gives us the ratio of the populations of the excited and ground state. Assuming that P (g) + P (e) = 1 and measuring P (e) P (g) , we obtain P (g) = 0.949 and P (e) = 0.051, corresponding to an effective qubit temperature of 71 mK.

F.2 Emission matrix elements
In order to characterize the emission matrix it is necessary to measure the readout infidelity of a particular transmon state. All the possible transmon states (|g , |e , |f ) are prepared (3000 independent experiments per state) and the resulting I,Q signals are digitized. The resulting distributions in I,Q space are used as a map to determine the probability that any readout signal is the result of transmon being in either |g , |e , or |f . Based on the calculated probability, the state is assigned to either G, E, or F (Fig. S6).
Readout errors are due to voltage excursions from amplifier noise or spurious qubit transitions. The emission matrix should only contain readout errors that occur due to voltage fluctuations. Errors due to qubit transitions during the readout window are accounted for in the transition matrix. To disentangle the two contributions the analysis is run with various contingencies, all resulting in the same detector false positive probability and efficiency, indicating that the Markov model is robust to small perturbations of the emission matrix when so heavily biased against false positives. In the most conservative case, the qubit errors are accounted for during the entire 10 µs window or each parity measurement. The readout infidelity is determined by finding how many errors are made (regardless of the source) during the 3 µs readout window (part of the 10 µs experiment time window). In this case qubit errors are counted twice during the readout window. In the second case, we consider qubit errors only for times when readout is not occurring (7 of the 10 µs) and include all error channels in the readout infideility. This avoids double counting of the qubit error during readout. The third case most closely aligns with the plausible physical model of errors during the readout window occurring due to a combination of qubit errors and amplifier noise. The readout infidelity is computed by subtracting the qubit error probabilities during the 3 µs readout window due to qubit decay (1 − e −3 µs/T q 1 ) or heating (n q [1 − e −3 µs/T q 1 ]) from the total measured error during readout, leaving only readout errors due to voltage noise from amplifiers. This is the readout infidelity used to determine the elements of the emission matrix in the analysis.

G Detector characterization
To characterize the detector, the cavity population is varied by applying a weak drive and the cavity photon number is counted using the technique described in the main text. In order to extract the efficiency (η) and false positive probability (δ) of the detector, the relationship between injected photon population (n inj ) and measured photon population (n meas ) is fit ton inj = η ×n meas + δ.

G.1 Detector efficiency
The detector efficiency and false positive probability is determined at varying thresholds for detection λ thresh .
As the detection threshold is increased, more parity measurements are required to determine the presence of a photon. This suppresses false positives due to qubit errors but also leads to a decrease in the detector efficiency as events with low likelihood ratio are now rejected (Fig.  S7). For large thresholds where 1 λ thresh +1 < δ, the qubit based errors are no longer the dominant source of detector errors. These errors occur due to the presence of a background of real photons whose population is given by the efficiency corrected false positive probability δ/η (shown in the main text).

G.2 Analysis with cavity backgrounds
In the initial application of the hidden Markov analysis, the cavity background population is set to zero to exclude the effects of cavity heating events during the measurement. We measure a background population of 7.3 ± 2.9 × 10 −4 and then includen c in the model to reanalyze the data. Now in addition to the possibility of a photon from injection or background initially occupying the cavity, we allow for both cavity heating during the measurement and qubit errors. The reconstructed false positive probability of the detector P (n = 0) is set by the probability of a cavity heating event preceding the first parity measurementn c × (1 − e −tm/T s 1 ) = 1.3 × 10 −5 . Therefore, the maximum likelihood ratio of the reconstructed probabilities cannot exceed the cavity heating limit. By setting the detection threshold to λ thresh = 2.0 × 10 4 and including cavity heating processes in the model, we measure the background population of the cavity to be 5.6 ± 1.8 × 10 −4 , which is consistent with the initial measurement ofn c = 7.3 ± 2.9 × 10 −4 . This reinforces our belief that repeated parity measurements successfully mitigate qubit based errors and that cavity background photons are the limiting process for photon detection.

H Sources of cavity backgrounds
The measured photon background contains a contribution from spurious photons injected due to the cavity interaction with the qubit. To characterize the significance of the effect of converted qubit excitations, we recognize that cavity ( 1 ) and qubit (|ẽ ) excitations are dressed  due to their interaction. In the dispersive limit, written in terms of the bare basis eigenstates (|e , |1 ), the dressed states are: |ẽ = sin θ |g, 1 + cos θ |e, 0 1 = cos θ |g, 1 − sin θ |e, 0 where θ is the mixing angle between the two systems. Qubit heating events from quasiparticle tunneling, in effect, prepare the system in the state |e, 0 = |ẽ − sin θ cos θ 1 . The probability that the heating event manifests as a cavity excitation is ( sin θ cos θ ) 2 = 3.5 × 10 −3 . Therefore, the contribution of qubit heating events converted to cavity photons is determined by the probability that there is a qubit heating event and the probability that it is projected into a cavity excitation,n q c =n q × ( sin θ cos θ ) 2 = 1.8 ± 0.1 × 10 −4 .
I Converting cavity occupation limit to hidden photon exclusion I.1 Calculating 90% confidence limit By counting single photons when the applied drive population less than the background population (n c ) we perform a hidden photon search. We count N = 22 background photons in N meas = 15,141 measurements. We determine the mean population ( NHP Nmeas ) deposited by a hidden photon signal that can be excluded at the 90% confidence level by computing the probability that the signal could produce the less than or equal to the measured 22 photons (N ≤ 22) with less than 10% probability. The signal is described by a binomial distribution and the cumulative probability is calculated as: For a given hidden photon candidate, a cumulative probability of < 0.1 implies that candidate has less than 10% chance of producing the observed signal, thereby excluding such a candidate with 90% confidence. This leads us to exclude hidden photon candidates that would produce more than 29.3 photons on average in 15,141 measurements with 90% confidence, so that all candidates withn 90% HP > 29.3/15,141 are excluded (Fig. S8).

I.2 Kinetic mixing angle exclusion
For a dark matter candidate on resonance with the cavity frequency (m DM c 2 =hω c ), the rate of photons deposited in the cavity by the coherent build up of electric field in  one cavity coherence time is given by 57 : The cavity coherence time is given by T s 1 = Qs ωs . The volume of the cavity is 0.953 × 3.48 × 3.56 cm 3 = 11.8 cm 3 . G encompasses the total geometric factor of the particular cavity used in the experiment. This includes a factor of 1/3 due to the dark matter field polarization being randomly oriented every coherence time. For the lowest order mode of the rectangular cavity coupled to the qubit with E = sin( πx l ) sin( πy w )z the geometric form factor is given by: Since the cavity decay and dephasing times (T s 1 and T s 2 ) are longer than the dark matter coherence (Q DM = 10 6 ), the cavity is displaced Qs QDM times with a random phase each dark matter coherence time. The cavity field displacement follows a random walk, leading to an signal amplitude enhancement by a factor of Qs QDM . The hidden photon generated current is set by the density of dark matter in the galaxy ρ DM = 0.3 GeV/cm 3 = 2π × 7.25 × 10 13 GHz/cm 3 : Substituting Equation S9 into Equation S7 yields the signal rate of photons deposited in the cavity by a hidden photon dark matter candidate: The total number of photons we expect to measure is determined by the photon rate and the integration time (T s 1 × N meas = 8.33 s): N HP = dN HP dt × T s 1 × N meas = 2 ρ DM Q DM Q s GV N meas ω s (S11) Rearranging to determine the mixing angle in terms of the excluded photon number = ω s N HP ρ DM Q DM Q s GV × N meas (S12) We can exclude all dark matter candidates that result in a cavity population larger than NHP Nmeas =n 90% HP = 1.94× 10 −3 , implying: (S13)

J Hidden photon parameter space exclusion
Single photon counting with repeated parity measurements is sensitive to a wide range of candidates in the parameter space of hidden photon mass (m γ ) and kinetic mixing angle ( ). To determine the sensitivity of the detector to a particular candidate, there are two considerations: the photon number dependent shift of the qubit transition as a function of the hidden photon mass, and the probability that a candidate would result in the measurement of a photon with probability larger than n 90% HP = 1.94 × 10 −3 . The photon dependent shift of the qubit transition as a function of the frequency of an external drive is determined in Gambetta et. al. 41 to be 2χ + ω c − ω γ wherehω γ = m γ c 2 . The efficiency of an individual parity measurement for a photon dependent shift that is incommensurate with the nominal shift 2χ is given by η parity = | 1 2 (e iπ(2χ+ωc−ω γ )/2χ − 1)| 2 (Fig. S9). The effect of an inefficient parity measurement is modeled as a higher probability of qubit error in the hidden Markov model. The data is then reanalyzed and the efficiency of detection in the presence of the additional error is extracted (Fig. S9).
A hidden photon candidate that could result in more detector counts than background counts is only possible if the population of the odd number states of the cavity state (P odd ) induced by the hidden photon is larger than the excluded hidden photon probability (n 90% HP ). To calculate this P odd we again follow Gambetta et. al. 41 .  where A = D π/T c n drive (π/T c 1 ) 2 (π/T c 1 ) 2 +(ωc−ω γ ±χ) 2 . At a given hidden photon mass, we calculate all n drive such that P odd ≥ n 90% HP . By combining the detector efficiency with the n drive such that P odd ≥n 90% HP , we determine all n drive to which the repeated parity measurements are sensitive enough to detect and exclude (Fig. S10). Using Equation S12 we convert the excluded n drive to a region of excluded hidden photon mixing angle ( ).
The above calculations assume an infinitely narrow dark matter line. To obtain the excluded region of the hidden photon kinetic mixing angle, we must account for the lineshape of the dark matter 58 . We convolve the dark matter lineshape, characterized by Q DM ∼ 10 6 , with the region shown in Fig. S10 to obtain the excluded shown in the main text.
We note that the storage cavity contains an infinite set of discrete resonances each with a unique coupling to the dark matter. We focus only on the lowest order mode that is specifically designed to couple to the qubit. In principle, the interactions between any modes and the dark matter could result in additional sensitivity to the hidden photon. This would require the mode of interest to have a sufficiently large geometric form factor as well as a resolvable photon number dependent qubit shift. Future dark matter searches could employ struc- tures with multiple resonances to enable multiple simultaneous searches.