1
1
<div align =" center " >
2
2
3
- <img alt =" Lightning " src =" https://pl-public-data.s3.amazonaws.com/assets_lightning/LightningColor.png " width =" 600px " style =" max-width : 100% ;" >
3
+ <img alt =" Lightning " src =" https://pl-public-data.s3.amazonaws.com/assets_lightning/LightningColor.png " width =" 800px " style =" max-width : 100% ;" >
4
4
5
5
<br />
6
6
<br />
9
9
10
10
** NEW- Lightning 2.0 is featuring a clean and stable API!!**
11
11
12
- ----
12
+ ______________________________________________________________________
13
13
14
14
<p align =" center " >
15
15
<a href =" https://www.lightning.ai/ " >Lightning.ai</a > •
40
40
41
41
</div >
42
42
43
-
44
43
## Install Lightning
45
44
46
45
Simple installation from PyPI
@@ -92,31 +91,31 @@ pip install -iU https://test.pypi.org/simple/ pytorch-lightning
92
91
</details >
93
92
<!-- end skipping PyPI description -->
94
93
95
- ----
94
+ ______________________________________________________________________
96
95
97
96
## Lightning has 3 core packages
98
97
99
- [ PyTorch Lightning: Train and deploy PyTorch at scale] ( #pytorch-lightning-train-and-deploy-pytorch-at-scale ) .
100
- [ Lightning Fabric: Expert control] ( #lightning-fabric-expert-control ) .
101
- [ Lightning Apps: Build AI products and ML workflows] ( #lightning-apps-build-ai-products-and-ml-workflows ) .
98
+ [ PyTorch Lightning: Train and deploy PyTorch at scale] ( #pytorch-lightning-train-and-deploy-pytorch-at-scale ) .
99
+ [ Lightning Fabric: Expert control] ( #lightning-fabric-expert-control ) .
100
+ [ Lightning Apps: Build AI products and ML workflows] ( #lightning-apps-build-ai-products-and-ml-workflows ) .
102
101
103
- Lightning gives you granular control over how much abstraction you want to add over PyTorch.
102
+ Lightning gives you granular control over how much abstraction you want to add over PyTorch.
104
103
105
104
<div align =" center " >
106
105
<img src="https://pl-public-data.s3.amazonaws.com/assets_lightning/continuum.png" width="80%">
107
106
</div >
108
107
109
- ----
108
+ ______________________________________________________________________
110
109
111
110
# PyTorch Lightning: Train and Deploy PyTorch at Scale
112
111
113
- PyTorch Lightning is just organized PyTorch - Lightning disentangles PyTorch code to decouple the science from the engineering.
112
+ PyTorch Lightning is just organized PyTorch - Lightning disentangles PyTorch code to decouple the science from the engineering.
114
113
115
114
![ PT to PL] ( docs/source-pytorch/_static/images/general/pl_quick_start_full_compressed.gif )
116
115
117
- ----
116
+ ______________________________________________________________________
118
117
119
- ### Hello simple model
118
+ ### Hello simple model
120
119
121
120
``` python
122
121
# main.py
@@ -125,11 +124,12 @@ import os, torch, torch.nn as nn, torch.utils.data as data, torchvision as tv, t
125
124
import lightning as L
126
125
127
126
# --------------------------------
128
- # Step 1: Define a LightningModule
127
+ # Step 1: Define a LightningModule
129
128
# --------------------------------
130
- # A LightningModule (nn.Module subclass) defines a full *system*
129
+ # A LightningModule (nn.Module subclass) defines a full *system*
131
130
# (ie: an LLM, difussion model, autoencoder, or simple image classifier).
132
131
132
+
133
133
class LitAutoEncoder (L .LightningModule ):
134
134
def __init__ (self ):
135
135
super ().__init__ ()
@@ -155,6 +155,7 @@ class LitAutoEncoder(L.LightningModule):
155
155
optimizer = torch.optim.Adam(self .parameters(), lr = 1e-3 )
156
156
return optimizer
157
157
158
+
158
159
# -------------------
159
160
# Step 2: Define data
160
161
# -------------------
@@ -170,11 +171,13 @@ trainer.fit(autoencoder, data.DataLoader(train), data.DataLoader(val))
170
171
```
171
172
172
173
Run the model on your terminal
173
- ``` bash
174
+
175
+ ``` bash
174
176
pip install torchvision
175
177
python main.py
176
178
```
177
- ----
179
+
180
+ ______________________________________________________________________
178
181
179
182
## Advanced features
180
183
@@ -197,6 +200,7 @@ trainer = Trainer(accelerator="gpu", devices=8)
197
200
# 256 GPUs
198
201
trainer = Trainer(accelerator = " gpu" , devices = 8 , num_nodes = 32 )
199
202
```
203
+
200
204
</details >
201
205
202
206
<details >
@@ -206,6 +210,7 @@ trainer = Trainer(accelerator="gpu", devices=8, num_nodes=32)
206
210
# no code changes needed
207
211
trainer = Trainer(accelerator = " tpu" , devices = 8 )
208
212
```
213
+
209
214
</details >
210
215
211
216
<details >
@@ -246,12 +251,13 @@ trainer = Trainer(logger=loggers.NeptuneLogger())
246
251
247
252
<details >
248
253
249
- <summary >Early Stopping</summary >
254
+ <summary >Early Stopping</summary >
250
255
251
256
``` python
252
257
es = EarlyStopping(monitor = " val_loss" )
253
258
trainer = Trainer(callbacks = [es])
254
259
```
260
+
255
261
</details >
256
262
257
263
<details >
@@ -261,6 +267,7 @@ trainer = Trainer(callbacks=[es])
261
267
checkpointing = ModelCheckpoint(monitor = " val_loss" )
262
268
trainer = Trainer(callbacks = [checkpointing])
263
269
```
270
+
264
271
</details >
265
272
266
273
<details >
@@ -271,6 +278,7 @@ trainer = Trainer(callbacks=[checkpointing])
271
278
autoencoder = LitAutoEncoder()
272
279
torch.jit.save(autoencoder.to_torchscript(), " model.pt" )
273
280
```
281
+
274
282
</details >
275
283
276
284
<details >
@@ -287,7 +295,7 @@ with tempfile.NamedTemporaryFile(suffix=".onnx", delete=False) as tmpfile:
287
295
288
296
</details >
289
297
290
- ----
298
+ ______________________________________________________________________
291
299
292
300
## Advantages over unstructured PyTorch
293
301
@@ -300,21 +308,20 @@ with tempfile.NamedTemporaryFile(suffix=".onnx", delete=False) as tmpfile:
300
308
- [ Tested rigorously with every new PR] ( https://github.com/Lightning-AI/lightning/tree/master/tests ) . We test every combination of PyTorch and Python supported versions, every OS, multi GPUs and even TPUs.
301
309
- Minimal running speed overhead (about 300 ms per epoch compared with pure PyTorch).
302
310
303
- ----
311
+ ______________________________________________________________________
304
312
305
313
<div align =" center " >
306
314
<a href="https://lightning.ai/docs/pytorch/stable/">Read the PyTorch Lightning docs</a>
307
315
</div >
308
316
309
- ----
317
+ ______________________________________________________________________
310
318
311
319
# Lightning Fabric: Expert control.
312
320
313
321
Run on any device at any scale with expert-level control over PyTorch training loop and scaling strategy. You can even write your own Trainer.
314
322
315
323
Fabric is designed for the most complex models like foundation model scaling, LLMs, diffussion, transformers, reinforcement learning, active learning.
316
324
317
-
318
325
``` diff
319
326
+ import lightning as L
320
327
import torch
@@ -354,13 +361,13 @@ Fabric is designed for the most complex models like foundation model scaling, LL
354
361
- Designed with multi-billion parameter models in mind
355
362
- Build your own custom Trainer using Fabric primitives for training checkpointing, logging, and more
356
363
357
- ----
364
+ ______________________________________________________________________
358
365
359
366
<div align =" center " >
360
367
<a href="https://lightning.ai/docs/fabric/stable/">Read the Lightning Fabric docs</a>
361
368
</div >
362
369
363
- ----
370
+ ______________________________________________________________________
364
371
365
372
# Lightning Apps: Build AI products and ML workflows
366
373
@@ -376,24 +383,28 @@ Lightning Apps remove the cloud infrastructure boilerplate so you can focus on s
376
383
# app.py
377
384
import lightning as L
378
385
386
+
379
387
class TrainComponent (L .LightningWork ):
380
388
def run (self , x ):
381
- print (f ' train a model on { x} ' )
389
+ print (f " train a model on { x} " )
390
+
382
391
383
392
class AnalyzeComponent (L .LightningWork ):
384
393
def run (self , x ):
385
- print (f ' analyze model on { x} ' )
394
+ print (f " analyze model on { x} " )
395
+
386
396
387
397
class WorkflowOrchestrator (L .LightningFlow ):
388
398
def __init__ (self ) -> None :
389
399
super ().__init__ ()
390
- self .train = TrainComponent(cloud_compute = L.CloudCompute(' cpu' ))
391
- self .analyze = AnalyzeComponent(cloud_compute = L.CloudCompute(' gpu' ))
400
+ self .train = TrainComponent(cloud_compute = L.CloudCompute(" cpu" ))
401
+ self .analyze = AnalyzeComponent(cloud_compute = L.CloudCompute(" gpu" ))
392
402
393
403
def run (self ):
394
404
self .train.run(" CPU machine 1" )
395
405
self .analyze.run(" GPU machine 2" )
396
406
407
+
397
408
app = L.LightningApp(WorkflowOrchestrator())
398
409
```
399
410
@@ -407,13 +418,13 @@ lightning run app app.py --setup --cloud
407
418
lightning run app app.py
408
419
```
409
420
410
- ----
421
+ ______________________________________________________________________
411
422
412
423
<div align =" center " >
413
424
<a href="https://lightning.ai/docs/app/stable/">Read the Lightning Apps docs</a>
414
425
</div >
415
426
416
- ----
427
+ ______________________________________________________________________
417
428
418
429
## Examples
419
430
@@ -444,7 +455,7 @@ lightning run app app.py
444
455
- [ Logistic Regression] ( https://lightning-bolts.readthedocs.io/en/stable/models/classic_ml.html#logistic-regression )
445
456
- [ Linear Regression] ( https://lightning-bolts.readthedocs.io/en/stable/models/classic_ml.html#linear-regression )
446
457
447
- ----
458
+ ______________________________________________________________________
448
459
449
460
## Continuous Integration
450
461
@@ -470,7 +481,7 @@ Lightning is rigorously tested across multiple CPUs, GPUs, TPUs, IPUs, and HPUs
470
481
</center >
471
482
</details >
472
483
473
- ----
484
+ ______________________________________________________________________
474
485
475
486
## Community
476
487
0 commit comments