Some neural networks for quantum chemistry are trained to output the electronic Hamiltonian, the matrix that encodes how every pair of atomic orbitals in a molecule interacts, instead of a single energy number. A standard linear-algebra step then turns that matrix into energies, forces and wavefunctions. These models now report very large accuracy gains on public benchmarks such as QH9 and ∇²DFT. Nobody has checked how much of that accuracy comes from recalling molecules the model has already seen. We propose a test borrowed from language-model contamination auditing. Keep one part of a benchmark molecule exactly as it appears in the benchmark, change the rest by a small, physically controlled amount, and recompute the true answer with density functional theory (DFT, the quantum-chemistry calculation that produces the reference labels). A model that has learned transferable physics should be about as accurate on the modified molecule as on the original. A model that has memorized the original shows an "error well": its accuracy is unusually sharp at the exact benchmark geometry and degrades faster than physics justifies once anything changes.
The test is only reliable if it scores the right part of the matrix. Global Hamiltonian error is dominated by interactions among unoccupied orbitals, which do not affect ground-state properties (Machine Learning Hamiltonians are Accurate Energy-Force Predictors). A probe that averages over the whole matrix therefore makes the same mistake that language-model probes make when their scoring window is filled with irrelevant prompt text (Probe Choice Changes Canary-Memorization Verdicts). We build the probe around the occupied part of the matrix, check it against molecules planted in the training data with known duplication counts, and then apply it to the split designs and pretraining practices of current Hamiltonian benchmarks.
Core Claim
The claim is that memorization in continuous operator models can be measured behaviorally, without trusting the training manifest, through a neighborhood contrast with a physical null. For a benchmark geometry $x$, let $\hat H(x)$ be the predicted Hamiltonian and $H(x)$ the DFT reference. Define the subspace error
$$e(x) = \lVert P_{\text{occ}}\,[\hat H(x) - H(x)] \rVert_F ,$$
where $P_{\text{occ}}$ keeps only the occupied–occupied and occupied–virtual blocks after both matrices are rotated into the reference molecular-orbital basis, and $\lVert\cdot\rVert_F$ is the Frobenius norm. These are the blocks that determine energies and forces.
Let $\mathcal N_F(x)$ be a set of counterfactual geometries. Each one keeps a fragment $F$ of $x$ fixed to the benchmark coordinates; this fragment plays the role of the "prefix" in language-model probing. The rest of the molecule is changed, either by small displacements along normal modes or by swapping a substituent beyond the fragment's first coordination shell. Each counterfactual gets its own fresh DFT label. The memorization score is
$$M_F(x) = \log \frac{\operatorname{median}_{x' \in \mathcal N_F(x)}\, e_F(x')}{e_F(x)} ,$$
where $e_F$ restricts the subspace error to the orbital blocks centered on the fixed fragment.
The physical null comes from the "nearsightedness" of electronic structure: changing atoms far from a fragment barely changes the true Hamiltonian blocks on that fragment. We measure that small change directly in the DFT labels. The model's accuracy on the kept fragment should therefore not depend on whether the rest of the molecule matches a training example exactly. A large positive $M_F$ means the model is keying on the identity of the whole molecule.
Some geometries are intrinsically easier than others. Stable minima, for example, may be easier than displaced structures. We handle this by calibrating $M_F$ against its distribution on molecules that are certifiably absent from training, so the reported quantity is an excess over that null.
The contribution is not "probing Hamiltonian models", which is currently empty territory. It is a specific probe that combines three pieces. From NLP Evaluation in trouble and Investigating Data Contamination in Modern Benchmarks it takes the idea of conditioning on part of an instance and checking completion of the rest. From NumLeak it takes the idea that memorization of continuous values is visible in graded scores even when point outputs look ordinary. From the canary study it takes the lesson that the scoring window decides the verdict. Its scoring subspace is chosen by the energy–force analysis of Machine Learning Hamiltonians are Accurate Energy-Force Predictors.
Why This Question Is Live
Two findings motivate the work. QH9 reports that Hamiltonian error nearly doubles when moving from its geometry-wise split, where test snapshots come from the same molecular-dynamics trajectories as training snapshots, to its molecule-wise split. That gap is consistent with models exploiting near-duplicate structures, but it is equally consistent with new molecules simply being harder. A difference in averages cannot separate the two explanations; a per-instance probe can.
Learning from the Electronic Structure of Molecules across the Periodic Table argues that the dense supervision of a Hamiltonian ($O(N^2)$ labels per structure instead of one energy) forces networks to learn bonding physics. It reports a 2× low-data energy gain from Hamiltonian pretraining. Dense targets could just as well make individual structures easier to memorize. The same paper's HELM model and QHFlow2 are also moving toward large pretraining mixtures and zero-shot evaluation on PubChem molecules. Once that happens, cross-benchmark overlap becomes a live concern: QM9-derived molecules could appear inside broader corpora, or MOSES scaffolds could be shared between datasets.
One result constrains the design. NumLeak shows that point predictions can look plausible while being driven by recall, and that graded scores expose recall that greedy outputs hide. We take from this that the probe must be a contrast of error magnitudes, not a pass/fail check on whether a prediction is "correct".
Research Program
The work has three stages.
Stage 1: build the counterfactual generator and DFT pipeline. We work on QH9 molecules (up to 29 atoms at B3LYP/Def2SVP) because counterfactual DFT at that size costs minutes, not days. For each probed molecule we generate two kinds of neighbors while freezing a chosen fragment. Geometric neighbors are small displacements along normal modes of the non-fragment atoms, sized to stay inside the thermal range represented in QH9-dynamic. Chemical neighbors swap a distal substituent while keeping the molecule valence-valid and close in composition. We label every neighbor with the same functional and basis as the benchmark, so the null variation in the fragment blocks is measured rather than assumed.
Stage 2: calibrate the probe in a controlled setting where membership is known. We retrain QHNet, the QH9 reference architecture, and one stronger equivariant model we can retrain from public descriptions. Into their training sets we plant a set of "canary" molecules drawn from a pool excluded from all splits. Canaries are duplicated 1, 4, 16 and 64 times, mirroring the duplication sweep in the canary study. Matched unplanted molecules from the same pool serve as non-members. This gives ground truth for detection curves. It also lets us compare scoring choices head to head: full-matrix mean absolute error (MAE), occupied-subspace error, fragment-restricted error, predicted energy, and predicted forces. The goal is to find where the continuous analogues of the "preamble trap" and "blind window" appear.
Stage 3: apply the calibrated probe to real benchmark designs. Here we ask three questions. What fraction of QH9-dynamic-geo test snapshots sit in error wells compared with QH9-dynamic-mol? How does well depth depend on distance to the nearest training snapshot along the trajectory? And for a model pretrained on ∇²DFT and evaluated on QH9, or the reverse, do molecules flagged as overlapping by structure matching show excess wells relative to non-overlapping ones? The final output is a contamination-adjusted score: benchmark error recomputed on instances whose $M_F$ falls within the clean null.
Baselines
Do-nothing reference. The first reference point is the benchmark's own reported error, taken at face value. The strongest reported number in the file is QHNet's Hamiltonian MAE of 76.31 × 10⁻⁶ Hartree on QH9-stable-id (QH9). The QH9 paper also reports that error nearly doubles from the geo to the mol dynamic split. We will reproduce both numbers with our retrained models before probing, so that any contamination-adjusted score is compared against a verified starting point. For memorization detection itself there is nothing to beat numerically: no reported result was found on Lacuna for membership or contamination detection on any Hamiltonian-prediction model. The detection baselines below therefore have to be run by us.
Train–test gap. The simplest detector compares a model's error on training molecules with its error on held-out molecules. At the instance level this becomes loss thresholding: flag a molecule as memorized if its own error is small. This is the continuous analogue of the teacher-forced negative-log-likelihood probes in the language-model literature. It is the natural competitor because it needs no counterfactual DFT at all. We run it on the same canary sets, models and checkpoints as our probe, with the threshold tuned on the same calibration fold.
Scalar energy and force neighborhood probe. This is the strongest cheap competitor. It uses the same neighborhood contrast as our probe, but scores only predicted total energy and forces. Answering the scalar-probe objection requires showing that the Hamiltonian subspace adds something. The probe runs on identical neighbors and DFT labels, so the only thing that differs between the two is what gets scored.
Structure matching. This is the strongest existing method when the training data is public. It means nearest-neighbor matching of each test structure against the training set, using root-mean-square deviation (RMSD) of coordinates after alignment together with a connectivity-fingerprint check. We give it the full training manifest, which is an advantage our probe does not use.
Ablations of the key ingredients. The first ablation keeps the neighborhood contrast but scores full-matrix MAE instead of the occupied subspace. This isolates the subspace choice. The second keeps the occupied subspace but scores the exact geometry alone, with no neighbors. This isolates the contrast.
What counts as winning. Our probe beats a baseline if, at matched false-positive rate on non-member canaries, it has higher area under the ROC curve (AUROC) for detecting planted molecules. We require this across at least the 4× and 16× duplication levels and on both architectures, with confidence intervals from bootstrap over canaries that do not overlap. Against structure matching the success criterion is different, because matching sees the manifest by construction. There, we win if the probe separates matched instances the model actually exploits from matched instances it does not, which matching cannot do.
Why not just…?
Why not just compare training and test error? A low error on one molecule does not show that the molecule was memorized, because some molecules are simply easy: rigid, small, or close to the center of chemical space. The QH9 geo-versus-mol gap illustrates exactly this confound. Our calibration stage settles the question directly. If loss thresholding reaches the same AUROC as $M_F$ on the planted canaries, the counterfactual machinery is unnecessary, and we will report that. We expect it to fail at low duplication, where the canary study found that single-score probes disagree with behavioral recall.
Why not just probe energies and forces, which are cheaper and what users care about? This is a serious alternative, and we run it as a baseline rather than dismissing it. The argument against relying on it is that energy error scales quadratically with density error (Machine Learning Hamiltonians are Accurate Energy-Force Predictors). The energy is therefore insensitive to exactly the moderate, structure-specific deviations a memorizing model produces off its well. Forces are more sensitive but give 3 numbers per atom, compared with many orbital-pair blocks. If the scalar probe matches the Hamiltonian probe's AUROC, we will recommend the scalar probe as the practical audit and narrow our claim to localizing memorization within the molecule.
Why not just match structures against the training set, since these datasets are public? For today's academic benchmarks, matching is the right tool for establishing presence, and we use it as ground truth in stage 3. It has two limits. First, presence is not exploitation: NLP Evaluation in trouble makes this point for text, and here a near-duplicate trajectory snapshot may or may not be recalled. Second, matching requires the full pretraining manifest, which large multi-source Hamiltonian models may not publish. If matched overlap alone predicts which instances have inflated accuracy, the probe's added value shrinks to the undisclosed-data case, and we would say so.
Why not just build fresh, uncontaminated test sets? For molecules the size of QH9, fresh DFT labeling is affordable, and fresh splits are the gold standard. We use a fresh held-out pool exactly this way to define the clean null. What fresh sets cannot do is tell you which published results on the existing benchmarks were inflated, or by how much. For the 150-atom def2-TZVPD systems in OMol_CSH_58k, relabeling at scale is also costly (Learning from the Electronic Structure of Molecules across the Periodic Table). The probe needs only a few hundred sampled instances plus their neighbors to estimate the contaminated fraction.
Proposed Experiments
Detection curves on planted canaries. The first experiment reports AUROC and true-positive rate at 1% false-positive rate against duplication count, for every scoring variant and both architectures. We expect detection with full-matrix MAE to be noticeably worse than with occupied-subspace error at low duplication, the continuous analogue of the preamble trap. We also expect exact-geometry scoring to be defeated by easy non-member molecules.
The first decisive check. Across both architectures and the 4× and 16× duplication levels, $M_F$ on the occupied subspace must beat the scalar energy/force contrast and the no-neighbor ablation. If it fails, the central claim of the proposal fails.
Geo versus mol splits. The second experiment addresses the QH9 dynamic splits. We report the distribution of calibrated $M_F$ for geo and mol test snapshots, and regress well depth on trajectory distance to the nearest training snapshot. If geo-split test snapshots show excess wells that grow as training neighbors get closer, part of the doubled mol-split error reflects geo-split inflation rather than mol-split difficulty. We then report contamination-adjusted geo error alongside the published figure.
Cross-benchmark contamination. The third experiment trains or fine-tunes one model on ∇²DFT and evaluates it on QH9, or the reverse, depending on which overlap structure matching finds. We compare wells on matched and unmatched instances.
The second decisive check. Chemical neighbors (distal substituent swaps) must produce wells on planted canaries but not on clean molecules. This would show that the probe detects keying on whole-molecule identity rather than just sensitivity to geometric distortion.
Negative results we would publish. If no architecture shows excess wells at realistic duplication levels, we would report that as evidence that dense Hamiltonian supervision does not encourage instance memorization. That would be a useful answer to the open question raised by HELM's information-density argument.
References
- Machine Learning Hamiltonians are Accurate Energy-Force Predictors
- Probe Choice Changes Canary-Memorization Verdicts: Three Post-Hoc Disagreement Case Studies in a Text-Dominant LoRA-Tuned Autoregressive Testbed
- NLP Evaluation in trouble: On the Need to Measure LLM Data Contamination for each Benchmark
- Investigating Data Contamination in Modern Benchmarks for Large Language Models
- NumLeak: Public Numeric Benchmarks as Latent Label in Foundation Models
- QH9: A Quantum Hamiltonian Prediction Benchmark for QM9 Molecules
- Learning from the Electronic Structure of Molecules across the Periodic Table