Where Memorized Molecules Live in a Graph Network

Molecular property predictors are now built in stages. A graph neural network, a model that represents a molecule as atoms connected by bonds and updates each atom by passing messages from its neighbors, is first pretrained on millions of unlabeled compounds. It is then adapted on molecules from the target chemistry, sometimes with property labels, and finally fine-tuned on a benchmark. At every stage the model can see molecules that later appear in the test set, or close relatives of them. Nobody currently knows how much of the reported benchmark gain comes from that exposure rather than from chemistry that transfers. Nobody knows either whether the exposure leaves a visible trace inside the network.

This proposal uses a property that makes molecules unusually convenient for studying contamination: the training corpora are public and searchable. We can therefore inject or remove test molecules at each adaptation stage and measure the effect exactly, which is not possible for web-scale language models. Two questions follow. First, how much do scaffold-split scores rise when test molecules, with or without labels, are seen during staged adaptation? Second, does that exposure concentrate at a consistent fraction of network depth? If it does, a depth-aware readout could recover most of the clean gain while discarding most of the exposure gain, and a probe trained on that internal trace could audit models whose training data were never disclosed.

Core Claim

We hypothesize that, in staged molecular graph models, exposure to evaluation molecules is stored mainly in the late message-passing layers and the final pooled readout. Transferable chemistry should peak earlier, at an intermediate relative depth $d = l/L$, where $l$ is a layer index and $L$ the total number of layers. Language-model evidence points the same way. Evaluation Awareness Scales Predictably in Open-Weights Large Language Models finds that clean evaluation-context signals peak near $d \approx 0.4$, and that only Qwen models carry the signal late, an anomaly the authors attribute to benchmark contamination. LaRA shows that memorized items have a distinctive geometry: their hidden states shift sharply when key content is removed, yet barely move when the input is paraphrased. The claim is new in three ways. It moves both ideas to message-passing graphs. It ties them to the stage at which exposure happened. It tests them against ground truth that text settings cannot provide.

The deliverable is a measured decomposition of benchmark gain together with a depth-localized auditor. For a model adapted under exposure condition $e$, we write

$$ \Delta_{\text{total}}(e) = \underbrace{S(\text{dedup}) - S(\text{scratch})}_{\text{transferable gain}} + \underbrace{S(e) - S(\text{dedup})}_{\text{exposure inflation}}, $$

Here $S(\cdot)$ is the scaffold-split test score. "Dedup" retrains the same pipeline with test molecules and near-analogues removed from every stage, and "scratch" trains without pretraining. We estimate both terms at every relative depth, not only at the final layer.

Why This Testbed, and What Prior Work Leaves Open

Two lines of work motivate the gap. MoleculeNet standardized scaffold splits, which hold out whole families of ring cores, and found that performance drops sharply from random to scaffold splits, a sign that models lean on remembered motifs. Scaffold splits only separate the downstream training set from the downstream test set, however. They say nothing about the 20M ZINC15 molecules used to pretrain GEM, which reported gains on 14 of 15 MoleculeNet tasks without checking that corpus against the test sets. On the adaptation side, Transformers for molecular property prediction found that adapting on task molecules with property regression added about 0.2 in $R^2$, more than scaling pretraining data did. It also found that pretraining plateaued after 30% of GuacaMol. Adaptation is exactly the stage where test-adjacent molecules enter, and that study used only final-layer embeddings and did no overlap audit.

Two lines of work supply our methods. MolGA adapts a frozen 2D encoder in two stages, first aligning it to 3D knowledge and then adding about 13,824 conditional parameters. It applies those parameters uniformly across layers and attributes its gains to geometry. We reuse its staged recipe as one of our pipelines and ask how much of its gain survives deduplication. Staged adaptation itself follows Don't Stop Pretraining, which runs domain-level and then task-level continued pretraining on unlabeled text. That second step, pretraining on the task's own unlabeled inputs, is by construction a form of structure-only test exposure when the inputs include test molecules.

On the depth side, Intermediate Layers Encode Optimal Biological Representations in Single-Cell Foundation Models shows a 31% gain from reading Tahoe-X1 at $d \approx 0.6$ instead of the final layer. It also shows that the best depth varies by task, and is even the first layer for some perturbation tasks. That finding constrains us: we cannot assume a single best depth and must measure the curve per task. Categorize Early, Integrate Late shows that architectures with similar accuracy can place the same function at different relative depths, so any depth finding must be checked across graph architectures. DyVal argues for generated test sets that cannot be contaminated. We borrow the logic in a weaker form by evaluating on held-out molecules whose absence from every corpus we verify.

Graph networks also raise a concern that text models do not. Message-passing encoders are shallow, often under ten layers, and each layer widens the neighborhood an atom sees by one bond. Relative depth is therefore coarse, and the "late layers" of a graph network may simply reflect over-smoothing, where repeated averaging makes atom features look alike. We address this by training encoders at several depths, $L \in \{4, 8, 16\}$. A real relative-depth effect should line up in $d$ across these depths. An effect driven by receptive-field size should line up in absolute hops instead. This comparison is the decisive test of whether "relative depth" is the right axis for graphs at all.

Research Program

We build two encoder families from public code paths described in the file: a standard 2D message-passing network and a GeoGNN-style dual graph over bonds and bond angles, as in GEM. Each is trained at three depths. Pretraining uses a ZINC15 subset of a few million molecules. We do not reproduce GEM's full scale, and the GuacaMol plateau suggests this costs little.

Adaptation then follows two staged recipes. The first is structure-only adaptation on target-domain molecules, followed by multi-task regression, followed by fine-tuning. The multi-task stage uses either computed descriptors, which are available at test time and so are not leakage, or real assay labels drawn from public bioactivity records that overlap the benchmarks. The second recipe is MolGA-style alignment plus conditional adaptation.

We cross each recipe with controlled exposure conditions. Test molecules are either removed from all stages (identity matches plus near-analogues above a fingerprint-similarity threshold) or injected. Injection varies in content (structure only, or structure with the true label), in stage (pretraining, adaptation, or multi-task), and in fraction (10%, 50%, or 100% of the test set). A further condition exposes only scaffold-sharing analogues rather than the test molecules themselves. Because we control injection, every test molecule carries a ground-truth exposure label.

Analysis has three parts. First, at each layer we fit a linear probe on frozen embeddings for the property, which gives a performance curve over $d$ under each exposure condition. The gap between curves shows where exposure inflation lives. Second, at each layer we compute a molecular analogue of LaRA's geometry. In place of paraphrase we use edits that should leave a molecule's identity essentially intact, such as tautomer or protonation changes and, for the 3D model, alternative conformers. In place of deletion we remove a substituent or functional group. Matched molecular pairs, which differ by one small chemical edit, serve as a separate check, because their real property changes are known. We then train a per-molecule exposure classifier on these layer-wise features from some models and test it on held-out models trained under hidden exposure conditions. Third, we compare readout strategies: final layer, the best intermediate depth chosen on clean validation data, and a learned mixture of layers. For each we report both terms of the decomposition.

Baselines

The naive reference point is the standard practice of final-layer readout from the exposed pipeline, scored on MoleculeNet scaffold splits and the seven ADME sets with Butina clustering. This is what papers currently report. Next to it we place a Random Forest on RDKit descriptors, trained on identical splits with an equal tuning budget. In Transformers for molecular property prediction this Random Forest was best on 5 of 7 ADME datasets. Any "transferable gain" we attribute to pretraining has to clear it, or the gain is not worth having.

The strongest existing adaptation method is MolGA. Its paper reports 62.72% ROC-AUC in 5-shot MUV against 59.87% for the next method. We rerun it on our encoders under both the deduplicated and the exposed corpora, with the same seeds and adapter budget. Beating it here does not mean a higher raw score. It means showing that our depth-selected readout matches its clean score while carrying measurably less exposure inflation, or that its 5-shot MUV margin shrinks after deduplication. For GEM, the file gives only relative improvements (8.8% on quantum tasks, 4.7% ROC-AUC on biophysical and physiological tasks) and no absolute per-task numbers. We therefore report our own reproduction rather than quoting figures.

For contamination detection, the strongest prior method is LaRA. It reaches ROC-AUC 0.79 and 31–38% true-positive rate at 5% false-positive rate, but only on text and math in reinforcement-learning post-training. We found no reported result on Lacuna for representation-level contamination detection on molecular graphs. Our detector is compared against three cheaper detectors, all given the same held-out models and the same 5% false-positive operating point: per-molecule prediction loss, prediction confidence, and nearest-neighbor fingerprint similarity to the corpus where the corpus is known. To beat the loss-based detector, ours must exceed its true-positive rate at 5% false positives on label-exposed models. To be useful at all, it must clearly exceed chance on structure-only exposure, where loss carries little signal.

The key ablation removes depth from the auditor. It collapses all layer features into a single pooled embedding while keeping the same perturbation features. If this matches the layer-wise detector, the relative-depth part of the claim fails. A second ablation scrambles the alignment across $L$ by indexing in absolute hops rather than in $d$.

Why not just…?

Why not just deduplicate the pretraining corpus against the test set and retrain? For any model whose corpus we control, this is the right answer, and we use it as ground truth rather than competing with it. It does not help for released checkpoints trained on proprietary or undisclosed compound libraries, which are common in industrial chemistry. It also does not say how much published scores were inflated, which requires the exposed condition too. Deduplication also requires choosing a similarity threshold. The analogue-exposure condition tests whether near-neighbors, rather than identical molecules, drive inflation, and so whether simple identity deduplication is enough.

Why not just use prediction loss as a membership test? For label exposure this is a serious threat. A regression model that saw a molecule's label will often fit it unusually well, and the reinforcement-learning collapse that undermined loss-based tests in LaRA may not occur in supervised graph training. We expect loss to do well on label exposure and poorly on structure-only exposure, where no label was seen. The head-to-head on held-out models settles this. If loss matches our detector in both regimes, we will report the representation-level auditor as unnecessary for molecules.

Why not just keep the final layer and rely on scaffold splits? MoleculeNet shows that scaffold splits expose motif reliance but cannot see corpus overlap. The single-cell results show that final layers can leave large gains unused. Whether intermediate readout actually reduces exposure inflation in graphs is an open empirical question, and the readout comparison under controlled exposure answers it directly.

Why not just use a descriptor Random Forest and skip pretraining? For small ADME sets it may simply be better, as the earlier study found. We keep it as the reference that every pretrained pipeline must beat after deduplication. If no pipeline clears it, that is itself the main finding.

Decisive Checks

The first check is whether exposure inflates scaffold-split scores at all. If structure-only exposure produces near-zero inflation and only label exposure matters, the worry about unlabeled pretraining corpora is largely unfounded, and the work narrows to auditing labeled adaptation stages. The second check is whether the inflation gap between probe curves sits at a consistent $d$ across $L \in \{4, 8, 16\}$ and across both architectures. Alignment in absolute hops instead would mean receptive-field size, not relative depth, organizes graph networks. The third check is whether depth-selected readout keeps at least most of the clean transferable gain while cutting measured inflation, judged against final-layer readout and MolGA under matched budgets. The fourth check is whether the layer-wise auditor, trained on some models, detects hidden exposure in held-out models better than loss and similarity proxies at 5% false positives. Only then is it worth applying to undisclosed public checkpoints. Each outcome is informative even if negative, because each corresponds to a practice the field currently follows without measurement.