1 Introduction

SpinQ Gemini is a commercial desktop quantum computing platform designed and manufactured by SpinQ Technology [1, 2], and the first generation product with two qubits was launched in January 2020. It is an integrated hardware-software system as shown in Fig. 1: the left figure shows the exterior look of the device, with a dimension of \(70\times 40 \times 80\text{ cm}^{3}\), and a weight of 55 kg; the right figure shows the user interface software SpinQuasar.

Figure 1
figure 1

(a) The photo of Gemini and (b) the homepage of SpinQuasar [1]. The Gemini connects with a personal computer (PC) installed with SpinQuasar. SpinQuasar provides an interface for the users to manipulate the desktop platform

The hardware part of Gemini is based on nuclear magnetic resonance (NMR) spectrometer. NMR was among the very first systems developed for quantum computing [39]. Despite its limitations on scalability, a lot of pioneer research and techniques for quantum computing were first demonstrated in NMR systems [1022]. Notably, many quantum control techniques developed in NMR can be readily applied to other quantum computing platforms [9, 2331].

Traditional NMR quantum computing is performed on commercial spectrometers with a superconducting magnet. Those spectrometers are expensive (almost 1 million USD), large (can be as high as ∼3 meters), and need to work in specially designed labs. They also require regular liquid nitrogen and helium refills for maintenance. These issues on cost, weight, volume and extreme physical conditions also in general exist on other systems for quantum computing, making them hard to be accessible for users in real life, but instead with only possible access on cloud, such as IBM Q [32], IonQ [33] and Rigetti.Footnote 1 As an example, superconducting qubits need to work in dilution fridges which usually cost almost 1 million USD. Similar to the superconducting NMR systems, they require special lab conditions and are not portable. Furthermore, special training is needed for operations of dilution fridges [3440].

With the development of permanent magnet technology in recent years [41], it is possible to bring down the size and cost of NMR spectrometers [4246]. This then makes the NMR technology an ideal choice for building portable quantum platforms. By using a permanent magnet providing 1 T magnetic fields, SpinQ Gemini highlights its lightweight (55 kg with a volume of \(70 \times 40\times 80\text{ cm}^{3}\)) and cost-effective (under 50k USD) features, and maintenance-free, making it portable almost like a desktop PC.

Customised quantum algorithm circuit design and programming are supported on SpinQ Gemini using its software SpinQuasar (Fig. 1). SpinQ Gemini also provides demonstrations of >10 famous quantum algorithms, such as Deutsch algorithm [47], Grover algorithm [48, 49], and HHL algorithm [50]. It also has build-in teaching examples for quantum mechanic, such as Rabi oscillation observation and decoherence time measurement. Gemini not only provides a very friendly platform for non-specialists who aim to learn quantum computing basics and quantum programming fast, but also serves as a powerful tool for quantum computing related research.

In this paper, we introduce the system of the first generation SpinQ Gemini. In Sec. 2, we discuss the system design, from hardware to software. In Sec. 3, we discuss how to perform quantum computing with SpinQ Gemini. We give two concrete examples of quantum computing tasks performed on SpinQ Gemini, one on the measurement of geometric phase of mixed state in Sec. 4, and the other on a variational quantum eigensolver for a two-qubit Heisenberg model in Sec. 5. A discussion on future plans of next generations products will follow in Sec. 6.

We believe that low-cost portable quantum computing products will facilitate hands-on experience for teaching quantum computing at all levels, well-prepare younger generations for the future of quantum technologies. It will also be accessible to a wider range of researchers to operate under real world conditions for quantum computers, benefiting them for further studies on quantum control and quantum noise.

2 System

The overall schematic diagram is shown in Fig. 2. Gemini is composed of a PC with SpinQuasar, a control system on the master board, a radio frequency (RF) system, a temperature control module, a pair of permanent magnets, a field shimming system, and a tube of sample.

Figure 2
figure 2

The overview of the schematic diagram of Gemini system and the interface SpinQuasar. The master board equipped with an FPGA, provides the control logic of Gemini. SpinQuasar communicates with FPGA through USB so that the user can access Gemini. The magnets, together with the temperature control unit and the field shimming system provide a stable static homogeneous magnetic field. The RF module provides the function required to control and measure the qubits

The PC with SpinQuasar and the master board together realize the algorithms and interfaces to all the functions. The magnets provide stable static magnetic field. The field shimming system and temperature control system together make the field stable and homogeneous enough for nuclear magnetic resonance as well as quantum computing. The RF system provides generation, modulation, amplification, transmission, detection and reception of the RF pulses and signals so that we can control and measure the quantum system.

The PC with SpinQuasar and the master board altogether realize the software part. The modules are shown in Fig. 3. The software SpinQuasar provides an interface for a user to communicate with Gemini. The master board, of which the core device is an FPGA, realizes all the algorithms to control the pulses (hence control the quantum state), the temperature and shimming of the field (hence generate a stable homogeneous field). SpinQuasar and the master board communicate with each other through USB.

Figure 3
figure 3

Software structure. The software could be divided into two parts: one (the left block) we called SpinQuasar provides an interface for users with access to all the functions of Gemini, the other (the right block) realizes the algorithms and controls required for Gemini to function properly. These two parts communicate with each other through USB

2.1 SpinQuasar

The left half of Fig. 3 shows the structure of SpinQuasar. It is composed of five modules: the quantum computing module, the NMR spectroscopy module, the instrument calibration module, the task management module and the dynamic library module. These modules can be easily accessed from the homepage of SpinQuasar, as shown in Fig. 1(b).

The quantum computing module provides an interface of a two-qubit quantum computer and will be discussed later in Sec. 3.

The NMR spectroscopy module provides an interface of direct accessing to the 1H and 31P nuclear magnetic resonance signal of our sample. It provides the direct control of the pulse parameters on the two nuclei. Also, it provides both the free induction decay (FID) signals and the spectra after fast Fourier transform (FFT). This interface provides a good demonstration of a modern FFT based NMR spectrometer.

The instrument calibration module provides an interface for users to calibrate the parameters of the spectrometer, such as field shimming, phase calibration, and the temperature control for the system.

Gemini also supports cloud quantum computing where one can access to it from the Internet [51]. For cloud quantum computing, the tasks are managed by the task management module. Also, to support more complicated control, such as the variational quantum eigensolver (VQE) which requires adjusting the parameters of the pulses, we provide the APIs for programmable control, and embedded these into the dynamic library.

2.2 Master board

The master board integrates the digital parts of the hardware, including an FPGA, an analog-digital converter (ADC) and a digital-analog converter (DAC). The digital parts, as shown in the right block of Fig. 3, altogether realize the algorithms required to generate the RF pulse, measure the readout signal, control the temperature and shimming. These algorithms will be described further in the introduction of each module. The ADC converts the readout signal from the RF part as measurement, while the DAC generates the initial RF signal for state manipulation.

2.3 Magnets

The permanent magnets provide a stable static homogeneous magnetic field, which split the nuclei with spin-half into two energy levels and therefore the spin becomes a qubit. The permanent magnets are two NdFeB plates. The field generated is ∼1 Tesla. The field near the center of the two magnets is roughly homogeneous: the homogeneity generated by such magnets can reach a level of ∼20 ppm. Compared with modern commercial NMR spectrometers, of which the magnet is generated by the superconducting coil that requires a large cryogenic storage dewar and regular refilling of liquid helium and nitrogen, the magnets of Gemini work under room temperature, hence are maintenance free and portable. The disadvantages are that the magnitude of the magnetic field could only reach about 2 T, and it is highly sensitive to the temperature of the magnets themselves.

2.4 Sample

The sample we use is Dimethylphosphite ((CH3O)2PH). The 31P and 1H atom are connected directly and provide a two-qubit quantum processor. Both 31P and 1H nuclei have a \(1/2\)-spin, and therefore have two energy levels. The Lamor frequency of 31P and 1H in 1 T magnetic field are 17.2 MHz and 42.6 MHz, respectively. The structure and the parameters of the sample are listed in Fig. 4.

Figure 4
figure 4

(a) The molecule structure (left) and its parameter table (right). There are multiple 1H nuclear spins. Only the 1H spin that is directly corrected to the 31P spin is used as a qubit. The J coupling between the 1H and 31P nuclear spins is 697.4 Hz. The control pulses are on resonance with 1H and 31P spins and thus their frequency offsets are both 0 Hz. The spin Hamiltonian is \(H_{0}=\pi J \sigma _{z}^{H}\sigma _{z}^{P}/2\), where \(J=697.4\text{ Hz}\). (b) The Fourier transform spectrum of the 1H spin which is directly connected to 31P, obtained using Gemini. The small spikes between the two major peaks are due to non-idea removal of the signals of the 1H spins in the methyl groups. The inset shows the thermal spectrum of all the 1H spins. The peaks (labeled as ‘P’) of methyl 1H spins are fitted using Lorentzian line shapes and removed on purpose in signal processing to get a clear signal of the 1H of interest. (c) The Fourier transform spectrum of the 31P spin obtained using Gemini

2.5 RF pulse generation

The states of the nuclei could be manipulated by irradiating electro-magnetic waves (pulses) with frequencies close to there Larmor frequency (the physics behind this will be described later). Since the Larmor frequencies of the two nuclei lie in the range of RF range, an RF system is designed and manufactured to operate the quantum state and realize the quantum gates. The largest RF power that can be applied is ∼2 W, and the linear range of the power amplifier is 0∼1 W. Pulses as short as 10 us and 20 us can be applied to realize 90 degree rotations of the 1H and 31P spins. While the default built-in sample in Gemini is Dimethylphosphite and the band-pass filters are optimized for 1H and 31P signals, the RF transmission and NMR reception parts as shown in Fig. 5 can work in the frequency range of 0∼100 MHz. This means it is possible to use this RF system to perform NMR spectroscopy on other nuclear species whose frequencies fall in this range after adjusting the band-pass filters.

Figure 5
figure 5

RF pulse generation and signal readout. The upper half shows how an arbitrary wave is generated. After the wave is generated, it is power amplified and sent to the control coil (see Fig. 2) so that the quantum state can be manipulated. After the RF pulse irradiation, the electro-magnetic signal induced during spin relaxation is picked up by the coil, and then is sent to the preamplifier. After the signal is amplified, it is sent to the ADC and processed by the master board

2.6 Temperature control

The field generated by the permanent magnets is highly sensitive to the temperature of the permanent magnets themselves. Therefore, a temperature control system is required to guarantee that the field does not drift following the room temperature. The architechture of the temprature control unit is shown in Fig. 6.

Figure 6
figure 6

Temperature control. The temperature control is realized by a famous feedback algorithm: the PID algorithm. The temperature probe picks the temperature signal and send it to the FPGA. The FPGA decides what to do next according to the temperature signal and then controls the power of the heating module accordingly

2.7 Field shimming

The homogeneity of the static magnetic field generated by the permanent magnets is ∼20 ppm, which is too large. To compensate this inhomogeneity, we designed a field shimming system to reduce the homogeneity to less than ∼1 ppm. The best homogeneity could reach ∼0.3 ppm. As a comparison, the homogeneity of a commercial NMR spectrometer with a superconducting magnet is ∼0.01 ppm. The struture of the shimming unit is shown in Fig. 7.

Figure 7
figure 7

Shimming module. Currently, the field shimming is accomplished by measuring the FWHM of the hydrogen signal. It is also a feedback algorithm by reading the FWHM information of the hydrogen signal and adjusting the current of the shimming coils

3 Quantum computation

3.1 The spin system

Gemini contains two qubits which are the two connected 31P and 1H nuclear spins in Dimethylphosphite ((CH4O)2PH) molecules (Fig. 4). The molecules are placed in the center of the parallel permanent magnets. The 31P and 1H Larmor frequencies are 17.2 MHz and 42.6 MHz, respectively. The 31P spin has a T1 and T2 of 7.2 s and 0.5 s, respectively. The 1H spin has a T1 and T2 of 4 s and 0.3 s, respectively. The J coupling between the two spins is 697.4 Hz. The control pulses are on resonance with 1H and 31P spins and thus their frequency offsets are both 0 Hz. The spin Hamiltonian in the rotating frame is

$$\begin{aligned} H_{0}=2\pi J I_{z}^{H}I_{z}^{P}= \frac{\pi }{2} J \sigma _{z}^{H} \sigma _{z}^{P}, \end{aligned}$$

where \(J=697.4\text{ Hz}\).

3.2 The gate set

Single-qubit 90 degree rotation gates can be realized using square pulses of 20 us and 10 us for 31P and 1H, respectively. The hardware-level pulse design and engineering are available in later versions of Gemini which provide an arbitrary waveform generation function to users. In the current paper, all quantum gates are realized using square pulses which are resonant with 1H or 31P and combined with free evolution. The available quantum gates contain single-qubit and two-qubit gates. The single-qubit gates are as follows:

$$\begin{aligned} &X=\sigma _{x}= \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, \quad\quad Y= \sigma _{y}= \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix},\quad\quad Z=\sigma _{y}= \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}, \\ &X90=e^{-i\frac{\pi }{4}\sigma _{x}},\quad\quad Y90=e^{-i\frac{\pi }{4}\sigma _{y}},\quad\quad Z90=e^{-i \frac{\pi }{4}\sigma _{z}}, \\ &Rx=e^{-i\frac{\alpha }{2}\sigma _{x}},\quad\quad Ry=e^{-i\frac{\beta }{2}\sigma _{y}},\quad\quad Rz=e^{-i \frac{\gamma }{2}\sigma _{z}}, \\ &H=\frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, \quad\quad I= \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}. \end{aligned}$$

Here, α, β and γ are the rotation angles defined by users. The two-qubit gates are as follows

$$\begin{aligned} &\mathrm{CX}= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}, \quad\quad \mathrm{CY}= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & 0 & i & 0 \end{pmatrix}, \\ &\mathrm{CZ}= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & -1 \end{pmatrix},\quad\quad \mathrm{delay}=e^{-itH_{0}}=e^{-it\frac{\pi }{2}J \sigma _{z}^{H}\sigma _{z}^{P}}, \end{aligned}$$

where CX gate is the famous control NOT (CNOT) gate. Here, the delay gate is a free evolution gate with the duration t defined by users. It should be noted that when t is comparable to \(T_{2}^{*}\), noise plays a non-negligible role and the action of this gate is not ideal as the form in the above equation. The single-qubit gate fidelity is estimated to be ∼0.99 and the two-qubit gate fidelity is estimated to be ∼0.98.

3.3 The pseudo-pure state

The initial state of the two-qubit system is prepared to be a pseudo-pure state (PPS) [3]. The thermal equilibrium state of a liquid-state NMR system is subject to Boltzmann distribution and at room temperature can be expressed as follow:

$$\begin{aligned} \rho _{\mathrm{eq}}= \frac{e^{-H_{s}/k_{B}T}}{\operatorname{Tr}(e^{-H_{s}/k_{B}T})}\approx \frac{1}{2^{n}}I^{\otimes n}+ \sum^{n}_{k=1}\frac{1}{2}\epsilon _{k} \sigma _{z}^{k}. \end{aligned}$$

Here, \(H_{s}\) is the spin Hamiltonian in the lab frame, and n is the number of qubits. The part \(\sum^{n}_{k=1}\frac{1}{2}\epsilon _{k}\sigma _{z}^{k}\) gives NMR signals. At room temperature \(\epsilon \sim e^{-5}\) is small and thus this is a highly mixed state. To implement quantum computation, researchers [3] proposed to use PPS as the initial state which has the following form,

$$\begin{aligned} \rho _{\mathrm{pps}}=\frac{1-\eta }{2^{n}}I^{\otimes n}+\eta \mathopen\vert \psi \mathclose\rangle \mathopen\langle \psi \mathclose\vert . \end{aligned}$$

\(\mathopen\vert \psi \mathclose\rangle \) is a pure state. The PPS above has the same unitary dynamics and observable effects as the pure state \(\mathopen\vert \psi \mathclose\rangle \) except for the factor η. PPS is widely used in NMR quantum computation.

Gemini utilizes the relaxation method in Ref. [52] to prepare the two-qubit PPS starting from the thermal equilibrium state. As shown in Fig. 8, the first four pulses realize a basis permutation gate which can be expressed as

$$\begin{aligned} &U_{\mathrm{permute}}= \begin{pmatrix} -i & 0 & 0 & 0 \\ 0 & 0 & 0 & -i \\ 0 & -1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix}. \end{aligned}$$

\(U_{\mathrm{permute}}\) permutes the basis \(\mathopen\vert 01\mathclose\rangle \), \(\mathopen\vert 10\mathclose\rangle \) and \(\mathopen\vert 11\mathclose\rangle \) and leaves \(\mathopen\vert 00\mathclose\rangle \) unchanged upon a phase. The relaxation method in Ref. [52] combines \(U_{\mathrm{permute}}\) and a delay after it during which T1 relaxation takes effect. By properly choosing the number of the repetitions of this combination and the delay time t, the system can reach a state whose dominantly occupied basis is \(\mathopen\vert 00\mathclose\rangle \) and the other three base have the same but smaller probability. This obtained state is a PPS and can be used as the initial state \(\mathopen\vert 00\mathclose\rangle \) in NMR quantum computing.

Figure 8
figure 8

The pulse sequence for pseudo-pure state preparation. The first four pulses realize a basis permutation gate. After it is a long delay within which the natural relaxation takes effect. By properly choosing the repetition number, N, and the duration of the delay, t, the system can be steered to the pseudo-pure state \(\mathopen\vert 00\mathclose\rangle \) from the thermal equilibrium state

3.4 Density matrix reconstruction

Gemini implements quantum state tomography [53] to reconstruct the density matrix of the quantum state after a certain gate sequence is applied. Any two-qubit density matrix can be expressed in the following way,

$$\begin{aligned} &\rho =\frac{1}{4}I^{\otimes 2}+\frac{1}{4}\sum _{i,j}c_{ij}\sigma _{i} \sigma _{j}, \\ &i(j)=x,y,z,0, \quad \text{but } (i,j)\neq (0,0). \end{aligned}$$

Here \(\sigma _{0}=I\) is the \(2 \times 2\) identity matrix. To reconstruct a density matrix, one need to measure all the \(c_{ij}\) which are \(c_{ij}=\operatorname{Tr}(\rho \sigma _{i}\sigma _{j})\), in other words, the expectation values of the Pauli matrices \(\sigma _{i}\sigma _{j}\). There are total 15 of \(\sigma _{i}\sigma _{j}\). But only \(\{\sigma _{x}I, \sigma _{x}\sigma _{z} , \sigma _{y}I , \sigma _{y}\sigma _{z} , I \sigma _{x} , \sigma _{z}\sigma _{x} , I\sigma _{y} , \sigma _{z}\sigma _{y} \}\) are observables in NMR. Additional readout pulses are needed to transform the unobservable components to be observable. For example, by applying a readout pulse Y90 to the first qubit prior to measurement, \(c_{z0}\) can be obtained, \(c_{z0}=\operatorname{Tr}(Y90\rho Y90^{\dagger }\sigma _{x}I)\). In Gemini, the reconstruction is realized by repeating an experiment six times, each time with a different readout pulse and observing either 31P or 1H. The readout pulses and \(c_{ij}\) obtained in each of the six repetitions are listed in Fig. 9. The reconstructed initial PPS has a fidelity of higher than 0.99.

Figure 9
figure 9

The readout pulses, observed spins and the obtained \(c_{ij}\) of the six experiments needed to reconstruct a density matrix in the form of Eq. (7)

3.5 Software interface

The user can use the quantum computing interface of SpinQuasar to access the quantum computing function of Gemini (Fig. 10). The structure and flow-chart of quantum computing is shown in Fig. 11. This system wraps up the calibrated pulses into the quantum gates aforementioned. Users can drag the supported gates into the circuits and press Run, the two-qubit quantum computer will start running. The final result will be shown in the form of density matrix which is reconstructed in the way discussed in last section. There is also a noiseless simulator embedded in this system so that one can easily compare the experimental results with theoretical results.

Figure 10
figure 10

The SpinQuasar interface for quantum computing [1]. There is a quantum circuit composer where users can drag and drop the supported quantum gates to construct a desired circuit. The corresponding pulse sequence is shown below the quantum circuit. There are two buttons, ‘Run’ and ‘Simulate’, for activation of the experiment and the simulation, respectively. The density matrices from the experiment and the simulation are shown in the bottom half of the interface

Figure 11
figure 11

Realization of the quantum computing system. It consists of the experiment on the two-qubit processor and the numerical simulation

4 Application: measurement of geometric phase of mixed state

Gemini provides demonstrations of >10 famous quantum algorithms, such as Deutsch–Jozsa algorithm [54], Grover search [48], and HHL algorithm [50]. In this paper, we provide two more advanced examples that demonstrate Gemini’s ability on running quantum algorithms. In this section, we will demonstrate the measurement of the geometric phase of mixed states.

4.1 Theory

Geometric phase [55] is a very important concept in quantum mechanics. It is a type of phase gained by a system that is determined by the geometry of the system’s evolution path. The most famous geometric phase is Berry phase [56] which is associated with cyclic adiabatic evolution. Here we use a spin half system as an example. A spin in a magnetic field is aligned with the field and is in the state \(\mathopen\vert 0\mathclose\rangle \). If the field direction changes slowly and the adiabatic conditions are satisfied, the spin direction changes also adiabatically and is always along the field direction. When the magnetic field returns to its initial direction, the spin returns to its initial direction as well. However, the spin state gains a global phase and is \(e^{i(\alpha +\beta )}\mathopen\vert 0\mathclose\rangle \), where α is the dynamic phase and β is the Berry phase. α and β have expressions as follows:

$$\begin{aligned}& \alpha =-\frac{1}{\hbar } \int _{0}^{\tau }E(t)\,\mathrm{d}t, \end{aligned}$$
$$\begin{aligned}& \beta =-\frac{1}{2}\Omega . \end{aligned}$$

\(E(t)\) is the energy of \(\mathopen\vert 0\mathclose\rangle \) at the time t and is determined by the instant Hamiltonian. Ω is the solid angle enclosed by the path. If the initial state is in \(\mathopen\vert 1\mathclose\rangle \), and the magnetic field changes along the same path, then the geometric phase gained by the spin is \(\Omega /2\). This is because the spin is opposite in this case and hence its path encloses a solid angle of −Ω.

Berry phase is discussed above in the context of adiabatic evolution. Researchers have proved that adiabatic evolution is not a necessary condition for geometric phase [57]. Geometric phase stays the same as long as the geometry of the evolution path stays the same, and is not affected by the Hamiltonian that drives this evolution.

Geometric phase is believed to be robust to local noise and fluctuations of Hamiltonian parameters because of its connection with the path geometry. Therefore, geometric quantum computation is proposed as a candidate for fault-tolerant quantum computation [21, 5867]. Geometric phase in noisy environments is also studied. When the environment is noisy, quantum systems are always in mixed states due to the interaction with the environment. The work in Ref. [68] provides a definition for the geometric phase of a mixed state: It is the phase shift of the interference oscillations in interferometry gained by the mixed state after a unitary evolution. The unitary evolution must satisfy the parallel transport requirement [55, 68]: The state at any instant is in-phase with the state after an infinitesimal time. It can be proved that the dynamical phase is 0 if the parallel transport requirement can be satisfied. After such a unitary evolution, each eigen state of the density matrix of the initial mixed state gains a phase denoted as \(\gamma _{n}\), and has the interference visibility \(\nu _{n}\). The geometric phase γ of the mixed state and its interference visibility ν satisfy the following equation:

$$\begin{aligned} \nu e^{i\gamma }=\sum_{n} p_{n}\nu _{n} e^{i\gamma _{n}}. \end{aligned}$$

Here, \(p_{n}\) is the eigen value of the nth eigen state of the density matrix.

4.2 Experimental protocol

We adapt the protocol used in Ref. [69] to measure the geometric phase in mixed states as defined in Eq. (10). A two-qubit system is used in this protocol. The first qubit is an ancilla qubit and the second qubit is in the mixed states whose geometric phase is to be measured. The mixed state is a mix of \(\mathopen\vert +\mathclose\rangle =\sqrt{2}(\mathopen\vert 0\mathclose\rangle + \mathopen\vert 1\mathclose\rangle )/2\) and \(\mathopen\vert -\mathclose\rangle =\sqrt{2}(\mathopen\vert 0\mathclose\rangle -\mathopen\vert 1\mathclose\rangle )/2\). The initial mixed state is:

$$\begin{aligned} \rho (0)=\frac{1}{2}(I+\vec{\boldsymbol{r}}\cdot \vec{\boldsymbol{\sigma }})= \frac{1}{2}(I-r\sigma _{x}). \end{aligned}$$

Here \(\vec{\boldsymbol{r}}\) is the Bloch vector, and r is its length that corresponds to the purity of the state. If \(r = 1\), the state is a pure state which is \(\mathopen\vert -\mathclose\rangle \). If \(r = 0\), the state is totally mixed. \(\mathopen\vert -\mathclose\rangle \) and \(\mathopen\vert +\mathclose\rangle \) are the two eigen states of the above density matrix with eigen values of \((1+r)/2\) and \((1-r)/2\). Here we steer the state along the path (A–B–C–D–A) which encloses a solid angle Ω as shown in Fig. 12. Because the path is made up of geodesic curves, the parallel transport requirement can be satisfied and thus the dynamical phase is zero. The \(\mathopen\vert -\mathclose\rangle \) and \(\mathopen\vert +\mathclose\rangle \) states gain geometric phases of \(-\Omega /2\) and \(\Omega /2\), and change to \(e^{-i\Omega /2}\mathopen\vert -\mathclose\rangle \) and \(e^{i\Omega /2}\mathopen\vert +\mathclose\rangle \), respectively. It can be proved that the interference visibilities of the two eigen states are both 1. Then the geometric phase γ of the mixed state satisfies

$$\begin{aligned}& \nu e^{i\gamma }=\frac{1}{2}(1+r)e^{-i\frac{\Omega }{2}}+ \frac{1}{2}(1-r)e^{i \frac{\Omega }{2}}=\cos \frac{\Omega }{2}-ir\sin \frac{\Omega }{2}, \end{aligned}$$
$$\begin{aligned}& \gamma =-\tan ^{-1}\biggl(r\tan \frac{\Omega }{2}\biggr). \end{aligned}$$

In order to measure γ, the ancilla qubit is prepared in the state \(\sqrt{2}(\mathopen \vert 0\mathclose \rangle _{a}+\mathopen \vert 1\mathclose \rangle _{a})/2\), which has the density matrix \((I+\sigma _{x}^{a})/2\). We control the two-qubit system so that when the ancilla qubit is in \(\mathopen \vert 1\mathclose \rangle _{a}\), the mixed state undergoes the unitary evolution and when the ancilla qubit is in \(\mathopen \vert 0\mathclose \rangle _{a}\) nothing happens. The phases gained by \(\mathopen\vert -\mathclose\rangle \) and \(\mathopen\vert +\mathclose\rangle \) in the mixed state (which are \(\mp \Omega /2\)) are passed to the ancilla qubit. Thus after the controlled evolution, the state of the ancilla qubit is \(\sqrt{2}(\mathopen \vert 0\mathclose \rangle _{a}+e^{\mp i\Omega /2}\mathopen \vert 1\mathclose \rangle _{a})/2\). The weighted average phase gained by the ancilla qubit has the form of Eq. (13).

Figure 12
figure 12

The unitary evolution path for the mixed state. The state vector of the initial mixed state is prepared to be along -x axis pointing to A. It evolves along the path A–B–C–D–A to return back to point to A. Ω is the solid angle enclosed by this path. \(\theta =\Omega /4\) is the angle between the xy plane and either of the half paths (A–B–C or C–D–A)

Next, we discuss how to prepare a mixed state in the form of Eq. (11) from the initial PPS state \(\mathopen \vert 00\mathclose \rangle \). The most used method in NMR to prepare such a mixed state is to use a pulsed gradient field, which can dephase the spin polarization in the xy plane fast. However, there is no pulsed gradient field in Gemini. Considering the time scale of dephasing caused by the static field inhomogeneity as well as T2 is much smaller than T1, we exploit the natural dephasing to remove the unwanted polarization. To prepare a state in Eq. (11), first the state \((I+r\sigma _{z})/2\) is prepared from \(\mathopen \vert 0\mathclose \rangle \):

$$\begin{aligned} \mathopen\vert 0\mathclose\rangle =\frac{1}{2}(I+\sigma _{z}) \xrightarrow{R_{x}\bigl(\cos ^{-1}r\bigr)} \frac{1}{2} \bigl(I+r\sigma _{z}-\sqrt{1-r^{2}}\sigma _{y} \bigr). \end{aligned}$$

The \(-\sqrt{1-r^{2}}\sigma _{y}\) part in the above equation can be removed using natural dephasing and we can get \((I+r\sigma _{z})/2\). Then, rotate \((I+r\sigma _{z})/2\) about y axis by \(-\pi /2\), we get \((I-r\sigma _{x})/2\).

The \(\mathopen \vert 1\mathclose \rangle _{a}\)-controlled unitary can be realized using the following sequence:

$$\begin{aligned} R_{x}(-\theta )\to \mathrm{CZ}\to R_{x}(2\theta -\pi )\to \mathrm{CZ}, \end{aligned}$$

θ is the angle between either of the two half paths and the xy plane, \(\theta =\Omega /4\). \(R_{x}(-\theta )\) operation rotates the first half of the path to the \(x < 0\) half of the xy plane. CZ is the controlled-Z gate. When the ancilla qubit is in \(\mathopen\vert 0\mathclose\rangle _{a}\), CZ does nothing; when the ancilla qubit is in \(\mathopen \vert 1\mathclose \rangle _{a}\), CZ rotates the mixed state about z axis by π counterclockwise, which means the mixed state evolves along the first half of the path. \(R_{x}(2\theta -\pi )\) rotates the second half of the path to the \(x > 0\) half of the xy plane. The CZ after it realizes the evolution of the mixed state along the second half of the path when the ancilla qubit is \(\mathopen \vert 1\mathclose \rangle _{a}\). In this way, the mixed state undergoes a closed path evolution conditional on the \(\mathopen\vert 1\mathclose\rangle _{a}\) state of the ancilla qubit. CZ can be further decomposed as

$$\begin{aligned} R_{x}\biggl(\frac{\pi }{2}\biggr)\to R_{y}\biggl( \frac{\pi }{2}\biggr)\to R_{x}\biggl(-\frac{\pi }{2}\biggr) \to \frac{1}{2J}, \end{aligned}$$

here \(1/2J\) refers to the free evolution for a duration of \(1/2J\) under the J coupling between the two qubits. The \(R_{x}(\pi /2)\) gate in CZ can be combined with the \(R_{x}(-\theta )\) and \(R_{x}(2\theta -\pi )\) operations in Eq. (15) and simplified. After this simplification, the quantum circuit is shown in Fig. 13. The first qubit is the ancilla qubit. \(\phi _{1}=\pi /2-\theta \), \(\phi _{2}=2\theta -\pi /2\). The geometric phase γ can be measured by measuring the phase change of the ancilla qubit after implementing the circuit in Fig. 13.

Figure 13
figure 13

The experimental circuit for the measurement of the geometric phase for mixed states

4.3 Results

Experiments with \(\Omega = 180^{\circ }\) and \(\Omega = 240^{\circ }\) are carried out. In each situation, r is chosen to be [0.26, 0.50, 0.71, 0.87, 0.97]. And for each of the r values, the experiment is repeated for five times to get a mean value of the measured phases as the result of γ (Fig. 14). The main error sources are the non-ideal initial mixed state and RF pulse imperfections, such as finite pulse width. The large fluctuations in the experimental results come from the uncertainty in fitting the NMR spectra. In spite of those errors and imperfections in experiments, the change trend of the geometric phase as a function of the purity and the solid angle of the path can be observed from the results.

Figure 14
figure 14

The theoretical and experimental results of the mixed state geometric phase in two situations: \(\Omega = 180^{\circ }\) and \(\Omega = 240^{\circ }\). For each situation, five purity values were chosen for the initial mixed state, \(r=[0.26, 0.50, 0.71, 0.87, 0.97]\). For each experimental data point, the experiments were repeated for 5 times and the mean value of the geometric phase was calculated. The error bar indicates the standard deviation of the geometric phase in the 5 repetitions. The theoretical values of the geometric phase are also shown as circles (\(\Omega = 180^{\circ }\)) and diamonds (\(\Omega = 240^{\circ }\)) in the figure

5 Application: variational quantum eigensolver

In this section, we implement a variational quantum eigensolver for a two-qubit Heisenberg model.

5.1 Background

Quantum algorithms such as the Grover search [48], Shor factorization [70, 71] and HHL [50], have proven advantages over their best known classical counterparts. However, these algorithms cannot be efficiently implemented on near-term quantum devices due to inevitable physical noises in quantum gates. Variational quantum algorithms (VQA) [7278], a class of algorithms under the hybrid quantum-classical framework, are more promising to have practical applications on noisy intermediate-scale quantum computers [79]. VQA use a parameterized quantum circuit to estimate the cost function \(C(\boldsymbol{\theta })\) and update θ with a classical optimizer. Variational quantum eigensolver (VQE) [73, 80] is a paradigmatic example of VQA that aims to find the ground state and ground state energy of a given Hamiltonian H. In this section, we will demonstrate the experimental realization of VQE on Gemini.

5.2 Algorithm

In classical computaitional physics (chemistry), we usually estimate the ground state energy of H through variational approaches: parameterize a wave function \(\mathopen \vert \psi \mathclose \rangle =\mathopen \vert \psi (\boldsymbol{\theta })\mathclose \rangle \), update θ to minimize the expectation value \(\mathopen \langle \psi (\boldsymbol{\theta })\mathclose \vert H\mathopen \vert \psi (\boldsymbol{\theta })\mathclose \rangle \) until convergence. VQE facilitates the above procedure with a quantum computer. The wave function is parameterized with a quantum circuit \(U(\boldsymbol{\theta })\) applied to the initial state \(\mathopen \vert \boldsymbol{0} \mathclose \rangle = \mathopen\vert 0\mathclose\rangle ^{\otimes n}\), and we optimize θ to minimize the expectation value,

$$ E(\boldsymbol{\theta })=\mathopen \langle \boldsymbol{0}\mathclose \vert U^{\dagger }(\boldsymbol{\theta }) H U(\boldsymbol{\theta }) \mathopen \vert \boldsymbol{0}\mathclose \rangle . $$

The classical optimizer can either be gradient-based methods like SGD, Adam, RMSprop, BFGD, or gradient-free methods like Nelder–Mead, Powell. Hardware-efficient ansatz [73], unitary coupled clustered ansatz [81], and Hamiltonian variational ansatz [82, 83] are common choices for \(U(\boldsymbol{\theta })\). In VQE, the gradient can be directly estimated via the parameter-shift rule [84, 85], i.e.,

$$ \frac{\partial E(\boldsymbol{\theta })}{\partial \theta _{i}}=\bigl(\mathopen \langle H\mathclose \rangle _{ \boldsymbol{\theta }_{i}^{+}}- \mathopen \langle H\mathclose \rangle _{ \boldsymbol{\theta }_{i}^{-}}\bigr)/2, $$

where \(\boldsymbol{\theta }_{i}^{\pm } = \boldsymbol{\theta }\pm \frac{\pi }{2} \boldsymbol{e}_{i}\), \(\boldsymbol{e}_{i}\) is the ith unit vector in the parameter space. Higher order derivatives \(\frac{\partial ^{2} E(\boldsymbol{\theta })}{\partial \theta ^{2}_{i}}\), \(\frac{\partial ^{3} E(\boldsymbol{\theta })}{\partial \theta ^{3} _{i}}\), which are required in some optimizers, can be estimated in a similar way [86].

5.3 Experimental protocol

In this work, we apply VQE to find the ground state of 2-qubit Heisenberg model. The Hamiltonian is

$$ H_{H} = X_{1}X_{2} + Y_{1} Y_{2} + Z_{1}Z_{2}, $$

where \(X_{j}\), \(Y_{j}\), \(Z_{j}\) are the Pauli operators on the jth qubit. The hardware efficient circuit is shown in Fig. 15.

Figure 15
figure 15

The hardware efficient circuit for 2-qubit VQE. \(\theta _{1}\)\(\theta _{4}\) are the parameters to be optimized

We implement experiments on SpinQ Gemini and IBM Q Yorktown with initial parameter \(\boldsymbol{\theta }=[ 10.2^{\circ } , 8.35^{\circ }, 108^{\circ },91.5^{ \circ }]\), learning rate \(\alpha =0.25\), and carry out numerical simulations.

IBM Q Yorktown is a superconducting quantum computer with 5 qubits [87], the structure is shown in Fig. 16. We only use the first two qubits \(Q_{1}\) and \(Q_{2}\). The single-gate error rates are \(1.173 \times 10^{-3}\) and \(9.810 \times 10^{-4}\), the readout errors are \(2.280 \times 10^{-2}\) and \(3.660 \times 10^{-2}\), and the CNOT error rate is \(1.825 \times 10^{-2}\).

Figure 16
figure 16

The hardware structure of IBM Q Yorktown

The experimental procedures are as follows:

  • Initialize the circuit parameters θ,

  • Estimate the derivatives of θ via parameter-shift rule, \(\frac{\partial E(\boldsymbol{\theta })}{\partial \theta _{i}}=(\mathopen \langle H \mathclose \rangle _{\boldsymbol{\theta }_{i}^{+}}-\mathopen \langle H\mathclose \rangle _{ \boldsymbol{\theta }_{i}^{-}})/2\).

  • Update the parameters with gradient descent, \(\boldsymbol{\theta '}=\boldsymbol{\theta }-\alpha \cdot \nabla E( \boldsymbol{\theta })\);

  • Estimate the expectation value \(\mathopen \langle \boldsymbol{0}\mathclose \vert U^{\dagger }(\boldsymbol{\theta }) H U(\boldsymbol{\theta }) \mathopen \vert \boldsymbol{0} \mathclose \rangle \);

  • Repeat steps 2–4 until convergence.

5.4 Results and simulation

Figure 17 (a) shows the original result of VQE experiment on SpinQ Gemini and IBMQ Yorktown, respectively. The ground state energy of \(H_{H}\) is −3, which is shown by the red line. SpinQ Gemini and IBM Q Yorktown perform similar, both converge to \(E(\boldsymbol{\theta }) \approx -2.6\) after enough iterations, as shown by the blue dot line and the green square line, respectively. According to our simulations and analysis, the error for Gemini mainly comes from the inhomogeneity of the magnetic field, while the error of IBMQ mainly comes from the readout error.

Figure 17
figure 17

Results of VQE. (a) The VQE energy with respect to each iteration on different quantum platforms and simulation. The blue dot line represents the experimental result on SpinQ Gemini. The purple dot line reperents the CNOT error mitigated (CEM) result on SpinQ Gemini. The red triangle line represents the numerical simulation without gate errors. The green square line represents the experimental result on IBM Q Yorktown. The gray square line represents the readout error mitigated (REM) result on IBM Q Yorktown. (b) Numerical simulation for quantum circuit in VQE experiment. The blue dot line represents the experimental result on SpinQ Gemini. The purple dot line reperents the CNOT error mitigated result on SpinQ Gemini. The orange triangle line represents the energy calculate by the noisy circuit with the SpinQ Gemini experimental parameters. The brown square line represents the energy calculate by the ideal circuit with the SpinQ Gemini experimental parameters

The noise in quantum computer cannot be neglected. To study the noise effect and stability of SpinQ Gemini, we construct a noise model to capture the quantum error of the SpinQ Genimi. In the realistic noisy NMR quantum device, the basic noise channels are dephasing and amplitude damping. For an initial state ρ of the system and the quantum circuit unitary transformation U, the local noise model for single-qubit and two-qubit quantum gates can be described by the Kraus representation

$$\begin{aligned} \rho \rightarrow \sum_{k} E_{k} U \rho U^{\dagger } E_{k}^{\dagger } = \sum _{k} E_{k} \rho ' E_{k}^{\dagger } , \end{aligned}$$

where \(E_{k}\)s are the Kraus operators and \(\sum_{k} E_{k} E_{k}^{\dagger } = I\). The \(E_{k}\)s act on the same single qubit and two qubits as U acts on. The amplitude damping noise can be characterized by the Kraus operators,

$$ K_{1}= \begin{pmatrix} 1 & 0 \\ 0 & \sqrt{1-p} \end{pmatrix}, \quad\quad K_{2}= \begin{pmatrix} 0 & \sqrt{p} \\ 0 & 0 \end{pmatrix}, $$

where \(p \in [0, 1]\) is the probability of the noise. For amplitude damping noise on single-qubit gate U, the Kraus operators \(E_{k}\)s in Eq. (20) run over the set \(\{K_{1}, K_{2}\}\). The Kraus operators \(E_{k}\)s run over the set \(\{K_{1}, K_{2}\}\otimes \{K_{1}, K_{2}\}\) for two-qubit noisy gate. The dephasing noise is characterized by the Kraus operators,

$$\begin{aligned} K_{1}=\sqrt{1-p}I_{2}, \quad\quad K_{2}= \sqrt{p}\sigma _{Z}, \end{aligned}$$

where \(I_{2}\) is the two dimensional identity matrix and \(\sigma _{Z}\) is Pauli operator. For dephasing noise on single-qubit gate U, the Kraus operators \(E_{k}\)s in Eq. (20) run over the set \(\{K_{1}, K_{2}\}\). The Kraus operators \(E_{k}\)s run over the set \(\{K_{1}, K_{2}\}\otimes \{K_{1}, K_{2}\}\) for two-qubit noisy gate.

We model the noise consisting of single-qubit thermal relaxation error and two-qubit thermal relaxation error. The thermal relaxation error model applies the amplitude damping noise and dephasing noise after each one- or two-qubit gate. This thermal relaxation error model is characterized through the parameters \((T_{1}, T_{2}^{*}, t_{q})\) and the noise probability is formulated by

$$\begin{aligned}& p_{\mathit{damping}} = 1 - e^{-\frac{t_{q}}{T_{1}}}, \end{aligned}$$
$$\begin{aligned}& p_{\mathit{dephasing}} = \frac{1}{2}\bigl(1- e^{-2\gamma }\bigr), \end{aligned}$$

where \(\gamma = \frac{t_{q}}{T_{2}^{*}} - \frac{t_{q}}{2T_{1}}\). When the thermal relaxation error model is applied to single-qubit gates, \(t_{q} = {t_{1q}}\) and \(t_{q} = {t_{2q}}\) for two-qubit gates. The final noise model to approximate the noise of NMR quantum device is characterized by the parameters \(\{T_{1}, T_{2}^{*}, t_{1q}, t_{2q} \}\). We set \(\{T_{1} = 5.6\text{ s} , T_{2}^{*}=0.025\text{ s}, t_{1q}=25\ \mu \text{s}, t_{2q}=800\ \mu \text{s}\}\) in the noise simulation for the NMR platform. In NMR system, the dephasing effect is caused by both the spin relaxation and the field inhomogeneity. \(T_{2}\) is used to measure the spin transversal relaxation rate, while \(T_{2}^{*}\) is used to measure the field inhomogeneity. The \(T_{2}\) data is measured using the technique called spin echo, which can refocus the magnetisation and remove the effect of inhomogeneous field. In our VQE experiment, we did not use such technique, so we use \(T_{2}^{*}\) instead of \(T_{2}\).

With the noise model described above, we first record every parameters θ in each iteration of the SpinQ Gemini VQE experiment. Then we take these parameters θ as the parameters of quantum circuit ansatz (Fig. 15) and calculate the energy of the Hamiltonian with respect to the ideal circuit and noisy circuit output in each iteration. As shown in Fig. 17 (b), the noisy circuit result shows great consistancy to the experiment data. The paramaters θ found by SpinQ Gemini is close to the parameters for ground state. These results indicate that our desktop quantum computing platform can run VQE algorithm well.

5.5 Error mitigation

Quantum error mitigation [8890] is a technique to diminish the influence of errors from the statistical perspective.

From the comparison and the simulation described above, we can see that the dephasing error caused by the inhomogeneous magnetic field is dominant. Our circuit consists of four single-qubit rotations and one CNOT gate. The time for a CNOT gate is about 800 μs and for single-qubit gates is \({\sim }20\ \mu \text{s}\). Therefore, the imperfections of the CNOT gate causes primary error. Consider the error model:

$$\begin{aligned} \rho \rightarrow \rho _{f} =\sum_{k} E_{k} U \rho U^{\dagger } E_{k}^{ \dagger } = \sum _{k} E_{k} \rho ' E_{k}^{\dagger }, \end{aligned}$$

where \(E_{k}\)s are the Kraus operators, \(\rho '\) is the ideal density matrix, and \(\rho _{f}\) is the measured density matrix. Error mitigation is a procedure that for a given \(\rho _{f}\) obtained from the experiment, finds a density matrix \(\rho _{0}\), which is as close to \(\rho '\) as possible, so that the final experiment result could be improved. Here, we employ the superoperator formalism to obtain \(\rho _{0}\). This formalism works as follows. First, let us rewrite the density matrix \(\rho '\) from an \(n\times n\) matrix into an \(n^{2} \times 1\) vector \(\boldsymbol{\rho }'\):

$$ \rho '=\sum_{ij} \rho '_{ij}\mathopen \vert i\mathclose \rangle \mathopen\langle j\mathclose \vert \rightarrow \boldsymbol{\rho }'=\sum _{ij} \rho '_{ij}\mathopen \vert i\mathclose\rangle \mathopen \vert j\mathclose \rangle . $$

Then the final state \(\boldsymbol{\rho }_{f}\), which is also an \(n^{2} \times 1\) vector is

$$ \boldsymbol{\rho }_{f} = \hat{\hat{S}} \boldsymbol{\rho }', $$

where \(\hat{\hat{S}}\) is the superoperator. With known Kraus operators \(E_{k}\), it can be obtained as

$$ \hat{\hat{S}}=\sum_{k} E_{k}\otimes E_{k}^{\dagger }. $$

Therefore, with known \(\boldsymbol{\rho }_{f}\) and \(\hat{\hat{S}}\), we can get

$$ \boldsymbol{\rho }'=\hat{\hat{S}}^{-1}\boldsymbol{\rho }_{f}. $$

The original result and the mitigated result of Gemini is shown in Fig. 17(b). The blue line and the purple line show the original result and the CNOT error mitigated result. We can see that the error mitigated result of the ground state of \(H_{H}\) could reach about −2.98, much closer to the ideal result. With both the simulation result and the error mitigated result, we can see that the error model we used is a good approximation.

For the IBMQ devices, the readout errors are dominant. Here we consider the simplest linear algebra measurement error mitigation scheme. On IBMQ Santiago we do projective measurement and obtain one of the strings \(\{0,1\}^{\otimes 2}\). Through tomography of measurement process, we get the probability of string \(S_{j}\) becoming \(S_{k}\), denoted by \(P_{kj}\). Suppose we repeat the same measurement many times and have the string probability distribution \(C_{\text{noisy}}\), then

$$ C_{\text{mitigated}}=P^{-1} C_{\text{noisy}} $$

provides the probability distribution with measurement error mitigated, although \(P^{-1}\) is not a physical operation. Measurement error mitigation can efficiently improve the performance of VQE on IBMQ Santiago, as shown in Fig. 17(a).

6 Discussion

For the next generations of SpinQ desktop quantum computing products, we will develop products running with more qubits (3∼4). Currently, the design of a 3-qubit machine is underway and the product is expected to be released in the second quarter of 2021, with a comparable price as SpinQ Gemini (i.e. under 50k USD). Along the way, compatible software modules with advanced pulse control functions will also be developed, providing more powerful abilities for quantum algorithm/control/error mitigation designs to meet the research needs of advanced users. Meanwhile, another direction is to make a simplified version of the current model, making it more portable with much lower cost (under 5k USD). This simplified version is expected to be released in the fourth quarter of 2021, such that it can be more affordable for most K-12 schools around the world.

7 Conclusion

In this work, we described a desktop and maintenance free quantum computing platform: SpinQ Gemini. We discussed the technique details for both hardware and software parts of it. We demonstrated how quantum computation is accomplished by Gemini, and realized measurement of geometric phase of mixed states as well as variational quantum eigensolver. To obtain a better accuracy in VQE, we also developed an error mitigation algorithm and realized it. In a word, we think SpinQ Gemini is a powerful tool for quantum computation education as well as research.