arXiv:2610.37843physics.chem-phOct 2026

Manuscript Offprint

arXiv:2610.37843

Where the Error Lives: Spectral Representations of Learned Kohn-Sham Hamiltonians

Fang Sun, Hekai Cheng, Ruoyan Li, Yuanzhou Chen, Wei Wang, Jason Cong, Yizhou Sun

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Kohn–Sham density functional theory (DFT) is the standard method for computing the electronic structure of molecules and materials, but its self-consistent-field (SCF) iterations make it expensive for large systems and high-throughput screening. Machine-learned Hamiltonian models offer a shortcut: an equivariant network predicts the Kohn–Sham Hamiltonian matrix in one forward pass, and diagonalizing the prediction yields orbital energies, the HOMO–LUMO gap, molecular orbitals and the electron density. These models are trained to match the reference matrix entry by entry, yet a small entry-wise error does not guarantee accurate eigenvalues or eigenvectors. Two physics-informed alternatives go partway: a recently proposed wavefunction-alignment loss adds a spectral penalty without diagonalizing the prediction, and matching the electron density of the diagonalized prediction supervises it directly. Neither is complete: by representing the prediction error in the eigenbasis of the reference Hamiltonian, we show that each sees only part of the error, and that shifting the predicted orbital energies leaves the electron density exactly unchanged. The same analysis identifies a complete training signal: the cumulative local density of states (cumulative LDOS), the number of electrons at each point in space with energy below a given threshold. The cumulative LDOS is a single physical observable that contains the electron density as a special case, responds to every component of the error, determines the Hamiltonian uniquely, and yields gradients that do not vanish for large orbital-energy errors. Supervising through it, a method we call FermiScope, requires no change to the network architecture. Fine-tuning three Hamiltonian networks (QHNet, SPHNet and WANet) on QH9 in this way reduces the HOMO–LUMO gap error by 49–79%, 2.0–2.6 times more than the wavefunction-alignment loss, without increasing the element-wise error by more than 0.3%. The gains carry over to out-of-distribution and molecular-dynamics splits (36–77%), where the wavefunction-alignment loss helps less. These results show that how a predicted Hamiltonian is represented during training, not only the architecture that produces it, decides whether it is useful in practice.

1 INTRODUCTION

Kohn–Sham density functional theory (DFT) (Hohenberg & Kohn, 1964; Kohn & Sham, 1965), recognized by the 1998 Nobel Prize in Chemistry (Kohn, 1999), is the most widely used method for computing the electronic structure of molecules and materials. It summarizes the electrons of a molecule in a single matrix, the Kohn–Sham Hamiltonian, whose generalized eigendecomposition gives the orbital energies, the energies of the highest occupied and lowest unoccupied molecular orbitals (HOMO and LUMO) and their gap, the molecular orbitals, and the electron density. These quantities determine chemical reactivity, optical and electronic behaviour and, through the total energy, molecular stability. Obtaining the Hamiltonian, however, requires self-consistent-field (SCF)

*Equal contribution.

Figure

Figure 1: Overview. (a–c) A Hamiltonian network maps a molecule, QH9 #23470 (C₈H₅N), to its Kohn–Sham Hamiltonian H^\hat{H}, whose eigendecomposition gives the orbital energies and HOMO–LUMO gap, the electron density and the molecular orbitals. All visualizations in panels (a–c) use reference DFT data for this molecule. (d) In the reference orbital basis, the prediction error splits into three sectors: orbital-energy shifts (A, yellow-orange diagonal), occupied–virtual mixing (B, blue off-diagonal block) and rotations within the occupied or the virtual space (C, purple off-diagonal blocks). The tags in panel (c) mark the sectors each downstream property depends on. (e) The sectors each training signal sees. WALoss is from Li et al. (2025); density matching, Equation 4, is the E=μE = \mu slice of our loss. (f) At a point r, the cumulative LDOS N(r,E)N(r,E) is a staircase with one step per orbital. An energy error shifts a step (A), and a shape error changes step heights (B, C). The shape error shown changes the LUMO step but not the slice at μ\mu, which is the density, so it is of type C and invisible to density matching; Figure 2 shows all three types.

iterations (Szabo & Ostlund, 1996). Each iteration builds the Hamiltonian from the current occupied orbitals (O(n4)O(n^4)) in the number of basis functions nn for hybrid functionals) and diagonalizes it to obtain new ones (O(n3)O(n^3)). A typical calculation repeats this TT times, until the Hamiltonian and the orbitals it is built from agree (T≈9T \approx 9 for the QH9 molecules studied here; Appendix A). This loop limits DFT on large systems and in high-throughput screening.

Machine-learned Hamiltonian models remove this bottleneck. An equivariant neural network predicts the Hamiltonian directly from the atomic numbers and positions (Schütt et al., 2019; Unke et al., 2021; Li et al., 2022; Yu et al., 2023b; Li et al., 2025; Luo et al., 2025), replacing all TT iterations by one forward pass. The predicted Hamiltonian is used in two ways: it can be diagonalized once to obtain orbital energies, orbitals and the density, or it can initialize a conventional DFT calculation to save SCF iterations (Yu et al., 2023a; Li et al., 2025). We focus on the first setting, where no SCF iteration is left to correct the prediction and the quality of the loss function directly determines the quality of the result. On the QH9 benchmark (Yu et al., 2023a), the entry-wise error of the predicted Hamiltonian has more than halved since the benchmark was introduced (Table 1), but this has not always translated into better eigenvalues.

The entry-wise error does not translate directly into accurate eigenvalues and eigenvectors. For example, continuing to train QHNet with its own element-wise loss lowers its matrix error but raises its HOMO–LUMO gap error, consistently on all four QH9 splits and by 53% on the standard split (Appendix G.2). Li et al. (2025) observed the same decoupling from the other side: on QH9, their alignment loss increased the matrix error while improving the orbital energies, and on larger molecules, matrices with tiny relative errors produced unusable total energies. The reason is that these models are trained with an element-wise loss, the mean absolute or squared error over matrix entries, which treats every entry alike, whereas eigenvalues and eigenvectors respond very unevenly to an error. Classical matrix perturbation theory makes this precise (Kato, 1995; Davis & Kahan,

1970; Stewart & Sun, 1990): to first order, an eigenvalue moves only with the corresponding diagonal entry of the error expressed in the eigenbasis, and the eigenvectors rotate by the off-diagonal entries divided by eigenvalue differences. On QH9, an error that couples the HOMO and the LUMO, about 0.25 Ha apart, therefore changes the LUMO about 75 times more than an equally large error that couples it to a core orbital some 19 Ha lower.

To make this precise, we represent the prediction error in the eigenbasis of the reference Hamiltonian, where it separates into three interpretable blocks, which we call sectors (Figure 1d): diagonal entries, which shift orbital energies; entries corresponding to an occupied and an unoccupied orbital, which mix the two and change the electron density; and entries corresponding to two occupied or two unoccupied orbitals, which only rotate orbitals within those spaces. This view explains why existing physics-informed losses help only partly. The wavefunction-alignment loss (WALoss) of Li et al. (2025) evaluates the predicted Hamiltonian in the reference orbital basis. In its full form it weights every entry of the error uniformly, like the element-wise loss, and therefore does not concentrate on the errors that matter; in the diagonal-only form proposed by Li et al. (2025), it penalizes only the orbital energies, and only to first order. A natural alternative is to diagonalize the prediction and match its electron density, which is exact and automatically focuses on the frontier orbitals, those closest to the HOMO–LUMO gap. We prove, however, that energy shifts and rotations within the occupied or the unoccupied space leave the density exactly unchanged, so a loss that depends only on the density does not respond to them at all; we say that it is blind to them. These errors span about 69% of the degrees of freedom of the error on QH9 and include every orbital-energy error.

The same representation tells us what a complete training signal must do: see every sector, weight each by its effect on the properties of interest, and use the exact eigenpairs of the prediction. We find such a signal in a physical observable, the local density of states (LDOS), which resolves the electron density by energy and is what a scanning tunnelling microscope measures (Tersoff & Hamann, 1985). Its cumulative form, N(r,E)N(\mathbf{r}, E), the number of electrons at point r\mathbf{r} with energy below EE, represents the Hamiltonian in the language of the density without discarding the orbital energies (Figure 1f). We prove four properties. The density is its slice at the Fermi level, the energy midway between the HOMO and the LUMO. It responds to every sector. It determines the Hamiltonian uniquely. And unlike a peak-shaped LDOS, it keeps pulling an orbital energy toward its target however far inside the energy window it starts. We turn NN into a training loss, the cumulative LDOS loss Lcum\mathcal{L}_{\text{cum}}: the mean squared difference between NN computed from the predicted and from the reference Hamiltonian, over sampled points r\mathbf{r} and energies EE. A network is fine-tuned on Lelem+wLcum\mathcal{L}_{\text{elem}} + w \mathcal{L}_{\text{cum}}, where Lelem\mathcal{L}_{\text{elem}} is its usual element-wise loss and ww a weight, with no change to its architecture. We call this method FermiScope, as it scans NN across a window of energies around the Fermi level.

Across three architectures and four QH9 splits, this loss improves every eigen-derived metric in all twelve settings and is the best method in each (Tables 1 and 6). On the standard split, it lowers the HOMO–LUMO gap error by 49–79%, 2.0–2.6 times more than WALoss, while the element-wise error rises by at most 0.3% and on QHNet even falls by 3.5%. Under distribution shift, it still lowers the gap error by 36–77%, whereas WALoss makes it worse in three of the nine shifted settings, all on QHNet.

Our contributions are as follows.

  • Problem. We show that the mismatch between how Hamiltonian networks are trained, entry by entry, and how they are used, through eigenpairs, is a question of where the error lies. In the reference orbital basis, the error separates into sectors that each property and each training signal read selectively, and the electron density, the most natural physical target, is blind to every orbital-energy error (Sec. 3.1).

  • Solution. We identify the cumulative LDOS as a representation of the Hamiltonian that contains the density, sees every sector and determines the Hamiltonian uniquely, and we turn it into a training loss that any Hamiltonian network can use unchanged (Secs. 3.2 and 3.3).

  • Results and implications. The loss improves every eigen-derived metric in all twelve backbone-split settings without raising the element-wise error by more than 0.3% (Sec. 4). How a predicted Hamiltonian is represented during training, and not only the architecture that produces it, decides whether it is useful.

References (67)