Skip to content
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

PTL 2.2 specifically causes torchscript errors when loaded in any environment not containing PTL 2.2 #19744

Open
jarmand-app opened this issue Apr 7, 2024 · 0 comments
Labels
bug Something isn't working needs triage Waiting to be triaged by maintainers

Comments

@jarmand-app
Copy link

jarmand-app commented Apr 7, 2024

Bug description

A pytorch lightning model that is converted to torchscript and saved in an environment running pytorch lightning 2.2 cannot be loaded in any environment not containing pytorch lightning 2.2, including both python environments and environments running other languages such as C++. This is obviously completely breaking, as PTL 2.2 cannot be installed in C++ environment, and this means we cannot serve our models.

Temp solution: downgrade to pytorch lightning 2.0, which does not have this problem

What version are you seeing the problem on?

v2.2

How to reproduce the bug

in environment running PTL 2.2:

import torch

model = SomeLightningModle(...)
jit_model = model.to_torchscript()
torch.save(jit_model, "test_model.pt")

in any environment not running PTL 2.2, say python for example:

import torch

jit_model = torch.load("test_model.pt")

JIT models are supposed to be completely package independent. Of course only in python we could just always run PTL 2.2, but this is not an option in C++ deployment and this makes it completely breaking for that use case.



### Error messages and logs

2024-04-05 00:54:30.593
class AttributeDict:

2024-04-05 00:54:30.593
Serialized File "code/torch/pytorch_lightning/utilities/parsing.py", line 2
2024-04-05 00:54:30.593
expected indent but found 'newline' here:
2024-04-05 00:54:30.593
Exception in loading model z5yixmej


### Environment

This occurs across environments.


### More info

_No response_
@jarmand-app jarmand-app added bug Something isn't working needs triage Waiting to be triaged by maintainers labels Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Waiting to be triaged by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant