Skip to content

fix: support loading .pth models - #165

Open
deependujha wants to merge 2 commits into
Lightning-AI:mainfrom
deependujha:fix/load-pth-models
Open

deependujha wants to merge 2 commits into
Lightning-AI:mainfrom
deependujha:fix/load-pth-models

Conversation

@deependujha

Copy link
Copy Markdown
Contributor
Before submitting
  • Was this discussed/agreed via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

The README documents saving and loading PyTorch models, but .pth artifacts currently fail with NotImplementedError during loading.

import litmodels as lm
import torch

# save a model
model = torch.nn.Module()
lm.save_model(model=model, name="model-name")

# load a model
model = lm.load_model(name="model-name")

output:

File "/teamspace/studios/this_studio/LitModels/src/litmodels/io/gateway.py", line 183, in load_model
    raise NotImplementedError(f"Loading model from {model_path.suffix} is not supported yet.")
NotImplementedError: Loading model from .pth is not supported yet.

Use torch.load(..., weights_only=False) to support loading .pth artifacts containing serialized model objects and ensure the README's save/load example works as documented.

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in GitHub issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84%. Comparing base (d3e3247) to head (05b620e).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #165   +/-   ##
===================================
- Coverage    84%    84%   -0%     
===================================
  Files        12     12           
  Lines       511    513    +2     
===================================
  Hits        430    430           
- Misses       81     83    +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants