11<div align =' center ' >
22
3- # Effortless Model Management for Your Development ⚡
3+ # Checkpoint and share AI models Lightning fast ⚡
44
55<img alt =" Lightning " src =" https://pl-public-data.s3.us-east-1.amazonaws.com/assets_lightning/LitModels.png " width =" 800px " style =" max-width : 100% ;" >
66
7- <strong >Effortless management for your ML models.</strong >
8-
9- 🚀 [ Quick start] ( #quick-start )
10- 📦 [ Examples] ( #saving-and-loading-models )
11- 📚 [ Documentation] ( https://lightning.ai/docs/overview/model-registry )
12- 💬 [ Get help on Discord] ( https://discord.com/invite/XncpTy7DSt )
13- 📋 [ License: Apache 2.0] ( https://github.com/Lightning-AI/litModels/blob/main/LICENSE )
14-
7+ <div align =" center " >
8+ <div style =" text-align : center ;" >
9+ <a target="_blank" href="#quick-start" style="margin: 0 10px;">Quick start</a> •
10+ <a target="_blank" href="#examples" style="margin: 0 10px;">Examples</a> •
11+ <a target="_blank" href="#features" style="margin: 0 10px;">Features</a> •
12+ <a target="_blank" href="#performance" style="margin: 0 10px;">Performance</a> •
13+ <a target="_blank" href="#community" style="margin: 0 10px;">Community</a> •
14+ <a target="_blank" href="https://lightning.ai/docs/overview/model-registry" style="margin: 0 10px;">Docs</a>
15+ </div >
16+ </div >
1517</div >
1618
1719______________________________________________________________________
1820
19- ** Lightning Models ** is a streamlined toolkit for effortlessly saving, loading, and managing your model checkpoints.
20- Designed to simplify the entire model lifecycle— from training and inference to sharing, deployment, and cloud integration— Lightning Models supports any framework that produces model checkpoints, including but not limited to PyTorch Lightning .
21+ Save, load, host, and share models without slowing down training.
22+ ** LitModels ** minimizes training slowdowns from checkpoint saving. Share public links on Lightning AI or your own cloud with enterprise-grade access controls .
2123
2224<pre >
23- ✅ Seamless Model Saving & Loading
24- ✅ Robust Checkpoint Management
25- ✅ Cloud Integration Out of the Box
26- ✅ Versatile Across Frameworks
25+ ✅ Checkpoint without slowing training.
26+ ✅ Instant model loading anywhere.
27+ ✅ Share with secure, link-based access.
28+ ✅ Host on Lightning or your own cloud.
2729</pre >
2830
2931# Quick start
3032
31- Install Lightning Models via pip (more installation options below):
32-
33- ``` bash
34- pip install -U litmodels
35- ```
36-
37- Or install directly from source:
33+ Install LitModels via pip:
3834
3935``` bash
40- pip install https://github.com/Lightning-AI/litModels/archive/refs/heads/main.zip
36+ pip install litmodels
4137```
4238
43- ## Saving and Loading Models
44-
45- Lightning Models offers a simple API to manage your model checkpoints.
46- Train your model using your preferred framework (our fist examples show ` scikit-learn ` ) and then save your best checkpoint with a single function call.
47-
48- ### Train scikit-learn model and save it
49-
39+ Toy example ([ see real examples] ( #examples ) ):
5040``` python
51- from sklearn import datasets, model_selection, svm
52- from litmodels import upload_model
53-
54- # Load example dataset
55- iris = datasets.load_iris()
56- X, y = iris.data, iris.target
57-
58- # Split dataset into training and test sets
59- X_train, X_test, y_train, y_test = model_selection.train_test_split(
60- X, y, test_size = 0.2 , random_state = 42
61- )
62-
63- # Train a simple SVC model
64- model = svm.SVC()
65- model.fit(X_train, y_train)
66-
67- # Upload the saved model using litmodels
68- upload_model(model = model, name = " your_org/your_team/sklearn-svm-model" )
69- ```
70-
71- ### Download and Load the Model for inference
72-
73- ``` python
74- from litmodels import load_model
41+ import litmodels as lm
42+ import torch
7543
76- # Download and load the model file from cloud storage
77- model = load_model(
78- name = " your_org/your_team/sklearn-svm-model" , download_dir = " my_models"
79- )
44+ # save a model
45+ model = torch.nn.Module()
46+ upload_model(model = model, name = ' model-name' )
8047
81- # Example: run inference with the loaded model
82- sample_input = [[5.1 , 3.5 , 1.4 , 0.2 ]]
83- prediction = model.predict(sample_input)
84- print (f " Prediction: { prediction} " )
48+ # load a model
49+ model = load_model(name = ' model-name' )
8550```
8651
87- ## Saving and Loading Models with plain Pytorch
52+ # Examples
8853
89- Next examples demonstrate seamless PyTorch integration with Lightning Models.
54+ <details >
55+ <summary >PyTorch</summary >
9056
57+ Save model:
9158``` python
9259import torch
9360from litmodels import load_model, upload_model
9461
62+ model = torch.nn.Module()
63+ upload_model(model = model, name = " your_org/your_team/torch-model" )
64+ ```
9565
96- class SimpleModel (torch .nn .Module ): ...
97-
98-
99- # First, simply upload the model object to registry
100- upload_model(model = SimpleModel(), name = " your_org/your_team/torch-model" )
101- # Later, you can download the model from the registry
66+ Load model:
67+ ``` python
10268model_ = load_model(name = " your_org/your_team/torch-model" )
10369```
10470
105- ## Saving and Loading Models with Pytorch Lightning
106-
107- Next examples demonstrate seamless PyTorch Lightning integration with Lightning Models.
71+ </details >
10872
109- ### Train a simple Lightning model and save it
73+ <details >
74+ <summary >PyTorch Lightning</summary >
11075
76+ Save model:
11177``` python
11278from lightning import Trainer
11379from litmodels import upload_model
@@ -124,8 +90,7 @@ checkpoint_path = getattr(trainer.checkpoint_callback, "best_model_path")
12490upload_model(model = checkpoint_path, name = " <organization>/<teamspace>/<model-name>" )
12591```
12692
127- ### Download and Load the Model for fine-tuning
128-
93+ Load model:
12994``` python
13095from lightning import Trainer
13196from litmodels import download_model
@@ -144,8 +109,53 @@ trainer = Trainer(max_epochs=4)
144109trainer.fit(BoringModel(), ckpt_path = checkpoint_path)
145110```
146111
112+ </details >
113+
147114<details >
148- <summary>Checkpointing Workflow with Lightning</summary>
115+ <summary >SKLearn</summary >
116+
117+ Save model:
118+ ``` python
119+ from sklearn import datasets, model_selection, svm
120+ from litmodels import upload_model
121+
122+ # Load example dataset
123+ iris = datasets.load_iris()
124+ X, y = iris.data, iris.target
125+
126+ # Split dataset into training and test sets
127+ X_train, X_test, y_train, y_test = model_selection.train_test_split(
128+ X, y, test_size = 0.2 , random_state = 42
129+ )
130+
131+ # Train a simple SVC model
132+ model = svm.SVC()
133+ model.fit(X_train, y_train)
134+
135+ # Upload the saved model using litmodels
136+ upload_model(model = model, name = " your_org/your_team/sklearn-svm-model" )
137+ ```
138+
139+ Use model:
140+ ``` python
141+ from litmodels import load_model
142+
143+ # Download and load the model file from cloud storage
144+ model = load_model(
145+ name = " your_org/your_team/sklearn-svm-model" , download_dir = " my_models"
146+ )
147+
148+ # Example: run inference with the loaded model
149+ sample_input = [[5.1 , 3.5 , 1.4 , 0.2 ]]
150+ prediction = model.predict(sample_input)
151+ print (f " Prediction: { prediction} " )
152+ ```
153+
154+ </details >
155+
156+ # Features
157+ <details >
158+ <summary>PyTorch Lightning Callback</summary>
149159
150160Enhance your training process with an automatic checkpointing callback that uploads the model at the end of each epoch.
151161
@@ -177,27 +187,12 @@ trainer.fit(
177187
178188</details >
179189
180- ## Model Registry Mixins
181-
182- Lightning Models provides mixin classes that simplify pushing models to and pulling models from the registry.
183- These mixins can be integrated directly into the model classes.
184-
185- ### Available Mixins
186-
187- 1 . ** PickleRegistryMixin** : For serializing any Python class with pickle
188- 2 . ** PyTorchRegistryMixin** : For PyTorch models, preserving both weights and constructor arguments
189-
190- Using these mixins provides several advantages:
191-
192- - Direct integration into the model classes
193- - Simplified save/load workflow
194- - Automatic handling of model metadata and constructor arguments
195- - Version management support
196-
197- ### Using ` PickleRegistryMixin `
190+ <details >
191+ <summary>Save any Python class as a checkpoint</summary>
198192
199- Add the mixin to a Python class for seamless registry integration:
193+ Why is this useful???
200194
195+ Save model:
201196``` python
202197from litmodels.integrations.mixins import PickleRegistryMixin
203198
@@ -213,20 +208,25 @@ class MyModel(PickleRegistryMixin):
213208# Create and push a model instance
214209model = MyModel(param1 = 42 , param2 = " hello" )
215210model.upload_model(name = " my-org/my-team/my-model" )
211+ ```
216212
217- # Later, pull the model
213+ Load model:
214+ ``` python
218215loaded_model = MyModel.download_model(name = " my-org/my-team/my-model" )
219216```
217+
218+ </details >
220219
221- ### Using ` PyTorchRegistryMixin `
220+ <details >
221+ <summary>Save custom PyTorch models</summary>
222222
223- This mixin preserves both the model architecture and weights:
223+ why is this useful? why do i need this?
224224
225+ Save model:
225226``` python
226227import torch
227228from litmodels.integrations.mixins import PyTorchRegistryMixin
228229
229-
230230# Important: PyTorchRegistryMixin must be first in the inheritance order
231231class MyTorchModel (PyTorchRegistryMixin , torch .nn .Module ):
232232 def __init__ (self , input_size , hidden_size = 128 ):
@@ -237,11 +237,24 @@ class MyTorchModel(PyTorchRegistryMixin, torch.nn.Module):
237237 def forward (self , x ):
238238 return self .activation(self .linear(x))
239239
240-
241240# Create and push the model
242241model = MyTorchModel(input_size = 784 )
243242model.upload_model(name = " my-org/my-team/torch-model" )
243+ ```
244+
245+ Use the model:
246+ ``` python
244247
245248# Pull the model with the same architecture
246249loaded_model = MyTorchModel.download_model(name = " my-org/my-team/torch-model" )
247250```
251+
252+ </details >
253+
254+ # Performance
255+ TODO: show the chart between not using this vs using this and the impact on training (the GPU utilization side-by-side)... also, what are tangible speed ups in training and inference.
256+
257+ # Community
258+
259+ 💬 [ Get help on Discord] ( https://discord.com/invite/XncpTy7DSt )
260+ 📋 [ License: Apache 2.0] ( https://github.com/Lightning-AI/litModels/blob/main/LICENSE )
0 commit comments