Torch.jit.script in nightly version

From PyTorch 1.6 to 1.7.0.dev20200914, I am able to export the PyTorch Lightning Module torch script.
But starting from 1.7.0.dev20200915, it started to show error like this.

RuntimeError: 
Wrong type for attribute assignment. Expected None but got Any:

Could this be there are some changes to the JIT? If so, how can I fix it so it can be exported in 1.6 and upcoming 1.7.

Reproducible Link:
https://colab.research.google.com/drive/1DuVwIZ1XHPdyzIUiQcP5jG1O13Zv6K7z?usp=sharing

Thank you in advance.

CC @williamFalcon in case this breaks Lightning.

@ptrblck Thank you for your reply. Actually I am working on a PR of Lightning to support PyTorch 1.7.
The tests were passing prior nightly version but failing on the recent nightly version.

Can you share some links about JIT changes?

I don’t know which change might have caused this error, but based on the stack trace I would start with torch/jit/_recursive.py, since concrete_type._create_methods_and_properties seems to be failing.

Based on the history of this file, there was this PR on Sept. 14th which would fit into the first breaking nightly release.
This PR also introduced _create_methods_and_properties as seen here, so it would be my best guess.

Maybe @SplitInfinity could help out as the author of this PR.

1 Like

I will look into it. Thank you for your reply

We added support for module and class type properties recently, and I think the issue here is that a previously existing property that included code incompatible with TorchScript is now failing to compile. There are two options:

  1. Modify the property definition so that it is TorchScript compatible.
  2. Exclude the property from compilation. This can be done by adding a class attributed named __ignored_properties__ and setting it to a list of the names of properties that should be ignored. You can see an example in this PR. In the same stack of PRs, there is another that enables the usual @ignore and @unused syntax work with properties, I plan to land that by the end of the week.
2 Likes

Hi @SplitInfinity, Thank you for your reply.
Setting __ignored_properties__ solves the issue, also this is good to see @ignore and @unused are WIP too.

Lastly, Thank you for your work on the PRs.

Hi, @ydcjeff can you explain a little bit more, where to add __ignored_properties__ ?