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.
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.
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
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.
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:
- Modify the property definition so that it is TorchScript compatible.
- 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
@unused syntax work with properties, I plan to land that by the end of the week.
Hi @SplitInfinity, Thank you for your reply.
__ignored_properties__ solves the issue, also this is good to see
@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