question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The conversion of the ANI-2x model to TorchScript fails with PyTorch 1.9

See original GitHub issue

The conversion of the ANI-2x model to TorchScript fails with PyTorch 1.9:

import torch
import torchani

print(torch.__version__)
print(torchani.__version__)

torch.jit.script(torchani.models.ANI2x())
$ conda install -c conda-forge pytorch=1.9 torchani
$ python debug.py 
1.9.0
2.2
Traceback (most recent call last):
  File "debug_torchani.py", line 7, in <module>
    torch.jit.script(torchani.models.ANI2x())
  File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_script.py", line 1096, in script
    return torch.jit._recursive.create_script_module(
  File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 412, in create_script_module
    return create_script_module_impl(nn_module, concrete_type, stubs_fn)
  File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 474, in create_script_module_impl
    script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
  File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_script.py", line 497, in _construct
    init_fn(script_module)
  File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 437, in init_fn
    cpp_module.setattr(name, orig_value)
RuntimeError: Could not cast attribute 'rev_species' to type Dict[Tensor, int]: Unable to cast Python instance to C++ type (compile in debug mode for details)

But it works with PyTorch 1.8:

$ conda install -c conda-forge pytorch=1.8 torchani
$ python debug.py
1.8.0
2.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
raimiscommented, Nov 5, 2021

@yueyericardo thanks for your effort! The issue is solved and the solution integrated into NNPOps (https://github.com/openmm/NNPOps/releases/tag/v0.1)

1reaction
IgnacioJPickeringcommented, Oct 15, 2021

ohh yes, thanks for the heads up! I will merge this tomorrow, I hadn’t noticed this stopped working in the public repo.

On Thu, 14 Oct 2021, 22:23 Jinze (Richard) Xue, @.***> wrote:

ping @IgnacioJPickering https://github.com/IgnacioJPickering

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aiqm/torchani/issues/598#issuecomment-943932556, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIFDKQXGCWCJK5BPJN2UZZTUG6GAVANCNFSM5FOSUROQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TorchScript — PyTorch 1.13 documentation
In many cases either tracing or scripting is an easier approach for converting a model to TorchScript. Tracing and scripting can be composed...
Read more >
Error when converting PyTorch model to TorchScript
I just figured out that models loaded from torchvision.models are in train mode by default. AlexNet and SqueezeNet both have Dropout layers, ...
Read more >
Converting Exact GP Models to TorchScript
In this notebook, we'll demonstrate converting an Exact GP model to TorchScript. In general, this is the same as for standard PyTorch models...
Read more >
Deploy models into production (advanced) - PyTorch Lightning
TorchScript allows you to serialize your models in a way that it can be loaded in non-Python environments. The LightningModule has a handy...
Read more >
TorchScript and PyTorch JIT | Deep Dive - YouTube
In this talk, we dive deep into TorchScript and PyTorch JIT.For more information on TorchScript, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found