Device fabrication
The qubit device was fabricated on an isotopically purified 28Si buffer layer (20 nm thick), epitaxially grown at 380 °C via ultrahigh-vacuum electron-beam deposition on a p-type natural silicon substrate (50–100 Ω cm). This layer maintains a 29Si concentration below 130 ppm, effectively isolating qubits from the nuclear spin bath of the natural silicon substrate and enhancing spin coherence times. Using STM-assisted hydrogen depassivation lithography at 77 K (Scienta Omicron INFINITY SPM Lab), we deterministically patterned the hydrogen-passivated silicon surface with atomic precision. The exposed regions were then dosed with phosphine (PH3) at 5 × 10−7 mbar for 5 min (room temperature), followed by thermal incorporation at 330 °C for 1 min to activate phosphorus donors. This process creates three tunnel-coupled quantum dot structures (P-atom clusters) positioned 17.0 nm away from a single-electron transistor charge sensor for individual qubit addressability and read-out. Subsequently, the doped nanostructure was encapsulated with a 20 nm epitaxial 28Si capping layer, grown at 250 °C (0.7 nm h−1 growth rate). This low-temperature epitaxial process ensures minimal dopant diffusion while maintaining crystalline perfection. After removing the device from the STM system, a polymethyl methacrylate resist and electron-beam lithography were used to define a series of small holes (200 nm in diameter) aligned with the phosphorus patches. This step was followed by reactive ion etching and aluminium lead deposition. Through these holes, the leads penetrated the dopant layer, establishing direct electrical contact between the metal and the phosphorus patches. The ohmic contacts between the buried P-dopant device and aluminium electrodes were formed through silicon vias. Then, an aluminium microwave antenna was fabricated atop the device, separated by a 10 nm atomic-layer-deposited Al2O3 dielectric layer to prevent current leakage and enable high-fidelity spin manipulation.
Estimation of uncertainties
All reported uncertainties correspond to 1 s.d. from the mean, estimated through 2,000 Monte Carlo bootstrap resampling trials. Specifically, we model the measured counts for each spin state (for example, \(\left|\Downarrow \Downarrow \Downarrow \Downarrow \right\rangle\) to \(\left|\Uparrow \Uparrow \Uparrow \Uparrow \right\rangle\)) across N measurement repetitions as following a multinomial distribution. To clarify the representation of the uncertainties, we provide the following illustrative example: the value 96.5(20)% corresponds to 96.5 ± 2.0%, where the number in parentheses denotes the s.d.
[[4, 2, 2]] detection code
The logical code words \(\left|{{\rm{L}}}_{1}{{\rm{L}}}_{{\rm{2}}}\right\rangle\) in the computational basis are
$$\begin{array}{rcl}{\left|00\right\rangle }_{{\rm{L}}} & = & \frac{1}{\sqrt{2}}\left(\left|0000\right\rangle +\left|1111\right\rangle \right),\\ {\left|01\right\rangle }_{{\rm{L}}} & = & \frac{1}{\sqrt{2}}\left(\left|0011\right\rangle +\left|1100\right\rangle \right),\\ {\left|10\right\rangle }_{{\rm{L}}} & = & \frac{1}{\sqrt{2}}\left(\left|0101\right\rangle +\left|1010\right\rangle \right),\\ {\left|11\right\rangle }_{{\rm{L}}} & = & \frac{1}{\sqrt{2}}\left(\left|0110\right\rangle +\left|1001\right\rangle \right).\end{array}$$
(1)
The stabilizers performing the syndrome extraction of the physical phase-flip and bit-flip errors are \({\widehat{S}}^{X}={X}_{1}{X}_{2}{X}_{3}{X}_{4}\) and \({\widehat{S}}^{Z}={Z}_{1}{Z}_{2}{Z}_{3}{Z}_{4}\), respectively. All logical basis states in equation (1) have even parity, while any single physical qubit errors lead to a state with odd parity.
The correspondence between logical operators and physical operators is as follows: the logical operation XLIL corresponds to applying X gates on physical qubits 1 and 3 (X1I2X3I4). Similarly, ILXL maps to X1X2I3I4. By contrast, the ZLIL operation corresponds to Z1Z2I3I4, while ILZL translates to Z1I2Z3I4. The logical Hadamard operation HLHL requires H gates on all four physical qubits (H1H2H3H4), followed by swapping of physical qubits 2 and 3 (SWAP23). Finally, the logical CNOTL is implemented as a SWAP12 operation, where the logical L1 is the control qubit.
Compared with the logical operations above, the implementation of the SLIL gate is less intuitive. The SLIL gate is implemented by applying physical S gates to the first two physical qubits, followed by a CZ gate between them (Fig. 3a). The physical S gates accumulate the target phase on the logical qubit L1, while the CZ gate cancels the extra phase accumulated on physical qubits 1 and 2. For example, when the two physical S gates are applied for the first two physical qubits, with the initial state being \({\left|{\psi }_{0}\right\rangle }_{{\rm{L}}}\,=\,{\left|00\right\rangle }_{{\rm{L}}}+{\left|10\right\rangle }_{{\rm{L}}}\), the corresponding physical qubit state becomes \(\left|{\psi }_{1}\right\rangle =\left|0000\right\rangle +{{\rm{e}}}^{i{{\uppi }}}\left|1111\right\rangle +\,{{\rm{e}}}^{i{{\uppi}}/2}\left|0101\right\rangle +{{\rm{e}}}^{i{{\uppi }}/2}\left|1010\right\rangle\). Then, the CZ gate is applied to correct the phase accumulated on the \(\left|1111\right\rangle\) state. As a result, the target logical qubit state is obtained: \({\left|{\psi }_{2}\right\rangle }_{{\rm{L}}}={\left|00\right\rangle }_{{\rm{L}}}+{{\rm{e}}}^{i{{\uppi }}/2}{\left|10\right\rangle }_{{\rm{L}}}\).
Quantum state tomography
The density matrix of a four-qubit state can be expressed as follows:
$$\rho =\frac{1}{16}\mathop{\sum }\limits_{i,\,j,k,l=1}^{4}{c}_{i,\,j,k,l}{M}_{i}\otimes M_{j}\otimes {M}_{k}\otimes {M}_{l},$$
(2)
where ci,j,k,l denotes the expansion coefficients of the density matrix and \({M}_{i},{M}_{j},{M}_{k},{M}_{l}\in \left\{I,X,Y,Z\right\}\) are the Pauli operators acting on the qubits i, j, k and l. There are 44 = 256 linear independent operators in total, from I ⊗ I ⊗ I ⊗ I, X ⊗ I ⊗ I ⊗ I, …to Z ⊗ Z ⊗ Z ⊗ Z.
To reconstruct the density matrix, 255 expectation values are to be determined in the experiment (except for c1,1,1,1 = 1). For qubit j in the I base measurement, no prerotation is applied after the target state \(\left|\psi \right\rangle\) is prepared; for qubit k in the X base measurement, a \({R}_{y}^{k}(-{{\uppi }}/2)\) prerotation is applied; a \({R}_{x}^{l}({{\uppi }}/2)\) prerotation is applied for qubit l in the Y base measurement; and we use I base projection outcomes for the Z base calculation rather than performing Rx(π) pretotation to any qubit, to prevent rotation error52. All the above prerotations are realized by NMR pulses, which are conditional on the electron spin being in the \(\left|\downarrow \right\rangle\) state.
After that, the maximum likelihood estimation method is used to restrict the measured density matrix to be physical (Hermitian, positive semidefinite and trace preserving) while providing the closest measurement probabilities. According to the Cholesky decomposition, a physical density matrix can be written as \(\rho ={T}^{\dagger }T/{\rm{Tr}}({T}^{\dagger }T)\). The matrix T is a complex lower triangle matrix, which has 22D (D = 4 for four qubits) parameters t1, t2, …t256. The loss function is defined as follows:
$$L({t}_{1},{t}_{2},\ldots {t}_{256})=\mathop{\sum }\limits_{i=1}\frac{{\left(\left\langle {\psi }_{i}\right|\rho \left({t}_{1},{t}_{2},\ldots ,{t}_{n}\right)\left|{\psi }_{i}\right\rangle -{P}_{i}\right)}^{2}}{16\left\langle {\psi }_{i}\right|\rho \left({t}_{1},{t}_{2},\ldots ,{t}_{n}\right)\left|{\psi }_{i}\right\rangle },$$
(3)
where Pi are the measured probabilities projected at basis \(\left|{\psi }_{i}\right\rangle\). We minimize this loss function to obtain the final and physical density matrix. All the fidelity in this paper is calculated by \(F={(\mathrm{Tr}\sqrt{\sqrt{{\rho }^{\mathrm{ideal}}}\rho \sqrt{{\rho }^{\mathrm{ideal}}}})}^{2}\), where ρideal is the corresponding ideal density matrix.
Logical density matrix reconstruction
The complete quantum state tomography reconstructs the physical density matrix, which generally contains components outside the logical subspace defined by the stabilizers \({\widehat{S}}^{X}\) and \({\widehat{S}}^{Z}\). The parity projection is fundamentally enabled by the projection operator (Π + I⊗4)/2, where Π represents the stabilizers of the [[4, 2, 2]] code, and I⊗4 denotes the four-qubit identity operator. We can project the physical density matrix into three subspaces defined by the +1 eigenspace of \({\widehat{S}}^{X}\), the +1 eigenspace of \({\widehat{S}}^{Z}\) and their simultaneous eigenspace. The logical density matrix is then obtained after applying the projection.
Quantum process tomography
A quantum operation can be described by the operator-sum representation, expressed as
$${\mathcal{E}}(\rho )=\mathop{\sum }\limits_{i}{\alpha }_{i}\rho {\alpha }_{i}^{\dagger },$$
(4)
where the operation elements {αi} satisfy the completeness condition:
$$\mathop{\sum }\limits_{i}{\alpha }_{i}^{\dagger }{\alpha }_{i}=I.$$
(5)
To experimentally determine the operators αi, we adopt an equivalent representation using a fixed basis \(\{{\widetilde{\alpha }}_{i}\}\) spanning the space of d2 complex matrices (for N-qubit systems, d = 2N). This gives the χ-matrix representation:
$${\mathcal{E}}(\,\rho )=\mathop{\sum }\limits_{{mn}}{\chi }_{{mn}}{\mathop{\alpha }\limits^{ \sim }}_{m}\rho {\mathop{\alpha }\limits^{ \sim }}_{n}^{\dagger },$$
(6)
where the d2 × d2 matrix χ fully characterizes the quantum process. For the single-qubit system, the standard basis operators are chosen as follows:
$${\widetilde{\alpha }}_{1}=I,\,{\widetilde{\alpha }}_{2}=X,{\widetilde{\,\alpha }}_{3}=-iY,{\widetilde{\,\alpha }}_{4}=Z.$$
(7)
Experimentally determining an arbitrary single-qubit operation requires measuring 12 parameters through input states \(\left|0\right\rangle\), \(\left|1\right\rangle\), \(\left|+\right\rangle =(\left|0\right\rangle +\left|1\right\rangle )/\sqrt{2}\) and \(\left|+i\right\rangle =(\left|0\right\rangle +i\left|1\right\rangle )/\sqrt{2}\). Quantum state tomography on the output states yields four matrices:
$$\begin{array}{rcl}{\rho }_{1}^{{\prime} } & = & {\mathcal{E}}(\left|0\right\rangle \left\langle 0\right|),\\ {\rho }_{4}^{{\prime} } & = & {\mathcal{E}}(\left|1\right\rangle \left\langle 1\right|),\\ {\rho }_{3}^{{\prime} } & = & {\mathcal{E}}(\left|+\right\rangle \left\langle +\right|)-i{\mathcal{E}}(\left|+i\right\rangle \left\langle +i\right|)-\frac{(1-i)}{2}({\rho }_{1}^{{\prime} }+{\rho }_{4}^{{\prime} }),\\ {\rho }_{2}^{{\prime} } & = & {\mathcal{E}}(\left|+\right\rangle \left\langle +\right|)+i{\mathcal{E}}(\left|+i\right\rangle \left\langle +i\right|)-\frac{(1+i)}{2}({\rho }_{1}^{{\prime} }+{\rho }_{4}^{{\prime} }).\end{array}$$
(8)
These correspond to \({\rho }_{j}^{{\prime} }={\mathcal{E}}({\rho }_{j})\) with \({\rho }_{1}=\left|0\right\rangle \left\langle 0\right|\), ρ2 = ρ1X, ρ3 = Xρ1 and ρ4 = Xρ1X. The linear decomposition of \({\mathcal{E}}({\rho }_{j})\) in the basis states ρk leads to the following relation:
$${\widetilde{\alpha }}_{m}{\rho }_{j}{\widetilde{\alpha }}_{n}^{\dagger }=\mathop{\sum }\limits_{k}{\beta }_{jk}^{mn}{\rho }_{k},$$
(9)
where coefficients \({\beta }_{jk}^{mn}\) are determined by the basis states and operators. For the single-qubit case, these relations are encapsulated in the transformation matrix:
$$\varLambda =\frac{1}{2}\left(\begin{array}{cc}I & X\\ X & -I\end{array}\right).$$
(10)
The χ-matrix is then constructed through block matrix operations:
$$\chi =\varLambda \left(\begin{array}{cc}{\rho }_{1}^{{\prime} } & {\rho }_{2}^{{\prime} }\\ {\rho }_{3}^{{\prime} } & {\rho }_{4}^{{\prime} }\end{array}\right)\varLambda .$$
(11)
The process fidelity definition we used here is
$${F}_{\chi }={\left({\rm{Tr}}\sqrt{\sqrt{{\chi }^{{\rm{ideal}}}}\chi \sqrt{{\chi }^{{\rm{ideal}}}}}\right)}^{2},$$
(12)
where χideal is the ideal process matrix.
Classical optimizer
For the classical optimizer, we employed the Nelder–Mead algorithm53 for optimization, which is a simplex-based direct-search method suitable for unconstrained minimization of objective functions. Compared with other direct-search methods such as gradient descent that may exhibit better convergence on smooth functions, Nelder–Mead demonstrates robustness for noisy functions and can explore nearby valleys, thereby avoiding local minima trapping and overcoming non-smoothness of objective functions.
We improved the Nelder–Mead algorithm to suit our specific experimental situation. To enforce the algorithm’s angular domain constraint of [−π, π), we applied periodic boundary conditions by computationally wrapping the optimization parameter θ (Fig. 5a) into this interval during each iterative optimization step. Furthermore, we optimized the Nelder–Mead algorithm’s reflection, expansion, contraction and shrink coefficients to achieve convergence to the global minimum with fewer iterations.
Clifford fitting
To reduce the impact of noise in near-term quantum computations, error mitigation techniques process noisy results to more accurately estimate ideal expectation values54. Clifford fitting is also referred to as Clifford data regression50,55. The core idea is to learn a correction function, fCF, using training data generated from efficiently simulatable Clifford circuits. For these circuits, both the noisy expectation values (Xnoisy) measured on hardware and the exact expectation values (Xexact) computed classically are obtained. The function fCF is determined by fitting these data pairs. Subsequently, this learned function is applied to the noisy result measured for the actual target circuit, for which an exact value may be hard to compute. Specifically, given the noisy measurement \({X}_{\psi }^{\,\mathrm{noisy}}\) for a target state \(\left|\psi \right\rangle\) (prepared by circuit Uψ) and observable X, Clifford data regression aims to find fCF to approximate the ideal value \({X}_{\psi }^{\,\mathrm{exact}}=\langle \psi | X| \psi \rangle\) via the following relation:
$${X}_{\psi }^{\,\mathrm{corrected}}={f}^{\,\mathrm{CF}}({X}_{\psi }^{\,\mathrm{noisy}},\vec{a})\approx {X}_{\psi }^{\,\mathrm{exact}},$$
(13)
where \(\vec{a}\) represents a set of parameters characterizing the function fCF.
In the VQE experiment, we implement Clifford fitting in a quantum parameterized circuit. First, according to the method in ref. 50, we distinguish between observables that vary with parameters and those that remain constant. Constant observables cannot be analysed using the Clifford fitting method. Let M denote the number of parameterized gates. Then, by randomly selecting K gates from M, we independently and uniformly sample their K parameters from the range [−π, π), while the remaining M − K gates are converted into identity operations. This process generates m random circuits \({\{{S}_{i}^{(K)}\}}_{i=1}^{m}\). The number m should be sufficient (typically over 10) to ensure an adequate fitting performance of \(\vec{a}\) in the linear regression. The dataset consists of pairs of noisy and exact expectation values, \({{\mathcal{T}}}_{\psi }=\{({X}_{\psi }^{\,\mathrm{noisy}},{X}_{\psi }^{\mathrm{exact}})\}\), generated from a set of quantum circuits \({\{{S}_{i}^{(K)}\}}_{i=1}^{m}\). Thus, the parameters \(\vec{a}\) of the correction function fCF can be fitted by the the linear regression function
$${f}^{\,\mathrm{CF}}\left({X}_{\psi }^{\,\mathrm{noisy}},\vec{a} \right)={a}_{1}{X}_{\psi }^{\,\mathrm{noisy}}+{a}_{2}.$$
(14)
The parameters a1 and a2 are typically determined by minimizing the least-squares cost function
$$C=\mathop{\sum }\limits_{i}{\left({X}_{{\psi }_{i}}^{\,\mathrm{exact}}-({a}_{1}{X}_{{\psi }_{i}}^{\,\mathrm{noisy}}+{a}_{2})\right)}^{2}.$$
(15)
There is theoretical justification for the linear model, as it can perfectly correct for certain noise models, such as global depolarizing noise.
Finally, after determining the optimal parameters \({\vec{a}}^{* }=({a}_{1}^{* },{a}_{2}^{* })\), the error-mitigated expectation value for the original target circuit is predicted using equation (13):
$${X}_{\psi }^{\,\mathrm{corrected}}={a}_{1}^{* }{X}_{\psi }^{\mathrm{noisy}}+{a}_{2}^{* }.$$
(16)
Symmetry verification
Molecular Hamiltonians in quantum simulations inherently possess symmetry constraints such as particle number conservation. Symmetry verification through subspace expansion provides an effective error mitigation strategy. Following the methodology in ref. 56, we implement this approach for the [[4, 2, 2]] code. For a general [[n, k, d]] code, the code space is defined by the projection operator:
$$\widehat{P}=\mathop{\prod }\limits_{i=1}^{l}{P}_{i}=\frac{1}{{2}^{l}}\mathop{\sum }\limits_{{M}_{i}\in S}{M}_{i},$$
(17)
where l = n − k; \({P}_{i}=\frac{1}{2}(I+{u}_{i})\) projects onto the +1 eigenspace of stabilizer generators ui ∈ G = 〈u1, …, ul〉; and S denotes the stabilizer group. For a code-space Hamiltonian Hc = ∑iγiΓi, where γi denotes the coefficient of the ith term, and Γi represents the corresponding Pauli string operator. the symmetry-verified expectation value becomes the following:
$$\langle {H}_{\rm{c}}\rangle =\frac{1}{c{2}^{l}}\mathop{\sum }\limits_{j,k}{\gamma }_{j}\mathrm{Tr}\left[\rho {\Gamma }_{j}{M}_{k}\right],$$
(18)
where \(c={\rm{Tr}}[\widehat{P}\rho ]\) normalizes the density matrix ρ projected onto the symmetry-preserving subspace.
