Manuscript Offprint
arXiv:2610.39687Transformer-inspired architectures make machine-learned electron densities accurate and transferable enough to bypass self-consistency
Abstract
We introduce machine learning models that accurately predict the electron density, the central variable of density functional theory. They are built on Transformer-inspired architectures, which require little computation per parameter and can therefore be enlarged at low cost. The proposed models, SwinUNETR-V2 and its attention-free counterpart NeXtUNETR, achieve state-of-the-art accuracy on QM9, with normalized mean absolute errors in the density averaging 0.075% and 0.046%, respectively. The predicted densities are accurate enough to bypass the self-consistent iteration: a single Kohn–Sham step reproduces the self-consistent electronic structure. For NeXtUNETR, the median errors are 0.036 meV in the total energy, 0.65 meV Å in the forces and 1.8 meV in the HOMO–LUMO gap. The forces not only recover the self-consistent minima in geometry optimization but also successfully drive ab initio molecular dynamics. Fine-tuned on small datasets, both networks also transfer accurately to systems containing elements absent from QM9 or larger than its molecules.
Kohn–Sham density functional theory is the most widely used electronic-structure method in chemistry and materials science, and the electron density is its central variable: it determines all ground-state properties , and the Kohn–Sham Hamiltonian is built from it. Finding the density is the costly part: the self-consistent-field (SCF) iteration diagonalizes a Hamiltonian built from a trial density and updates the density until the input and output densities agree. Because this iteration is repeated at every step of quantum-chemical simulations such as geometry optimization and molecular dynamics, it dominates their cost. Machine learning offers two ways around it. Machine-learned interatomic potentials (MLIPs) avoid the electronic problem by mapping atomic positions directly to energies and forces , and foundation models now span most of the periodic table , but they return no electronic structure. Learning the density , or the density matrix or Hamiltonian , retains it: from a predicted density, a single Kohn–Sham step returns energies, forces and orbitals together, and their quality is set by that of the density.
The density at a point is determined mainly by the atoms nearby, a property known as the nearsightedness of electronic matter , so a model can learn it from local environments and apply it to larger systems. A useful model must be accurate, because density errors propagate into every derived property, and transferable, because a model trained on small molecules must also serve larger, charged or differently composed systems. Most density models describe a molecule by its atoms: kernel methods and graph neural networks, mostly rotationally equivariant, expand the density in atom-centered or floating basis functions or predict it point by point . Others work on the real-space grid of the calculation, where the density forms a three-dimensional image, and refine a superposition of atomic densities (SAD), alone or together with grid-projected atomic fingerprints , with convolutional neural networks (CNNs). Li et al. cast this refinement as image super-resolution : their residual network (here SR-ResNet), trained on QM9 (ref. 18), was more accurate than earlier models and transferred to unseen geometries and elements after fine-tuning on small datasets.
If density prediction is an imaging problem, advances in computer vision may carry over to it. The Transformer , developed for natural language processing, was applied to images by the Vision Transformer , and hierarchical variants such as the Swin Transformer , with self-attention in local windows and a hierarchy of resolutions, reach or exceed the accuracy of CNNs such as ResNet on major vision benchmarks. In three dimensions, SwinUNETR and SwinUNETR-V2 (refs. 23,24) are widely used for volumetric medical image segmentation, where the convolutional 3D U-Net had long been the standard. Transformers have also reshaped CNNs: ConvNeXt reached the accuracy of Swin by adopting its macro-design, with large-kernel depthwise convolutions in place of attention, and 3D UX-Net and MedNeXt carried this design to volumetric images . We call both kinds of networks Transformer-inspired: they share the hierarchical macro-design and block recipe of the Swin Transformer, with or without attention. To our knowledge, density refinement on real-space grids treated as images has so far used only CNNs , and whether Transformer-inspired architectures make densities more accurate and transferable has not been tested.
An accurate density can replace the SCF iteration altogether. The Kohn–Sham Hamiltonian built from the predicted density is diagonalized once, and this single Kohn–Sham step gives the orbitals, a new density and the energy. Because the Kohn–Sham energy is stationary at the self-consistent density, the error of this one-step energy is second order in the density error . Forces need more care. The predicted density is not exactly self-consistent, so, as for other non-self-consistent energies , the exact gradient of the one-step energy retains a term, omitted by standard Kohn–Sham forces, from the response of the density to the nuclear positions. For a learned density, the response must be propagated through the network; we call the added term the non-self-consistency correction (NSCC). Non-self-consistent properties of learned densities have so far been tested on fixed structures , and SCF-free dynamics has used system-specific models of the density or density matrix . Whether a transferable density model makes one Kohn–Sham step accurate enough for geometry optimization and energy-conserving molecular dynamics has remained open.
Here we show that Transformer-inspired architectures make learned densities accurate and transferable enough to bypass the SCF iteration. We adapt two U-shaped networks to refine the SAD guess: SwinUNETR-V2, with windowed self-attention, and NeXtUNETR, an attention-free counterpart with the same hierarchical design. Trained on QM9, they reach normalized mean absolute errors (NMAEs) in the density averaging 0.075% and 0.046%, respectively, below those of any published model trained on the same data. At equal training data, NeXtUNETR is the most accurate network at every size tested, and in the same U-shaped network, ConvNeXt blocks are markedly more accurate than Swin blocks. One Kohn–Sham step from the NeXtUNETR densities gives median errors of 0.036 meV in the total energy and 0.65 meV Å in the forces, and both networks give frontier orbital energies within a few meV. With or without the NSCC, the forces relax 200 molecules from nearby starting structures, 97–98.5% of them to within 0.1 Å of the SCF minima. The NSCC, which also lowers the force error for most molecules, makes molecular dynamics energy-conserving for a molecule with more heavy atoms than any training molecule. Both networks also transfer: without fine-tuning, SwinUNETR-V2 is the most accurate model on a Guess density
Network
Predicted density
One-step Kohn–Sham
Properties

on a 3D grid
U-shaped encoder-decoder
no SCF loop
one diagonalization
b

C
d
Fig. 1 | One-step Kohn–Sham calculation from predicted densities, and the architectures compared. a, Schematic workflow. A U-shaped network refines the superposition of atomic densities (SAD) on the real-space grid (left) into the predicted density . Its encoder blocks mix features within -voxel regions (enlarged): SwinUNETR-V2 by windowed attention, NeXtUNETR by a depthwise convolution. One diagonalization of the Kohn–Sham Hamiltonian , without a self-consistent-field (SCF) loop, gives the energy, forces and orbital energies (right: the one-step energy surface). b, Density NMAE against parameter count for three families trained on the same 8,000 QM9 molecules (QM9-subset-8k). c, Floating-point operations per molecule against parameter count. d, Density NMAE against network forward time per molecule (one NVIDIA H200 NVL, batch size 1, fp32). b–d, Means over 500 randomly sampled QM9 test molecules; one training run per model; labels give the parameter count; counting and timing in Methods. Extended Data Fig. 1 shows the details of the architectures.
charged fragments with unseen elements and on water clusters, and fine-tuned on about a hundred structures, both outperform SR-ResNet on these fragments. Architectural advances made for images thus carry over to electronic structure.
Results
Both networks are U-shaped encoder-decoders that process the grid at its input resolution and five successively halved ones (Extended Data Fig. 1). SwinUNETR-V2 (ref. 24) mixes information within -voxel windows by self-attention, whose weights depend on the input; NeXtUNETR mixes a neighborhood of the same size by a depthwise convolution , whose weights are fixed after training. The baseline is the SR-ResNet of Li et al. .
All densities are Perdew–Burke–Ernzerhof (PBE) valence densities (Methods). We measure the error of a density by its NMAE over the grid, in percent of the electron count (Methods). The energy error is per molecule, and the force error is the absolute error of a Cartesian force component, summarized by its mean or median over all components.
Architecture comparison at equal training data
We trained ten models of the three families on the same 8,000 QM9 molecules (QM9-subset-8k) and evaluated them on 500 molecules randomly sampled from the QM9 test split (Fig. 1b–d). The U-shaped networks were enlarged through the channel width C, the number of feature channels in the first encoder stage, which sets the widths of all later stages; SR-ResNet was enlarged in width and depth. NeXtUNETR is the most accurate family at every size. Its smallest model, with 17 million parameters and an NMAE of 0.187%, is more accurate than every SwinUNETR-V2 model (best 0.204%, 292 million parameters) and the largest SR-ResNet (0.198%, 70 million). At the same channel width, C = 96, NeXtUNETR-67M reaches 0.133% against 0.204% for SwinUNETR-V2-292M, with a quarter of the parameters and one-eleventh of the floating-point operations.
In every family, the floating-point operations grow in proportion to the parameter count (Fig. 1c), but the operations per parameter differ: 7–9 GFLOPs per million parameters for NeXtUNETR, 19–22 for SwinUNETR-V2 and 285 for SR-ResNet, because the U-shaped networks place most of their parameters on coarse grids, whereas SR-ResNet runs all its residual blocks at half resolution. The U-shaped networks can therefore be enlarged at little computational cost, and the added capacity makes them more accurate: in both families the NMAE falls with model size until it levels off at 150–300 million parameters (Fig. 1b).
In ablations (Extended Data Table 1), the encoder block makes a large difference. With Swin Transformer blocks in place of the ConvNeXt blocks of its encoder, NeXtUNETR's NMAE rises from 0.133 to 0.250%. The two blocks have the same feed-forward layers and differ chiefly in how they mix space, by windowed attention or by depthwise convolution, and in their normalization (layer or group). Removing the convolutional residual blocks on the downsampled skips and in the bottleneck, which SwinUNETR-V2 inherits from SwinUNETR , nearly halves its parameter count, from 292 to 154 million, but raises the NMAE only from 0.204 to 0.209%.
For the remaining results, SwinUNETR-V2 and NeXtUNETR were trained on the full QM9 training set (123,835 molecules) in the SwinUNETR-V2-292M and NeXtUNETR-67M configurations, which share C = 96. SR-ResNet is Li et al.'s published 9-million-parameter QM9 model.
Densities, energies and orbitals on QM9
On the 10,000 QM9 test molecules, the three models reduce the mean NMAE of the SAD guess, 13.9%, to 0.138% for SR-ResNet, 0.075% for SwinUNETR-V2 and 0.046% for NeXtUNETR (Table 1). The last two are 46% and 67% below that of SR-ResNet and below the 0.116% reported for BOA, an equivariant basis-function network trained on the same densities and split . The ranking of the three models holds for almost every molecule.
One diagonalization brings the density closer to the self-consistent one, lowering the mean NMAE
Table 1 | Accuracy on the QM9 test set. Density NMAE of the predicted density and of the density after one Kohn–Sham step, and errors of the one-step energies and forces (HOMO, LUMO and gap: absolute errors of the highest occupied and lowest unoccupied molecular orbital (HOMO and LUMO) energies and of the gap). For the SAD guess and the three models evaluated here, mean and median over the 10,000 test molecules (: over 539,613 force components); in parentheses, the mean without the two molecules with a reference HOMO–LUMO gap below 1 eV. For the other models, mean errors as reported. Best value in bold.
| Model | Density NMAE (%) | One-step energies (meV) | One-step forces (meV Å) | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Predicted | One step | HOMO | LUMO | gap | w/o NSCC | w/ NSCC | |||
| SAD guess (input) | mean | 13.9 | - | - | - | - | - | - | |
| median | 14.0 | - | - | - | - | - | - | ||
| Previous work | |||||||||
| eqDeepDFT (ref. 13) | mean | - | - | - | - | - | - | ||
| ELECTRA (ref. 16) | mean | - | - | - | - | - | - | ||
| BOA (ref. 37) | mean | ; | - | - | - | - | - | - | |
| SR-ResNet (ref. 8) | mean | 0.138 | 0.058 | 2.84 (1.03) | 11.7 | 9.4 | 10.7 | 11.87 (11.63) | 17.05 (8.68) |
| median | 0.129 | 0.050 | 0.52 | 9.2 | 6.4 | 7.1 | 5.54 | 3.37 | |
| This work | |||||||||
| SwinUNETR-V2 | mean | 0.075 | 0.030 | 0.90 (0.26) | 6.1 | 4.5 | 5.7 | 6.21 (6.04) | 10.12 (4.36) |
| median | 0.070 | 0.026 | 0.14 | 4.8 | 3.0 | 3.7 | 2.93 | 2.37 | |
| NeXtUNETR | mean | 0.046 | 0.015 | 0.42 (0.087) | 2.8 | 2.2 | 2.9 | 3.21 (3.09) | 4.46 (1.63) |
| median | 0.043 | 0.013 | 0.036 | 2.1 | 1.4 | 1.8 | 1.45 | 0.65 | |
QM9 56343 (0.38 eV) and 37992 (0.03 eV); without them, the other means change by at most 0.06 meV and 0.001 percentage points.
Trained and tested on VASP-computed densities of QM9 molecules, with splits of the same sizes; not directly comparable. BOA: 0.116% on the densities used here, 0.134% on QM9-VASP. eqDeepDFT: the equivariant version of DeepDFT.
Li et al.'s published QM9 model, re-evaluated with the one-step code used for our models (Methods).
SR-ResNet SwinUNETR-V2 NeXtUNETR
a
b

c

d
e

QM9 85492, , 17 atoms
Optimization from an MMFF94 start
f

Fig. 2 | Accuracy on QM9 and geometry optimization on the one-step surface. a, Cumulative distribution of the density NMAE over the 10,000 QM9 test molecules; solid, predicted density ; dashed, density after the one-step diagonalization. b, Same for the one-step energy error . c, Same for the force error per Cartesian component; solid, with the non-self-consistency correction (w/ NSCC); dashed, without it (w/o NSCC). At most 4 molecules (b) and 110 components (c) per model lie beyond the axes, for SwinUNETR-V2 and NeXtUNETR almost all from the two molecules with a reference HOMO–LUMO gap below 1 eV. d, QM9 85492 ( ), drawn at random from the molecules that every model optimizes to within 0.01 Å of the reference optimum (four more in Supplementary Fig. 1). e,f, Its optimization from an MMFF94 starting structure on the SCF and one-step surfaces, w/ and w/o NSCC: energy relative to each surface’s optimum (e; symmetric logarithmic axis) and maximum force (f; dotted, the convergence criterion). Extended Data Table 2 summarizes all 200 molecules.
by a factor of 2.4–3.0 for all three models (Fig. 2a, dashed). The energy error is second order in the density error, so the differences between models widen (Fig. 2b). The median is 0.52 meV for SR-ResNet, 0.14 meV for SwinUNETR-V2 and 0.036 meV for NeXtUNETR; the last two are 2.5–3 orders of magnitude below the 1 kcal mol (43 meV) threshold usually called chemical accuracy. NeXtUNETR's mean errors in the highest occupied and lowest unoccupied molecular orbital (HOMO and LUMO) energies and in the HOMO–LUMO gap are 2.8, 2.2 and 2.9 meV, about a quarter of SR-ResNet's; its median gap error is 1.8 meV.
The two molecules with reference HOMO–LUMO gaps below 1 eV, 0.38 and 0.03 eV, dominate the mean energy errors and the mean force errors with the NSCC. For them, one diagonalization can occupy the wrong orbitals, giving energy errors of 0.3–18 eV. Table 1 therefore also gives the means without them, and Extended Data Fig. 2 excludes them.
One-step forces
With the NSCC, the median absolute errors of the force components are 3.37 meV Å⁻¹ for SR-ResNet, 2.37 meV Å⁻¹ for SwinUNETR-V2 and 0.65 meV Å⁻¹ for NeXtUNETR (Fig. 2c and Table 1). The median absolute reference component is 90 meV Å⁻¹. Without the NSCC, the medians of the same three models are 5.54, 2.93 and 1.45 meV Å⁻¹. The NSCC lowers the per-molecule mean absolute error of the forces for 88% of the molecules with SR-ResNet, 86% with SwinUNETR-V2 and 97% with NeXtUNETR.
The mean over all molecules is nevertheless larger with the NSCC, because the correction amplifies the errors of the two small-gap molecules. Without them, the mean is smaller with the NSCC for every model (Table 1). The NSCC, which makes the force the exact gradient of the one-step energy, thus also brings it closer to the SCF force for most molecules.
Geometry optimization
To test whether the one-step surfaces place their minima where the SCF surface does, we optimized 200 QM9 test molecules drawn at random (Methods). Each molecule was optimized on the SCF surface and on the one-step surfaces of both networks, w/ and w/o NSCC, and of the SAD guess as a control (Fig. 2d–f, Extended Data Table 2). All runs used geomeTRIC with the same criteria and started from an MMFF94 (ref. 40) relaxation of the reference optimum.
All optimizations with SwinUNETR-V2 and NeXtUNETR, w/ and w/o NSCC, converged in a median of 15.5–16 steps, as on the SCF surface (15.5). The final structures lie a median of 0.002–0.005 Å from the optimum the reference reaches from the same start, and 97–98.5% lie within 0.1 Å, against 42.5% of the starting structures. The runs shown also follow the reference step by step (Fig. 2e,f and Supplementary Fig. 1). QM9 contains only equilibrium structures, but every optimization starts from a distorted one; the agreement along the paths indicates that the predicted densities, and the energies and forces derived from them, remain accurate away from equilibrium.
Without a network, optimization fails: on the SAD surface the runs end, in the median, farther from the reference optimum than they started (w/ NSCC) or do not converge (w/o NSCC) (Extended Data Table 2). The one-step surfaces of the networks thus place their minima where the SCF surface does and are as easy to optimize on. This agreement comes from the accuracy of the predicted density, and near minima it does not depend on the NSCC.
Molecular dynamics
Molecular dynamics probes the one-step surface farther from its minima. We ran 1 ps of constant-energy (NVE) dynamics of alanine dipeptide from four conformational basins, C7eq, C5, C7ax and L (Fig. 3), with forces from the SCF reference or from the one-step calculation with the NSCC. With 10 heavy atoms, the dipeptide has more than any QM9 molecule, and near room temperature it samples distorted structures unlike any in QM9.
The models reproduce the energy landscape and the motion on it. On the map, the relative one-step energies deviate from the SCF ones by 1.5 meV for SwinUNETR-V2 and 1.3 meV for NeXtUNETR on average within 1 eV of the minimum (Fig. 3a). As in the reference, the trajectories from C7eq, C5 and C7ax stay in their basins, and those from L leave it in the same direction; individual trajectories are not expected to coincide, because nearby ones diverge.

Reference (SCF)
SwinUNETR-V2 – reference
NeXtUNETR – reference
b
NeXtUNETR w/ NSCC
c
d

Wavenumber (cm )

Time (fs)
Time (fs)
Fig. 3 | Molecular dynamics with one-step forces. 1 ps NVE trajectories of alanine dipeptide from four basins (C7eq, C5, C7ax, αL), with forces from the SCF reference or from one Kohn–Sham step on the SwinUNETR-V2 or NeXtUNETR density, w/ NSCC; all runs from a basin share their initial velocities (Methods). a, Left: backbone dihedrals φ (C′–N–Cα–C) and ψ (N–Cα–C–N′). Middle: the reference trajectories on the SCF (φ, ψ) energy map (contours at 0.15, 0.3, 0.5 and 0.75 eV); stars, starting structures. Right: error of each model’s map (model – SCF, each relative to its own minimum; color scale saturates at ±5 meV) with that model’s trajectories and the 0.3 and 0.75 eV SCF contours; hatched, more than 1 eV above the reference minimum. b, Vibrational density of states (VDOS) of the C7eq trajectories (reference in gray). c,d, Error of the one-step energy (c) and forces (d; mean absolute error over force components) on the frames of the C7eq reference trajectory; light lines, every frame; dark lines, 25 fs running means. Extended Data Fig. 3 shows energy conservation and the dynamics w/o NSCC.
The vibrational density of states (VDOS), which reflects the curvature of the surface along the trajectory, has the same bands for both models as for the reference (Fig. 3b); the amide I and amide II band centroids lie within 9 cm of the reference in all four trajectories, below the 33 cm resolution of a 1 ps trajectory.
Along the reference C7eq trajectory, the one-step energies of SwinUNETR-V2 and NeXtUNETR are offset from the SCF energy by +17.3 and +8.9 meV on average (Fig. 3c), and their force errors, 38.7 and 19.7 meV Å , do not grow with time (Fig. 3d). The errors exceed those on QM9, as expected for distorted structures, and NeXtUNETR's are about half of SwinUNETR-V2's in all four trajectories.
With the NSCC, the models conserve energy nearly as well as the reference: the standard deviation of the total energy is 0.06–0.10 meV atom , against 0.05–0.07 meV atom (Extended Data Fig. 3). Without the NSCC, the deviation is 20–70 times larger, and the systems heat by 24–97 K. Energy conservation shows that the forces are consistent with the one-step energy, and the small energy errors show that this energy stays close to the SCF energy: one Kohn–Sham step can replace the SCF calculation in molecular dynamics of this molecule outside the training distribution.
Transfer beyond QM9
We tested transfer on four test sets (Table 2), three from Li et al. and one new: thermally distorted isomers from molecular dynamics; charged biomolecular fragments containing phosphorus and magnesium, both absent from QM9 (the MT set); water clusters of 30 molecules (W1500/30), three times larger than the largest QM9 molecule; and donor–bridge–acceptor (D–B–A) chains, in which an electron donor and an acceptor at the two ends polarize the density along a saturated or conjugated bridge. The test chains have longer bridges than any training chain, so this set tests extrapolation to longer molecules. Following Li et al., each model was applied directly (zero-shot), fine-tuned on a small target set and trained from scratch on that set.
After fine-tuning, SwinUNETR-V2 and NeXtUNETR are more accurate than SR-ResNet on all four test sets, by up to a factor of 2.0 on the D–B–A chains (0.075 against 0.149%). NeXtUNETR is the most accurate on C₇O₂H₁₀ and D–B–A, and the two are within 6% of each other on MT and W1500/30. Trained from scratch, SwinUNETR-V2 is the most accurate model on every test set.
Without fine-tuning, the most accurate model depends on the test set: SwinUNETR-V2 on MT and W1500/30, NeXtUNETR on D–B–A and SR-ResNet on C₇O₂H₁₀. NeXtUNETR, the most accurate model on QM9, is the least accurate zero-shot on MT. Fine-tuning removes most of the differences between the two networks. Pretrained on QM9, SwinUNETR-V2 and NeXtUNETR adapt to new systems from 110–353 structures better than SR-ResNet and extrapolate to longer D–B–A bridges; trained from scratch on the same sets, every model is far less accurate.
Size transfer to water clusters
To test zero-shot transfer in size, we built Wmin-PBE/3–100, a set of 53 water clusters of 3–100 molecules (Fig. 4). Up to 30 molecules, they are the putative global minima of the WDBase database ; larger ones were grown from the 30-molecule minimum one water at a time with the TIP4P model , and all were relaxed with PBE (Methods). The largest has 300 atoms, ten times as many as the largest QM9 molecule. SwinUNETR-V2's NMAE is nearly independent of size,
Table 2 | Transfer beyond QM9. Density NMAE (%) of the QM9 models applied directly (zero-shot) and after fine-tuning on the target training set, and of the same architectures trained from scratch on that set. One training run per fine-tuned or from-scratch entry (protocols in Methods). Best value per row in bold.
| Test set | Training | SR-ResNet | SwinUNETR-V2 | NeXtUNETR |
|---|---|---|---|---|
| zero-shot | 0.662 | 0.853 | 0.809 | |
| fine-tuned | 0.244 | 0.228 | 0.167 | |
| from scratch | 1.885 | 1.064 | 1.706 | |
| zero-shot | 2.168 | 1.518 | 3.501 | |
| fine-tuned | 0.339 | 0.214 | 0.203 | |
| from scratch | 3.478 | 0.993 | 1.931 | |
| zero-shot | 0.723 | 0.432 | 0.637 | |
| fine-tuned | 0.127 | 0.088 | 0.089 | |
| from scratch | 1.283 | 0.403 | 0.981 | |
| zero-shot | 0.299 | 0.356 | 0.250 | |
| fine-tuned | 0.149 | 0.093 | 0.075 | |
| from scratch | 0.725 | 0.540 | 0.860 |
Ab initio molecular dynamics snapshots of 113 isomers; 4,520 test and 226 training structures.
Charged biomolecular fragments containing P and Mg; 110 test and 110 training structures.
The three 30-molecule clusters of W1500 (WDBase minima); trained on 3–13-molecule clusters (226 structures).
Donor–bridge–acceptor molecules; 144 test (C10, C12 bridges) and 353 training structures (C2–C8 bridges).

Fig. 4 | Zero-shot transfer to water clusters far larger than any training molecule. Density NMAE on Wmin-PBE/3–100 (log–log axes), 53 PBE-optimized water clusters: one of each size from 3 to 50 molecules and clusters of 60, 70, 80, 90 and 100 molecules, up to 300 atoms (right: the 100-molecule cluster, with hydrogen bonds dotted). None of the models was trained on water. Solid lines, models trained on the full QM9 training set; dashed lines, the same architectures trained on QM9-subset-8k (SwinUNETR-V2-292M, NeXtUNETR-67M and SR-ResNet-9M of Fig. 1).
0.50–0.59% in each size band (3–10, 11–30, 31–50 and 60–100 molecules), whereas SR-ResNet's rises from 0.72 to 1.10%. NeXtUNETR is the most accurate on the smallest clusters, 0.46% for 3–10 molecules, but degrades beyond about 30 molecules, reaching 2.6% for 60–100 molecules.
This degradation does not appear to be intrinsic to the architecture. Trained on QM9-subset-8k, NeXtUNETR and SwinUNETR-V2 both have nearly flat errors, 0.68 and 0.69% over all clusters, whereas SR-ResNet degrades to 3.4% at 100 molecules (Fig. 4, dashed). During NeXtUNETR's full-QM9 training, the NMAE on 60–100-molecule clusters fell to 0.68% after 20 epochs and then rose to 2.6% by the end of training, while that on small clusters fell to 0.46% (Extended Data Fig. 4). As its accuracy on QM9 improves, NeXtUNETR thus appears to specialize to the molecular sizes of QM9.
Discussion
Transformer-inspired hierarchical networks predict electron densities accurately enough that a single Kohn–Sham step reproduces the self-consistent electronic structure, from the total energy and forces to the orbital energies. The one-step forces recover the SCF minima in geometry optimization and drive energy-conserving molecular dynamics of a molecule with more heavy atoms than any training molecule. On QM9, NeXtUNETR outperforms SwinUNETR-V2 at lower cost. Two features of the design matter. The Transformer-style hierarchy, which starts at half resolution and holds most parameters on coarse grids, keeps the cost per parameter low. The block design determines how well the parameters are used: in the same U-shaped network, with the same feedforward layers, ConvNeXt blocks outperform Swin blocks that mix a neighborhood by attention (NMAE 0.133 against 0.250%). In computer vision, too, much of the advantage of Transformers comes from their macro-design and block recipe rather than from self-attention itself . Attention may still help away from the training distribution, where SwinUNETR-V2 transfers best without fine-tuning to the charged fragments and the water clusters, but the size transfer of NeXtUNETR changes with its training (Extended Data Fig. 4), so single training runs cannot settle this.
The NSCC makes one-step forces usable for dynamics and lowers their error for most molecules. Minima are found equally well without it, but the uncorrected force is not the gradient of the one-step energy, and trajectories heat up. The NSCC costs one network backward pass per force evaluation.
A one-step evaluation costs far more than an MLIP evaluation, so this route complements MLIPs rather than replacing them. In exchange, it keeps the Kohn–Sham Hamiltonian: orbital energies, the density and the properties derived from them come with the energy and forces, from one model trained only on densities. Unlike an SCF calculation, it has a fixed cost and is differentiable end to end. One-step surfaces could generate or check training data for MLIPs, or drive simulations that need electronic properties along the trajectory.
The study has limitations. Each model was trained once per condition, so differences of a few percent may lie within seed variation, and each molecular dynamics condition was run once, for 1 ps. One diagonalization can fail for near-degenerate frontier orbitals, as in two of the 10,000 QM9 molecules. All calculations used closed-shell PBE valence densities with pseudopotentials for molecules in periodic cells. Training on off-equilibrium structures and applying the approach to extended systems and other functionals are the next steps.
Methods
Reference densities
All densities are valence densities from Kohn–Sham density functional theory with the PBE functional , computed with PySCF in the Gaussian-and-plane-wave (GPW) scheme : Goedecker–Teter–Hutter (GTH) pseudopotentials with PBE parameters , GTH-TZV2P basis sets and a plane-wave cutoff of 200 Ha (400 Ry) for the density. Valence electron counts are H 1, C 4, N 5, O 6, F 7, P 5 and Mg 10. Each molecule is placed with the centroid of its atoms at the center of an orthorhombic periodic cell whose edges are its extent along each axis plus 4 Å, rounded up to an even number of grid intervals. The Hartree potential is evaluated by fast Fourier transform with the G = 0 term omitted, and no Coulomb truncation is applied. The self-consistent field (SCF) is converged to Ha. The density is stored on the real-space grid of the calculation, whose spacing, bohr (0.083 Å), resolves plane waves up to the 200 Ha cutoff.
QM9 (ref. 18) densities are those of Li et al. , computed with this protocol on the B3LYP geometries of QM9, with their training, validation and test split of 123,835, 50 and 10,000 molecules (the split sizes of DeepDFT ). The C O H and MT densities are also theirs; the MT labels use Fermi–Dirac smearing of 0.01 Ha and an SCF tolerance of Ha. We computed all other densities with PySCF 2.6.2 and a reimplementation of their generator, with the same settings, cell rule and grid; because PySCF 2.6.2 rounds the number of grid points per axis to an odd value, the grid size is fixed to the even value their version (PySCF 2.0.1) produces.
Input density
The input to every network is a superposition of atomic densities (SAD) sampled on the grid of the reference density, generated with PySCF 2.6.2 by a reimplementation of Li et al.'s procedure . For each element, a free-atom density matrix is obtained in the minimal GTH-SZV basis from the one-electron Hamiltonian with the pseudopotential and spherically averaged occupations, and projected onto GTH-TZV2P. The atomic blocks are assembled into a block-diagonal density matrix, scaled to N valence electrons, evaluated on the grid and renormalized to N on the grid. For geometry optimization and molecular dynamics, the same density is built as a structure-factor sum, , of element densities precomputed in reciprocal space (G is a reciprocal-lattice vector and the element of atom A), which makes it differentiable with respect to the nuclear positions by automatic differentiation.
Network architectures
Output. Both networks predict a correction to the SAD density. The input is centered in a zero-padded grid of the next multiple of 32 voxels (at least 64) along each axis, passed through the backbone and a convolution head , and added back: , cropped to the original grid. The output is rescaled to the number of valence electrons, , where is the voxel volume. The ReLU makes the density non-negative and the rescaling conserves the electron count exactly (Extended Data Fig. 1a).
SwinUNETR-V2. We used the MONAI implementation of SwinUNETR-V2 (ref. 24). A patch embedding maps the input to feature size C at half resolution; four encoder stages follow, each opened by a residual block of two convolutions (the V2 addition) and built from Swin Transformer blocks that apply multi-head self-attention within -voxel windows, shifted by 3 voxels in alternate blocks. Patch merging after each stage halves the resolution and doubles the channels, giving channels down to 1/32 of the input resolution. The stage depths are (5, 4, 2, 2), with (3, 6, 12, 24) attention heads; the depths were chosen in a preliminary search. As in MONAI's implementation of SwinUNETR , the skip connections carry the input, the patch-embedded input and the outputs of the first three stages, and the stage-4 output feeds the bottleneck; all but the input are first layer-normalized without learned parameters. The input, the patch-embedded input and the outputs of the first two stages then pass through such residual blocks; the stage-3 output, at 1/16 resolution, enters the decoder without one, and the stage-4 output passes through one as the bottleneck. The decoder upsamples by transposed convolution, concatenates the skip features and applies a residual block, and a final convolution maps its C output channels to the single channel passed to h. Where a residual block changes the channel count, its shortcut is a convolution with group normalization. The convolutional blocks use group normalization with C/3 groups instead of MONAI's default instance normalization.
NeXtUNETR. NeXtUNETR keeps the macro-design of SwinUNETR-V2 — a patchify stem to half resolution, four stages of depths (5, 4, 2, 2) with channels and a 16C bottleneck at 1/32 resolution — and replaces each Swin block by a three-dimensional ConvNeXt block : a depthwise convolution (zero-padded), group normalization (C/3 groups), a convolution expanding the channels fourfold, GELU, a projection and a residual connection, without layer scale or stochastic depth. The stem and the downsampling between stages are strided convolutions followed by group normalization and GELU; the bottleneck is one ConvNeXt block. NeXtUNETR has none of the residual blocks of SwinUNETR-V2: each stage begins directly with its ConvNeXt blocks, and the skip connections take each stage's output unchanged. Each decoder level applies a transposed convolution, concatenation with the skip features, a fusion convolution and one ConvNeXt block, and a final transposed convolution returns to the input resolution before the head.
SR-ResNet. The baseline is the super-resolution residual network of Li et al. : 32 residual blocks of 32 channels ( convolutions with circular padding) applied to the SAD density sampled at every second grid point, followed by twofold pixel-shuffle upsampling to the full grid. It does not add the input density to its output, and it rescales the output to the integral of its subsampled input (times eight) instead of to N; we evaluate it as published, without further rescaling. Table 1 uses Li et al.'s released QM9 model; for Fig. 1 the same architecture was retrained with their schedule (see QM9-subset-8k below).
Training
The networks were implemented in PyTorch (version 2.3.1) with MONAI (version 1.3.2). SwinUNETR-V2 and NeXtUNETR were trained with the same settings. The loss is the per-molecule normalized mean absolute error (NMAE) of the density on the unpadded grid (defined below, without the factor of 100). Training used AdamW with learning rate , weight decay and moment decay rates ( , ) = (0.9, 0.999), batch size 1, for 50 epochs. The first epoch uses a constant learning rate of as a warm-up; the learning rate then follows a cosine decay from toward zero over the remaining 49 epochs, stepped once per epoch. Each training molecule is augmented on the fly, identically in input and label, by a rotation of the grid by multi-ples of 90° about each axis (drawn independently per axis) and, with probability 0.5, by an integer periodic shift of up to 4 voxels along each axis. During training the output is rescaled to the grid integral of the reference density, which equals N up to the discretization, and the rescaling factor is capped at 100; at inference the factor is not capped (the target equals N to within ). Of the end-of-epoch checkpoints, we kept the one with the lowest NMAE on the 50 validation molecules; for both full-QM9 models this is the last epoch.
QM9-subset-8k. The 8,000 molecules were drawn from the QM9 training split, stratified by size (five bins) and composition (molecules with F, and the CHNO, CHO, CHN and CH classes), with proportional allocation and at least five molecules per stratum (fixed random seed). The ten models of Fig. 1 and the ablation models of Extended Data Table 1 were trained on it for 50 epochs with the validation set above. SwinUNETR-V2 has widths C = 24, 48, 96 and 144 (18.5, 73.1, 291.7 and 655.9 million parameters) and NeXtUNETR C = 48, 96, 144 and 192 (17.5, 67.5, 150.1 and 265.4 million). SR-ResNet was trained with Li et al.'s schedule: Adam ( , as in their released code) without weight decay, a first epoch at of the learning rate, then cosine decay over the remaining epochs, with their NMAE loss and augmentation. The learning rate was 0.1, the value Li et al. used for their QM9 variants (0.01 for their main model), and the best validation checkpoint was kept. SR-ResNet-70M has 64 channels and 64 residual blocks. The 3D U-Nets of Extended Data Table 1 have four levels, from the full grid down to 1/8 resolution, with 96, 192, 384 and 768 channels; each level applies two convolutions with circular padding and ReLU, downsampling is by max pooling and upsampling by transposed convolution, and the output is formed as for SwinUNETR-V2 and NeXtUNETR. The plain version has no normalization; the residual version adds a residual connection around each pair of convolutions and group normalization (16 groups). Both used the optimizer, learning rate and loss of SwinUNETR-V2 and NeXtUNETR. The plain ResNet applies the 32 residual blocks of SR-ResNet to the full grid, without subsampling or upsampling, and was trained like SR-ResNet. The 500 test molecules of Fig. 1 were drawn uniformly at random from the 10,000 test molecules (fixed seed).
Full QM9. The models of Table 1 and of all later Results sections were trained on all 123,835 training molecules at (SwinUNETR-V2 291.7 and NeXtUNETR 67.5 million parameters; breakdown in Extended Data Fig. 1e).
Density error, cost and precision
The density error is the normalized mean absolute error on the reference grid, in percent, NMAE = . For the one-step density, is replaced by the density of the one-step density matrix on the same grid points.
All network inference reported in the paper is in fp32 with TF32 tensor-core arithmetic disabled. Networks were trained with PyTorch's default, which enables TF32 for cuDNN convolutions. Switching it on changes the predictions of SwinUNETR-V2 and NeXtUNETR by at most 0.01% and their mean NMAE by at most 0.001 percentage points (Supplementary Table 1), and the mean NMAE of Li et al.'s published model on the 500 molecules of Fig. 1 from 0.135 to 0.136%; the SR-ResNets trained on QM9-subset-8k are more accurate when evaluated in TF32, the precision they were trained in (0.238 and 0.191% instead of 0.320 and 0.198%; Supplementary Table 1).
For Fig. 1, every model was run on the same 500 QM9 test molecules on one NVIDIA H200 NVL GPU (PyTorch 2.3.1, CUDA 12.1) with batch size 1 and the input already on the GPU.
The forward time is the network alone, without the construction of the SAD density or the Kohn–Sham step; each molecule was timed three times and the median kept, and the reported value is the mean over the 500 molecules. The inputs have 483 distinct grid shapes and cuDNN autotuning was disabled. Floating-point operations were counted with PyTorch's FlopCounterMode on each input (convolutions, including depthwise and transposed ones, matrix products and attention); the operations not counted (normalization, activations, softmax and residual additions) contribute little.
One-step Kohn–Sham calculation
From the predicted density , the Kohn–Sham Hamiltonian matrix is built with the same GPW integration as the reference: the Hartree potential by fast Fourier transform on the grid, the PBE potential through libxc with density gradients from the same transform, the local pseudopotential on the grid and the kinetic and non-local pseudopotential terms analytically. The generalized eigenvalue problem is solved once and the lowest N/2 orbitals are doubly occupied, . The eigenvalues are the one-step orbital energies. The one-step energy is the Kohn–Sham energy functional of this density matrix,
where is the density of and the nuclear repulsion, evaluated by Ewald summation. Because is an idempotent density matrix with the correct number of electrons, ( for all 10,000 QM9 test molecules and all three models).
Neither PySCF nor GPU4PySCF provides the one-step energy or its gradient. The one-step calculation and all forces described below are our own code, which calls the libraries' routines for the grid density, the potentials, the integrals and their nuclear derivatives. The QM9 energies, orbital energies and forces (Table 1, Fig. 2a–c) were computed on the CPU with the PySCF build distributed by Li et al. (PySCF 2.0.1 with libxc 5.1.7), with which their reference energies are reproduced exactly and their published SR-ResNet errors are recovered (NMAE 0.138% against 0.14%; 2.84 against 3.0 meV); with the reference density as input, the one-step energy differs from the SCF energy by 0.001 meV on average. Geometry optimization and molecular dynamics used our GPU implementation built on GPU4PySCF (version 1.8.0, with PySCF 2.14.0, CuPy 14.1.1 and CUDA 12). In this implementation, the network and the diagonalization stay on the 200 Ha grid of the training data. , the force terms at fixed D and the response amplitudes are evaluated on a finer grid of 400 Ha ( times as many points per axis, rounded up to an even number); the derivative of and the vector–Jacobian product stay on the 200 Ha grid. The reference SCF runs entirely at 400 Ha with GPU4PySCF's multigrid Kohn–Sham solver . The finer grid reduces the egg-box artifact of a grid fixed in space by a factor of 13–16 in energy and 5–6 in force, and the force remains the exact gradient of the reported energy (Supplementary Note 1 and Supplementary Fig. 2). These checks used an earlier CPU counterpart of the GPU implementation, run with PySCF 2.6.2, that evaluated the matrix G of the NSCC (defined below) on the 200 Ha grid; its later version, which evaluates G on the 400 Ha grid as the GPU implementation does, gives the CPU timings of Supplementary Table 2.
Within each study, the reference and the models use the same implementation and grid. Given the same density matrix, the CPU (PySCF 2.0.1) and GPU implementations differ at 200 Ha by 0.2–3.4 meV in energy and 0.3–6.9 meV Å in force (component mean absolute error, MAE;
three structures), mainly through the discretization of the density on the multigrid; at 400 Ha, SCF calculations of alanine dipeptide (C7eq and C5) with the two implementations agree within 0.41 meV in energy and 0.1 meV Å in force (component MAE).
Forces and the non-self-consistency correction
The one-step energy depends on the nuclear positions through the basis functions, the pseudopotentials and the nuclear repulsion, and through the input density , which in turn determines . The force without the non-self-consistency correction (NSCC), denoted w/o NSCC, is minus the standard Kohn–Sham gradient evaluated for the one-step solution: the Hellmann–Feynman, pseudopotential, kinetic and basis-function (Pulay) derivatives contracted with , the energy-weighted overlap term with , and the nuclear repulsion. It treats as if it were self-consistent, neglecting the response of to , both explicit and through the input density.
The force with the NSCC (w/ NSCC) is the exact gradient . With , the Kohn–Sham Hamiltonian matrix of the output density, . Because is built from and not from , follows from uncoupled first-order perturbation theory,
where and are the total derivatives of and of the overlap matrix with respect to , in the basis of the orbitals . The force w/o NSCC replaces this term by the overlap term , its value at self-consistency; the NSCC is the difference. It vanishes when the input density is self-consistent, since then , and . The explicit part of (basis functions and pseudopotentials at fixed ) is evaluated analytically by contracting the amplitude matrix , , with the integral derivatives. The implicit part, through , is with the cotangent field (with the corresponding gradient terms of the PBE kernel), where is the density of . This integral is obtained by a vector–Jacobian product (one backward pass) through the rescaling and the network, followed by the derivative of the SAD density.
For the SAD control of Extended Data Table 2, the same expressions are applied with replaced by . For SR-ResNet the vector–Jacobian product follows its own input (every second grid point) and output (no rescaling to N) conventions.
Every term was checked against finite differences of . End to end, analytic and central-difference forces (step 0.002 Å) agree within 0.03–1.8 meV Å (largest component deviation, at most 0.4% of the component) on QM9 molecules and within 0.36 meV Å (component MAE) for alanine dipeptide; for the SAD control (step 0.001 Å) their ratio is 0.9995–1.0001. The QM9 reference forces are the gradient w/o NSCC of the one-step calculation with the reference density as input, which agrees with PySCF's own SCF gradient in Li et al.'s build within 0.006–0.2 meV Å (largest component deviation) on five molecules. In the GPU implementation, the reference force is likewise our gradient (the w/o NSCC terms, exact at self-consistency) applied to the converged SCF density matrix, so that reference and model forces pass through the same code; it agrees with GPU4PySCF's own SCF gradient within 0.0003 meV Å (component MAE). Evaluating the SR-ResNet and SwinUNETR-V2 force errors on 30 QM9 molecules at 400 instead of 200 Ha changes the per-molecule force MAEs by at most 0.16 meV Å , so the reported errors reflect the predicted density, not the integration grid. QM9 forces are reported as computed, without removing the net force.
Geometry optimization
The 200 QM9 test molecules are the first, in a fixed random order, for which RDKit assigned the bonds, an MMFF94 (ref. 40) starting structure could be built, the cell converged (below) and no heavy-atom dihedral differed by more than 60° between the starting structure and the reference optimum.
For each molecule, the reference optimum is the SCF minimum in a cell built by the rule of “Reference densities”, obtained from the QM9 geometry by alternating SCF relaxation (with the optimizer and criteria below) and cell rebuilding until the cell no longer changed (at most three passes), and the starting structure is an MMFF94 relaxation of with RDKit, Kabsch-aligned to it. From this start, the structure was optimized on each surface of Extended Data Table 2 with geomeTRIC (version 1.1.1) in translation–rotation internal coordinates, with its default trust radius and convergence criteria (maximum force 23.1 meV Å , RMS force 15.4 meV Å , energy change 10 Ha, maximum and RMS displacement 1.8 × 10 and 1.2 × 10 Å), and at most 300 optimization steps. Net translation and rotation were projected out of every force. All runs used the 400 Ha GPU implementation; the reference SCF was converged to 10 Ha from an atomic guess at every step, and the networks ran in fp32. Distances are all-atom Kabsch root-mean-square deviations (RMSDs) from the optimum the reference run reached from the same start (median 0.116 Å for the starting structures).
On each network surface, 7–14 molecules ended more than 0.05 Å from the reference optimum. For the 11 such molecules with SwinUNETR-V2 w/ NSCC, restarting each optimization from the other surface’s end point showed that the two runs ended in different minima along soft torsions, which in all but one case exist on both surfaces.
Molecular dynamics
Alanine dipeptide (Ace-Ala-NMe, 22 atoms) was started from its four gas-phase basins C7eq, C5, C7ax and αL; each starting structure was built with MMFF94, the backbone dihedrals restrained to literature values, relaxed again without the restraint and then relaxed on the PBE/GTH surface in the cell below (200 Ha grid) to a maximum force of 20 meV Å⁻¹, which changed φ and ψ by at most 3.3°. The cell is cubic, 13.30 Å (160³ grid), large enough for the molecule to rotate.
Trajectories were integrated with velocity Verlet in the NVE ensemble for 2,000 steps of 0.5 fs (1 ps). Initial velocities were drawn from a Maxwell–Boltzmann distribution at 600 K (one random seed shared by all methods for a basin) with the net momentum removed; by equipartition the trajectories settle at 258–284 K (except the runs w/o NSCC, which heat up). Forces came from the reference SCF (400 Ha, Ha, started from the previous step’s density matrix) or from the one-step calculation on the SwinUNETR-V2 or NeXtUNETR density, with or without the NSCC. Because the grid is fixed in space, the forces do not sum exactly to zero; rather than projecting out the net force, which would break consistency with the reported energy, we recentered the centroid in the cell and removed the center-of-mass velocity at every step.
Energy conservation is measured by the standard deviation of the total energy per atom over the second half of each trajectory (not detrended). The vibrational density of states is the Fourier transform of the windowed, mass-weighted velocity autocorrelation function (velocities every 2.5 fs; resolution 33 cm ); band positions are intensity-weighted centroids over fixed windows (amide II, 1,250–1,550 cm ; amide I, 1,550–1,800 cm ). The ( , ) maps were computed on a 15° grid (576 points) of MMFF94 structures relaxed with the two dihedrals constrained, with the SCF and each model's one-step energy (with the implementation and cell of the dynamics), each relative to its own minimum; mean absolute map errors are taken over the 541 points within 1 eV of the SCF minimum. The per-frame errors of Fig. 3c,d are the one-step energies and forces (w/ NSCC) evaluated on the 400 frames (every 2.5 fs) of each reference trajectory.
Single-point timing
Single-point wall times (Supplementary Table 2) were measured on the 200 QM9 molecules of the geometry-optimization set, each at its reference-SCF minimum, on one NVIDIA A40 (48 GB), A100 SXM4 (80 GB) or H100 NVL GPU and on 16 cores of an AMD EPYC 7543 CPU. On each device the reference SCF and the one-step calculation used the same implementation: on the GPUs that of the geometry optimizations, on the CPU the PySCF 2.6.2 implementation above. Both used the settings of the geometry optimizations (SCF converged to Ha from the atomic guess on the 400 Ha grid). Each time is that of a new molecule in a running program; program start, model loading, file input and cell construction are excluded, and performance options that leave the results unchanged (forces within 0.02 meV Å ) were used. Every calculation was run once per molecule, after a warm-up on a molecule outside the set and with per-molecule caches emptied before each calculation, and the table reports the median over the 200 molecules. Network forward and backward passes are also reported separately.
Transfer benchmarks
Datasets. : 113 isomers × 50 snapshots from ab initio molecular dynamics; following Li et al., the first two snapshots of each trajectory are used for training (226), the third for validation (113) and the last 40 for testing (4,520). : charged biomolecular fragments from a GTP-bound microtubule (total charge -4) containing C, H, N, O, P and Mg; the first 10 structures of each of Li et al.'s runs are used for training (110) and the 11th for validation, and the test set is 10 structures per run drawn from their test range in ten index-quantile bins (110). W1500: water clusters from the WDBase database of water-cluster minima (its 1 kcal mol files), taking the first min(count, ) structures of each n-molecule file, which reproduces Li et al.'s counts; training on (226), validation on (17) and testing on the three clusters (W1500/30). Wmin-PBE/3-100: for the putative global minima of the TTM2.1-F potential listed in WDBase (for from an incomplete search), and for , 60, 70, 80, 90 and 100 clusters grown deterministically from the 30-molecule minimum, one rigid water at a time: among the TIP4P placements within 0.02 eV of the lowest-energy one, the one giving the smallest cell was kept, with rigid-body reorganization every five additions and a beam of three candidate structures. All Wmin-PBE clusters were relaxed on the PBE/GTH surface (200 Ha) to a maximum force of 50 meV Å ; W1500 uses the WDBase geometries as given. Both were labeled with the protocol above. D-B-A chains (constructed here): six donors (NMe , NH , OMe, OH, Me, F) and six acceptors (NO , CN, CF , CHO, COOH, CONH ) at the ends of saturated (alkane) and conjugated (trans-polyene) bridges of C2, C4, ..., C12. The parent chains, built with
RDKit (ETKDG version 3 and MMFF94), were relaxed on the PBE/GTH surface (200 Ha) to a maximum force of 50 meV Å ; donor and acceptor substituents were relaxed with the bridge frozen (to the same threshold, except two NMe fragments that stopped at 56 and 84 meV Å after 80 steps) and the doubly substituted molecules assembled from them. All molecules of a series (one bridge type and length) share one cell, centered on the bridge, whose edges are the largest extent in the series plus 4 Å. Models were trained on all C2–C8 molecules (parent, singly and doubly substituted; 353 training, 39 validation drawn at random) and tested on the 144 doubly substituted molecules with C10 and C12 bridges.
Protocols. Zero-shot results apply the QM9 models of Table 1 directly. Fine-tuning starts from them and trains for 50 epochs on the target training set, with fresh optimizer and scheduler states. SwinUNETR-V2 and NeXtUNETR use the loss, optimizer, schedule and augmentation of pre-training (AdamW, learning rate ), and SR-ResNet Li et al.'s protocol (Adam, learning rate 0.01, a first epoch at of that rate, then cosine decay, with the Adam settings above). Models trained from scratch use the same settings from random initialization. For every model, the end-of-epoch checkpoint with the lowest validation NMAE is evaluated. Wmin-PBE/3–100 was evaluated zero-shot only. On the transfer sets, only the density was evaluated.
Statistics and reproducibility
Each model and condition was trained once, and each molecular dynamics condition was run once; no seed variation is reported. QM9 results include all 10,000 test molecules; the two molecules with a reference HOMO–LUMO gap below 1 eV are excluded only from the parenthesized means of Table 1 and from Extended Data Fig. 2, by that criterion alone.
Data availability
The QM9, and MT reference densities are those of Li et al. , deposited in Caltech-DATA ; their released SR-ResNet models are on Figshare . The densities computed here (the W1500 clusters used, Wmin-PBE/3–100 and the D–B–A chains), the structures and the source data will be made publicly available upon publication.
Code availability
The model definitions, the training code, the one-step and force code and the analysis scripts will be made publicly available upon publication.
References
-
Hohenberg, P. & Kohn, W. Inhomogeneous electron gas. Phys. Rev. 136, B864–B871 (1964).
-
Kohn, W. & Sham, L. J. Self-consistent equations including exchange and correlation effects. Phys. Rev. 140, A1133–A1138 (1965).
-
Behler, J. & Parrinello, M. Generalized neural-network representation of high-dimensional potential-energy surfaces. Phys. Rev. Lett. 98, 146401 (2007).
-
Batatia, I., Kovács, D. P., Simm, G. N. C., Ortner, C. & Csányi, G. MACE: higher order equivariant message passing neural networks for fast and accurate force fields. In Adv. Neural Inf. Process. Syst. 35, 11423–11436 (2022).
-
Unke, O. T. et al. Machine learning force fields. Chem. Rev. 121, 10142–10186 (2021).
-
Batatia, I. et al. A foundation model for atomistic materials chemistry. J. Chem. Phys. 163, 184110 (2025).
-
Brockherde, F. et al. Bypassing the Kohn–Sham equations with machine learning. Nat. Commun. 8, 872 (2017).
-
Li, C., Sharir, O., Yuan, S. & Chan, G. K.-L. Image super-resolution inspired electron density prediction. Nat. Commun. 16, 4811 (2025).
-
Li, H. et al. Deep-learning density functional theory Hamiltonian for efficient ab initio electronic-structure calculation. Nat. Comput. Sci. 2, 367–377 (2022).
-
Shao, X., Paetow, L., Tuckerman, M. E. & Pavanello, M. Machine learning electronic structure methods based on the one-electron reduced density matrix. Nat. Commun. 14, 6281 (2023).
-
Prodan, E. & Kohn, W. Nearsightedness of electronic matter. Proc. Natl Acad. Sci. USA 102, 11635–11638 (2005).
-
Grisafi, A. et al. Transferable machine-learning model of the electron density. ACS Cent. Sci. 5, 57–64 (2019).
-
Jørgensen, P. B. & Bhowmik, A. Equivariant graph neural networks for fast electron density estimation of molecules, liquids, and solids. npj Comput. Mater. 8, 183 (2022).
-
Koker, T., Quigley, K., Taw, E., Tibbetts, K. & Li, L. Higher-order equivariant neural networks for charge density prediction in materials. npj Comput. Mater. 10, 161 (2024).
-
Fu, X. et al. A recipe for charge density prediction. In Adv. Neural Inf. Process. Syst. 37, 9727–9752 (2024).
-
Elsborg, J., Thiede, L., Aspuru-Guzik, A., Vegge, T. & Bhowmik, A. ELECTRA: a Cartesian network for 3D charge density prediction with floating orbitals. In Adv. Neural Inf. Process. Syst. 38, 31897–31926 (2025).
-
Lee, R.-G. & Kim, Y.-H. Convolutional network learning of self-consistent electron density via grid-projected atomic fingerprints. npj Comput. Mater. 10, 248 (2024).
-
Ramakrishnan, R., Dral, P. O., Rupp, M. & von Lilienfeld, O. A. Quantum chemistry structures and properties of 134 kilo molecules. Sci. Data 1, 140022 (2014).
-
Vaswani, A. et al. Attention is all you need. In Adv. Neural Inf. Process. Syst. 30 (2017).
-
Dosovitskiy, A. et al. An image is worth words: transformers for image recognition at scale. In Proc. International Conference on Learning Representations (2021).
-
Liu, Z. et al. Swin Transformer: hierarchical vision transformer using shifted windows. In Proc. IEEE/CVF Int. Conf. Comput. Vis. (ICCV), 9992–10002 (2021).
-
He, K., Zhang, X., Ren, S. & Sun, J. Deep residual learning for image recognition. In Proc. IEEE Conf. Comput. Vis. Pattern Recognit. (CVPR), 770–778 (2016).
-
Hatamizadeh, A. et al. Swin UNETR: Swin transformers for semantic segmentation of brain tumors in MRI images. In Brainlesion: Glioma, Multiple Sclerosis, Stroke and Traumatic Brain Injuries (BrainLes 2021), Lecture Notes in Computer Science Vol. 12962, 272–284 (Springer, 2022).
-
He, Y. et al. SwinUNETR-V2: stronger Swin transformers with stagewise convolutions for 3D medical image segmentation. In Medical Image Computing and Computer Assisted Intervention – MICCAI 2023, Lecture Notes in Computer Science Vol. 14223, 416–426 (Springer, 2023).
-
Çiçek, Ö., Abdulkadir, A., Lienkamp, S. S., Brox, T. & Ronneberger, O. 3D U-Net: learning dense volumetric segmentation from sparse annotation. In Medical Image Computing and Computer-Assisted Intervention – MICCAI 2016, Lecture Notes in Computer Science Vol. 9901, 424–432 (Springer, 2016).
-
Liu, Z. et al. A ConvNet for the 2020s. In Proc. IEEE/CVF Conf. Comput. Vis. Pattern Recognit. (CVPR), 11966–11976 (2022).
-
Lee, H. H., Bao, S., Huo, Y. & Landman, B. A. 3D UX-Net: a large kernel volumetric ConvNet modernizing hierarchical transformer for medical image segmentation. In Proc. International Conference on Learning Representations (2023).
-
Roy, S. et al. MedNeXt: transformer-driven scaling of ConvNets for medical image segmentation. In Medical Image Computing and Computer Assisted Intervention – MICCAI 2023, Lecture Notes in Computer Science Vol. 14223, 405–415 (Springer, 2023).
-
Harris, J. Simplified method for calculating the energy of weakly interacting fragments. Phys. Rev. B 31, 1770–1779 (1985).
-
Foulkes, W. M. C. & Haydock, R. Tight-binding models and density-functional theory. Phys. Rev. B 39, 12520–12536 (1989).
-
Niklasson, A. M. N. Next generation extended Lagrangian first principles molecular dynamics. J. Chem. Phys. 147, 054103 (2017).
-
Niklasson, A. M. N. & Negre, C. F. A. Shadow energy functionals and potentials in Born-Oppenheimer molecular dynamics. J. Chem. Phys. 158, 154105 (2023).
-
Focassio, B., Domina, M., Patil, U., Fazzio, A. & Sanvito, S. Linear Jacobi-Legendre expansion of the charge density for machine learning-accelerated electronic structure calculations. npj Comput. Mater. 9, 87 (2023).
-
Grisafi, A., Lewis, A. M., Rossi, M. & Ceriotti, M. Electronic-structure properties from atom-centered predictions of the electron density. J. Chem. Theory Comput. 19, 4451–4460 (2023).
-
Hazra, S., Patil, U. & Sanvito, S. A charge-density machine-learning workflow for computing the infrared spectrum of molecules. J. Chem. Phys. 163, 174104 (2025).
-
Hazra, S., Patil, U. & Sanvito, S. Predicting the one-particle density matrix with machine learning. J. Chem. Theory Comput. 20, 4569–4578 (2024).
-
Klockow, M. V., Ickler, M. K., Lippmann, P. & Hamprecht, F. A. A function-centric graph neural network approach for predicting electron densities. In Proc. International Conference on Learning Representations https://openreview.net/forum?id=HDdkFjFEZd (2026).
-
Jørgensen, P. B. & Bhowmik, A. QM9 charge densities and energies calculated with VASP. DTU Data https://doi.org/10.11583/DTU.16794500 (2022).
-
Wang, L.-P. & Song, C. Geometry optimization made simple with translation and rotation coordinates. J. Chem. Phys. 144, 214108 (2016).
-
Halgren, T. A. Merck molecular force field. I. Basis, form, scope, parameterization, and performance of MMFF94. J. Comput. Chem. 17, 490–519 (1996).
-
Rakshit, A., Bandyopadhyay, P., Heindel, J. P. & Xantheas, S. S. Atlas of putative minima and low-lying energy networks of water clusters . J. Chem. Phys. 151, 214307 (2019).
-
Database of water cluster minima (WDBase). University of Washington https://sites.uw.edu/wdbase/database-of-water-clusters/ (2026).
-
Jorgensen, W. L., Chandrasekhar, J., Madura, J. D., Impey, R. W. & Klein, M. L. Comparison of simple potential functions for simulating liquid water. J. Chem. Phys. 79, 926–935 (1983).
-
Perdew, J. P., Burke, K. & Ernzerhof, M. Generalized gradient approximation made simple. Phys. Rev. Lett. 77, 3865–3868 (1996).
-
Sun, Q. et al. Recent developments in the PySCF program package. J. Chem. Phys. 153, 024109 (2020).
-
Lippert, G., Hutter, J. & Parrinello, M. A hybrid Gaussian and plane wave density functional scheme. Mol. Phys. 92, 477–487 (1997).
-
Goedecker, S., Teter, M. & Hutter, J. Separable dual-space Gaussian pseudopotentials. Phys. Rev. B 54, 1703–1710 (1996).
-
Krack, M. Pseudopotentials for H to Kr optimized for gradient-corrected exchange-correlation functionals. Theor. Chem. Acc. 114, 145–152 (2005).
-
VandeVondele, J. et al. Quickstep: fast and accurate density functional calculations using a mixed Gaussian and plane waves approach. Comput. Phys. Commun. 167, 103–128 (2005).
-
Van Lenthe, J. H., Zwaans, R., Van Dam, H. J. J. & Guest, M. F. Starting SCF calculations by superposition of atomic densities. J. Comput. Chem. 27, 926–932 (2006).
-
Cardoso, M. J. et al. MONAI: an open-source framework for deep learning in healthcare. Preprint at https://arxiv.org/abs/2211.02701 (2022).
-
Wu, Y. & He, K. Group normalization. In Computer Vision – ECCV 2018, Lecture Notes in Computer Science Vol. 11217, 3–19 (Springer, 2018).
-
Paszke, A. et al. PyTorch: an imperative style, high-performance deep learning library. In Adv. Neural Inf. Process. Syst. 32 (2019).
-
Loshchilov, I. & Hutter, F. Decoupled weight decay regularization. In Proc. International Conference on Learning Representations (2019).
-
Kingma, D. P. & Ba, J. Adam: a method for stochastic optimization. In Proc. International Conference on Learning Representations (2015).
-
Lehtola, S., Steigemann, C., Oliveira, M. J. T. & Marques, M. A. L. Recent developments in libxc—a comprehensive library of functionals for density functional theory. SoftwareX 7, 1–5 (2018).
-
Wu, X. et al. Enhancing GPU-acceleration in the Python-based simulations of chemistry frameworks. WIREs Comput. Mol. Sci. 15, e70008 (2025).
-
Li, R., Sun, Q., Zhang, X. & Chan, G. K.-L. Introducing GPU acceleration into the Python-based simulations of chemistry framework. J. Phys. Chem. A 129, 1459–1468 (2025).
-
Li, R. et al. Implementation of the multigrid Gaussian-plane-wave algorithm with GPU acceleration in PySCF. J. Chem. Theory Comput. 22, 10101–10112 (2026).
-
Soler, J. M. et al. The SIESTA method for ab initio order-N materials simulation. J. Phys. Condens. Matter 14, 2745–2779 (2002).
-
RDKit: open-source cheminformatics, release 2024.03.3. Zenodo https://doi.org/10.5281/zenodo.11396708 (2024).
-
Kabsch, W. A solution for the best rotation to relate two sets of vectors. Acta Crystallogr. A 32, 922–923 (1976).
-
Swope, W. C., Andersen, H. C., Berens, P. H. & Wilson, K. R. A computer simulation method for the calculation of equilibrium constants for the formation of physical clusters of molecules: application to small water clusters. J. Chem. Phys. 76, 637–649 (1982).
-
Wang, S., Witek, J., Landrum, G. A. & Riniker, S. Improving conformer generation for small rings and macrocycles based on distance geometry and experimental torsional-angle preferences. J. Chem. Inf. Model. 60, 2044–2058 (2020).
-
Li, C., Sharir, O., Yuan, S. & Chan, G. K.-L. QM9 DFT electron density. CaltechDATA https://doi.org/10.22002/7vr2f-0r732 (2024).
-
Li, C., Sharir, O., Yuan, S. & Chan, G. K.-L. C₇O₂H₁₀ isomer DFT electron density. Caltech-DATA https://doi.org/10.22002/04d1z-1d608 (2024).
-
Li, C., Sharir, O., Yuan, S. & Chan, G. K.-L. GTP-in-microtubule DFT electron density. CaltechDATA https://doi.org/10.22002/v5tec-g6p43 (2024).
-
Li, C., Sharir, O., Yuan, S. & Chan, G. K.-L. Image super-resolution inspired electron density prediction. Figshare https://doi.org/10.6084/m9.figshare.25365508 (2024).
Acknowledgements
This work was supported by a KIAS Individual Grant (AP110201) via the Center for Artificial Intelligence and Natural Sciences at Korea Institute for Advanced Study.
Author contributions
J.W. conceived the study, carried out all calculations and analyses, and wrote the manuscript.
Competing interests
The author declares no competing interests.
Extended Data a Density formulation (both models) ρSAD zero-pad to a multiple of 32 backbone B (b or c) 1×1×1 conv head h ReLU unpad rescale: ∫ρ dV = N ρML residual: h(B(ρSAD)) is the correction to ρSAD b SwinUNETR-V2 (291.7 M) encoder skip blocks decoder 1, 1 ch 1/2, C 1/4, 2C 1/8, 4C 1/16, 8C 1/32, 16C input 3 3 res. conv Swin ×5 3 3 res. conv Swin ×4 3 3 res. conv Swin ×2 3 3 res. conv Swin ×2 patch embed 2 3 patch merging patch merging patch merging patch merging 3 3 res. block 3 3 res. block 3 3 res. block 3 3 res. block 3 3 res. block bottleneck ↑ 2, concat, 3 3 res. block ↑ 2, concat, 3 3 res. block ↑ 2, concat, 3 3 res. block ↑ 2, concat, 3 3 res. block ↑ 2, concat, 3 3 res. block 1 3 conv, C → 1, to the head (a) c NeXtUNETR (67.5 M) encoder skip blocks decoder 1, 1 ch 1/2, C 1/4, 2C 1/8, 4C 1/16, 8C 1/32, 16C input ConvNeXt ×5 ConvNeXt ×4 ConvNeXt ×2 ConvNeXt ×2 ConvNeXt ×1 bottleneck stem 2 3 , stride 2 2 3 conv, stride 2 2 3 conv, stride 2 2 3 conv, stride 2 2 3 conv, stride 2 no skip blocks ↑ 2, concat, 1×1, ConvNeXt ×1 ↑ 2, concat, 1×1, ConvNeXt ×1 ↑ 2, concat, 1×1, ConvNeXt ×1 ↑ 2, concat, 1×1, ConvNeXt ×1 ↑ 2 (transposed conv) to the head (a) d Blocks Swin block (alternate blocks: windows shifted by 3) x LN W-MSA 7 3 LN MLP ×4 118,431 parameters at C = 96: attention 43,839 (relative-position bias 6,591); heads 3, 6, 12, 24 3 3 residual block x 3 3 conv, GN, leaky ReLU 3 3 conv, GN leaky ReLU V2 stage convs, skip blocks, decoder of b 54C 2 weights: 498k at C = 96 shortcut 1 3 conv + GN where channels change ConvNeXt block (stages, bottleneck, decoder of c) x DW 7 3 GN 1×1 C → 4C GELU 1×1 4C → C 107,424 parameters at C = 96: depthwise kernel 33,024 (7 3 per channel) e Parameters by function spatial mixer (attention / depthwise 7 3 ) channel mixing (MLP, 1×1, norms) standard 3 3 conv blocks resampling (embedding, merging, strided / transposed conv) 0 50 100 150 200 250 300 Parameters (M) SwinUNETR-V2 NeXtUNETR 2.4 % 84 % 9 % 291.7 M 3.3 % 59 % 37 % 67.5 M Extended Data Fig. 1 | SwinUNETR-V2 and NeXtUNETR. k 3 denotes a k × k × k kernel or patch. a, Density formulation shared by both models: the zero-padded SAD density is refined by the backbone B and a 13 convolution head h into a correction that is added back, made non-negative, cropped and rescaled to the number of valence electrons N (Methods). b,c, The backbones of SwinUNETR-V2 (b) and NeXtUNETR (c) on a common grid: rows are resolutions from the input grid to 1/32 (channel counts in multiples of C = 96); columns are the encoder, the blocks on the skip connections and the decoder. SwinUNETR-V2 places 33 residual blocks on the skips (except at 1/16), in the bottleneck and in the decoder, layer-normalizes the features leaving the encoder (without learned parameters) and ends in a 13 convolution from C channels to one; NeXtUNETR uses ConvNeXt blocks in the bottleneck and decoder and passes the skips unchanged. d, Swin block (alternate blocks shift the windows by 3 voxels), 3 3 residual block (with a 13 convolution on the shortcut where the channel count changes) and ConvNeXt block, with parameter counts at C = 96 for the first stage. e, Parameters by function. Spatial mixing takes 2.4% (attention) and 3.3% (depthwise 73 kernels) of the parameters of SwinUNETR-V2 and NeXtUNETR, respectively; SwinUNETR-V2’s size comes from its standard (non-depthwise) 33 convolutions (84%), with 44% in the bottleneck block alone. 25

Extended Data Fig. 2 | One-step energies and forces against the reference SCF, QM9 test set. Total energy per molecule (a,d) and Cartesian force components with (b,e) and without (c,f) the non-self-consistency correction, for SwinUNETR-V2 (top) and NeXtUNETR (bottom). The two molecules with a reference HOMO–LUMO gap below 1 eV (QM9 56343 and 37992; energy errors 0.6–5.3 eV with these two models and 0.3–18 eV including SR-ResNet, force-component errors up to 300 eV Å w/ NSCC) are excluded; with them, the force-component R w/ NSCC becomes negative. R (1 – R for energies) and MAE are over the remaining 9,998 molecules (539,508 components); Table 1 reports all 10,000. Dotted: y = x.

Reference (SCF), VDOS SwinUNETR-V2 w/ NSCC NeXtUNETR w/ NSCC
Reference (SCF) SwinUNETR-V2 w/o NSCC NeXtUNETR w/o NSCC
b

c
d
e
Extended Data Fig. 3 | Energy conservation requires the non-self-consistency correction. a, Backbone dihedrals of the four alanine-dipeptide trajectories of each method on its own ( , ) map: the SCF map for the reference, the model's one-step map for the model (w/ and w/o NSCC share it). b, Vibrational density of states (VDOS) of the C7eq trajectories w/ and w/o NSCC (SwinUNETR-V2 above, NeXtUNETR below, offset vertically), each over the reference (gray). c, Total energy per atom relative to its initial value along the C7eq trajectories. d, Standard deviation of the total energy over the second half of each trajectory, all four trajectories. e, Force error (component MAE, 25 fs running mean) on the frames of the C7eq reference trajectory, w/ and w/o NSCC. Without the NSCC, the s.d. is 1.7–3.7 meV atom (reference 0.05–0.07 meV atom ) and the systems heat by 24–97 K (not shown). Settings as in Fig. 3; one trajectory per condition.

b
Extended Data Fig. 4 | Size extrapolation during training. Density NMAE on Wmin-PBE/3–100 for full-QM9-trained NeXtUNETR (a) and SwinUNETR-V2 (b) after 10, 20, 30 and 40 epochs and at the end of training (50 epochs). The NeXtUNETR error on small clusters falls with training (3–10 molecules: from 0.58% to 0.46%), whereas that on large clusters is lowest after 20 epochs and then rises (60–100 molecules: from 0.68% to 2.57%). The SwinUNETR-V2 error falls in every size range up to 40 epochs and then levels off (60–100 molecules: from 0.80% to 0.59%).
Extended Data Table 1 | Structural ablations on QM9-subset-8k. Density NMAE (%) on the 500 QM9 test molecules of Fig. 1. Each variant is compared with the first row of its block: relative change of the mean ( mean) and share of molecules on which the variant is worse. One training run each (50 epochs); fp32 evaluation.
| Family | Model | Params (M) | NMAE mean / median (%) | mean | Worse on |
|---|---|---|---|---|---|
| SwinUNETR-V2 | reference (SwinUNETR-V2-292M of Fig. 1) | 291.7 | 0.204 / 0.190 | — | — |
| without the residual blocks on the downsampled skips and in the bottleneck | 153.8 | 0.209 / 0.196 | +2% | 69% | |
| NeXtUNETR | reference (ConvNeXt encoder blocks) | 67.5 | 0.133 / 0.124 | — | — |
| encoder blocks replaced by Swin blocks | 73.2 | 0.250 / 0.236 | +88% | 99.8% | |
| SR-ResNet | reference (half-resolution input, 2 pixel-shuffle upsampling) | 9.4 | 0.320 / 0.309 | — | — |
| plain ResNet on the full grid (no upsampling) | 8.3 | 0.301 / 0.276 | -6% | 29% | |
| 3D U-Net | reference (plain 3D U-Net, base width 96) | 50.4 | 0.499 / 0.466 | — | — |
| 3D residual U-Net with group normalization (base width 96) | 51.2 | 0.259 / 0.243 | -48% | 0% |
Residual blocks on the 1/2, 1/4 and 1/8 skip connections and the bottleneck block (138 M parameters, 127 M of them in the bottleneck block).
Windowed attention in a window; everything outside the encoder blocks unchanged.
Li et al.'s architecture (32 channels, 32 residual blocks) with their schedule; SR-ResNet-9M of Fig. 1.
Extended Data Table 2 | Geometry optimization on one-step surfaces. 200 QM9 test molecules optimized with geomeTRIC from MMFF94 starting structures. RMSD: Kabsch root-mean-square deviation from the optimum the reference reaches from the same start. SAD: the one-step calculation on the SAD density, without a network. Converged: all criteria met within 300 steps. Steps include the starting structure; 301 means not converged within 300 steps. w/ and w/o NSCC: with and without the non-self-consistency correction. p90: 90th percentile.
| Surface | Converged | Steps, median (max) | RMSD, median / p90 (Å) | Within 0.1 Å | Heavy-atom RMSD, median (Å) |
|---|---|---|---|---|---|
| MMFF94 start | — | — | 0.116 / 0.335 | 42.5% | 0.078 |
| Reference SCF | 200/200 | 15.5 (61) | 0 (by definition) | — | — |
| SwinUNETR-V2 w/ NSCC | 200/200 | 16 (45) | 0.003 / 0.034 | 98.0% | 0.002 |
| SwinUNETR-V2 w/o NSCC | 200/200 | 16 (63) | 0.005 / 0.038 | 97.0% | 0.003 |
| NeXtUNETR w/ NSCC | 200/200 | 15.5 (52) | 0.002 / 0.021 | 98.5% | 0.001 |
| NeXtUNETR w/o NSCC | 200/200 | 15.5 (53) | 0.003 / 0.032 | 98.0% | 0.002 |
| SAD w/ NSCC | 199/200 | 22 (301) | 0.156 / 0.472 | 23.0% | 0.120 |
| SAD w/o NSCC | 5/200 | 301 (301) | 0.245 / 0.416 | 2.5% | 0.181 |
Supplementary Information
Supplementary Note 1: the 400 Ha evaluation grid
Why. The labels, the SAD input and the network outputs are all defined on the uniform 200 Ha (400 Ry) grid of the reference densities of Li et al. . A grid fixed in space is not translation invariant: moving a molecule rigidly relative to the grid points changes the multigrid energy and forces, with the period of the grid (the egg-box effect). We encountered it in geometry optimization on the 200 Ha grid, where the maximum force stalled at 12–28 meV Å while the energy kept decreasing.
Size of the effect. Supplementary Fig. 2 quantifies it for the relaxed alanine dipeptide (C7eq), translated rigidly by one grid spacing along each axis (0.144 Å along the cell diagonal, 13 points). A rigid translation changes no physical quantity, so every variation is an artifact. These measurements used our CPU implementation (PySCF 2.6.2).
- At 200 Ha, the energy varies by 21.5 meV peak to peak (reference SCF) and 21.3 meV (one-step, SwinUNETR-V2), and returns to within 0.02 meV after one period.
• Per-atom forces (net force removed) vary by 26.8 and 27.3 meV Å RMS.
- The variation is concentrated on oxygen (up to 200 meV Å ) and nitrogen (90 meV Å ), whose GTH pseudopotential cores are the hardest and whose valence densities are therefore the sharpest relative to the grid spacing. Carbon and hydrogen vary by 22–30 meV Å .
What the 400 Ha grid changes. On a 400 Ha grid ( times as many points per axis), the same translation changes the energy by 1.3 meV (SCF) and 1.6 meV (one-step) and per-atom forces by 4.4 and 5.4 meV Å RMS (largest 38 and 45 meV Å , on oxygen). The artifact thus falls 13–16-fold in energy and 5–6-fold in force.
The artifact is common to the reference and the one-step calculation, so it cancels in the comparisons the paper reports:
-
the electronic-energy error of the one-step calculation (SwinUNETR-V2, alanine dipeptide) is 2.97 meV on average at 200 Ha and 2.96 meV at 400 Ha, varying by 0.42 meV over the translation on both grids;
-
on 30 QM9 molecules the per-molecule force MAE against the reference changes by at most 0.16 meV Å between the two grids.
The 400 Ha grid therefore matters for the energy surface itself, which geometry optimization and molecular dynamics follow, and not for the accuracy figures.
How. The networks are not retrained: the SAD input, the prediction , the Kohn–Sham Hamiltonian matrix and its diagonalization stay on the 200 Ha grid, where the training data are defined, and only the evaluation of the resulting density matrix D moves to the finer grid.
• Energy. is assembled on the 400 Ha grid. The kinetic and nonlocal-pseudopotential terms are analytic and do not depend on the grid. The local pseudopotential, Hartree and exchange-correlation terms use the density of D collocated on GPU4PySCF's multigrid at 400 Ha.
- Grid size. The fine mesh is the label mesh scaled by per axis and rounded up to an even number of points, since odd meshes break the parity on which the label grid's density representation relies.
• Force. The force is the exact gradient of this energy.
– The w/o NSCC term (fixed D) is evaluated on the 400 Ha grid.
– The NSCC uses , the Kohn–Sham Hamiltonian matrix of D on the 400 Ha grid, in the response amplitudes of Methods.
– The derivative of with respect to the nuclear positions, and the vector–Jacobian product through the network and the SAD, are taken on the 200 Ha grid, where is defined.
• Reference. The reference SCF runs entirely at 400 Ha. Its force is our gradient at the converged density matrix, which agrees with GPU4PySCF’s own SCF gradient within 0.0003 meV Å (component MAE).
Validation and cost.
• For alanine dipeptide, the analytic force agrees with central finite differences of the 400 Ha energy within 0.36 meV Å (component MAE, SwinUNETR-V2 w/ NSCC, h = 0.002 Å). This is the same residual as that of the 200 Ha path against its own energy.
• Building the response amplitudes from the 200 Ha Kohn–Sham Hamiltonian matrix instead would leave an inconsistency of 1.15 meV Å .
• Along the translation, the analytic net force reproduces the derivative of the energy within the error of the 13-point difference.
• The finer evaluation adds 4% to an energy-and-force step (alanine dipeptide, SwinUNETR-V2 w/ NSCC, GPU implementation on an A100: 6.72 against 6.44 s).
• The RMS of what remains of the artifact (4.4–5.4 meV Å ; 1.3–1.6 meV in energy) is well below the geometry-optimization maximum-force criterion (23 meV Å ), although the largest per-atom deviation over a full grid period, on oxygen, is 38–45 meV Å .
SwinUNETR-V2 NeXtUNETR
a

QM9 72909, , 20 atoms
b
QM9 39043, , 19 atoms
C
QM9 40727, , 23 atoms
d
QM9 107860, , 20 atoms
Optimization step
Supplementary Fig. 1 | Further geometry optimizations from MMFF94 starting structures. Four molecules drawn at random, together with the example of Fig. 2d–f, from the molecules whose model optima all lie within 0.01 Å RMSD of the optimum the reference reaches from the same start: QM9 72909 (C₇H₁₁NO; a), 39043 (C₈H₁₀O; b), 40727 (C₉H₁₄; c) and 107860 (C₇H₁₁NO; d). Left, reference optimum; right, energy relative to each surface’s own optimum (top) and maximum force (bottom) along the optimization, for the reference SCF and for SwinUNETR-V2 and NeXtUNETR with and without the non-self-consistency correction (blue circles, SwinUNETR-V2; green diamonds, NeXtUNETR; black triangles, reference; solid, w/ NSCC; dashed, w/o NSCC). Energy on a symmetric logarithmic axis. Dotted: maximum-force criterion.
Reference (SCF), 200 Ha
One-step, 200 Ha
Reference (SCF), 400 Ha
One-step, 400 Ha
a
b

C
Supplementary Fig. 2 | The egg-box effect of the 200 Ha grid and the 400 Ha evaluation. The relaxed alanine dipeptide (C7eq) translated rigidly by one spacing of the 200 Ha grid along each axis (0.144 Å along the cell diagonal; 13 points). a, Energy relative to the unshifted geometry, for the reference SCF (solid lines, filled circles) and the one-step calculation (SwinUNETR-V2; dashed lines, open squares), evaluated on the 200 Ha grid (orange) and on the 400 Ha grid (blue); the 400 Ha curves are not periodic in the 200 Ha spacing. b, Per-atom force variation: deviation of each force component from its mean over the 13 points, net force removed at each point, RMS over atoms. c, Largest deviation of a per-atom force vector over the translation, by element (filled, SCF; hatched, one-step). One-step forces are w/ NSCC; in this CPU calculation the fixed-D term is evaluated on the 400 Ha grid but the Kohn–Sham matrix of the output density that enters the NSCC on the 200 Ha grid (the GPU implementation evaluates both on the 400 Ha grid; fully consistent, the 400 Ha RMS is 5.3 instead of 5.4 meV Å ).
Supplementary Table 1 | Inference in fp32 and TF32. Density NMAE (%), mean over the 500 QM9 test molecules of Fig. 1) and network forward time per molecule, with TF32 tensor-core arithmetic disabled (fp32, used throughout the paper) and enabled; forward times on one NVIDIA H200 NVL GPU with batch size 1, as in Fig. 1d. “Prediction change” is the mean relative change of the predicted density between the two settings. All networks we trained used TF32 (PyTorch’s default for cuDNN convolutions).
| Model | Params (M) | NMAE fp32 | NMAE TF32 | Forward fp32 (ms) | Forward TF32 (ms) | Prediction change (%) |
|---|---|---|---|---|---|---|
| SwinUNETR-V2-18M | 18.5 | 0.369 | 0.370 | 88 | 76 | 0.006 |
| SwinUNETR-V2-73M | 73.1 | 0.255 | 0.255 | 145 | 94 | 0.004 |
| SwinUNETR-V2-292M | 291.7 | 0.204 | 0.204 | 278 | 116 | 0.003 |
| SwinUNETR-V2-656M | 655.9 | 0.215 | 0.215 | 550 | 165 | 0.003 |
| NeXtUNETR-17M | 17.5 | 0.187 | 0.188 | 38 | 33 | 0.010 |
| NeXtUNETR-67M | 67.5 | 0.133 | 0.133 | 74 | 60 | 0.008 |
| NeXtUNETR-150M | 150.1 | 0.116 | 0.116 | 115 | 89 | 0.007 |
| NeXtUNETR-265M | 265.4 | 0.120 | 0.120 | 157 | 115 | 0.007 |
| SR-ResNet-9M | 9.4 | 0.320 | 0.238 | 213 | 57 | 0.222 |
| SR-ResNet-70M | 70.2 | 0.198 | 0.191 | 1,544 | 208 | 0.123 |
Supplementary Table 2 | Single-point wall times. Median time per molecule (s; three significant figures) over the 200 QM9 molecules of Extended Data Table 2 (4–25 atoms, median 19), each at its reference-SCF minimum. One calculation per molecule and row.
| A40 | A100 | H100 | CPU (16 cores) | |
|---|---|---|---|---|
| Reference SCF | ||||
| energy | 10.6 | 2.29 | 2.17 | 61.8 |
| energy + forces | 12.8 | 2.69 | 2.41 | 68.4 |
| NeXtUNETR | ||||
| network forward | 0.140 | 0.113 | 0.0686 | 1.89 |
| network backward | 0.159 | 0.128 | 0.0837 | 2.22 |
| energy | 1.63 | 0.543 | 0.451 | 6.95 |
| energy + forces w/o NSCC | 2.89 | 0.687 | 0.573 | 12.7 |
| energy + forces w/ NSCC | 4.39 | 0.997 | 0.801 | 24.2 |
| SwinUNETR-V2 | ||||
| network forward | 0.788 | 0.708 | 0.268 | 8.34 |
| network backward | 0.818 | 0.557 | 0.297 | 11.8 |
| energy | 2.32 | 1.15 | 0.664 | 13.1 |
| energy + forces w/o NSCC | 3.61 | 1.32 | 0.791 | 19.6 |
| energy + forces w/ NSCC | 5.78 | 2.03 | 1.23 | 39.2 |
Times are for a new molecule in a running program: program start, library and model loading, file input and cell construction are excluded; every row starts from the same emptied caches.
Reference SCF: PBE, converged to Ha from the atomic guess, density and forces on the 400 Ha grid; median 16 SCF cycles (range 9–20). One-step: as described in Methods (network on the 200 Ha grid, energy and forces on the 400 Ha grid).
Networks run in fp32 (TF32 off). Network forward and backward: the network alone, from the SAD input. The backward pass gives the gradient with respect to the network input only (weights frozen); it is the network part of the w/ NSCC force.
Hardware: one NVIDIA A40 (48 GB), A100 SXM4 (80 GB) or H100 NVL GPU (GPU4PySCF 1.8.0 with PySCF 2.14.0, CuPy 14.1.1, PyTorch 2.3.1); CPU: 16 cores of an AMD EPYC 7543 (PySCF 2.6.2, PyTorch 2.3.1).