Torch.jit.script in nightly version

username: ydcjeff
cooked: <p>From PyTorch 1.6 to 1.7.0.dev20200914, I am able to export the PyTorch Lightning Module torch script.<br>
But starting from 1.7.0.dev20200915, it started to show error like this.</p>
<pre><code class="lang-auto">RuntimeError: 
Wrong type for attribute assignment. Expected None but got Any:
</code></pre>
<p>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.</p>
<p>Reproducible Link:<br>
<a href="https://colab.research.google.com/drive/1DuVwIZ1XHPdyzIUiQcP5jG1O13Zv6K7z?usp=sharing" class="onebox" target="_blank" rel="nofollow noopener">https://colab.research.google.com/drive/1DuVwIZ1XHPdyzIUiQcP5jG1O13Zv6K7z?usp=sharing</a></p>
<p>Thank you in advance.</p>

username: ptrblck
cooked: <p>CC <a class="mention" href="/u/williamfalcon">@williamFalcon</a> in case this breaks Lightning.</p>

username: ydcjeff
cooked: <p><a class="mention" href="/u/ptrblck">@ptrblck</a> Thank you for your reply. Actually I am working on a PR of Lightning to support PyTorch 1.7.<br>
The tests were passing prior nightly version but failing on the recent nightly version.</p>
<p>Can you share some links about JIT changes?</p>

username: ptrblck
cooked: <p>I don’t know which change might have caused this error, but based on the stack trace I would start with <code>torch/jit/_recursive.py</code>, since <code>concrete_type._create_methods_and_properties</code> seems to be failing.</p>
<p>Based on the history of this file, there was <a href="https://github.com/pytorch/pytorch/pull/42390">this PR</a> on Sept. 14th which would fit into the first breaking nightly release.<br>
This PR also introduced <code>_create_methods_and_properties</code> as seen <a href="https://github.com/pytorch/pytorch/commit/e7d782e724c76bb0572023d52ee7438a40a7a262#diff-fb8eed23326063aef5f5843c34d460ce">here</a>, so it would be my best guess.</p>
<p>Maybe <a class="mention" href="/u/splitinfinity">@SplitInfinity</a> could help out as the author of this PR.</p>

username: ydcjeff
cooked: <p>I will look into it. Thank you for your reply</p>

username: SplitInfinity
cooked: <p>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:</p>
<ol>
<li>Modify the property definition so that it is TorchScript compatible.</li>
<li>Exclude the property from compilation. This can be done by adding a class attributed named <code>__ignored_properties__</code> and setting it to a list of the names of properties that should be ignored. <a href="https://github.com/pytorch/pytorch/pull/45233/files#diff-facd1187e022303568f653cb6b745110R1170" rel="nofollow noopener">You can see an example in this PR</a>. In the same stack of PRs, there is another that enables the usual <code>@ignore</code> and <code>@unused</code> syntax work with properties, I plan to land that by the end of the week.</li>
</ol>

username: ydcjeff
cooked: <p>Hi <a class="mention" href="/u/splitinfinity">@SplitInfinity</a>, Thank you for your reply.<br>
Setting <code>__ignored_properties__</code> solves the issue, also this is good to see <code>@ignore</code> and <code>@unused</code> are WIP too.</p>
<p>Lastly, Thank you for your work on the PRs.</p>

username: yunusemre
cooked: <p>Hi, <a class="mention" href="/u/ydcjeff">@ydcjeff</a> can you explain a little bit more, where to add <code>__ignored_properties__</code> ?</p>