Project Introduction: Lightning Bolts
Lightning Bolts is an exciting project aimed at extending the capabilities of PyTorch Lightning, a framework widely used for simplifying the process of building and training deep learning models. Bolts provides a plethora of components, including callbacks and datasets, that cater to both applied research and production environments.
Installation
Installing Lightning Bolts is a straightforward process. Users can simply use pip or conda to get started. This can be done by running the following command:
pip install lightning-bolts
For those looking to explore cutting-edge features, there is an option to install the latest version directly from the development branch, though stability isn't guaranteed. For additional functionality, all optional dependencies can also be installed.
What is Bolts?
Bolts is essentially a toolkit designed to complement PyTorch Lightning by offering additional features and optimizations. Here are a couple of examples that illustrate how Bolts can be beneficial:
Example 1: Speed Up Training with Torch ORT Callback
The Torch ORT Callback is one of the powerful tools provided by Bolts. It transforms your model into an optimized ONNX graph, which can significantly boost training and inference speeds, especially when using NVIDIA or AMD GPUs. This optimization is ideal for those looking to enhance performance without delving into complex coding changes.
from pytorch_lightning import LightningModule, Trainer
import torchvision.models as models
from pl_bolts.callbacks import ORTCallback
class VisionModel(LightningModule):
def __init__(self):
super().__init__()
self.model = models.vgg19_bn(pretrained=True)
model = VisionModel()
trainer = Trainer(gpus=1, callbacks=ORTCallback())
trainer.fit(model)
Example 2: Use Sparsity for Faster Inference
Another enhancement offered by Bolts is the SparseMLCallback. This feature integrates sparsity into the model during fine-tuning, which ultimately improves inference performance by leveraging the DeepSparse engine.
from pytorch_lightning import LightningModule, Trainer
import torchvision.models as models
from pl_bolts.callbacks import SparseMLCallback
class VisionModel(LightningModule):
def __init__(self):
super().__init__()
self.model = models.vgg19_bn(pretrained=True)
model = VisionModel()
trainer = Trainer(gpus=1, callbacks=SparseMLCallback(recipe_path="recipe.yaml"))
trainer.fit(model)
Support for Specific Research Implementations
The Lightning Bolts project encourages contributions that provide general components applicable to a wide range of problems. However, contributions that support specific domains or research areas are also welcome. For example, a callback for training Self-Supervised Learning (SSL) models would be a valuable addition.
For those interested in state-of-the-art model training, predicting, and serving, Lightning Flash is recommended. It integrates with VISSL for SSL-based tasks and is a complementary tool to Lightning Bolts.
Contributing to Lightning Bolts
Both the PyTorch Lightning team and the broader community support the Bolts project. Contributors are encouraged to join the community through Slack or by consulting the contribution guidelines. This is a collaborative effort where developers and researchers can contribute to advancing deep learning capabilities.
License Information
The Lightning Bolts project is released under the Apache 2.0 license, with the framework itself being patent pending. Users and contributors should observe the licensing terms in the repository.
In summary, Lightning Bolts offers a robust set of features that extend PyTorch Lightning, making it an essential tool for researchers and developers seeking to optimize and broaden their deep learning models.