Skip to content

Fail to train synthon completion in retrosynthesis: Pre-condition Violation #42

@KiddoZhu

Description

@KiddoZhu

Following the tutorial in the doc, I got error on this line.

synthon_solver = core.Engine(synthon_task, synthon_train, synthon_valid, synthon_test, synthon_optimizer , gpus=[0], batch_size=128)

The error message is

****
Pre-condition Violation
bgnIdx not connected to begin atom of bond
Violation occurred on line 292 in file /opt/conda/conda-bld/rdkit_1603173682698/work/Code/GraphMol/Bond.cpp
Failed Expression: getOwningMol().getBondBetweenAtoms(getBeginAtomIdx(), bgnIdx) != nullptr
****

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zhuzhaoc/torchdrug/torchdrug/core/engine.py", line 143, in train
    loss, metric = model(batch)
  File "/home/zhuzhaoc/.local/envs/ogb/lib/python3.7/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/zhuzhaoc/torchdrug/torchdrug/tasks/retrosynthesis.py", line 596, in forward
    pred, target = self.predict_and_target(batch, all_loss, metric)
  File "/home/zhuzhaoc/torchdrug/torchdrug/tasks/retrosynthesis.py", line 993, in predict_and_target
    graph2, node_in_target2, node_out_target2, bond_target2, stop_target2 = self.all_stop(reactant, synthon)
  File "/home/zhuzhaoc/.local/envs/ogb/lib/python3.7/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/home/zhuzhaoc/torchdrug/torchdrug/tasks/retrosynthesis.py", line 586, in all_stop
    graph, feature_valid = self._update_molecule_feature(graph)
  File "/home/zhuzhaoc/torchdrug/torchdrug/tasks/retrosynthesis.py", line 385, in _update_molecule_feature
    mols = graphs.to_molecule(ignore_error=True)
  File "/home/zhuzhaoc/torchdrug/torchdrug/data/molecule.py", line 788, in to_molecule
    bond.SetStereoAtoms(*stereo_atoms[j])
RuntimeError: Pre-condition Violation
        bgnIdx not connected to begin atom of bond
        Violation occurred on line 292 in file Code/GraphMol/Bond.cpp
        Failed Expression: getOwningMol().getBondBetweenAtoms(getBeginAtomIdx(), bgnIdx) != nullptr
        RDKIT: 2020.09.1
        BOOST: 1_73

This is because some molecules in USPTO50k have stereo bonds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions