torchani icon indicating copy to clipboard operation
torchani copied to clipboard

Unsupported atoms are simply ignored?

Open RMeli opened this issue 2 years ago • 3 comments

I would expect the following code to fail

import torch
import torchani

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model = torchani.models.ANI2x(periodic_table_index=True).to(device)

coordinates = torch.tensor([[[0.03192167, 0.00638559, 0.01301679],
                             [-0.83140486, 0.39370209, -0.26395324],
                             [-0.66518241, -0.84461308, 0.20759389],
                             [0.45554739, 0.54289633, 0.81170881],
                             [0.66091919, -0.16799635, -0.91037834]]],
                           requires_grad=True, device=device)

# Species with unsupported atomic number 42
species = torch.tensor([[42, 1, 1, 1, 1]], device=device)

energy = model((species, coordinates)).energies

but it works without error/warnings despite the unsupported atom

In [12]: energy.item()
Out[12]: -2.1059779035978243

Is this intended? I understand the need to ignore atoms internally due to padding, but ignoring input atoms silently feels very error-prone to me (from an user perspective).

RMeli avatar Apr 03 '22 17:04 RMeli

An exception should be raised on such cases. Silently ignoring atoms is really bad.

UnixJunkie avatar Oct 23 '23 00:10 UnixJunkie

Thanks! We will take care of this issue soon!

yueyericardo avatar Oct 23 '23 01:10 yueyericardo

@UnixJunkie totally agree. I closed this issue only because it has not been acknowledged for over a year and I don't even know if it's still relevant.

Thanks @yueyericardo for re-opening an looking into this.

RMeli avatar Oct 23 '23 06:10 RMeli