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 orbitalenergy errors. Fine-tuning three Hamiltonian networks on QH9 in this way, which we call FermiScope, reduces the HOMO-LUMO gap error without increasing the element-wise error. The gains carry over to out-of-distribution and molecular-dynamics splits, where the wavefunction-alignment loss helps less.
Figures & tables
Figure 1: Overview. (a–c) A Hamiltonian network maps a molecule, QH9 #23470 (C 8 H 5 N), to its Kohn–Sham Hamiltonian 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=μ slice of our loss. (f) At a point r , the cumulative LDOS 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 μ , which is the density, so it is of type C and invisible to density matching; Figure 2 shows all three types.
Figure 2: How each kind of error shows up in the cumulative LDOS: the first-order change of N(r,E) at one point r as a function of energy (schematic levels with the median QH9 gap, σ=0.02 Ha; sign and scale arbitrary). An orbital-energy error ( A , left) adds a bump at its level. An occupied–virtual coupling ( B , middle) adds a plateau between the two levels, which crosses the Fermi level μ . A coupling of two occupied orbitals ( C , right) adds a plateau that ends below μ . Density matching reads only the slice E=μ (dashed line), where only the B plateau is nonzero; the cumulative LDOS loss reads the whole energy window and sees all three (Theorem 3.5 (ii)).
backbone
role
method
H
diag
non-diag
HOMO ↓
LUMO ↓
gap ↓
εO↓
ψ↑
pretrained
77.56
129.25
73.68
1041
9445
9632
1206
96.28
baseline
+ WALoss
78.04
119.03
74.95
847
5458
5835
570
96.79
ablation
+ density only ( w=100 )
76.82
118.70
73.65
719
1575
2081
356
97.87
QHNet
ours
+ cumulative LDOS (ours)
74.81
109.54
72.19
678
1482
2027
341
97.91
pretrained
36.60
44.79
35.38
345
1309
1554
380
99.06
baseline
+ WALoss
37.28
46.03
35.98
341
957
1259
288
99.17
Table 1: Results on the QH9-stable-id test set (13,084 molecules) after 30k fine-tuning steps. Energies in μ Ha, ψ in %. For each backbone, the gray rows are the two baselines, the pretrained model and fine-tuning with WALoss ( Li et al., 2025 ) . The violet row, density only , is the ablation at weight w=100 that keeps only the E=μ slice of our loss, which is density matching (Proposition B.4 ). The blue row is our cumulative LDOS loss, which adds the energy resolution. All fine-tuning runs share every other setting, and the peak-shaped variant is in Appendix G.4 . Bold marks the best downstream metric per backbone.
Figure 3: Reduction of the HOMO–LUMO gap error relative to each pretrained model on the three shifted QH9 splits (higher is better; negative values mean that the error grew). The cumulative LDOS loss (ours, trained as Lelem+wLcum ) lowers the gap error on every backbone and split, and it also improves every other downstream metric; Table 6 in Appendix G.1 lists all metrics.
Appendix figures & tables23 assets
Supplementary material from the paper’s appendix.
Appendix
term
meaning
atomic number Z
Number of protons of a nucleus; it identifies the element (H 1, C 6, N 7, O 8, F 9).
basis set, basis function, atomic orbital
A fixed set of functions ϕμ centred on the atoms, in which the molecular orbitals are expanded; each function is called an atomic orbital.
def2-SVP
A standard Gaussian basis set of split-valence quality with polarization functions; it gives 5 functions per H atom and 14 per C, N, O or F atom.
molecular orbital ψi
A one-electron wavefunction of the molecule, a linear combination of basis functions; ∣ψi(r)∣2 is the probability density of an electron in that orbital.
Kohn–Sham DFT
Density functional theory in which the interacting electrons are replaced by non-interacting electrons in an effective potential that depends on the electron density.
exchange–correlation functional, B3LYP
The approximate part of the effective potential that accounts for many-electron effects; B3LYP is a widely used hybrid functional, which mixes in exact exchange.
Appendix
Table 2: Quantum-chemistry terms used in this paper.
Figure 4: (a) The self-consistent-field loop of Kohn–Sham DFT: the Kohn–Sham matrix is built from the current density matrix and diagonalized, and the occupied orbitals give the next density matrix, until the two agree. (b) A Hamiltonian network predicts the converged matrix in one forward pass; one diagonalization gives the orbital energies, orbitals and density, and the prediction can also initialize SCF. Iteration counts are medians over 50 QH9-stable-ood test molecules (PySCF, B3LYP/def2-SVP).
loss
energies di
ΔOV (density)
ΔOO,ΔVV
weighting
eigenpairs of H^
element-wise Lelem
✓
✓
✓
uniform
–
WALoss, full ( Li et al., 2025 )
✓
✓
✓
uniform
–
WALoss, diagonal-only ( Li et al., 2025 )
first order
–
–
occupied orbitals and LUMO
–
density matching Lρ
–
✓
–
frontier, 1/(εa−εi)
✓
cumulative LDOS Lcum (ours)
✓
✓
✓
frontier and energy window
✓
Appendix
Table 3: Which sectors of the error each loss responds to (first order), how it weights them, and whether it uses the eigenpairs of the prediction. The element-wise loss is uniform up to the overlap metric (Lemma B.1 ).
split
selection rule
train
val
test
tests
stable-id
random 80/10/10
104,664
13,083
13,084
interpolation
stable-ood
≤20 / 21 – 22 / ≥23 atoms
104,001
17,495
9,335
molecule size
dynamic-geo
geometries within a molecule
79,920
9,990
9,990
unseen geometry
dynamic-mol
disjoint molecules
79,900
9,900
10,100
unseen molecule
Appendix
Table 4: The four QH9 splits. Sizes are the exact record counts read from the released split masks. The size split thresholds are on the total atom count, hydrogens included; the random split uses a fixed permutation with seed 43.
quantity
median
range
min–max
atoms per molecule
18
–
5–29
heavy atoms (C, N, O, F)
9
–
1–9
basis functions n
171
141–196
34–226
occupied orbitals nocc
33
29–35
5–37
occupied fraction f=nocc/n
0.193
0.178–0.219
0.147–0.256
HOMO–LUMO gap (Ha)
0.248
0.173–0.305
0.079–0.463
Appendix
Table 5: QH9-stable composition and reference spectra, measured on a uniform 4,000-molecule sample. Ranges are 5 – 95% intervals unless a min–max is stated. The last row is the exact fraction of the parameters of a symmetric residual that lie in the two sectors the density loss cannot resolve.
Figure 5: QH9-stable statistics from a uniform 4,000-molecule sample. (a) Basis size. (b) Number of occupied orbitals. (c) Reference HOMO–LUMO gap. (d) Exact partition of the n(n+1)/2 parameters of a symmetric residual Δ into the three sectors of Proposition 3.1 , at fixed n=171 , as a function of the occupied fraction f . Only the occupied–virtual slice changes the density; at the QH9 median occupied fraction it accounts for 31% of the parameters, and the remaining 69% is invisible to Lρ .
Figure 6: Reference electron density for twelve QH9-stable molecules, on the best-fit plane through the nuclei, logarithmic colour scale, all panels on the same length scale and the same colour scale. Bonds are drawn from covalent-radius criteria; nuclei more than 0.7a0 off the plane are drawn open, so a panel with many open markers is a non-planar molecule seen in projection. Molecular formulae are in Hill notation.
Figure 7: Anatomy of a reference Kohn–Sham Hamiltonian, molecule #12345 (C 7 H 10 O, n=162 , nocc=30 ). (a) ∣Hμν⋆∣ and (b) ∣Sμν∣ on a logarithmic colour scale; thin white rules mark heavy-atom block boundaries. Entries below 10−5 are shown at the floor of the scale. (c) Magnitude of the Hamiltonian elements against the distance between the atoms carrying the two basis functions, with same-atom pairs placed at zero and jittered. The orange curve is the binned median and the orange marker the same-atom median. The decay over six orders of magnitude is what local message-passing architectures exploit.
Figure 8: Real-space reference quantities for molecule #23470 , 2,5-diethynyl-1H-pyrrole (C 8 H 5 N, n=151 , nocc=30 ), which is exactly planar. (a) Electron density in the nuclear plane, logarithmic scale, with the molecular skeleton overlaid and the nitrogen drawn open. (b,c) HOMO and LUMO amplitudes sampled 1a0 above the nuclear plane and normalized by their own maxima; both vanish identically in the plane itself. (d) Upper envelope ( 99.5 th percentile per radial bin) of ρ⋆ and of the core-suppressed target ρ⋆/div against distance to the nearest nucleus; the two coincide beyond 2a0 , where div=1 . (e) The 256 sampled points reproduce the radial distribution of the full 14,112-point quadrature grid. (f) Relative error of the atomic-superposition density against distance to the nearest nucleus.
Figure 9: Spectral reference quantities for molecule #23470 . (a) Generalized eigenvalues with the loss window shaded; the energy axis is broken so that the nine core levels are visible. (b) Cumulative LDOS N(r,E) of Equation 7 at five of the 256 sample points, spanning three orders of magnitude in local density. (c) Proposition B.4 tested pointwise: N(r,μ) against ρ⋆(r)/2 at all 256 sample points. (d) The two energy profiles at one sample point, with the constant contribution of the levels below the window removed and each curve normalized by its own maximum. Ticks mark the orbital energies.
Figure 10: Sector content of a physically realized Hamiltonian change, and two numerical properties of the estimator. (a) ∣Δ∣ for one pair of QH9-dynamic frames of the same molecule separated by 0.30 Å RMSD, in the eigenbasis of the reference frame; red rules mark the occupied/virtual boundary at nocc=34 , and values are clipped to the colour range at both ends. (b) Median share of ∥Δ∥F2 per sector against displacement, over 640 frame pairs from 214 trajectories. The virtual–virtual share, which contains the LUMO energy error and is invisible to Lρ , doubles from 15% to 30% as the displacement grows. (c) Relative standard error of the per-molecule loss estimate when ∣R∣ of the 256 cached sample points are used, over 400 draws; solid lines are a random 75μ Ha element-wise residual, dashed lines a 10 mHa LUMO shift, and the grey guide is the ∣R∣−1/2 rate. (d) Observed amplification ∥Δ∥F/∥δH∥F against the bound ∥S−1∥2 of Lemma B.1 , same frame pairs.
backbone
split
method
H
diag
non-diag
HOMO ↓
LUMO ↓
gap ↓
εO↓
ψ↑
QHNet
stable-ood
pretrained
73.53
122.32
70.78
561
4632
4522
740
95.54
+ WALoss
72.70
115.00
70.30
475
5511
5671
393
95.04
+ cumulative LDOS (ours)
71.10
110.81
68.87
442
1420
1506
290
96.17
dynamic-geo
pretrained
98.4
161.4
93.6
960
5561
6090
840
96.66
+ WALoss
100.0
162.2
95.3
976
6950
7441
597
96.06
+ cumulative LDOS (ours)
95.6
148.5
91.6
771
1517
2132
400
97.85
Appendix
Table 6: Results on the shifted QH9 splits (test sets; energies in μ Ha, ψ in %). Same protocol as Table 1 . Bold marks the best downstream metric per block.
backbone
method
H
diag
non-diag
HOMO ↓
LUMO ↓
gap ↓
εO↓
ψ↑
QHNet
pretrained
77.56
129.25
73.68
1041
9445
9632
1206
96.28
+ element-wise loss only (control)
74.44
108.11
71.90
1280
14946
14769
868
95.57
+ WALoss
78.04
119.03
74.95
847
5458
5835
570
96.79
+ cumulative LDOS (ours)
74.81
109.54
72.19
678
1482
2027
341
97.91
SPHNet
pretrained
36.60
44.79
35.38
345
1309
1554
380
99.06
+ element-wise loss only (control)
36.55
44.67
35.35
349
1311
1555
381
99.05
Appendix
Table 7: QH9-stable-id, all three backbones (Table 1 with the element-wise-only control added; test set, μ Ha, ψ in %). Bold marks the best downstream metric per backbone.
split
method
H
diag
non-diag
HOMO ↓
LUMO ↓
gap ↓
εO↓
ψ↑
stable-id
pretrained
77.56
129.25
73.68
1041
9445
9632
1206
96.28
+ element-wise loss only (control)
74.44
108.11
71.90
1280
14946
14769
868
95.57
+ WALoss
78.04
119.03
74.95
847
5458
5835
570
96.79
+ cumulative LDOS (ours)
74.81
109.54
72.19
678
1482
2027
341
97.91
stable-ood
pretrained
73.53
122.32
70.78
561
4632
4522
740
95.54
+ element-wise loss only (control)
70.86
109.25
68.70
783
15801
15638
582
94.35
Appendix
Table 8: QHNet on all four QH9 splits (the QHNet rows of Tables 1 and 6 with the element-wise-only control added; test sets, μ Ha, ψ in %). Bold marks the best downstream metric per split.
method
H
diag
non-diag
HOMO
LUMO
gap
εO
ψ
pretrained
77.56
129.25
73.68
1041
9445
9632
1206
96.28
element-wise loss only (control)
74.44
108.11
71.90
1280
14946
14769
868
95.57
WALoss w=0.03
76.01
112.51
73.26
823
5728
6072
593
96.81
WALoss w=0.1
78.04
119.03
74.95
847
5458
5835
570
96.79
density only w=1
77.72
126.93
74.02
780
1923
2376
571
97.44
density only w=10
79.01
138.44
74.55
802
2500
2896
373
97.43
Appendix
Table 9: QHNet on QH9-stable-id: all metrics against the auxiliary weight w (test set, μ Ha). WALoss is the full form used throughout the paper; the weight of the cumulative loss, w=30 , is selected on the validation split.
method
H
diag
non-diag
HOMO
LUMO
gap
εO
ψ
pretrained
77.56
129.25
73.68
1041
9445
9632
1206
96.28
diagonal-only WALoss w=1
74.48
108.29
71.93
1130
12504
12373
797
95.88
diagonal-only WALoss w=10
75.20
110.03
72.58
1090
14208
13701
977
95.59
diagonal-only WALoss w=100
77.84
117.44
74.86
1862
28282
26813
1573
93.66
Appendix
Table 10: QHNet on QH9-stable-id with the diagonal-only form of WALoss at three weights (test set, μ Ha).
Figure 11: Weight sensitivity on QHNet (entries of Tables 9 and 10 ). (a) Gap error and (b) occupied-orbital energy error against the auxiliary weight w , with the pretrained checkpoint, the element-wise-only control and WALoss ( w=0.1 ) as horizontal references. The diagonal-only WALoss gets worse as its weight grows; the density-only and cumulative losses improve or stay flat, and the cumulative loss is the lowest at every weight.
loss
LUMO +2
LUMO +1
LUMO
HOMO
HOMO −5
HOMO −19
HOMO −21
HOMO −23
pretrained
3455
3838
9593
1005
403
635
1029
1049
peak LDOS
2287
1698
7685
1053
593
5955
11364
20979
cumulative LDOS
1032
994
1567
690
235
195
251
367
Appendix
Table 11: Per-orbital energy error on QHNet (1,000 test molecules, μ Ha) for the peak-shaped and the cumulative loss at the same weight ( w=30 ), window and σ . The peak-shaped loss corrects the virtual orbitals inside the window but lets the deep occupied orbitals drift; the cumulative loss improves every orbital.
method
SCF iterations
SCF time
total time
pretrained
0.6732
0.8115
0.8619
element-wise loss only (control)
0.6735
0.8139
0.8655
density only ( w=100 )
0.6710
0.8171
0.8682
cumulative LDOS ( w=100 )
0.6713
0.8028
0.8505
Appendix
Table 12: SCF acceleration on 50 QH9-stable-id test molecules: ratio of SCF iterations and of wall time relative to the minao initial guess (lower is better; total time includes model inference).
auxiliary loss
seconds/step
overhead
peak GPU memory (GB)
none (element-wise only)
1.47
–
31.2
density only
1.92
+0.45 s ( +30% )
31.2
peak LDOS
2.28
+0.81 s ( +55% )
31.2
cumulative LDOS
2.19
+0.72 s ( +49% )
31.2
Appendix
Table 13: Training cost of the auxiliary losses on QHNet (QH9-stable-id), measured on one NVIDIA L40S with the same code, data order and batch size (32). Seconds per step are averaged over steps 50–300 without validation; memory is the peak reserved CUDA memory. The eigendecompositions run on the CPU in double precision.
Figure 12: (a) Response of each loss to controlled perturbations of the reference Hamiltonian of one QH9 molecule ( #12345 ): shifting the LUMO or HOMO energy by 2 mHa with all orbitals fixed, or rotating the HOMO and LUMO into each other with all energies fixed. Density matching does not respond to energy shifts at all (values at the level of floating-point round-off); both LDOS losses respond to both kinds of error. (b) Mismatch between a displaced and a reference orbital as a function of the energy error δ , for a Gaussian peak and for a cumulative step (closed forms of Theorem 3.5 (iv)): the peak mismatch saturates, the step mismatch keeps growing. (c) The corresponding gradient with respect to δ , normalized by its maximum: the peak gradient vanishes beyond a few σ , whereas the step gradient approaches a constant.
statement
what is checked
result
reference
generalized eigenbasis
∥C^⊤SC^−I∥∞
4.8×10−14
–
cache consistency
recomputed vs. released S
2.2×10−7
App. C
cache consistency
∫ρ⋆dV vs. Ne=60
59.978
App. C
Prop. B.4
N(r,μ) vs. ρ⋆(r)/2 , all 256 points
6.4×10−8 rel. (float32 cache)
Fig. 9 c
Prop. B.6
closed forms g(δ) , c(δ) vs. quadrature
9.3×10−16 rel.
Fig. 12 b
energy-only perturbation
induced Δεi
2.000 mHa (exact)
Fig. 12 a
Appendix
Table 14: Numerical checks. Molecule #12345 and #23470 are the two QH9-stable geometries used in the appendix figures; the lower block also uses molecule #18 . “Machine zero” means the response is at or below the double-precision noise floor of the quantity being differenced.
QHNet
SPHNet / WANet
optimizer
AdamW, β=(0.99,0.999)
native
learning rate
1×10−5
1×10−5
warm-up steps
1,000
native
fine-tuning steps
30,000
30,000
batch size
32
64
gradient clipping
norm 5.0
norm 5.0
Appendix
Table 15: Fine-tuning settings. Every method of a given backbone shares all settings except the auxiliary loss and its weight; unlisted settings follow each backbone’s released training recipe (“native”). The cumulative LDOS weight is selected on the validation split; Table 9 reports its test-set sensitivity on QHNet.
Department of Computing and Mathematical Sciences, California Institute of Technology · Department of Mathematics, ETH Zürich · Division of Chemistry and Chemical Engineering, California Institute of Technology +1