-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Torchscripting not possible with NeuralODE
due to function redefinition
#163
Comments
Came to the conclusion that it's likely because of
The weird thing about this is that I can see that |
I did a bit more looking and can see that torchscript is not happy with https://pytorch.org/docs/stable/jit_language_reference.html#supported-type |
Update again: removing that type annotation revealed another annotation to be incorrect and also revealed a problem in the way |
Thanks for looking into this! I've started a refactor in this branch. I fixed some of the typing inconsistencies and managed to push through to:
Is that the error you observed? |
Hi @Zymrael - yes, that one is a problem because what you would do there is:
but torchscript isn't happy with types being passed as parameters and errors if you do that fix. This implies that some of the inheritance the current factoring of the code relies on would potentially need to be addressed - this isn't necessarily a bad thing if it reduces the amount of redirection in the code a little anyway. Hope this helps, happy to keep chatting on this one if it helps. |
Describe the bug
Torchscript is unable to script the
NeuralODE
class due to a function being redefined. This is a problem because there is control flow present in the code that tracing would not necessarily respect, implying that alternative would produce an incorrect output.Step to Reproduce
Minimal working example:
produces the following errors:
The first time you run it, the error is:
on subsequent attempts, the error is:
Note that changing the solvers doesn't appear to change anything.
Expected behavior
Torchscript should not break
I'm using the latest available version of torchdyn from pip and
torch==1.11.0+cu102
, would be very grateful for your advice as to how to torchscript this safely.The text was updated successfully, but these errors were encountered: