AtomicConv applies dropout during eval, so predict() is nondeterministic
Author: chiruu12Created Aug 12, 2026Updated Sep 22, 2026
Bug
AtomicConv.forward calls F.dropout(x, dropout) without passing training. F.dropout defaults to training=True, so it stays active after model.eval(). dropouts defaults to 0.5, and AtomConvModel.predict() runs through this path, so repeated predictions on the same input differ.
deepchem/models/torch_models/layers.py:
if dropout > 0:
x = F.dropout(x, dropout)Other modules guard this. fcnet.py uses if dropout > 0.0 and self.training, and the uncertainty path uses an explicit dropout_switch. AtomicConv has neither.
To Reproduce
- Build an
AtomConvModelwith a nonzerodropoutsvalue (0.5 is the default). - Fit it, then call
predicton the same dataset twice. - The two prediction arrays differ.
Isolating the mechanism:
import torch, torch.nn as nn, torch.nn.functional as F
m = nn.Linear(8, 8).eval()
t = torch.ones(1, 8)
print(torch.equal(F.dropout(m(t), 0.5), F.dropout(m(t), 0.5)))
# False
print(torch.equal(F.dropout(m(t), 0.5, training=m.training),
F.dropout(m(t), 0.5, training=m.training)))
# TrueExpected behavior
Dropout is disabled under eval(), so predict() returns the same values for the same input.
Environment
- OS: macOS 26.5.1
- Python version: 3.12.11
- DeepChem version: main @ 43e6f2e
- PyTorch version: 2.8.0
- Any other relevant information: same defect class as #5086 / PR #5087, which fixed
ScScore.forward
Additional context
Both this and the layer chaining question in #5091 sit in the same loop. Filing separately since they are independent.
Source: deepchem/deepchem