Loading model from .pth is not supported yet
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 42/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
调研方向
从 src/litmodels/io/gateway.py 开始,对比第 94-96 行附近的 save_model 处理逻辑与第 166 行的 load_model 失败。复现 issue 中的 Python 示例,并跟踪加载过程中的 .pth 路径。当通过 save_model 保存的模型可以在不触发当前 NotImplementedError 的情况下加载时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
🐛 Bug
To Reproduce
import torch
from litmodels import save_model, load_model
model = torch.nn.Module()
save_model(model=model, name="skaftenicki/language-model/torch-model")
model_ = load_model(name="skaftenicki/language-model/torch-model")
generates
❯ python main.py
Uploading files...: 100%|█████████████████| 1/1 [00:01<00:00, 1.73s/it]
Model uploaded successfully. Link to the model: 'https://lightning.ai/skaftenicki/language-model/models/torch-model'
Downloading default: 100%|█████████| 1.32k/1.32k [00:00<00:00, 1.71kB/s]
Traceback (most recent call last): | 0.00/1.32k [00:00<?, ?B/s]
File "/home/nsde/Documents/LitModels/main.py", line 6, in <module>
model_ = load_model(name="skaftenicki/language-model/torch-model")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/nsde/Documents/LitModels/src/litmodels/io/gateway.py", line 166, 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.
Expected behavior
Code is basically taken from the examples. The problem seems to be that save_model function saves torch models to pth (which are not ScriptModule):
https://github.com/Lightning-AI/LitModels/blob/e9075da71a1cea1ec1d978de3971df937856280f/src/litmodels/io/gateway.py#L94-L96
but not supported in the load_model function.
Environment
- PyTorch Version (e.g., 1.0):
- OS (e.g., Linux):
- How you installed PyTorch (
conda,pip, source): - Build command you used (if compiling from source):
- Python version:
- CUDA/cuDNN version:
- GPU models and configuration:
- Any other relevant information:
Additional context
- 主要语言
- Python
- 星标
- 40
- 派生
- 9
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
相似的 Issue
-
ReadQwen3PaperTask5 rejects correct answers that differ only in order, case, or underscore form可能已有人在做 @Kingpython123 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 90/100
Tongyi-MAI/MobileWorld#72 ·
-
_threads/application: Update typing annotations using `pyupgrade --py311-plus`可能已有人在做 @gudnimg 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Health probes return 401 when authentication is enabled and the API is served under /orb可能已有人在做 @fgogolli 今天认领。 未关闭area: api priority: p2 size: S type: bug
难度 2/5 半天 新手友好度 75/100
finos/open-resource-broker#704 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
BCDA-APS/polar-bits#93 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
GoogleCloudPlatform/gce-rescue#218 ·
维护者通常 2 天内回复