Lightning Fabric is a lightweight, high-performance library for training deep learning models at scale with PyTorch. It provides core utilities for distributed training, mixed-precision, and device management, allowing users to write pure PyTorch code while Fabric handles the boilerplate. It is currently at version 2.6.1 and follows the release cadence of the broader Lightning ecosystem, typically with monthly or bi-monthly patch releases.
pip install lightning-fabric torchVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use Lightning Fabric to set up a simple PyTorch model for training, leveraging Fabric for device management, mixed precision, and distributed training boilerplate. It covers initialization, model/optimizer/dataloader setup, and a basic training loop with a backward pass handled by Fabric.
Refer to the official Lightning Fabric 2.x documentation for updated API usage, especially for `Fabric` initialization, `setup`, and manual training loop construction.
Embrace the 'pure PyTorch' philosophy; use Fabric's `setup` methods and `backward` for core distributed operations, but manage the loop structure, metrics, and logging yourself.
Always use `fabric.setup()` for your model and optimizer, and `fabric.setup_dataloader()` for your data loaders. Fabric will handle the device placement. Avoid manual `to(device)` calls on objects managed by Fabric.