On the road to construct quantum machines that employ the power of quantum mechanics for unraveling problems inaccessible to their most powerful classical counterparts, the quest for greater control over quantum systems has stimulated the discoveries of new materials with an expanded set of technological capabilities. The spin carried by an electron naturally implements a qubit, and those confined in group IV materials such as donor-based qubits in silicon1,2 and point defect-based qubits in diamond3,4, are poised to play a major role in solid-state quantum information due to the largely spin-free environment and weak spin–orbit coupling bestowed by this group of materials.

Single-walled carbon nanotubes (SWCNTs), an all-carbon one-dimensional system, are predicted to be a prime candidate for hosting electronic spin qubits with long coherence times5,6. SWCNTs also offer diverse degrees of freedom for efficient qubit control and detection, as well as for an extended range of functionality not available to bulk systems. Owing to their low mass and high Young’s modulus, SWCNTs afford ultrahigh-quality mechanical responses7,8,9 that are instrumental in achieving strong qubit–resonator coupling for ground-state cooling and qubit control and entanglement implementation10. Conversion between spin and optical degrees of freedom in SWCNTs could facilitate ultrafast all-optical control and detection of electron spins11. Benefiting from the natural compatibility of SWCNTs with nanofabricated electronic and microwave devices12, coherent coupling between SWCNT electron spins and microwave cavity photons could be exploited for quantum nondemolition readout of spin states13 and coupling to superconducting qubits14. For these reasons, SWCNTs constitute an appealing host system for spin qubits.

A prerequisite to the implementation of these grand schemes is the well-controlled confinement of isolated spins in SWCNTs, a goal that is antithetical to the one-dimensional, ballistic conductor nature of SWCNTs15,16. To date, confinement of electron spins has been achieved by patterning electrostatically defined quantum dots in SWCNTs17,18. Great strides made in SWCNT electron transport devices have facilitated the experimental demonstration of valley-spin qubits19. However, this approach relies on spin–orbit coupling mediated by randomly occurring structural disorders such as bends in SWCNTs20,21. The electrostatically defined confining potential imposes unsurmountable charge noises and lithographic complexity19,22. Moreover, the weak confinement in such devices implicates a high probability of including multiple 13C nuclei in each dot23. These factors have limited the coherence time of such valley-spin qubits to a few tens to hundreds of nanoseconds19,23,24. A pressing challenge to fully exploit opportunities encompassed by the unique spin physics in SWCNTs is the development of a robust and highly reproducible approach that can confine electron spins in SWCNTs.

Unpaired electrons in carbon-centered molecular systems, namely radicals, are commonly deemed unstable despite their high relevance to the fields of magnetic materials and optoelectronics. Synthetic chemists have discovered that by delocalizing an unpaired electron over several adjacent atoms, the stability of the molecular radical can be drastically improved25,26. Inspired by this success, here, we report the confinement of isolated electron spins in SWCNTs via a bottom-up approach for qubit application. We discover that the electron spins introduced to SWCNTs through a mild covalent doping approach exhibit an unrivaled spin coherence time, T2, of 1.2 µs and can be further extended up to 8.2 µs through dynamical decoupling. This long coherence time allows quantum control operation of the spin qubits using microwave magnetic fields. The spin-lattice relaxation time, T1, reflecting the thermal limit of the spin coherence time is measured to be around 13 ms. Our investigation of the decoherence sources reveals that instantaneous diffusion caused by inter-tube spin–spin interactions in SWCNT bundles, together with hyperfine coupling, is the primary mechanism limiting T2 to be four orders of magnitude shorter than T1. These findings suggest that chemically functionalized SWCNTs, which represent a powerful combination of the molecular and crystalline quantum worlds, hold great promise for a versatile spin qubit system.

Results and discussion

To engender confined electron spins in SWCNTs, we perform mild covalent doping of SWCNTs utilizing diazonium salts (Fig. 1a), a method that allows the introduction of sp3 defects to the sidewalls of SWCNTs with well-controlled density27,28. The reaction of a diazonium salt with a SWCNT breaks the sp2 carbon lattice and leaves behind an unpaired electron29. Analogous to stable radicals in molecular systems, delocalization of the electron spins over multiple unit cells of SWCNTs renders them highly stable30,31. Two different types of diazonium salts, 4-nitrobenzene diazonium tetrafluoroborate and 3, 5-dichlorobenzene diazonium tetrafluoroborate, are used to functionalize the SWCNTs to elucidate the influence of the nuclear spins introduced by the functional groups, particularly the 14,15N, 17O, and 35,37Cl nuclei. We refer to these two types of samples as NO2Ph-SWCNT and Cl2Ph-SWCNT, respectively (see Supplementary Fig. 1 for structures). To discern and minimize the nuclear spin sources in the system, we employ a modified purification and doping approach to rid the SWCNTs free of most surfactants (see the “Methods” section for details). In addition, we keep the defect density and hence spin density to be sufficiently low so that the average distance between the spins is in the range of 12–45 nm (Supplementary Note 2). This would help minimize intra-tube electron spin–spin interactions while maintaining sufficient spin concentrations for measurements. Powders of SWCNTs with designated electron spin densities are then dispersed in toluene and cooled to 5 K for pulsed electron paramagnetic resonance (EPR) measurements (see the “Methods” section and Supplementary Notes 3 for details). Echo-detected field-swept (EDFS) spectra, which monitor the Hahn echo intensity (vide infra) at various magnetic fields, of the SWCNTs, reveal a singular symmetric sharp peak with a full-width at half-maximum of 0.013 MHz (Fig. 1b inset), indicating an isotropic giso, consistent with previous cw EPR studies31. The intensity of the EDFS spectrum increases with defect density, confirming that the confined spins originate from doping-induced defects.

Fig. 1: Confinement of electron spins with long coherence times in SWCNTs through chemical modification.
figure 1

a Schematic of an electron spin (S = 1/2) confined in SWCNTs via chemical functionalization. B and ms are the applied magnetic field and spin quantum number, respectively. b Hahn echo decay curve of the confined electron spins in SWCNTs (dots) and a stretched exponential fit (curve). Inset: Echo-detected field-swept spectra of SWCNTs with various spin densities. Average spin densities (in the units of spins/nm) are labeled. c Coherence decay under various numbers of CPMG decoupling pulses as a function of total evaluation time. Black curves are stretched exponential fits to the data. d Scaling of the extracted T2 with the number n of CPMG pulses. The dashed line is a fit of the data to a power law: T2n0.56.

Spin coherence properties and demonstration of qubit manipulation

We first perform a two-pulse Hahn echo sequence to measure the T2 of the spins (see Supplementary Note 3 for detailed explanations of the pulse sequence). The obtained decay curves are fit by stretched exponential functions, a form predicted by semiclassical models involving stochastic nuclear spin flip-flops32. For SWCNTs, it is potentially possible that tube chirality may also contribute to the stretched exponential decay33. Similar T2 values are obtained for various batches of samples prepared under similar conditions, and we obtain an average T2 of 1.26 ± 0.29 µs. For the representative decay curve in Fig. 1b, T2 = 1.2 µs. In the solid state, the coherence time of electron spins is strongly influenced by couplings to their spin baths, which can cause spin dephasing by imposing random local magnetic fields B1 on the electron spins. This problem can be partially circumvented through the use of dynamical decoupling protocols, which suppress the effect of spin bath noises and extend the coherence time via the implementation of a sequence of refocusing pulses before the echo detection34,35. We use the well-known Carr–Purcell–Meiboom–Gill (CPMG) pulse sequence, in which n equally spaced spin-locking π-pulses along the y-axis are applied to the measured system after initially rotating it into the y-axis with a π/2 pulse along the x-axis (Supplementary Note 3). As shown in Fig. 1c, the T2 value is increased to 2.7 µs from the 1.2 µs of a Hahn echo measurement upon application of n = 4 CPMG sequence and can be further extended to 8.2 µs by applying n = 32 CPMG sequence before the signal becomes too weak for reliable extraction of T2 values. We note that the oscillations in the CPMG curves are due to nuclear spin modulations. The improved coherence time is related to the number of π-pulses by T2n0.56 (Fig. 1d), consistent with a fluctuating Lorentzian spin bath with a bath correlation time longer than the probed electron spin coherence time36. We would like to note that although dynamical decoupling is powerful in protecting the spin coherence from nuclear spin baths and weak spin–spin interactions, it cannot fully eliminate strong spin–spin interactions37. As such, the moderate improvement obtained upon applying the CPMG sequences implies the potential existence of strong spin–spin interactions such as instantaneous diffusion38 in the SWCNT system.

Nevertheless, the microsecond-long T2 of the defect-confined spins are nearly two orders of magnitude longer than those observed for electrostatically confined spin qubits19,39. This long coherence time allows quantum control operation of the spin qubits. We exemplify the ability to coherently manipulate the spins by performing nutation experiments, in which microwave pulses of various durations are applied to coherently drive the electron spins between the two Zeeman-split energy levels (Supplementary Note 3). Oscillation in the echo intensity as a function of pulse duration, namely the Rabi oscillation, is clearly observed (Fig. 2a). Such experiments are conducted under various microwave magnetic field amplitudes B1 (B1 is proportional to the square root of the microwave power). Rabi frequency obtained by Fourier transformation of the oscillation signals shows a linear dependence on the microwave field amplitude B1 (Fig. 2b and c), confirming that the signal is indeed due to coherent electron spin oscillation rather than other phenomena such as cavity and nuclear modulation effects40. The observation of Rabi oscillation not only demonstrates the capability to rotate the spin qubits around one axis of the Bloch sphere41 but also helps determine the spin–flip time, namely the time length between adjacent minima and maxima in the Rabi oscillation signal. The spin–flip time and T2 together decide the quality factor of the system, Q, which is the number of qubit operations available before coherence is lost. With a spin–flip time of 16–60 ns that is achievable with our setup and a maximum T2 of 8.2 µs, a Q value on the order of a few hundred could be expected, which is already close to that required for fault-tolerant universal gate operations in such spin qubit systems42.

Fig. 2: Coherent manipulation of spin-qubits in SWCNTs.
figure 2

a Rabi oscillations of spin qubits measured using different microwave powers. b Fourier transformation of the nutation curves. Note that the shoulder at 15 MHz obtained at high powers is due to Hartman–Hahn effect from precessing 1H nucleus. c Rabi frequencies obtained at various microwave powers versus the relative amplitudes of the applied microwave field. The line is a linear fit to the data.

Decoherence mechanism and derivation of the intrinsic T 2

Encouraged by the long coherence times of the defect-induced spin qubits and their implication for coherent quantum control operations, we further sought to investigate the thermal limit of the system’s coherence time, the spin-lattice relaxation time, T1. Saturation recovery experiments, in which a series of picket-fence π/2-pulses are used to establish the equal distribution of the two spin states followed by subsequent polarization measurements after various delay times to monitor the gradual return of the spin toward the equilibrium (Supplementary Note 3), are carried out to measure the T1 values (Fig. 3a). The resultant saturation recovery traces are best fit by biexponential functions. For the representative trace in Fig. 3a, a fast component of 0.55 ms and a slow component of 13 ms can be obtained. Such biexponential decays have been observed before43,44, and it is commonly accepted that the fast component arises from deleterious effects such as spectral diffusion and solvent effects, while the slow component is representative of the spin-lattice relaxation process. We, therefore, adopt the same approach and assign the slow component to T1.

Fig. 3: Environmental nuclear spin baths of the localized electron spins in SWCNTs.
figure 3

a A representative saturation recovery trace of NO2Ph-SWCNTs dispersed in toluene (dots) together with a biexponential fit (curve). b CP-ESEEM spectrum of NO2Ph-SWCNTs dispersed in toluene. c HYSCORE spectrum of NO2Ph-SWCNTs dispersed in toluene. d Zoomed in view of the area marked in (c). Ax,y,z represent the hyperfine tensors. e Simulated HYSCORE spectrum of NO2Ph-SWCNTs using the experimentally obtained hyperfine tensors. f HYSCORE spectrum of NO2Ph-SWCNTs dispersed in deuterated toluene measured at 5 K.

The fact that T1 » T2 suggests that the microsecond-long T2 we have obtained is far below the upper limit imposed by spin–phonon coupling and signifies the potential for achieving even longer T2 in this system. Decoherence of an electron spin can be caused by hyperfine coupling with its nuclear spin bath and electron spin–spin interactions. Nuclear spin baths in the SWCNT/toluene system are simplified by virtue of the all-carbon backbones of SWCNTs, and they mainly consist of 13C from the nanotubes and 1H from toluene. To understand decoherence caused by the nuclear spin bath, we perform combination-peak electron spin echo envelope modulation (CP-ESEEM) measurements (Fig. 3b, see Supplementary Note 3 for pulse sequence), which reveal identities of the coupled nuclear spins and their hyperfine couplings. A strong peak centered at 7.5 MHz, which is the double frequency of the X-band Larmor frequency of 13C (ω(13C)/2π = 3.75 MHz), and a much weaker peak at twice of the Larmor frequency of 1H (ω(1H)/2π = 14.9 MHz), can be observed, suggesting couplings of the electron spins to 1H and 13C nuclei. More details about the nuclear spin environment are elucidated by hyperfine sublevel correlation (HYSCORE) spectroscopy (Fig. 3c), which shows signals consistent with couplings to 1H and 13C nuclei. The signal arising from coupling to 13C nuclei clearly consists of a pair of correlation ridges centered around the Larmor frequency of 13C (Fig. 3c and d), from which the hyperfine coupling tensor, A(13C), is estimated to be [0.3, 0.3, 2.1] MHz. The small isotropic coupling of aiso = 0.90 MHz corresponds to a negligible electron density on the 13C atoms and weak hyperfine coupling. The lack of apparent correlation ridges observed for the 1H nuclei implies their even weaker couplings to the electron spins. Using the hyperfine coupling tensors obtained from the HYSCORE measurements, simulation contours agreeing well with the experimental results can be obtained (Fig. 3e). It is peculiar to observe the 13C signal dominating over 1H, given the overwhelming abundance of 1H (99.98%) compared to 13C (1.11%) and the larger magnetic moment of 1H (2.8µN) than 13C (0.7µN). Provided negligible influence from the tau-suppression effect45, this intensity ratio between the 1H and 13C peaks observed in HYSCORE and CP-ESEEM suggests that the defect-induced spins on the SWCNTs are to some degree protected from 1H nuclear spins in the solvent, likely due to bundling of the SWCNTs. This conclusion is further consolidated by the similar coherence times obtained for SWCNTs dispersed in toluene and deuterated toluene (Supplementary Fig. 8) despite the smaller magnetic moment of 2H compared to 1H. Our TEM measurements of the samples also confirm the formation of SWCNT bundles (Supplementary Fig. 9).

Interestingly, SWCNTs with the two types of functional groups, namely NO2Ph-SWCNT and Cl2Ph-SWCNT, exhibit similar HYSCORE spectra (Fig. 3c and Supplementary Fig. 10), and no signal associated with the nuclear spins at the far ends of the functional groups such as 14,15N, 17O, and 35,37Cl is detected. Nuclear spins within a short distance (typically <1 nm) of an electron spin can exhibit coupling to the central electron spin and cause its decoherence32. Given the dimensions of the diazonium functional groups used in this study, the absence of signals from the 14,15N, 17O, and 35,37Cl nuclei on the functional groups (about 0.5–0.7 nm away from the closest C on the SWCNTs) suggests that the electron spins are primarily confined at the defect sites on the SWCNT sidewalls rather than on the functional groups (Fig. 1a), consistent with previous theoretical predictions31,46. This conclusion is also in agreement with the similar coherence times observed for the two types of SWCNTs.

To estimate the influence of this nuclear spin bath on the coherence times, we apply the cluster correlation expansion (CCE) method, which has been established to provide accurate spin dynamics in a variety of systems32,47, to simulate the decoherence dynamics of the electron spins in the SWCNTs (see the “Methods” section for details). The simulation predicts a T2 value of 128 ms at close to 0 K for an isolated electron spin in a SWCNT (Fig. 4g, see Supplementary Fig. 13 for statistics). This value only considers contributions from 13C in the functionalized SWCNT, and the 1H and 14N in the phenyl ring in the functional group. Immersing the electron spin in 1H and 2H nuclear spin baths provided by toluene and deuterated toluene reduces the T2 value drastically to 8.7 µs and 0.29 ms, respectively (Fig. 4e). For the bundled SWCNTs used in this study, bundling induced 13C spin bath is only supposed to shorten T2 to 1.3 ms (Fig. 4f, see Supplementary Fig. 13 for statistics), as a result of the smaller abundance and weaker magnetic moment of 13C compared to 1H. This finding is in stark contrast to the microsecond-long T2 value we obtained from Hahn echo measurements. We reach two major conclusions based on these simulation results: (i) shielding the electron spins from solvent nuclear spin baths has great potential in preserving their coherence and (ii) hyperfine coupling to the nuclear spin baths only partially accounts for the microsecond-long T2 value.

Fig. 4: Decoherence sources and simulation of T2.
figure 4

a, b Hahn echo decay curves (a) and saturation recovery traces (b) of NO2Ph-SWCNTs with various spin densities. The spin densities (spins/nm) are labeled next to the data. The dashed lines are stretched and biexponential fits. c Illustration of the decoherence mechanism in the SWCNT spin system. Inter-tube spin-spin interaction and hyperfine couplings to 13C and 1H are the main sources. d–g Simulated dynamics (dots) of a spin experiencing decoherence due to instantaneous diffusion (d) and hyperfine coupling to spin active nuclei including 1H, 2H, and 13C in the solvents (e) and 13C in the SWCNT bundles (f), as well as the simulated dynamics of an isolated spin in a single SWCNT without solvent or bundling (g) using the CCE method. The curves are stretched exponential fits.

To understand decoherence effects aside from hyperfine coupling, we continue to investigate the potential influence of electron spin–spin interactions. In this study, we have controlled the average distance between spins to be in the range of 12–45 nm to minimize intra-tube electron spin–spin interactions. As a result, the T1 and T2 values of the SWCNTs exhibit no apparent spin-density dependence for the samples used in this study (Fig. 4a and b, and Supplementary Table 1), confirming the negligible intra-tube spin–spin interactions. The small variations observed for the T1 and T2 values are most likely due to slight differences in the sample/measurement conditions. However, bundling in the samples may strengthen inter-tube electron spin–spin interactions through the so-called instantaneous diffusion (ID) phenomenon (see Supplementary Note 9 for a detailed explanation of ID)38,48. ID becomes dominant when the rotation of resonantly driven spins causes decoherence to each other due to the high local density of spins, in this case, electron spins in neighboring tubes in the same bundle. In principle, ID can be accounted for as an artifact due to the measurement process and suppressed by using small rotation angle pulses in the refocusing pulse during the Hahn echo measurements38. However, the limited overall amount of spins in our samples and the weakening of echo signals at small rotation angles render the direct measurement of the T2 values by suppressing the ID effect unfeasible. Nevertheless, we are able to estimate the ID time based on the experimental parameters. From the average size of the SWCNT bundles and the average defect densities (Supplementary Note 2 and Supplementary Fig. 9), we estimate the local spin concentrations to be around 5.0 × 1017–1.9 × 1018 spins/cm3 for the samples used in this study. Electron spin-echo decay signal solely caused by ID can be simulated following a previously reported method:48

$${V}_{{{\rm {ID}}}}\left(2\tau \right)={{{{{\rm{exp }}}}}}\left[-\frac{8{\pi }^{2}}{9\sqrt{3}}{g}^{2}{\beta }^{2}{{{\hslash }}}^{-1}C{\left\langle {{{{{{\rm{sin }}}}}}}^{2}\frac{\theta (\omega )}{2}\right\rangle }_{g(\omega )}\tau \right],$$

where β is the nuclear magneton, C is the local spin concentration, θ is the angle that spins with a resonance frequency ω are turned by the microwave pulses, \({\left\langle \ldots \right\rangle }_{g(\omega )}\) is the averaging over the ω frequency distribution, and \(\tau\) is the time interval between microwave pulses. Fitting of the simulated decay signal yields an ID time of 0.63–2.4 µs (Fig. 4d, left). This result is consistent with the experimentally obtained T2 values from the Hahn echo measurements. Taken together, although bundling in our SWCNT samples protects the electron spins from the nuclear spin bath imposed by the protiated solvent environment, it also leads to ID that results in five orders of magnitude reduction in the T2 value, as conceptualized in Fig. 4c.

Through further sample optimization by isolating SWCNTs using spin-free surfactants, T2 value of the electron spins can be extended to the millisecond scale, as evidenced by the 13 ms T1 value from the saturation recovery measurements and the 128 ms T2 value predicted by our theoretical simulations. Fabricating SWCNTs from isotopically purified 12C feedstock to eliminate hyperfine couplings3 may further prolong the T2 value to seconds22. However, the T1 and T2 values we obtained here are already encouragingly long, making them well-suited for quantum control operations. In addition, the confinement of the electron spins demonstrated here is defined by atomic structures rather than electrostatically defined potential wells, thus the probability of including 13C nuclei in the spin bath is reduced by nearly two orders of magnitude22,23. The flexibility in generating these confined electron spins also renders them highly compatible with device processing for future qubit manipulation and coupling to a variety of degrees of freedom10,11,49. This system also offers the versatility to use different chemical motifs to introduce and tune magnetic interactions for sophisticated quantum architecture designs1,50. For example, the introduction of heavy metal ions in the vicinity of the defects may provide means for introducing spin anisotropy46. Representing a powerful combination of both top-down fabrication and bottom-up molecular approaches, defect-induced spins in SWCNTs are poised to serve as highly reproducible and integratable alternatives for spintronic and quantum devices.


Preparation of sp 3-functionalized SWCNTs

(6,5)-enriched SWCNT samples (1 mg/mL) were obtained by dispersing raw powders (CoMoCAT SG65i, Sigma-Aldrich) in 1 wt% aqueous solutions of sodium dodecyl sulfate (SDS) by tip sonication for 1 h while being cooled in an ice bath. Impurities were removed by subsequent ultracentrifugation at 39,200×g for 2 h. The resultant supernatant was extracted for chemical functionalization. Two types of diazonium salts, 4-nitrobenzene diazonium tetrafluoroborate and 3,5-dichlorobenzene diazonium tetrafluoroborate (Sigma-Aldrich), were used to introduce sp3 quantum defects to SWCNTs27. Stock solutions of diazonium salts of various concentrations (2.1*10−6–8.0*10−6 M) were added to SWCNT solutions to achieve different doping levels. The reactions occurred at room temperature in the dark with stirring, and the reaction progresses were monitored by measuring the photoluminescence spectra of the solutions until desirable defect-to-pristine emission ratios were reached28. With the diazonium salt concentrations used in this study, the reactions typically take around 0.5–1 h to complete. The functionalized SWCNT solutions were filtered by vacuum filtration and washed with deionized water and isopropanol to remove excess surfactants and unreacted dopants. The purified SWCNTs were then dried overnight in a vacuum oven at 100 °C. To prepare samples for the pulsed EPR experiments, typically around 1.5 mg of the as-prepared SWCNT powders were dispersed in 1 mL toluene or deuterated toluene via bath sonication (Branson 2510R-DTH) for 1 h. Here, toluene is chosen to serve as a non-polar dispersing solvent to control the density of SWCNTs in the detection volume. In addition, toluene is used as the glassing agent to ensure that SWCNTs were well-separated and randomly oriented. Around 100 µL of the dispersion was then added into an EPR tube and cooled immediately to 5 K for detailed measurements.

X-band pulsed electron paramagnetic resonance (EPR) spectroscopy measurements

All pulsed EPR data were acquired at X-band on a Bruker ELEXSYS-E580 FT/CW EPR spectrometer equipped with a pulsed EPR/ENDOR resonator (EN 4118 X-MD4W) and a 1 kW traveling wave tube amplifier (Applied Systems Engineering 117X). The temperature was controlled by a helium cryostat (Oxford Instruments CF935O) and a temperature controller (Oxford Instruments MercuryiTC). See more experimental details in Supplementary Note 3.

Theoretical modeling

The HYSCORE spectra were simulated using Easyspin51 by employing the Hamiltonian \(\hat{H}=g{\mu }_{{{{{{\rm{B}}}}}}}{{{{{\boldsymbol{HS}}}}}}-{g}_{{\rm {N}}}{\mu }_{{\rm {N}}}{{{{{\boldsymbol{HI}}}}}}+{{{{{\boldsymbol{IAS}}}}}}\), where H is the magnetic field, S is the electron spin, I is the nuclear spin, and A is the axial hyperfine coupling tensor. By comparing the simulated HYSCORE spectra with those from experimental measurements, we can roughly estimate the hyperfine coupling tensor.

To calculate spin dynamics, the SWCNT/toluene system was modeled as a periodically repeating box of size 70.00 × 70.00 × 40.45 Å3 containing a unit-cell length of 4-nitrophenyl functionalized (6,5) SWCNT with 1200 toluene molecules. The solvent molecules were placed in the box with the program PACKMOL52. The electron spin confined at the sp3 defect site was modeled as a central spin interacting with a nuclear spin bath via hyperfine interactions. The total spin Hamiltonian included a single spin, spin–bath, and bath component. Given the spin total Hamiltonian, the time-evolution operator for the spin–bath density matrix was calculated using the pyCCE code47. Briefly, the spin correlation function (\({{{{{\mathscr{L}}}}}}\)) was given by the off-diagonal element of the density matrix (ρ): \({{{{{\mathscr{L}}}}}}\left(t\right)=\frac{{{\rm {tr}}}\left[{{{{{{\rm{\rho }}}}}}}_{{{\rm {tot}}}}\left(t\right){S}_{+}\right]}{{{\rm {tr}}}\left[{{{{{{\rm{\rho }}}}}}}_{{{\rm {tot}}}}\left(0\right){S}_{+}\right]}\), from which the decoherence time T2 can be derived. The cluster correlation expansion method53,54 was used to reduce the size of the spin Hilbert space allowing for a large spin bath to be coupled with the central spin. Spin-active nuclei including 1% 13C, 99.6% 14N, 99.99% 1H according to natural isotope abundance while deuterated toluene molecules including 99% 2H and 1% 1H were considered. All spin-active nuclei were assumed to interact with the magnetic field (nuclear Zeeman interactions), the electric field gradient (nuclear electric-quadrupole couplings), and other nuclear spins through dipole–dipole interactions. For nuclei with spin > ½, the quadrupole tensor was calculated using the density functional theory within the Perdew–Burke–Ernzerhof (PBE) approximation to exchange-correlation55 using the GIPAW module and the Quantum espresso code56. The hyperfine interactions were approximated as point-dipole interactions. Due to the low abundance of 13C and variations in their distances to the functional site, an ensemble of spin baths was considered with 130 (134) 13C spin baths for bundled SWCNTs (isolated individual SWCNTs in vacuum) (see Supplementary Fig. 13 for statistics). We obtain average T2 values of 1.23 ms and 167 ms for bundled SWCNTs and isolated individual SWCNTs in a vacuum, respectively. Spin correlation functions of representative spin baths are shown in Fig. 4f and 4g.