{'fraction_non_alphanumeric': 0.033678853422145716, 'fraction_numerical': 0.02308872506829323, 'mean_word_length': 4.44720750101916, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A quantum spectrum analyzer enhanced by a nuclear spin memory

We realize a two-qubit sensor designed for achieving high spectral resolution in quantum sensing experiments. Our sensor consists of an active"sensing qubit"and a long-lived"memory qubit", implemented by the electronic and the nitrogen-15 nuclear spins of a nitrogen-vacancy center in diamond, respectively. Using state storage times of up to 45 ms, we demonstrate spectroscopy of external ac signals with a line width of 19 Hz (~2.9 ppm) and of carbon-13 nuclear magnetic resonance (NMR) signals with a line width of 190 Hz (~ 74 ppm). This represents an up to 100-fold improvement in spectral resolution compared to measurements without nuclear memory.


INTRODUCTION
Quantum sensors based on nitrogen-vacancy (NV) centers in diamond show promise for a number of fascinating applications in condensed matter physics, materials science, and biology. 1,2 By embedding them in a variety of nanostructures, such as tips, [3][4][5][6] nanocrystals, 7 or surface layers, 7,8 local properties of samples can be investigated with high sensitivity and spatial resolution. In particular, diamond chips with near-surface NV centers have enabled pioneering experiments in nanoscale detection of nuclear magnetic resonance (NMR), potentially enabling structural analysis of individual molecules with atomic resolution. [9][10][11] A key feature of many quantum sensing experiments is the ability to record time-dependent signals and to reconstruct their frequency spectra. The canonical approach uses dynamical decoupling sequences, which are sensitive to frequencies commensurate with the pulse spacing while efficiently rejecting most other frequencies. [12][13][14][15][16] The spectral resolution of dynamical decoupling spectroscopy, however, is Fourier-limited by decoherence to~(πT 2 ) −1 ∼ 10-100 kHz for shallow NV centers, 17 where T 2 is the electronic decoherence time. It has recently been recognized that by correlating two consecutive decoupling sequences, separated by a variable waiting time t, the spectral resolution can be extended to the inverse state life time T 1 , which can be 10-100× longer than T 2 (refs. 18, 19). Correlation spectroscopy has been applied to both generic ac magnetic fields and to nuclear spin detection, and spectral resolutions of a few 100 Hz have been demonstrated. [20][21][22] Despite these impressive advances, there is a strong motivation to further extend the spectral resolution. For example, many proposed nanoscale NMR experiments 9-11 require discrimination of fine spectral features, often in the few-Hz range. In addition, atomic-scale mapping of nuclear spin positions strongly relies on precise measurements of NMR frequencies and hyperfine coupling constants. 22 Therefore, methods to acquire frequency spectra with even higher spectral resolution are highly desirable.
In this study, we implement a two-qubit sensor designed to further refine the spectral resolution by a factor of 10-100×. Our two-qubit sensor consists of an active sensing qubit and an auxiliary memory qubit, formed by the electronic spin and the 15 N nuclear spin of the NV center in diamond. By intermittently storing the state information in the nuclear-rather than electronic-spin qubit, we extend the maximum waiting time t from T 1~1 ms to the nuclear T 1,n > 50 ms, with a corresponding gain in spectral resolution. In addition, we use the nuclear memory to enhance sensor readout efficiency through repeated readout, 23,24 which would otherwise result in untenably long acquisition times. The presented two-qubit system is particularly useful because it is intrinsic to the NV center, with no need for additional sensor engineering.
The advantages of one or more "auxiliary" qubits have been recognized in several different contexts, including the quantum logic clock for enhanced atomic clock performance [25][26][27] and resettable auxiliary qubit(s) for emulating the environment in quantum simulation. 28,29 Multi-qubit probes may also assist the detection of cross-correlations in environmental noise 30 or the study of non-classical dynamics. 31 In recent experiments with spin qubits in diamond, auxiliary nuclear spins have been used to increase the effective coherence time of an electronic sensor spin by quantum error correction, 32 quantum feedback, 33,34 or by exploiting double-quantum coherence. 35 Moreover, ancillary nuclei have been used to enhance the readout efficiency. 23,24 In our study we utilize the auxiliary nuclear spin as a long-lived memory for the electron qubit's state.

RESULTS
Implementation of the nuclear spin memory Our two-qubit sensor exploits the four-level system formed by the m S ∈ {0, −1} subspace of the S = 1 electronic spin and the two m I ∈ {−1/2, +1/2} states of the I = 1/2 nuclear spin. This pair has four allowed spin-flip transitions (Fig. 1). Due to the hyperfine interaction (a || = 2π × 3.05 MHz), all four transitions are spectrally resolved and can be addressed individually using frequencyselective microwave (MW) or rf pulses. Driving a selective R π X rotation on either of theses transitions leads to a conditional inversion, depending on the state of the other spin. This realizes controlled-NOT gates on the electronic and nuclear spins, respectively, which we denote by c-NOT e and c-NOT n . The specific transitions used in our study are indicated in Fig. 1b.
To implement the "store" and "retrieve" operations, we combine a c-NOT e gate and c-NOT n gate (dashed boxes in Fig. 2). Assuming the electronic spin is initially in the 0 e j i state and the nuclear spin in an idle (unspecified) state α n j i, the effect of the two gates is 0 e j i α n j i À! cÀNOTe 0jα h i n 1 e j i 0 n j i+ 1jα h i n 0 e j i 1 n j i À! cÀNOTn 0jα h i n 1 e j i 0 n j i + 1jα h i n 0 e j i 0 n j i ¼ α ′ e 0 n j i, where 0 e j i α n j i etc. denote product states. Likewise, if the electronic spin is initially in the 1 e j i state, 1 e j i α n j i À! cÀNOTn cÀNOTe α ′ e 1 n j i. As a result, the state of the electronic spin is stored in the state of the nuclear spin. To retrieve the state, the order of the c-NOT gates simply needs to be reversed (Fig. 2). Alternatively, the state can also be retrieved by initializing the electronic spin followed by a single c-NOT e gate (dotted box in Fig. 2). Advantages of the single-gate retrieval are that it is fast (because no c-NOT n is involved) and that it can be repeated many times. 23,24,36 A disadvantage is a reduced contrast due to NV charge state conversion 37 (Supplementary Fig. S1). In the implementation of the quantum spectrum analyzer discussed below, we therefore use a two-gate retrieval during the signal correlation period t and a single-gate retrieval for improving readout efficiency.
We assess the performance of the nuclear spin memory under a set of store, retrieve, and hold operations. To characterize the efficiency of the store and retrieve operations, we perform selective Rabi rotations on all four spin-flip transitions, and find efficiencies >90% for c-NOT e and 60-80% for c-NOT n , respectively ( Supplementary Fig. S1). The memory access time is between 20 and 50 μs for the double c-NOT implementation, limited by the duration of the rf pulse, and~2 μs for the single c-NOT Fig. 1 Experimental arrangement. a Atomistic picture of the 15 NV − two-spin system, showing the NV center's electronic spin (red) and 15 N nuclear spin (blue). Distant 13 C nuclei, which produce measurable NMR signals, are also shown. Experiments are carried out on a single-crystal diamond chip with a shallow (3−10 nm) layer of NV centers created by ion implantation. b Energy level diagram in the electronic ground state showing four resolved spin-flip transitions. In a typical bias field of 320 mT, aligned with the NV symmetry axis, the electron spin transition frequencies are ω mw,1 = 6097 MHz and ω mw,2 = 6100 MHz, and the nuclear spin transition frequencies are ω rf,1 = 1.381 MHz and ω rf,2 = 1.669 MHz, respectively. The transitions used in our study are ω mw,1 (red) and ω rf,1 (blue). Control pulses are applied via a coplanar waveguide connected to two separate arbitrary waveform generators (see Methods section) Fig. 2 Implementation of the memory-assisted spectroscopy protocol for detecting alternating signals V(t). a Qubit gate diagram. The core of the protocol are two-phase gates R Φ1 Z and R Φ2 Z that are separated by a variable waiting time t, where Φ 1 ∝ V(t A ) and Φ 2 ∝ V(t C ). The long-lived memory qubit allows extending the waiting t, which greatly enhances the Fourier-limited resolution of the spectroscopy protocol. In addition, the memory qubit can be used to improve detection efficiency by a factor of~n through repeated readouts. b Pulse timing diagram. Laser pulses are shown in green, microwave pulses in red, radio frequency pulses in blue, and the photon detector gate in a black contour. The twophase measurements are implemented by XY8 sequences 52 with N = 8 or N = 32 pulses and τ ≈ 1/(2f ac ), where f ac is the expected signal frequency implementation. We further test the complete memory by performing an electronic Rabi oscillation, storing the result in the nuclear memory, clearing the electronic qubit by an initialization step, and retrieving the Rabi signal ( Supplementary  Fig. S2). Lastly, we assess the memory hold time-given by the nuclear T 1,n -in the absence and presence of laser illumination, with typical values of T 1,n ≈ 52 ms (no laser) and T 1,n ≈ 1.2 ms (under periodic readout) at a bias field of 320 mT. This bias field supports n~1000 non-destructive readouts of the memory (dotted box in Fig. 2) before the nuclear spin becomes repolarized 36 (Supplementary Fig. S3).

Implementation of the quantum spectrum analyzer
We compose the full spectroscopy protocol from a correlation sequence 19,22 and several storage and retrieval operations (Fig. 2). In a first step, we initialize the electronic sensor spin into the 0 e j i state. An initial phase measurement is then performed using a multipulse sensing sequence approximately tuned to the frequency f ac of the ac field (Fig. 2b). During the multipulse sequence, the ac signal VðtÞ ¼ V 0 cos 2πf ac t ð Þimprints a phase Φ 1 ∝ V(t A ) on the electronic qubit, leaving it in a superposition ψ e j i of states 0 e j i and 1 e j i with a probability amplitude 0jψ Next, we store ψ e j i in the nuclear memory, wait for a variable delay time t (which can be longer than the electronic T 1 time), and read it back. A second-phase measurement is then used to acquire a further phase Φ 2 ∝ V(t C ). In a last step, we read out the final state of the electronic qubit via storing it in the nuclear memory and performing n periodic readouts. By averaging the protocol over many repetitions, the probability p = |〈0|ψ〉 e | 2 of finding the sensor in the initial state 0 e j i can be precisely estimated.
Because Φ 1 and Φ 2 depend on the relative phase of the ac signal V(t), the total phase acquired by the qubit oscillates with f ac . As detailed in the Methods section, the resulting state probability p(t) then also oscillates with f ac , where we assume that the ac signal is not synchronized with the acquisition. Equation (2) is for small signals where sin (Fig. 2). In order to obtain a frequency spectrum of V(t), we can therefore simply measure p(t) for a series of t values followed by a Fourier transform. Crucially, the spectral resolution is only limited by the duration t of the correlation measurement, which can now be as long as the nuclear memory time T 1,n . Since the nuclear memory time typically far exceeds both the electronic decoherence time T 2 and relaxation time T 1 , a much finer spectral resolution can be expected compared to dynamical decoupling or standard correlation spectroscopy.
High-resolution spectroscopy of ac signals We demonstrate the performance of the memory-enhanced spectrometer for two experimental scenarios. In a first experiment, we expose the sensor to an external ac test signal with a nominal frequency of f ac = 6.626070 MHz and an amplitude of V 0 ≈ 90 μT. The test signal is produced on an auxiliary function generator not synchronized with the acquisition, and coupled into the same waveguide structure used for spin control. Two measurements are carried out: in a first acquisition (Fig. 3a) we perform a regular spectroscopy measurement without the nuclear memory. We can clearly observe an oscillation in the time trace due to the ac signal. The signal decays on a time scale of~0.5 ms, limited by the electronic T 1 of this NV center. In Fig. 3b we repeat the measurement, now making use of the nuclear memory. The oscillation persists beyond t = 45 ms, overcoming the limitation due to the electronic T 1 by almost two orders of magnitude.
Fourier spectra of the two time signals (Fig. 3c) show that the peak width reduces from 1.3 kHz (200 ppm) without memory to 20 Hz (3.0 ppm) with memory. This corresponds to an improvement in spectral resolution by~×65. Figure 3d shows a second example of nuclear memory-assisted spectroscopy, where two ac test signals separated by about 0.2 kHz are applied. Both peaks can be clearly distinguished, demonstrating that the method is effective in precisely resolving spectral features. A narrow line width of only 19 Hz (~2.9 ppm) is observed, and peak positions are defined with eight digits of precision. The absolute accuracy of the frequency measurement is governed by the internal clock of the MW pulse generator. The spectral resolution in Fig. 3c, d is limited by the memory hold time given by the nuclear T 1,n , here~52 ms. Since the nuclear relaxation is dominated by a flip-flop process with the NV center's electron spin and slows down for higher bias fields, 36 there is scope for an additional improvement in spectral resolution at Tesla bias fields. 38 High-resolution 13 C NMR spectroscopy We further apply the two-qubit sensor to detect NMR spectra from nearby 13 C nuclear spins that are naturally present at~1% in the diamond chip. This experiment represents an important test case toward the detection of more complex NMR spectra, such as those from molecules deposited on the chip. 17,39,40 The detection of NMR signals is considerably more involved compared to external ac signals, because the sensor can affect the 13 C nuclear spin precession during t via the hyperfine interaction. In addition, NMR spectroscopy is known to be very sensitive to drifts in the external bias field. Figure 4 shows a set of four NMR spectra recorded from the same 13 C nuclear spin using the memory-assisted spectroscopy protocol. The four panels represent increasing refinements in spectrum acquisition. Figure 4a shows an initial 13 C spectrum that displays features over a wide frequency range of several kHz (~1000 ppm). We find these features to be linked to small changes in the bias field, probably caused by temperature-induced drifts in the magnetization of the permanent magnet in our set up. By carefully tracking the electron spin resonance during the experiment and using post-correction, these drifts can be eliminated (Fig. 4b). Further details are given in the Methods section and Supplementary Fig. S5.
The remaining line width of the 13 C resonance is~220 Hz, which corresponds to a dephasing time of T Ã 2; 13 C % 1= π 220 Hz ð Þ%1:4 ms. Because the dephasing time is very similar to the relaxation time T 1~1 .4 ms of this NV center, the 13 C dephasing is most likely dominated by the hyperfine interaction with the electronic spin. Thus, even if our spectrometer is technically capable of achieving a ×10 better spectral resolution, this improvement does not carry over to the 13 C spectrum because of dephasing.
In an attempt to extend the 13 C dephasing time and further reduce the 13 C NMR line width, we have explored several decoupling protocols, neither of which turned out to be effective. A first protocol (Fig. 4b) includes a series of π pulses that are applied to the m S = 0 ↔ −1 transition during the free evolution time t. This protocol suppresses the hyperfine interaction with the electronic m S = −1 state. However, this protocol does not decouple the interaction with the m S = +1 state, and only a marginal improvement can be expected. Indeed, no significant change is observed in the 13 C line width without and with dynamical decoupling even when using many hundred decoupling pulses (Fig. 4c). A more effective approach would be to simultaneously decouple both the m S = 0 ↔ −1 and m S = 0 ↔ +1 transitions using double-frequency irradiation, 41 but this control is not currently supported by our hardware. Instead, we use a series of laser pulses to periodically repolarize the NV center into the m S = 0 state (Fig. 4d) or the m S = −1 state (data not shown). No narrowing of the 13 C resonance is observed with either protocol. There are two possible explanations for the observations made in Fig. 4b-d: Either the decoupling is ineffective due to the relatively strong hyperfine coupling, and the T Ã 2; 13 C dephasing is still dominated by the hyperfine interaction. This hypothesis is supported by a numerical simulation (Supplementary Fig. S6). Alternatively, the measured T Ã 2; 13 C dephasing time represents the intrinsic 13 C decoherence time due to nuclear dipole-dipole interactions within the 13 C bath. This scenario is less likely because the expected decoherence time is of order~10 ms ( Supplementary  Fig. S7).

DISCUSSION
In summary, we implemented a two-qubit quantum sensor based on the electronic and 15 N nuclear spins in diamond. By operating the nuclear spin as a long-lived memory qubit, we achieve exceptionally high-spectral resolution, with a best effort of 19 Hz or 2.9 ppm. The 15 N spin forms a particularly suitable memory qubit because the nucleus is a natural part of the NV center, and because long storage times are possible combined with rapid memory access. Looking forward, we note that the implemented spectroscopy protocol entails several interesting opportunities for further refinements, especially toward application in nanoscale NMR and for realizing larger quantum registers. Active manipulation of both nuclei during the waiting time could, for example, be used to individually address a large number of weakly coupled 13 C spins. 42 Advanced NMR concepts, such as multi-dimensional spectroscopy 22,43 or spectral editing could be used to study interactions between nuclei. 44 These concepts will likely require compressed sensing methods 11,45 and efficient NV readout 23,46 to accelerate data collection. Implementation of these techniques will be the key for performing structural analysis of single molecules, especially if larger biomolecules are to be targeted.

Note added
Recently, we became aware of related work describing quantum sensing with a nuclear memory qubit. 35,38,42,47 The work of refs. 35, 47 use the nuclear memory in a coherent state. This approach has the advantage of conserving the full phase information, but is limited by the T 2,n time (rather than the T 1,n ) of a 15 N nuclear memory and requires NMR pulses on the target 13 C nuclei. By contrast, our approach is limited by T 1,n and does not require 13 C NMR pulses. The work of ref. 38 describes both T 2,n and T 1,n storage but also requires NMR pulses. The works of ref. 42   ref. 19 describe a nuclear memory that is similar to our implementation, but use different schemes for the state SWAP and target 13 C manipulation during coherent evolution, and no memory-assisted electron spin readout.

Diamond chips
Two different single-crystal diamond chips were used in the study. Sample A was an electronic-grade, natural abundance (1.1% 13 C) plate with a shallow NV layer created by 5 keV 15 N + ion implantation and an 800°C annealing step. The average NV center depth was 8 nm according to SRIM simulations. Sample B was an electronic-grade, isotopically pure (<0.01% 13 C) plate with a similar NV layer as sample A. Except for providing proximal 13 C nuclei for the NMR experiments, the higher 13 C concentration of sample A compared to sample B played no role in any of the measurements. In particular, the 13 C concentration had no influence on the electronic and 14 N spin relaxation times relevant for our study. To further reduce the NV-center-to-surface distance, sample B was subjected to an oxygen etch at~550°C (ref. 17). The average NV center depth was 3−5 nm. Both samples were baked at 465°C in air before experiments to clean the surface.

Measurement apparatus
The measurement apparatus consists of a home-built confocal microscope with 532 nm laser excitation and 630-800 nm fluorescence detection using a single photon counter module. The confocal microscope is equipped with a patterned, 50−100 μm-wide coplanar waveguide transmission line for producing MW and radio frequency magnetic control pulses at the sample location. Timing of experiments is controlled by the digital marker channels of a Tektronix AWG 5002 arbitrary waveform generator. Photons are analyzed by time tagging arrival times and correlating them with the timing of the pulse sequence. In addition, the microscope is equipped with a permanent NdFeB magnet to produce bias fields of up to~400 mT. The direction of the vector magnetic field is aligned via a mechanical xyz stage.
To control the electronic and nuclear spin transitions of the NV center, separate MW and radio frequency channels are used, respectively. MW pulses are generated on the arbitrary waveform generator at a 100 MHz carrier and upconverted to the desired GHz frequency using a local oscillator (Quicksyn FSW-0020) and a single-sideband mixer (Marki MW IQ-1545). For the radio frequency pulses, a National Instruments NI PCI 5421 arbitrary waveform generator is used, which directly synthesizes the desired pulses without a mixing step. The two signals are amplified separately and then combined using a bias-T (Meca) before being connected to the MW transmission line. The output of the transmission line is terminated in a 50 Ω load. With this arrangement, typical Rabi frequencies of 20−30 MHz for the electron spin and 10−30 kHz for the 15 N nuclear spin could be achieved. We observed that the Rabi frequency of the 15 N nuclear spin was significantly enhanced by the hyperfine interaction. 48 Store and retrieve operations Storage and retrieval operations are implemented by selective pulses on one of the two resolved hyperfine lines. Square-shaped pulses are used for both electronic and nuclear spin manipulations. Selective MW pulses have a typical duration of 700 ns corresponding to a Rabi frequency of~0.7 MHz. Selective rf pulses have a duration between 20 and 50 μs depending on the set up and NV center. A delay of 1−2 μs is added after every radio frequency pulse due to amplifier ringing. Rabi oscillations used to calibrate the selective pulses are provided in Supplementary Fig. S1.

Correlation spectroscopy
Correlation spectroscopy [18][19][20][21][22] correlates the outcomes of two subsequent sensing periods to obtain high-resolution spectra of time-dependent signals. In the present experiment, the method is implemented by subdividing a multipulse sequence into two equal periods of duration t meas = t B − t A = t D − t C that are separated by an incremented free evolution period t (Fig. 2). Since the multipulse sequence is phase sensitive, constructive or destructive phase build-up occurs between the two sequences depending on whether the free evolution period t is a half multiple or full multiple of the ac signal period T ac = 1/f ac . The final transition probability p oscillates with t as where Φ 1 and Φ 2 are the phases accumulated by the electronic spin during the first and second measurement period, respectively. The approximation is for weak signals where sin Φ 1 ð Þ % Φ 1 and sin Φ 2 ð Þ % Φ 2 . For strong signals, higher harmonics appear in the correlation spectrum and the amplitude of the correlation signal does not directly reflect the amplitude of the ac signal any longer. 49 For an ac signal VðtÞ ¼ V 0 cos 2πf ac t þ ϕ ð Þwhose period T ac = 2τ is commensurate with the pulse spacing τ of the multipulse sequence, the phase Φ 1 is given by where y(t′) = (−1) [t′/τ] is the modulation function 50, 51 of the sequence and N = t meas /τ is the number of pulses. This integral evaluates to Likewise, the phase Φ 2 evaluates to In our experiments, the ac signal is not synchronized with the detection sequence, such that the phase ϕ is arbitrary. Therefore, the observed correlation signal p(t) is an average over ϕ = 0...2π. For the small signal approximation this leads to where we have set t A = 0 in the third step and used that cos 2πf ac t C ð Þ¼ cos 2πf ac t A þ t meas þ t ½ ð Þ ¼ cos 2πf ac t ð Þ . Here, p 0 ¼ 2γ 2 e V 2 0 t 2 meas =π 2 is the amplitude of the correlation signal.
Tracking and post-correction of spectral drift When performing NMR experiments, we noticed considerable drifts, often several kHz, in the 13 C nuclear transition frequency. Such frequency drifts are a well-known problem in high-resolution NMR spectroscopy, as they lead to unwanted line broadening. Frequency drifts are typically caused by drifts in the static magnetic field; in our case, this is likely due to a temperature-related change of the magnetization of the permanent magnet.
We have implemented a tracking and post-correction scheme to eliminate the frequency drifts. To follow the drift in magnetic field, we track the electron paramagnetic resonance (EPR) resonance of the NV center during long-term measurements as shown in Supplementary  Fig. S2. The difference between measured EPR frequency ω e and reference EPR frequency ω e,0 corresponds to a drift in field by ΔB = (ω e − ω e,0 )/γ e where γ e = 2π × 28 GHz/T is the electron gyromagnetic ratio. Measured data sets p(t) are separately saved in intervals of 5−20 min with a specific ΔB tag for each data set.
To correct for frequency drift, we multiply each data set p(t) by e −iΔωt , where Δω = γ n ΔB is the expected shift in the 13 C nuclear resonance due to A quantum spectrum analyser T Rosskopf et al.
the drift in magnetic field. γ n = 2π × 10.7 MHz/T is the 13 C gyromagnetic ratio and T is the maximum t time. The corrected data sets p(t) are then Fourier transformed and averaged. Alternatively, the averaged NMR spectrum can also be obtained by performing a Fourier transform of the uncorrected p(t) and shifting the frequency scale for each spectrum before averaging.

Data availability
The data sets generated during and/or analyzed during the current study are available from the corresponding author on reasonable request.