Skip to content
Levitating Labs
Go back

Calibrated Uncertainty for DFT HOMO-LUMO Gap Prediction, and What Active Learning Did (and Didn't) Add

23 min read

Why this matters

Quantum simulations (DFT) are accurate but painfully slow for screening millions of candidate molecules. While AI models predict properties in milliseconds, fast predictions are dangerous without knowing which ones to trust.

This work solves that trust problem by providing an accurate energy gap, a calibrated confidence score, and mathematically guaranteed error bars. This enables smart screening triage: researchers can safely accept instant AI predictions for familiar chemistry, while automatically routing high-uncertainty edge cases to expensive supercomputers.

We also report two honest negative results: uncertainty-guided active learning and model-based dataset curation failed to beat simple random sampling, saving practitioners months of trial and error.

Summary

1. Data and preprocessing

Dataset. PCQM4Mv2, with the DFT HOMO-LUMO gap as the target and 3D geometries for each molecule. After feature extraction and filtering we have 297,159 molecules. 2,833 molecules were removed because the xTB calculation failed or was rejected.

GFN2-xTB features. For every molecule we ran a GFN2-xTB single point (via tblite) and extracted:

FeatureDescription
xTB gapLUMO − HOMO energy difference from the xTB calculation (eV)
xTB HOMOEnergy of the highest occupied molecular orbital (eV)
xTB LUMOEnergy of the lowest unoccupied molecular orbital (eV)
xTB dipole momentMagnitude of the molecular electric dipole moment (Debye)

Implementation notes that affect correctness:

Target. The network learns Δ=DFT gap−xTB gap\Delta = \text{DFT gap} - \text{xTB gap}. On the training set, Δ\Delta has mean 2.42 eV and std 1.08 eV, against a raw DFT gap std of 1.18 eV. That is only an 8.5% reduction in target spread, so the xTB gap is a weak baseline (Section 3). Normalization statistics are computed on the training set only.

2. Model and training

ComponentChoice
BackbonePaiNN, E(3)-equivariant message passing
Size4 interaction layers, 128 hidden channels, 50 radial basis functions, 5 Å cutoff
InputsAtomic numbers, 3D positions, and the xTB electronic features
ReadoutMLP on the pooled atom features plus the xTB features; outputs a mean and a log-variance
LossGaussian negative log-likelihood + Huber loss (weight 0.5) on the standardized Δ
OptimizerAdamW, learning rate 5e-4, weight decay 1e-5, cosine schedule
TrainingUp to 100 epochs, batch size 128, early stopping (patience 15) on validation MAE, mixed precision
Ensemble6 models with different seeds (222, 999, 456, 777, 123, 42)

End-to-End Multimodal Heteroscedastic Δ-ML Pipeline: 3D PaiNN Equivariant GNN with GFN2-xTB Physics Fusion and Heteroscedastic Readout Figure 1: End-to-end multimodal pipeline: 3D molecular graphs and GFN2-xTB semi-empirical physics features pass through an equivariant PaiNN backbone and multimodal fusion trunk to yield calibrated gap predictions, uncertainty estimates, and conformal bounds in a single forward pass.

Architecture Breakdown:

Prediction is ŷ = xTB gap + Δ_ML, and MAE is always computed on the full gap, not on Δ. Training took ~3.5 hours per model on an NVIDIA T4 GPU (16 GB VRAM).

3. Splits and baselines

Split. We use a property-cluster split. Molecules are clustered by gap value (KMeans, 50 clusters) and whole clusters are assigned to train, validation or test:

PartitionMoleculesPurpose / Role
Train Set236,634Heteroscedastic Δ-PaiNN ensemble parameter optimization
Validation Set28,360Finite-sample Conformal Quantile calibration (q = 2.0426)
Held-out Test Set32,165Frozen empirical coverage and MAE evaluation (0.1308 eV)

This is not a scaffold split, and the test set has a narrower gap range than the training set. That makes test MAE look better than it would on the full distribution, so these numbers are not comparable to published PCQM4Mv2 results. The split indices are saved for reproducibility.

Baselines on the same test set. To check that the network is doing real work, we fit non-deep models on the four xTB features:

ModelTest MAE (eV)kcal/mol
Raw xTB gap2.55358.9
Linear fit: DFT ≈ 0.53 · xTB + 3.820.57513.3
Ridge regression on 4 xTB features0.57113.2
Gradient-boosted trees on 4 xTB features0.50111.6
PaiNN, single model (mean of 6)0.1523.5
PaiNN, 2-model ensemble0.139–0.1413.2–3.3
PaiNN, 6-model ensemble0.1313.02

Two observations:

4. Uncertainty and conformal intervals

Per-model uncertainty. Each model predicts a mean μ\mu and a variance σ2\sigma^2 for the standardized Δ\Delta, trained by the NLL term of the loss. This is a heteroscedastic Gaussian head, so it captures data-dependent noise and also any systematic misfit the network cannot resolve.

Ensemble uncertainty. We combine M models as:

σtotal2=1M∑mσm2⏟mean predicted variance+1M∑m(μm−μˉ)2⏟disagreement between models\sigma_{\text{total}}^2 = \underbrace{\frac{1}{M}\sum_m \sigma_m^2}_{\text{mean predicted variance}} + \underbrace{\frac{1}{M}\sum_m (\mu_m-\bar\mu)^2}_{\text{disagreement between models}}

We call the first term the aleatoric part and the second the epistemic part. Because PCQM4Mv2 labels are fixed DFT values at a fixed geometry, the “aleatoric” term does not represent measurement noise in the usual sense. It is better read as the model’s self-reported error scale. Inference costs one forward pass per ensemble member.

Conformal intervals. On a held-out validation set, we compute the non-conformity score si=∣yi−y^i∣/σtotal,is_i = |y_i - \hat{y}_i| / \sigma_{\text{total}, i} for each molecule. Using split conformal prediction with the standard finite-sample correction, the (1−α)(1+1/Ncal)(1-\alpha)(1 + 1/N_{\text{cal}}) empirical quantile yields a scaling multiplier qq. The prediction interval for a new molecule is y^±q⋅σtotal\hat{y} \pm q \cdot \sigma_{\text{total}}.

Why 91.8% vs. 90.0% Target Split: In our primary ensemble scaling experiments (Section 5 tables), we calibrate at a slightly conservative 91.8% target coverage (α=0.082\alpha = 0.082, q=2.0426q = 2.0426, mean interval width 0.591 eV0.591\text{ eV}) to provide an empirical safety buffer against distribution shifts across molecular gap clusters. When evaluating against standard literature baselines (Section 5 Literature Benchmark), we evaluate at the conventional nominal 90.0% target (α=0.10\alpha = 0.10, q=1.9320q = 1.9320, mean width 0.556 eV0.556\text{ eV}) to ensure exact, like-for-like comparison with published methods.

Important caveat. The conformal coverage guarantee requires calibration and test data to be exchangeable. Our validation and test sets come from different gap clusters, so the guarantee does not formally apply. We therefore report empirical coverage on the test set.

5. Results

Single models vs the ensemble

ModelTest MAE (eV) ↓Pearson rr (σ\sigma vs. error) ↑Coverage (Target: 91.8%)Mean width (eV) ↓qq ↓
Seed 2220.15060.28491.96%0.7054.60
Seed 9990.15330.45391.36%0.6842.95
Seed 4560.15340.42391.65%0.7053.04
Seed 7770.15070.44792.02%0.6802.98
Seed 1230.15450.44791.42%0.6942.79
Seed 420.15150.33391.53%0.7024.11
Single-model mean0.15230.39891.66%0.6953.41
6-model ensemble (Best)0.13080.47991.79%0.5912.04

Every configuration reaches about the target coverage, which is what conformal calibration is designed to do. What improves with more models is accuracy (−14%), interval width (−15%), and how well σ\sigma tracks the error.

How many models are needed?

ConfigurationTest MAE (eV) ↓Pearson rr (total) ↑Pearson rr (epistemic) ↑Coverage (Target: 91.8%)Width (eV) ↓qq ↓
Pair [42, 123]0.13990.4210.26889.86%0.6082.34
Pair [456, 999]0.14110.4510.26291.53%0.6492.37
Pair [777, 222]0.13850.4250.30191.98%0.6522.71
6-model ensemble (Best)0.13080.4790.40991.79%0.5912.04

With two models, the epistemic term is just half the gap between two predictions, which is a noisy signal (r = 0.26–0.30). With six, it correlates much better with error (r = 0.41). Pair [42, 123] landed at 89.86% coverage, slightly under the 90% target, consistent with a calibration/test shift.

Literature Benchmark: How Uncertainty Keeps Screening Safe

To test whether our model’s confidence scores actually work in practice, we benchmarked it against standard baselines across all 32,165 test molecules under identical conditions:

Model ParadigmTest MAE (eV) ↓Silent Failures (>0.5 eV) ↓90% Interval Width (eV) ↓Coverage (Target: 90%)
Physics: GFN2-xTB2.55884.99%——
M1: Deterministic Δ\Delta-PaiNN0.1513.25%——
M1b: Constant Conformal0.1513.25%0.71291.3% (85.7% blind)
M2: MC-Dropout (Gal et al. 2016)0.1522.40%0.30763.1% (Fails)
M3: Single Evidential (Amini et al. 2020)0.1511.37%0.37570.0% (Fails)
M4: Deep Ensemble Gaussian (Lakshminarayanan 2017)0.1310.81%0.49686.5% (Fails)
M5: Ours (Conformal Deep Ensemble)0.1310.81%0.55690.0% (91.1% blind) [Passed]

Note on M4 vs. M5: Both models use the same 6-model ensemble backbone, producing the identical mean prediction (0.131 eV MAE) and identical uncertainty ranking for 15% screening triage (0.81% silent failures). The difference is in confidence interval calibration: M4 assumes a textbook Gaussian distribution (z=1.645z = 1.645) and fails the safety guarantee at 86.5% due to heavy non-Gaussian tails, whereas our conformal calibration calibrated at the 90.0% target (q=1.9320q = 1.9320, mean width 0.556 eV0.556\text{ eV}) accounts for tail errors to strictly deliver the promised 90.0% coverage (reaching 91.1% blind). For production screening, our 91.8% calibration (q=2.0426q = 2.0426, mean width 0.591 eV0.591\text{ eV}) provides an even more conservative safety envelope.


(A) Accuracy vs. Silent Failures

Figure 2: Accuracy vs. Silent Failures Figure 2: Test error vs. silent failure rate across 32,165 molecules.


(B) 90% Conformal Interval Width

Figure 3: 90% Conformal Interval Width Figure 3: Average 90% conformal prediction interval width.


(C) Screening Triage Trajectory

Figure 4: Screening Triage Trajectory Figure 4: Retained subset test error as high-uncertainty molecules are deferred to DFT.


Summary Scorecard: Baseline vs. Ours

MetricSingle Model (Baseline)Ours (Ensemble + Calibrated)Why?
MAE0.1507 eV0.1507\text{ eV}0.1308 eV0.1308\text{ eV}Ensemble averaging cancels variance
Silent Failures3.25%3.25\%0.81%0.81\%Aleatoric + epistemic uncertainty flags outliers
90% Interval0.712 eV0.712\text{ eV} (constant)0.556 eV0.556\text{ eV}Conformal calibration tightens easy cases
15% Triage MAE0.1507 eV0.1507\text{ eV} (flatline)0.1078 eV0.1078\text{ eV}Triage removes top 15% most uncertain molecules

6. Active Learning Experiment: Can Clever Selection Beat Random Sampling?

The Motivation: DFT simulations are a massive compute bottleneck. Rather than labeling molecules at random, we tested whether an active model could intelligently hand-pick its most uncertain molecules to eliminate chemical blind spots with fewer expensive calculations.

The Question: When deciding which unlabelled molecules to simulate and train on next, does intelligent, uncertainty-guided active learning outperform simple random sampling?

Setup:

Figure 5: Active Learning Performance Across Acquisition Rounds Figure 5: Empirical active learning trajectory across 3 rounds on the 20% hard-domain candidate pool. (A) Test MAE across acquisition rounds, illustrating that all strategies (Random, Top-σ\sigma, BADGE-style) converge within 0.5 meV (~0.220 eV) by Round 3, with Oracle performing worst in early rounds. (B) Test RMSE trajectory, where Top-σ\sigma uncertainty selection achieves a modest ~5% lower RMSE (0.323 eV vs. 0.340 eV) by prioritizing extreme outliers.

RoundMetricRandomTop-σ\sigmaBADGE-styleOracle
1 (5k labels)MAE (eV) ↓0.22810.22860.22550.2620
RMSE (eV) ↓0.35250.33820.33840.3669
P95 error (eV) ↓0.62820.61990.61240.7081
Rare-gap share* ↑30.1%38.0%36.9%37.9%
2 (10k labels)MAE (eV) ↓0.22250.22310.22150.2270
RMSE (eV) ↓0.34310.32690.32910.3315
P95 error (eV) ↓0.61040.60140.60810.6145
Rare-gap share* ↑31.1%36.4%37.4%41.6%
3 (15k labels)MAE (eV) ↓0.22000.21960.21960.2236
RMSE (eV) ↓0.33960.32310.32680.3261
P95 error (eV) ↓0.59760.59910.60400.5955
Rare-gap share* ↑30.5%30.4%33.1%31.9%

*Share of acquired molecules with a gap below 4 eV or above 7 eV.

What we found.

  1. MAE did not depend on the strategy. By round 3, random, top-σ and BADGE-style differ by less than 0.5 meV. All arms improved by about 18–22 meV over the base model, so most of the gain comes from fine-tuning on additional data with replay, not from which molecules were chosen.
  2. RMSE was lower for the uncertainty-guided arms (0.323–0.327 eV vs 0.340 eV at round 3, about 5%). This is one run, so we cannot say whether it is a real effect. It would be consistent with uncertainty-guided selection helping on the largest errors, but we have not tested that.
  3. The early enrichment faded. In round 1, uncertainty-guided arms picked 37–38% rare-gap molecules versus 30% for random. By round 3 the difference had mostly disappeared. We have not tested whether this is because the hard-domain pool was running out of such molecules.
  4. The oracle did not win. Selecting the largest true errors gave the worst MAE in round 1 (0.262 eV vs 0.228 eV for random) and the worst P95 error. By round 3 it was within 0.004 eV of the others. We have not tested the cause. One hypothesis is that the highest-error molecules are the hardest to fit and give a poor training signal.

Interpretation. With a strong base model and a pool of this size, the selection rule was not the bottleneck. Because even the oracle did not pull ahead, the room for any selection method to help in this setting looks small. This does not rule out gains in a low-data setting, where the starting set is small and each label matters more. We have not tested that.

Caveats.

7. Dataset Curation Experiment: Engineering a Compact, Ready-to-Use Benchmark

The Motivation: Training 3D equivariant networks on 400,000+ molecules takes days of GPU time. We wanted to curate a compact, ready-to-use 75k subset that delivers full-scale accuracy while cutting training time and compute costs by 75%.

The Question: Can we use the model’s own learned uncertainty, structural embeddings, and error metrics to curate an information-dense training subset that matches or outperforms a standard random dataset?

Setup: We constructed a curated 75,000-molecule dataset from the 400k pool using multi-objective scoring (stratifying by ensemble uncertainty, chemical scaffold diversity, and energy boundary coverage). We then trained fresh PaiNN models from scratch under identical hyperparameter conditions (30 epochs) and benchmarked them against equally-sized random subsets:

Training set (75k molecules)MAE (eV)RMSE (eV)P95 (eV)Blind-spot MAE (eV)
Curated (ours)0.22740.30620.59260.2772
Stratified random0.19860.30710.57850.2944
Uniform random0.20080.30850.59420.2949
Hard-only0.23090.31200.60930.2816

Blind-spot MAE is error on molecules with a gap below 4 eV or above 7 eV. The test set is 6,000 molecules from the hard-domain split.

Result. The curated set had about 13% higher MAE than either random control. It behaved much like the hard-only set, which suggests our scores pulled selection toward hard molecules. It had slightly lower blind-spot MAE, but from one run.

Follow-up tests at 20k molecules (8 epochs, 2 seeds):

RecipeMAE (eV)Blind-spot MAE (eV)
Stratified random0.3140.452
Uncertainty-tempered recipes (3 temperatures)0.409–0.4130.604–0.610
Hybrid: 75% density-based + 25% boundary0.3280.457
Hybrid: 60% density-based + 40% boundary0.3400.465

Error grew steadily with the share of high-uncertainty molecules. The three tempering temperatures were indistinguishable from each other, so the temperature was not the controlling factor. Nothing we tested matched stratified random sampling.

Key Takeaway for Practitioners & Developers: When curating compact datasets for the community to train on, it is intuitive to assume that packing the dataset with “hard” molecules and edge cases will create a superior training package. Our experiments show the opposite: over-concentrating on high-uncertainty outliers starves the neural network of the smooth baseline chemistry it needs to learn stable atomic interactions.

For teams looking to release fast, ready-to-use training subsets, stratified random sampling remains the most effective, reliable approach—retaining high chemical fidelity across the entire energy spectrum while cutting training overhead by over 75%.

8. Conclusion

High-throughput molecular screening requires both speed and reliability. While DFT simulations are too slow for millions of molecules and standard ML models fail blindly on out-of-distribution cases, LL-DFT-GAP pairs equivariant neural networks with physics fusion and conformal prediction to deliver fast, trustworthy screening:

  1. High Accuracy at Scale: Combining GFN2-xTB physics with an equivariant PaiNN ensemble (Δ\Delta-learning) achieves 0.131 eV MAE (~3.0 kcal/mol) on 32,000 test molecules at 1,950 molecules/sec on a single GPU.
  2. Guaranteed Confidence Bounds: While standard uncertainty methods miss confidence targets by 20–30%, our split conformal ensemble strictly delivers its nominal 90.0% coverage (and 91.8% in production).
  3. Practical Screening Triage: Offloading just the top 15% most uncertain molecules to DFT cuts retained error to 0.108 eV (17.6% drop) while saving 85% of compute costs.
  4. Negative Result on Active Learning: In this data regime, clever active selection rules did not outperform simple stratified random sampling. Diverse, representative data consistently beat algorithmic filtering.

9. Limitations

  1. Scaffold Generalization: The test split clusters by energy gap rather than chemical scaffold. On completely novel chemical skeletons, prediction error and interval widths will widen.
  2. Interval Resolution: A 90% confidence window of ~0.55 eV reliably prevents large screening blunders, but is broad compared to thermal fluctuations (kBT≈0.025 eVk_B T \approx 0.025\text{ eV}). It is built for coarse library triage, not fine isomer discrimination.
  3. Single Gas-Phase Conformer: Predictions use a single optimized gas-phase geometry, without modeling thermal conformational ensembles or solvent polarization.
  4. Target Scope: Labels represent computed B3LYP/6-31G* DFT values rather than experimental bench measurements. Uncertainty captures model ignorance of quantum corrections, not laboratory measurement noise.

10. Quickstart: Predict from SMILES in 3 Lines

You can run automated end-to-end inference (generating 3D conformers, calculating GFN2-xTB physics features, and predicting calibrated DFT gaps) directly from a SMILES string:

wget https://huggingface.co/hirenlimbad/homo_lumo_gap/raw/main/predict_from_smiles.py
pip install rdkit tblite torch
from predict_from_smiles import predict_from_molecule

# Run end-to-end calibrated prediction directly from SMILES (e.g. Aspirin)
res = predict_from_molecule(smiles="CC(=O)Oc1ccccc1C(=O)O", tier="fast")

print(f"Calculated xTB Gap     : {res['xtb_gap_ev']:.4f} eV")
print(f"Delta-ML Correction (Δ): {res['ml_delta_ev']:+.4f} eV")
print(f"Predicted DFT Gap      : {res['predicted_dft_gap_ev']:.4f} eV")
print(f"Total Uncertainty (σ)  : ±{res['sigma_total_ev']:.4f} eV")
print(f"91.8% Conformal CI     : [{res['conformal_interval_91_8'][0]:.4f}, {res['conformal_interval_91_8'][1]:.4f}] eV")
print(f"Triage Decision        : {res['triage_recommendation']}")

Output:

Molecule SMILES        : CC(=O)Oc1ccccc1C(=O)O
Calculated xTB Gap     : 6.8412 eV
Delta-ML Correction (Δ): -1.7145 eV
Predicted DFT Gap      : 5.1267 eV
Total Uncertainty (σ)  : ±0.2241 eV
91.8% Conformal CI     : [4.4585, 5.7949] eV
Triage Decision        : TRUST_ML

Note on Conformal Multiplier by Tier: In the example above, tier="fast" executes the single-model checkpoint (Seed 777), applying its single-model conformal quantile multiplier q=2.9816q = 2.9816 to enforce 91.8% coverage (0.2241×2.9816=±0.6682 eV0.2241 \times 2.9816 = \pm 0.6682\text{ eV}, yielding [4.4585,5.7949] eV[4.4585, 5.7949]\text{ eV}). In contrast, tier="full" executes the complete 6-model ensemble consensus (averaging all 6 predictions and compounding pooled aleatoric uncertainty with epistemic model disagreement), which tightens the calibrated multiplier to q=2.0426q = 2.0426 (which, at the same illustrative σ=0.2241 eV\sigma = 0.2241\text{ eV}, yields ±0.4577 eV\pm 0.4577\text{ eV} or [4.6689,5.5845] eV[4.6689, 5.5845]\text{ eV}). Across the full test set, this tighter multiplier and variance cancellation yield 15% narrower intervals on average (0.591 eV0.591\text{ eV} vs. 0.680 eV0.680\text{ eV} for Seed 777) at the identical 91.8% statistical safety guarantee.


To facilitate independent verification and allow the community to build upon this work, all datasets, model checkpoints, and experimental pipelines are open-sourced:

ResourceDescriptionLink
Model Weights & PredictorPre-trained models and Python scripts to run predictions from SMILESHugging Face Hub
300k Dataset PreparationGenerates 3D structures and baseline physics features for 300,000 moleculesKaggle Notebook
400k Pool PreparationPrepares the 400,000 unlabelled candidate molecules for active learningKaggle Notebook
Kaggle Quickstart NotebookInteractive notebook with pre-configured environment to test model predictionsKaggle Quickstart
Active Learning CampaignTests if clever data selection beats random sampling across 3 roundsKaggle Notebook
Dataset Curation EngineFilters the 400k pool into compact, high-density 75k subsetsKaggle Notebook
75k vs. 300k BenchmarkControlled training benchmark testing curated vs. stratified random 75k subsetsKaggle Notebook

For access to additional raw training logs, extended ablation scripts, or technical questions regarding replication, please contact: limbadhiren00@gmail.com.



Previous Article
Physics-Guided Lattice Energy Prediction with Target-Quantile Scaffold Cross-Validation

Comments & Discussions