Introduction

The ultimate goal of quantum information processing is to design a quantum processor that is capable of performing any given task. As with its classical counterpart, the versatility of quantum processors come from reprogramming the quantum logic gates to solve the given problem. Arbitrary operations on a multi-qubit system can be broken down into sequences of quantum gates.1,2,3 Reconfiguring these gate sequences provides the flexibility to implement a variety of algorithms without altering the hardware. A programmable quantum processor is more versatile than one designed for a fixed task. Programmable quantum processors based on a few qubits have been demonstrated using trapped ions,4,5 superconducting qubits6 and quantum-dot-based qubits,7 but the experimental realization of a solid-state programable quantum processor at room temperature remains elusive. Here, we demonstrate that with the electron spin and 14N nuclear spin of nitrogen-vacancy (NV) center in diamond one can combine initialization, readout, single- and two-qubit gates to form a programmable quantum processor that can perform quantum algorithms. NV centers in diamond have emerged as one of the promising candidates for implementing quantum technologies because they exhibit long coherence time and universal quantum gates with fault-tolerant control fidelity.8 Several algorithms have been demonstrated based on NV center. The quantum circuits employed in these studies are designed for the specific task.9,10 The programmable quantum processor is capable of realizing the target two-qubit unitary operation with a universal quantum circuit. In our work, arbitrary two-qubit unitary operation determined by external fields can be programmed and reconfigured with fifteen parameters.11

Results

As depicted in Fig. 1a, the NV center consists of a substitutional nitrogen atom with an adjacent vacancy site in the diamond crystal lattice. The ground state of NV center is an electron spin triplet state with three sublevels |mS = 0〉 and |mS = ±1〉. A static magnetic field is applied along the NV symmetry axis ([1 1 1] crystal axis) to remove the degeneracy between the |mS = +1〉 and |mS = −1〉 states, yielding the electron and nuclear Zeeman splitting. The Hamiltonian of the electron spin and the 14N nuclear spin system is

$$H_{{\mathrm{NV}}} = 2\pi \left( {DS_z^2 + \omega _eS_z + QI_z^2 + \omega _nI_z + A_{zz}S_zI_z} \right),$$
(1)

where Sz and Iz are the spin operators of the electron spin (spin-1) and the nuclear spin (spin-1). The electronic zero-field splitting is D = 2.87 GHz and the nuclear quadrupolar interaction is Q = −4.95 MHz. The two spins are coupled by a hyperfine interaction Azz = −2.16 MHz. The two-qubit quantum system is composed of |mS = 0, mI = +1〉, |mS = 0, mI = 0〉, |mS = −1, mI = +1〉, and |mS = −1, mI = 0〉 without considering the other spin levels. The four energy levels are denoted by |1〉, |2〉, |3〉 and |4〉 as shown in Fig. 1a. At the magnetic field strength of 500 G, the spin state of the NV center is effectively polarized to |mS = 0, mI = +1〉 when a 532 nm laser pulse is applied.12

Fig. 1
figure 1

Two-qubit programmable quantum processor in NV center. a Schematic atomic structure and energy levels of the NV center. The experiments are implemented on the two-qubit system composed of four energy levels within the dashed box (i.e., |mS = 0, mI = +1〉, |mS = 0, mI = 0〉, |mS = –1, mI = +1〉, and |mS = −1, mI = 0〉 denoted by |1〉, |2〉, |3〉 and |4〉). b Circuit diagrams for arbitrary unitary transformations. The brackets highlight the decomposition of arbitrary two-qubit operation into (CD) · V · (AB). R(θ, φ) corresponds to a rotation angle θ around the axis in the XY plane. φ denotes the angle between the axis and the X axis. Rz(φz) represents a rotation angle φz around the Z axis. The entangling two-qubit gate Uzz is exp(iπSzIz). c Realization of the single-qubit gates. The single-qubit rotations on the electron spin are realized by hard microwave pulses with fixed Rabi frequency of Ω1MW = 40 MHz. The duration of the pulses corresponds to the rotation angle θ. The single-qubit rotations on the nuclear spin are realized by decoherence-protected gates consisting of dynamical decoupling of the electron spin and nuclear spin driving during the time interval. The strength of the nuclear spin driving is determined by the rotation angle. The time τ corresponds to the interaction between electron spin and nuclear spin

Arbitrary single-qubit gates combined with applications of a maximally entangling two-qubit gate are sufficient for realization of universal two-qubit unitary operation. Our choice of a universal gate library consists of single-qubit gates and an entangling two-qubit gate, Uzz = exp(iπSzIz), which can be realized by the free evolution under the hyperfine coupling between electron spin and nuclear spin. We decompose a given two-qubit unitary operation U into U = (CD) · V · (AB) as shown in Fig. 1b, where V is a two-qubit gate and A, B, C, D are single-qubit gates. The decomposition follows a three-step procedure analogous to that in ref. 4. First, the matrix eigenvalues of V and U are matched to find the three parameters α, β and δ shown in the dashed rectangle in Fig. 1b. Second, the four remaining single-qubit gates, A, B, C and D, are found by mapping the eigenvectors of V and U to satisfied the equation U = (CD) · V · (AB). Finally, the single-qubit gates are parameterized by the decomposition Rz(φz,j) · R(θj, φj) for j = [A, B, C, D]. R(θj, φj) = exp[−j(cosφjSx + sinφjSy)], corresponds to a rotation of angle θ around the axis in the XY plane. φ denotes the angle between the axis of rotation and the X axis. Rz(φz,j) represents a rotation of angle φz,j around the Z axis. After the procedure discussed above, arbitrary two-qubit unitary transformations can be realized using the universal quantum circuit with fifteen parameters, which are α, β, δ, θA, φA, φz,A, θB, φB, φz,B, θC, φC, φz,C, θD, φD, and φz,D.

For the quantum processor, the two-qubit entangling gate, Uzz, is realized by the free evolution under the hyperfine coupling Hhf = 2πAzzSzIz. So the time duration of Uzz is 231.5 ns. The single-qubit rotations on the electron spin are realized by microwave (MW) pulses with fixed Rabi frequency of Ω1MW = 40 MHz. The pulses flip the electron spin practically independent of the nuclear spin state for the large Rabi frequency comparing to the hyperfine coupling Azz. The length of the MW pulse t is determined by the rotation angle θ as shown in the upper panel in Fig. 1c. Since the states of the electron and nuclear spin evolve and decohere at very different rates, decoherence-protected gates are implemented to realize the single nuclear spin rotation10 as shown in the lower panel in Fig. 1c. The XY-4 sequence is applied on the electron spin to protect the electron’s coherence. The states of nuclear spin is driven during the time between the decoupling pulses. A rotation of the nuclear spin, which is independent of the electron spin state, is constructed by choosing τ = 2/Azz with integer n. Here we fixed τ = 2777.8 ns with n = 6 and the strength of the radio-frequency (RF) pulses is set as Ω1RF = θ/4τ. The rotation around the Z axis Rz(φz) is realized by adding a phase to the drive field for all subsequent gates.

To exhibit the flexibility of the processor to generate unitary transformations, we first implement the Deutsch–Jozsa algorithm13 as an example. It has been employed in different systems to demonstrate the exponential speedup in distinguishing constant from balanced functions with respect to the corresponding classical algorithm.9,14,15,16,17,18,19 A function that has an n-bit input and a 1-bit output (f:0, 1, 2, …, 2n − 1 → 0, 1) is balanced when exactly half of the inputs result in the output 0 and the other half in the output 1, while a constant function assumes a single value irrespective of the input. The constant function (f(0) = f(1) = 0) and the balanced function (f(0) = 0, f(1) = 1) are mapped onto the unitary operators Ui with U1 = I and U2 = CNOT as shown in the quantum circuit in Fig. 2a, where the I denotes the identity and the CNOT is the controlled-NOT gate. A measurement of the populations, P = {P1P2P3P4}, of the final state determines if the function is constant or balanced. The populations, P, of the final state are determined by performing a set of measurements with different pulse sequences to redistribute the population of the final state. Comparing to the direct measurement of the final state, πe and πn pulses on the electron and nuclear spin respectively are also applied on the final state to flip the populations within the two-qubit system. The population of each energy level can be achieved from the resulting photoluminescence of these states. The entire quantum circuit combined with the flipping pulses can be treated as a unitary operator. This unitary operator is decomposed into the universal quantum circuit as shown in Fig. 1b following the three steps discussed above. The corresponding 15 parameters are shown in Table 1. Different unitary operators are implemented using the universal quantum circuit with different sets of parameters. Measurement of output P = {1000} indicates a constant function, while P = {0010} indicates a balanced function. In Fig. 2b, c, we show the measured population of each spin level of the final state after the Deutsch-Josza algorithm. The red bars indicate the ideal result, while the green bar is the simulation result considering the decoherence of the electron spin and the imperfect polarization (see Supplementary Information Section 2). The experimental results (blue bars) are in good agreement with the simulated results. The average success probability is 0.88(2) for constant and 0.93(2) for balanced functions.

Fig. 2
figure 2

Experimental demonstration of Deutsch-Josza algorithm. a Quantum circuit of Deutsch–Josza algorithm. Y \(\left( {\overline {\mathrm{Y}} } \right)\) indicates the π/2 (−π/2) rotation around the Y axis. The constant function and the balanced function are mapped onto the unitary operators U1 = I and U2 = CNOT, respectively. b, c The experimental results of Deutsch–Josza algorithm with constant and balanced functions, respectively. P1, P2, P3 and P4 denote the population of |1〉, |2〉, |3〉 and |4〉, respectively. The red bars are the ideal case. The green bars are the simulation results considering the imperfect polarization and the decoherence. The blue bars are the experimental results

Table 1 The parameters of the two-qubit programmable processor for Deutsch–Josza algorithm

Now we show that another quantum algorithm, named Grover search algorithm, can be executed by our programable quantum processor by just adjusting the 15 parameters. The Grovers search algorithm20 provides an optimal method for finding the unique input value x0 of a function f(x) that gives f(x0) = 1 and f(x) = 0 for all other values of x. It has been demonstrated in various systems.21,22,23,24 In the two-qubit version of this algorithm there are four input values, x (00, 01, 10, 11), resulting in four possible functions fij(x), with i, j (0, 1). These functions are mapped onto the C-Phase gate cUij that encodes fij(x) in a quantum phase, \(cU_{ij}\left| x \right\rangle = ( - 1)^{f_{ij}(x)}\left| x \right\rangle\). The C-Phase gate cUij is denoted by the oracle Ui as shown in the quantum circuit in Fig. 3a. The quantum circuits to realize the C-Phase gate cUij are designed specifically to the four cases in the conventional implementation of the two-qubit version of Grover search algorithm. In our work, the algorithm is demonstrated by the universal quantum circuit. The unitary operator of the four possible quantum circuit is programmed into the four sets of parameters as shown in Table 2. A measurement of the populations, P = {P1P2P3P4}, of the final state finds the state that has been marked. In Fig. 3b–e, we show the measured the population of each spin level of the final state after the Grover search algorithm of four possible oracle functions. The experimental results (blue bars) are in good agreement with the simulated results (green bars). The average success probability is 0.85(1), 0.82(2), 0.81(2), and 0.84(2) for four possible functions, respectively.

Fig. 3
figure 3

Experimental demonstration of Grover search algorithm. a Quantum circuit of Grover search algorithm. Four possible function fij(x) are mapped onto the oracle Ui which is the C-Phase gate cUij. be The results of Grover search algorithm characterized by the population of each spin level of the final state. P1, P2, P3, and P4 denoted the population of |1〉, |2〉, |3〉, and |4〉, respectively. The red bars are the ideal case. The green bars are the simulated case considering the imperfect polarization and the decoherence. The blue bars are the experimental results

Table 2 The parameters of the two-qubit programmable processor for Grover search algorithm

Discussion

The algorithms presented here illustrate the computational flexibility provided by the solid-state spin-based quantum architecture at room temperature. The programmable quantum processor is capable of implementing arbitrary unitary operation on two qubits using the universal quantum circuit with altering the parameters. Substantial improvements could be made in the performance of the processor by using isotopically purified 12C, which would increase the coherence times of the qubits.25 Furthermore, dipolar coupling of electronic spins could mediate interactions between nuclear spins associated with different NV centers,26 offering a potentially scalable platform for information processing.27 Optical channels provide an alternate platform that is well suited to mediating interactions over macroscopic distances or in highly connected networks.28,29 With these improvements quantum computers with multiple qubits and fidelities above the fault-tolerance threshold should be realizable.

Methods

Experiment setup

Our experiment was performed on a [100] oriented NV center in bulk diamond with low concentration of nitrogen impurity (<5 ppb) and natural abundance of 13C isotope (1.1%). The sample was mounted on a home-built confocal setup (see Supplementary Information Section 1 for the schematic of the setup). Optical excitation was provided by a 532 nm green laser, which was gated by an acousto-optic modulator. The laser beam was double passed through the acousto-optic modulator to suppress the laser leakage. And then the laser was delivered through an oil objective. The red fluorescence from the NV center was collected by an avalanche photodiode. A solid immersion lens was utilized to enhance the photon detection efficiency. The magnetic field was aligned along the NV symmetry axis ([1 1 1] crystal axis) by a permanent magnet. At the static magnetic field of 500 G, the state of the two-qubit solid-state quantum processor can be effectively polarized to |mS = 0, mI = +1〉 with 532 nm laser pumping. After the optical pumping, 95% of the population occupied the |mS = 0〉 state of the electron spin and 98% of the population occupied the |mI = +1〉 state of the nuclear spin. The microwave and radio-frequency pulses were created by an arbitrary waveform generator. Power amplifiers were utilized to amplify the pulses. A broadband coplanar waveguide with 15 GHz bandwidth was installed for the microwave pulses on the NV center. The radio-frequency pulses were carried by a home-built coil.

Code availability

The codes that were used in this study are available from the corresponding author upon reasonable request.