aiqm / torchani

Accurate Neural Network Potential on PyTorch
https://aiqm.github.io/torchani/
MIT License
461 stars 127 forks source link

Unsupported atoms are simply ignored? #616

Open RMeli opened 2 years ago

RMeli commented 2 years ago

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).

UnixJunkie commented 11 months ago

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

yueyericardo commented 11 months ago

Thanks! We will take care of this issue soon!

RMeli commented 11 months ago

@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.