Lightning-AI/pytorch-lightning
47.4
Weak · 15 November 2026
53.7k
lines of production code
Python
primary language
5
measurements over time
What this system is
This system is a unified deep learning framework that provides two distinct APIs: PyTorch Lightning for high-level, declarative model training and Lightning Fabric for low-level, customizable training loops. It supports distributed training across various hardware accelerators and cluster environments, offering strategies like DDP, FSDP, and tensor parallelism. The library includes comprehensive tooling for experiment logging, checkpoint management, and model serving, alongside extensive examples and parity tests to ensure compatibility with raw PyTorch.
How it got here
2019–2022 — Unified packaging and test expansion
36 changes.
The project consolidated its distribution into a single 'lightning' meta-package while restructuring the source layout and dependency management. This period was dominated by the creation of a comprehensive test suite covering the Trainer, strategies, plugins, and utilities to ensure stability and backward compatibility.
2023–2024 — Fabric expansion and namespace consolidation
65 changes.
This period focused on significantly expanding the Lightning Fabric module by introducing comprehensive test coverage, new cluster environment and precision plugins, and extensive usage examples for distributed training and advanced parallelism. Simultaneously, the PyTorch Lightning codebase underwent a major architectural reorganization, migrating core classes, strategies, and utilities into the unified \lightning\ namespace while maintaining backward compatibility through legacy shims.
Features
Add DCGAN example with Lightning Fabric acceleration
A new example in the Fabric section demonstrates a Deep Convolutional Generative Adversarial Network (DCGAN) trained on the CelebA dataset to generate realistic face images. The example provides two implementations: a raw PyTorch version and a Lightning Fabric version that simplifies device management and scaling. Users can run either script to train the model and save generated samples to an output directory.
examples/fabric/dcgan · high confidence
Add Fabric PPO reinforcement learning example with coupled and decoupled training modes
The \examples/fabric/reinforcement\_learning\ directory now contains a complete Proximal Policy Optimization (PPO) implementation accelerated by Lightning Fabric. This example demonstrates two distinct distributed training architectures: a coupled mode where the environment and agent run on the same processes, and a decoupled mode where a dedicated 'Player' process handles environment interaction while separate 'Trainer' processes optimize the agent, communicating via Fabric collectives. The entry includes the core training scripts (\train\_fabric.py\, \train\_fabric\_decoupled.py\), a raw PyTorch baseline (\train\_torch.py\), and documentation explaining how to configure distributed execution, share data between processes, and visualize results.
_examples/fabric/reinforcement\learning · high confidence
Add MAML meta-learning example with Lightning Fabric and raw PyTorch implementations
Added a new example in examples/fabric/meta\_learning demonstrating the Model Agnostic Meta Learning (MAML) algorithm on the Omniglot dataset. The example provides two distributed training scripts: train\_fabric.py, which uses Lightning Fabric to handle device placement and distributed synchronization, and train\_torch.py, which implements raw PyTorch distributed training using torch.distributed. Both implementations leverage the learn2learn library for task sampling and the MAML algorithm, allowing users to compare the boilerplate reduction offered by Fabric against standard PyTorch distributed code.
_examples/fabric/meta\learning · high confidence
Add minimal Transformer language model example
A new example has been added to the Fabric documentation demonstrating a simple training loop for next-word prediction using a Transformer model on the WikiText2 dataset. The example includes a \train.py\ script and a \README.md\ that explains how to run the training on CPU, GPU, or multiple devices using the \fabric run\ command.
_examples/fabric/language\model · high confidence
Experimental API for validating model serving with FastAPI
A new experimental feature allows users to verify that their PyTorch Lightning models can be correctly served as REST APIs. By subclassing the new \ServableModule\ and implementing specific hooks (\configure\_payload\, \configure\_serialization\, \serve\_step\, and optionally \configure\_response\), users can attach the \ServableModuleValidator\ callback to their Trainer. This validator automatically spins up a local FastAPI server, sends a test request using the configured payload, and validates the response against the expected output, ensuring the model's serialization and inference logic are correct before deployment.
src/lightning/pytorch/serve · high confidence
Introduce Fabric experiment loggers (CSV and TensorBoard)
The \src/lightning/fabric/loggers\ module now provides \CSVLogger\ and \TensorBoardLogger\ for saving experiment metrics and hyperparameters in Lightning Fabric. \CSVLogger\ writes metrics to local CSV files with automatic versioning and supports remote storage paths via \fsspec\. \TensorBoardLogger\ integrates with \tensorboard\ or \tensorboardX\ to record metrics, hyperparameters, and model graphs, allowing users to visualize training progress in TensorBoard.
src/lightning/fabric/loggers · high confidence
Introduce \`lightning.pytorch.core\` package with core module and data module classes
The \lightning.pytorch.core\ package is now available, exposing \LightningModule\ and \LightningDataModule\ directly from \lightning.pytorch.core\. This new location consolidates the core abstractions, including the \LightningDataModule.from\_datasets\ factory method, the \on\_exception\ hook for error handling, and the \load\_from\_checkpoint\ logic with \weights\_only\ support and secure instantiator validation to prevent arbitrary code execution.
src/lightning/pytorch/core · high confidence
Introduce experimental collective communication plugin API
The \src/lightning/fabric/plugins/collectives\ module now provides a new experimental API for collective operations, exposing \Collective\ (abstract base), \TorchCollective\ (wrapping \torch.distributed\), and \SingleDeviceCollective\ (no-op fallback). \TorchCollective\ allows users to perform standard distributed operations like \all\_reduce\, \broadcast\, and \barrier\ while managing process group lifecycle (init, create, destroy) through a consistent interface, and defaults to using the \torch.distributed\ WORLD process group when no custom group is explicitly created.
src/lightning/fabric/plugins/collectives · high confidence
Introduction of the unified 'lightning' meta-package
The \src/lightning\ directory now serves as a meta-package that aggregates \pytorch-lightning\ and \lightning-fabric\ into a single distribution. Users can now install the \lightning\ package to access core components like \Trainer\, \LightningModule\, \Fabric\, and \seed\everything\ from a single entry point. This change introduces a new top-level \\\init\\_.py\ that re-exports these key classes, updates the package metadata to require Python 3.10+, and configures the build system to include necessary type hints and version information.
src/lightning · high confidence
New Build Your Own Trainer (BYOT) example for Fabric
Added a new example in \examples/fabric/build\_your\_own\_trainer\ that demonstrates how to build a fully customizable training loop using \lightning.fabric\. The example includes a \trainer.py\ file implementing a \MyCustomTrainer\ class that handles hardware orchestration, optimization, and checkpointing, and a \run.py\ script that trains a simple MNIST model using this custom trainer.
_examples/fabric/build\_your\_own\trainer · high confidence
New FP8 distributed transformer examples for Fabric and PyTorch Lightning
Added new example scripts and documentation for both Lightning Fabric and PyTorch Lightning that demonstrate training a Transformer model using FP8 low-precision quantization, FSDP2 (DTensor) for distributed model parallelism, and torch.compile for performance optimization. The Fabric example uses the \ModelParallelStrategy\ with a \parallelize\_fn\ to apply quantization and compilation, while the PyTorch Lightning example implements the same logic within a \LightningModule\'s \configure\_model\ hook, providing users with reference implementations for combining these advanced PyTorch features.
_examples/fabric/fp8\_distributed\_transformer, examples/pytorch/fp8\_distributed\transformer · high confidence
New Fabric MNIST example demonstrating scalable training
Added a new example in \examples/fabric/image\_classifier\ that contrasts a vanilla PyTorch MNIST classifier with a Lightning Fabric version. The Fabric script (\train\_fabric.py\) shows how to use \fabric.run\ for command-line configuration of accelerators and devices, \fabric.setup\ for automatic device placement, \fabric.backward\ for distributed loss computation, and \torchmetrics\ for accurate multi-GPU metric aggregation, providing a reference for scaling PyTorch code with Fabric.
_examples/fabric/image\classifier · high confidence
New Fabric example for 2D tensor and data parallelism
Added a new example in \examples/fabric/tensor\_parallel\ demonstrating how to combine tensor parallelism (TP) and data parallelism (DP) using PyTorch's FSDP2 and \ModelParallelStrategy\. The example shows how to parallelize a Llama 3 7B model across multiple GPUs, including configuration for mixed precision, activation checkpointing, and distributed checkpointing.
_examples/fabric/tensor\parallel · high confidence
New K-Fold Cross Validation example for Lightning Fabric
Added a new example in \examples/fabric/kfold\_cv\ that demonstrates how to perform K-Fold cross validation using Lightning Fabric. The example trains a CNN on the MNIST dataset, utilizing \sklearn.model\_selection.KFold\ to create data splits and \fabric.setup\_dataloaders\ to handle data loading across devices. It also showcases best practices such as using \fabric.rank\_zero\_first\ for dataset downloads and \fabric.save\ for checkpointing in distributed environments.
_examples/fabric/kfold\cv · high confidence
New PyTorch Lightning domain templates for computer vision, GANs, and reinforcement learning
Added new runnable example scripts in the \examples/pytorch/domain\_templates\ directory to demonstrate specific deep learning patterns. These include \computer\_vision\_fine\_tuning.py\ for transfer learning with staged unfreezing, \generative\_adversarial\_net.py\ for GAN training with manual optimization, \imagenet.py\ for large-scale ImageNet classification, \reinforce\_learn\_Qnet.py\ for Deep Q-Networks, \reinforce\_learn\_ppo.py\ for Proximal Policy Optimization, and \semantic\_segmentation.py\ for U-Net-based segmentation on the KITTI dataset.
_examples/pytorch/domain\templates · high confidence
New PyTorch Lightning examples for basics and bug reporting
The \examples/pytorch/basics\ directory now includes runnable reference scripts demonstrating core Lightning capabilities: an MNIST autoencoder (\autoencoder.py\), a backbone image classifier (\backbone\_image\_classifier.py\), a Transformer-based language model (\transformer.py\), and a PyTorch Profiler integration example (\profiler\_example.py\). Additionally, a new \examples/pytorch/bug\_report\ directory provides a minimal \BoringModel\ (both Python and Jupyter Notebook versions) to help users create reproducible bug reports.
examples/pytorch/basics · high confidence
New build assistant and legacy checkpoint retrieval tooling
The repository introduces a new Python build assistant script (.actions/assistant.py) that manages package requirements for PyTorch, Fabric, and Data subpackages, including logic to adjust version constraints (unfreezing) for different release scenarios, and a shell script (.actions/pull\_legacy\_checkpoints.sh) to download and extract legacy model checkpoints into the test directory for compatibility testing.
.actions · high confidence
New cluster environment plugins for Fabric
The \src/lightning/fabric/plugins/environments\ module now provides a set of cluster environment plugins that allow Lightning Fabric to automatically detect and configure distributed training across various schedulers and runtimes. This includes support for SLURM, LSF, MPI, TorchElastic, Kubeflow, and XLA (TPU), each implementing the \ClusterEnvironment\ interface to handle process management, rank/size detection, and communication settings specific to their respective environments.
src/lightning/fabric/plugins/environments · high confidence
New demo modules for LSTM and Transformer models
The \lightning.pytorch.demos\ package now includes ready-to-use examples for sequence modeling: a simple LSTM language model (\LightningLSTM\, \SimpleLSTM\) and a Transformer-based language model (\LightningTransformer\, \Transformer\) backed by a mini WikiText2 dataset. These demos are exported from the package root, allowing users to import them directly via \from lightning.pytorch.demos import LightningLSTM, LightningTransformer\.
src/lightning/pytorch/demos · high confidence
New distributed overrides module for PyTorch Lightning
The \src/lightning/pytorch/overrides\ package has been introduced, providing specialized utilities for PyTorch's distributed training. This includes a \DistributedDataParallel\ backward preparation hook to handle gradient synchronization and unused parameters, a helper to register custom DDP communication hooks (such as FP16 compression or PowerSGD), and a state-syncing utility. Additionally, it adds an \UnrepeatedDistributedSampler\ that allows deterministic, non-repeating data iteration across processes, which is specifically designed to be safe and effective for prediction phases where batch counts may vary slightly between processes.
src/lightning/pytorch/overrides · high confidence
New examples and core loop refactoring for tensor parallelism and production serving
Added new example scripts for tensor parallelism in both Fabric and PyTorch Lightning, demonstrating how to implement and run models using tensor-parallel strategies. Introduced a new production-serving example that wraps a model with \ServableModule\ to handle serialization and deserialization of image payloads. Under the hood, the training and evaluation loops were refactored to support these new capabilities, including changes to how data is fetched and how the fit loop handles restarts and state management.
python · high confidence
New tensor-parallel example supporting 2D parallelism with Llama 3
Added a new example in \examples/pytorch/tensor\_parallel\ that demonstrates how to apply tensor parallelism to a Llama 3 7B model using the \ModelParallelStrategy\. The example supports 2D parallelism by combining tensor parallelism with FSDP, requiring PyTorch 2.3+ and at least 4 GPUs with 24 GB of memory each. It includes a training script (\train.py\) that configures the \ModelParallelStrategy\ with specific data and tensor parallel sizes, a parallelism module (\parallelism.py\) that applies parallelization plans and activation checkpointing, and a simple dataset (\data.py\) for demonstration purposes.
_examples/pytorch/tensor\parallel · high confidence
Project initialization and repository structure setup
This change establishes the foundational structure for the Lightning project repository. It introduces the core packaging configuration via \setup.py\, which supports installing the \lightning\ meta-package, \pytorch-lightning\, and \lightning-fabric\ individually or together. A \Makefile\ is added to streamline development tasks, including environment setup, testing, documentation building, and standalone test execution. The repository is configured with a \.gitignore\ to exclude build artifacts and caches, a \.pre-commit-config.yaml\ to enforce code quality using tools like Ruff and mdformat, and a \.codecov.yml\ to define coverage reporting standards. Documentation is supported by \.readthedocs.yml\ and a \CITATION.cff\ file for academic referencing. The project license is updated from MIT to Apache 2.0, and a \SECURITY.md\ file is added to direct security reports to the development team.
(repo-wide) · high confidence
Architecture
Fabric strategies moved to src/lightning/fabric/strategies
The distributed training strategies (DDP, DeepSpeed, FSDP, DataParallel, ModelParallel, XLA, and SingleDevice) have been relocated to the \src/lightning/fabric/strategies\ package. This change reorganizes the codebase structure, making the strategies explicitly part of the Fabric module's public API and simplifying imports for users configuring distributed training within Fabric.
src/lightning/fabric/strategies · high confidence
Introduce modular launcher architecture for Fabric strategies
The distributed process-launching logic in Lightning Fabric has been reorganized into a dedicated \src/lightning/fabric/strategies/launchers\ package. This change introduces an abstract \\_Launcher\ base class and concrete implementations for multiprocessing (\\_MultiProcessingLauncher\), subprocess scripts (\\_SubprocessScriptLauncher\), and XLA hardware (\\_XLALauncher\). For users, this provides a cleaner internal structure for how Fabric spawns and manages worker processes across different hardware and cluster environments, while maintaining the same external behavior for distributed training.
src/lightning/fabric/strategies/launchers · high confidence
Restructure of the \`lightning.pytorch.utilities\` package with new module organization
The \lightning.pytorch.utilities\ package has been reorganized into a set of distinct modules (e.g., \combined\_loader\, \compile\, \data\, \enums\, \grads\, \imports\, \memory\, \model\_helpers\, \model\_registry\, \parameter\_tying\, \parsing\, \rank\_zero\, \\pytree\) and re-exported via a consolidated \\\init\\_.py\. This change groups related functionality—such as \CombinedLoader\ modes, \torch.compile\ handling, data utilities, gradient norms, and environment variable parsing—into specific files for better maintainability, while exposing the same public API surface through the main utilities namespace.
src/lightning/pytorch/utilities · high confidence
Trainer module restructured into a new package layout
The \src/lightning/pytorch/trainer\ directory has been reorganized into a dedicated Python package. The \Trainer\ class and \seed\everything\ function are now explicitly exported via \\\init\\_.py\, and the internal trainer logic has been split into modular files including \call.py\ (hook execution and interrupt handling), \configuration\_validator.py\ (loop configuration checks), and \setup.py\ (initialization of debugging flags, profilers, and device info).
src/lightning/pytorch/trainer · high confidence
Behavioural changes
Accelerator implementations moved to lightning.pytorch.accelerators
The PyTorch Lightning accelerator implementations (CPU, CUDA, MPS, and XLA) have been relocated from the legacy \\pytorch\_lightning.accelerators\\ namespace to \\lightning.pytorch.accelerators\\. This change consolidates the accelerator logic within the new \\lightning\\ package structure, ensuring that users importing from the new namespace will access the correct, updated implementations for device management and statistics.
src/lightning/pytorch/accelerators · high confidence
Automatic legacy checkpoint migration and unpickling support
Lightning now automatically upgrades legacy checkpoints when loading them, applying version-specific migrations (e.g., for loop structures, progress tracking, and callback keys) to match the current format. The system also handles unpickling of older checkpoints that contain removed classes or modules (such as \\_FaultTolerantMode\ or \pytorch\_lightning\ imports) by temporarily patching the environment, ensuring seamless resumption of training from older saved states.
src/lightning/pytorch/utilities/migration · high confidence
Backward compatibility shims for renamed and removed components
The library now includes a compatibility layer in the \\_graveyard\ module to support legacy imports and class names. Deprecated precision plugins (e.g., \PrecisionPlugin\, \HalfPrecisionPlugin\) are aliased to their new counterparts (e.g., \Precision\, \HalfPrecision\) with deprecation warnings. TPU-specific classes (\TPUAccelerator\, \SingleTPUStrategy\) are mapped to their XLA equivalents (\XLAAccelerator\, \SingleDeviceXLAStrategy\). Removed Habana (HPU) integrations are replaced with stub classes that raise \NotImplementedError\ to clearly indicate removal. Additionally, a patch ensures older versions of \torchmetrics\ (\<0.8.0) correctly resolve internal imports to the unified \lightning.pytorch\ package.
_src/lightning/pytorch/\graveyard · high confidence
Callbacks module reorganized under lightning.pytorch.callbacks
The callback implementations have been moved to the \src/lightning/pytorch/callbacks\ package, establishing a new public import path (\from lightning.pytorch.callbacks import ...\). This change exposes core utilities such as \ModelCheckpoint\, \EarlyStopping\, \LearningRateMonitor\, \BatchSizeFinder\, and \EMAWeightAveraging\ through a unified \\_\init\\_.py\ module, replacing previous import locations.
src/lightning/pytorch/callbacks · high confidence
Changelog and CLI updates for 2.6.6
The CHANGELOG.md file has been updated to document the 2.6.6 release, highlighting security fixes for arbitrary code execution in \load\_from\_checkpoint\ via \\_instantiator\ and \\_class\path\ restrictions, as well as fixes for \FSDPPrecision\ rejecting gradient scalers, \torch.compile\ crashes in \self.log()\, and \RichProgressBar\ negative epoch totals. The \cli.py\ module enforces a minimum \jsonargparse\ version of 4.39 and adapts to 4.50+ API changes, while \\\init\\_.py\ exposes the \Trainer\, \LightningModule\, \LightningDataModule\, and \Callback\ classes along with \seed\_everything\ and \disable\_possible\_user\_warnings\.
src/lightning/pytorch · high confidence
Decoupled Fabric PPO example with PyTorch and configurable training options
The reinforcement learning example in examples/fabric/reinforcement\_learning/rl has been refactored to use PyTorch instead of NumPy, introducing a new modular structure with separate files for the agent, loss functions, and utilities. This change enables users to configure specific training behaviors via command-line arguments, including toggling GPU usage, enabling data sharing between processes, selecting activation functions (ReLU or Tanh), and adjusting PPO hyperparameters like advantage normalization and value loss clipping.
_examples/fabric/reinforcement\learning/rl · high confidence
Enhanced ModelSummary with training mode, FLOPs, and Deepspeed support
The model summary output now includes columns for the module's training mode (train/eval) and estimated FLOPs, providing deeper insight into model behavior and computational cost. It also correctly handles non-layer parameters by listing them separately and supports PyTorch DTensors. For users of the DeepSpeed strategy, a specialized summary is available that displays parameters per device and fixes column alignment issues.
_src/lightning/pytorch/utilities/model\summary · high confidence
Fabric 2.6.5 release with remote checkpoint support and bug fixes
This release introduces support for remote storage (fsspec URLs) when saving and loading distributed checkpoints with FSDPStrategy, ModelParallelStrategy, and the checkpoint consolidation CLI. It also adds \using\_sparse\_model\ and \sparse\_cuda\_acceleration\_factor\ parameters to the \Throughput\ utility to correctly default to dense peak FLOPs and allow explicit sparse peak opt-in. Several bugs are fixed: FSDP mixed precision now correctly initializes parameters in fp32 instead of half precision, the \BitsandbytesPrecision\ plugin type checking is corrected for bitsandbytes 0.48/0.49, DeepSpeed checkpoint path validation now accepts remote filesystem URIs (S3, GCS, HDFS), and a RuntimeError under PyTorch 2.5+ when FSDP's \root\_device\ is CPU is resolved by passing an explicit \torch.device("cpu")\. Additional fixes address an AccumulateGrad stream mismatch warning with DDP, incorrect CUDA device initialization in \CUDAAccelerator.setup\_device\, and \PermissionError\ swallowing during atomic checkpoint saves. Dead code paths for PyTorch below 2.6 have been removed.
src/lightning/fabric · high confidence
Fabric accelerator implementations and registry are restructured
The \src/lightning/fabric/accelerators\ module now provides the concrete accelerator classes (CPU, CUDA, MPS, XLA) and the \\_AcceleratorRegistry\ that Fabric uses to select hardware. This change introduces a registry-based lookup for accelerators, ensuring that the correct hardware implementation is instantiated based on the user's configuration. It also includes specific fixes for CUDA device initialization (ensuring \set\_device\ is called before precision checks) and XLA runtime detection (supporting \torch-xla\>=2.5\ PJRT checks).
src/lightning/fabric/accelerators · high confidence
Fabric precision plugin API restructured with new context managers and plugin classes
The precision plugin system in Fabric has been reorganized to support a more granular control over model initialization and data conversion. The base \Precision\ class now exposes \tensor\_init\_context\ and \module\_init\context\ hooks, allowing plugins to control tensor creation and module instantiation separately. New concrete plugins have been introduced: \BitsandbytesPrecision\ for quantization (supporting modes like \nf4\, \fp4\, and \int8\), \TransformerEnginePrecision\ for FP8 training via NVIDIA's Transformer Engine, and \XLAPrecision\ for XLA devices. Existing plugins like \MixedPrecision\, \FSDPPrecision\, \DeepSpeedPrecision\, \HalfPrecision\, and \DoublePrecision\ have been updated to align with the new API, including changes to how they handle input/output conversion and optimizer steps (e.g., \FSDPPrecision\ now uses \ShardedGradScaler\). The \\\init\\_.py\ module now explicitly exports all these precision plugins.
src/lightning/fabric/plugins/precision · high confidence
Fabric utilities module reorganization and new checkpointing features
The \src/lightning/fabric/utilities\ package has been reorganized into a dedicated module, exposing a consolidated set of utilities including \AttributeDict\, \Throughput\ monitoring, and data-handling helpers like \move\_data\_to\_device\. This change introduces atomic checkpoint saving via \fsspec\ to prevent corruption during interruptions, supports remote storage URLs for FSDP checkpoints, and adds a CLI tool to consolidate sharded FSDP checkpoints into a single file. Additionally, the \\_DeviceDtypeModuleMixin\ now respects PyTorch 2.8's default device context, and the \load\ module implements lazy checkpoint loading to reduce memory overhead when loading large models.
src/lightning/fabric/utilities · high confidence
Hyperparameter handling logic moved to a dedicated mixin
The \save\_hyperparameters\ functionality and related hyperparameter management (including \hparams\ and \hparams\_initial\ properties) have been extracted from the core model classes into a new \HyperparametersMixin\ in \src/lightning/pytorch/core/mixins\. This change restructures how hyperparameters are stored and accessed, making the logic available for reuse and potentially altering inheritance patterns for classes that previously relied on the previous implementation location.
src/lightning/pytorch/core/mixins · medium confidence
Introduce Lightning Data as a wrapper for the litdata package
The \src/lightning/data\ module now acts as a compatibility layer that re-exports the core functionality of the \litdata\ package. Users can continue to import \StreamingDataset\, \optimize\, \map\, and other data processing tools from \lightning.data\, but the implementation is now sourced from the external \litdata\ library. This change requires the \litdata\ package to be installed, as the module explicitly checks for its presence and raises an error if it is missing, effectively decoupling the data loading logic from the main Lightning repository.
src/lightning/data · high confidence
Introduction of FX-level logging validation and integration suggestions
The logger connector now enforces strict rules on which Lightning hooks allow metric logging via the new \\_FxValidator\, preventing invalid \self.log()\ calls in unsupported lifecycle methods. Additionally, when no \LitLogger\ is configured and the \suggest\_integrations\ flag is enabled, the Trainer now suggests installing \litlogger\ for seamless cloud logging.
_src/lightning/pytorch/trainer/connectors/logger\connector · high confidence
Lightning Fabric package structure and Python version requirements
The Lightning Fabric package now includes a MANIFEST.in file to ensure necessary metadata and documentation files are included in distributions, alongside a py.typed marker file to enable PEP 561 type checking support. The package setup explicitly requires Python 3.10 or higher and lists support for Python 3.10 through 3.13, reflecting the deprecation of older Python versions.
_src/lightning\fabric · high confidence
New CheckpointIO plugin interface with weights\_only support
The \src/lightning/fabric/plugins/io\ module now exposes a new \CheckpointIO\ interface along with \TorchCheckpointIO\ and \XLACheckpointIO\ implementations. This change introduces a \weights\_only\ parameter to checkpoint loading, allowing users to restrict loading to safe state dicts for improved security when handling untrusted sources. The \XLACheckpointIO\ implementation specifically handles TPU-specific requirements, including OmegaConf compatibility workarounds.
src/lightning/fabric/plugins/io · high confidence
New plugin architecture for layer synchronization and precision management
The \src/lightning/pytorch/plugins\ module has been restructured to introduce a dedicated plugin system for managing model layer synchronization and precision. This change adds a new \LayerSync\ abstract base class and a concrete \TorchSyncBatchNorm\ implementation, allowing users to wrap batch normalization layers with synchronization logic for multi-GPU and multi-node training scenarios. Additionally, the module now explicitly exports a comprehensive set of precision plugins—including \BitsandbytesPrecision\, \TransformerEnginePrecision\, \FSDPPrecision\, and \XLAPrecision\—alongside standard options like \MixedPrecision\ and \HalfPrecision\, centralizing how these configurations are accessed and applied within the PyTorch Lightning Trainer.
src/lightning/pytorch/plugins · high confidence
New precision plugin architecture in PyTorch Lightning
The precision handling in PyTorch Lightning has been reorganized into a new plugin layout under \src/lightning/pytorch/plugins/precision\. This change introduces a unified \Precision\ base class and dedicated plugins for various precision strategies, including \MixedPrecision\ (AMP), \HalfPrecision\, \DoublePrecision\, \FSDPPrecision\, \DeepSpeedPrecision\, \XLAPrecision\, \BitsandbytesPrecision\, and \TransformerEnginePrecision\. Users can now configure these specific precision modes via the \Trainer\'s \precision\ argument, which routes to the appropriate plugin to handle dtype conversion, gradient scaling, and optimizer stepping logic for each strategy.
src/lightning/pytorch/plugins/precision · high confidence
Profiler module relocated to lightning.pytorch.profilers
The profiler implementations (AdvancedProfiler, PyTorchProfiler, SimpleProfiler, XLAProfiler, and PassThroughProfiler) have been moved from the legacy pytorch\_lightning namespace to the new lightning.pytorch.profilers package. Users should update their imports to use the new location, for example: from lightning.pytorch.profilers import PyTorchProfiler.
src/lightning/pytorch/profilers · high confidence
Progress bar logic reorganized into a dedicated module
The progress bar implementation has been restructured into a new \src/lightning/pytorch/callbacks/progress\ package, separating the base \ProgressBar\ class, the default \TQDMProgressBar\, and the \RichProgressBar\ into distinct files. This change consolidates the progress bar code, making it easier to maintain and extend, while preserving the existing functionality for tracking training, validation, and testing progress.
src/lightning/pytorch/callbacks/progress · high confidence
PyTorch Lightning loggers module restructured and LitLogger added
The \src/lightning/pytorch/loggers\ package has been reorganized to expose a unified \\_\init\\_.py\ that imports and exports all available loggers, including the newly added \LitLogger\ for remote experiment tracking on Lightning AI. The \NeptuneLogger\ has been removed and replaced with a deprecated stub that raises a \RuntimeError\ directing users to migrate to \LitLogger\. The module now includes updated implementations for \CometLogger\, \CSVLogger\, \MLFlowLogger\, \TensorBoardLogger\, and \WandbLogger\, along with shared utilities for checkpoint scanning and hyperparameter logging.
src/lightning/pytorch/loggers · high confidence
PyTorch Lightning package structure and metadata reorganization
The \src/pytorch\lightning\ directory has been restructured to support the new \src/\ layout and unified packaging strategy. A new \MANIFEST.in\ ensures that version info, changelogs, READMEs, and requirement files for both PyTorch Lightning and Lightning Fabric are correctly included in the distribution. The package now includes a \py.typed\ marker file to enable PEP 561 type checking support. Metadata files (\\\about\\.py\, \\\version\\.py\, \\\setup\\_.py\) have been updated to reflect the new source root, load version information from \version.info\, and configure the package to include both \pytorch\_lightning\ and \lightning\_fabric\ source code. The setup script now explicitly requires Python 3.10+ and defines classifiers for Python 3.10 through 3.13.
_src/pytorch\lightning · high confidence
Reorganized cluster environment plugins under the new lightning package structure
The cluster environment plugins have been reorganized to align with the new package structure. The \src/lightning/pytorch/plugins/environments/\_\init\\_.py\ file now serves as a central re-export point, importing \ClusterEnvironment\ from \lightning.fabric.plugins\ and exposing specific environment classes (\KubeflowEnvironment\, \LightningEnvironment\, \LSFEnvironment\, \MPIEnvironment\, \SLURMEnvironment\, \TorchElasticEnvironment\, \XLAEnvironment\) from \lightning.fabric.plugins.environments\. This change consolidates the availability of these environment configurations for users migrating to the new \lightning\ namespace.
src/lightning/pytorch/plugins/environments · high confidence
Reorganized distributed training strategies into a new package structure
The distributed training strategies (DDP, DeepSpeed, FSDP, ModelParallel, Parallel, SingleDevice, and XLA) have been reorganized into the new \src/lightning/pytorch/strategies\ package. This change introduces a centralized \\_\init\\_.py\ that registers these strategies with the global strategy registry, making them available for import from \lightning.pytorch.strategies\. The individual strategy files have been updated to import from the new location and register themselves, ensuring that users can continue to use these strategies via the standard Lightning entry points without code changes.
src/lightning/pytorch/strategies · high confidence
Restructure PyTorch Lightning launchers into a dedicated module
The launcher implementations for multiprocessing, subprocess scripts, and XLA have been moved into a new \src/lightning/pytorch/strategies/launchers\ package. This change introduces a base \\_Launcher\ class that extends the Fabric launcher with a \kill\ method for process termination, and exposes the specific launchers (\\_MultiProcessingLauncher\, \\_SubprocessScriptLauncher\, \\XLALauncher\) via a new \\\init\\_.py\. The \\_SubprocessScriptLauncher\ now validates cluster environment settings before spawning child processes, and the \\_XLALauncher\ enforces a restriction against calling \trainer.fit()\ twice on the same instance when using spawn-based strategies.
src/lightning/pytorch/strategies/launchers · high confidence
Restructured and refactored internal training loops and data fetching
The internal loop architecture in \src/lightning/pytorch/loops\ has been reorganized: the \\_\init\\_.py\ now explicitly exports core loop classes (\\_FitLoop\, \\_EvaluationLoop\, \\_PredictionLoop\, \\_TrainingEpochLoop\, and optimization loops), and a new \fetchers.py\ module centralizes data fetching logic with dedicated classes like \\_PrefetchDataFetcher\ and \\_DataLoaderIterDataFetcher\. This refactoring moves data-fetching responsibilities out of the loops themselves, introduces a unified \CombinedLoader\ assumption for fetcher inputs, and adds utilities for selecting the appropriate fetcher based on hook signatures (e.g., \dataloader\_iter\ support). Users benefit from a more modular internal structure that supports flexible data iteration patterns while maintaining backward compatibility with existing training, validation, and prediction workflows.
src/lightning/pytorch/loops · high confidence
Restructured examples with Fabric and Trainer scripts
The examples directory has been reorganized to clearly separate Lightning Fabric and Lightning Trainer use cases. A new README provides navigation to Fabric examples (MNIST, DCGAN) and Trainer examples (Image Classifier, Autoencoder). Additionally, shell scripts (run\_fabric\_examples.sh, run\_pl\_examples.sh) have been added to simplify running these examples with default parameters.
examples · high confidence
Trainer connectors restructured with new default callbacks and signal handling
The \src/lightning/pytorch/trainer/connectors\ module has been reorganized into distinct connector classes (\\_AcceleratorConnector\, \\_CallbackConnector\, \\_CheckpointConnector\, \\_SignalConnector\) to manage specific Trainer configurations. By default, the Trainer now uses \RichProgressBar\ and \RichModelSummary\ when the \rich\ library is available, falling back to \TQDMProgressBar\ and \ModelSummary\ otherwise. A new \LitLogger\ integration is supported, with a tip displayed to users if \litmodels\ is installed but not actively used for model logging. Additionally, signal handling for SLURM auto-requeueing and SIGTERM has been centralized in \\_SignalConnector\ to improve graceful shutdown and job requeuing reliability.
src/lightning/pytorch/trainer/connectors · high confidence
Tuner module relocated to lightning.pytorch.tuner with security and stability fixes
The tuner functionality (LearningRateFinder and BatchSizeFinder) has been moved into the \lightning.pytorch.tuner\ package, exposing the \Tuner\ class for model tuning. This change includes a security fix for the LearningRateFinder to support the \weights\_only\ parameter when restoring checkpoints, and addresses stability issues such as resetting the epoch loop restarting flag and fixing gradient calculation for exponential mode.
src/lightning/pytorch/tuner · high confidence
Fixes
AsyncCheckpointIO snapshots tensors to prevent race conditions
The AsyncCheckpointIO plugin now clones checkpoint tensors before submitting them to the thread pool for asynchronous saving. This snapshotting prevents race conditions where model parameters might be mutated by the training loop while the background thread is still processing the checkpoint data, ensuring data integrity during async checkpointing.
src/lightning/pytorch/plugins/io · high confidence
Test coverage
Added comprehensive test coverage for Rich and TQDM progress bars; Added comprehensive test suite for Fabric precision plugins; Added internal testing utility for conditional test execution; Added model tests for AMP, CPU, GPU, hooks, hparams, ONNX, and TensorRT; Added parity and benchmarking tests for PyTorch integration; Added parity tests for Lightning Fabric against raw PyTorch; Added test coverage for Fabric accelerator implementations; Added test coverage for PyTorch Tuner components; Added test coverage for PyTorch plugins; Added test helper utilities for Fabric; Added test infrastructure for legacy checkpoint compatibility; Added test script for LightningCLI integration; Added test suite for PyTorch Lightning loops; Added test suite for PyTorch Trainer configuration and validation; Added test suite for PyTorch core components; Added test suite for Trainer connectors; Added tests for Fabric CSV and TensorBoard loggers; Added tests for Fabric cluster environment plugins; Added tests for Fabric multiprocessing and subprocess launchers; Added tests for LSTM and Transformer demo utilities; Added tests for PyTorch Lightning utilities; Added tests for PyTorch accelerator implementations; Added tests for PyTorch checkpoint migration utilities; Added tests for PyTorch distributed overrides; Added tests for PyTorch multiprocessing and subprocess script launchers; Added tests for RunIf utility; Added tests for ServableModuleValidator callback; Added tests for Trainer flag configurations; Added tests for Trainer properties; Added tests for deprecated and removed PyTorch Lightning components; Added tests for deprecated precision plugins and API behaviors; Added tests for trainer logging behavior; Added tests for trainer optimization and dynamic arguments; Fabric test suite reorganization and isolation improvements; New PyTorch test suite structure and fixtures; New test helper utilities and fixtures for PyTorch Lightning; New test suite for Fabric distributed strategies; New test suite for PyTorch Lightning strategies; New test suite for PyTorch loggers; New testing utilities for conditional test skipping.
Dependencies
Introduce pyproject.toml and structured requirements files
The project now uses a centralized pyproject.toml for build configuration and tooling settings (including Ruff, mypy, and pytest), replacing ad-hoc configurations. Dependency management is restructured into a modular system: the root requirements.txt now aggregates base requirements from ./requirements/fabric/base.txt and ./requirements/pytorch/base.txt, while specific examples (such as FP8 distributed transformers and reinforcement learning) have their own dedicated requirements.txt files to isolate their dependencies.
(dependencies) · high confidence
PyTorch Lightning 2.6+ dependency requirements updated
The PyTorch Lightning package now requires PyTorch \>=2.6.0 and updates its core dependencies to ensure compatibility with the latest versions. Key changes include upgrading tqdm to \<4.68.0, fsspec\[http\] to \<2026.4.0, torchmetrics to \<1.9.0, and lightning-utilities to \<0.16.0. For users enabling extra features, matplotlib is updated to \<3.11.0, hydra-core to \<1.4.0, and jsonargparse to \<4.51.0. DeepSpeed support is restricted to version 0.16.x for non-Windows/Darwin platforms, and bitsandbytes is pinned to \>=0.45.2,\<0.50.0 (excluding macOS). Test dependencies have also been refreshed, with pytest bumped to 9.0.2 and coverage to 7.13.5/7.10.7 depending on Python version.
requirements/pytorch · high confidence
Reorganized requirements into focused sub-folders with updated dependency versions
The project requirements have been restructured from a flat structure into a \requirements/\ folder containing specific files for different build contexts: \ci.txt\ for continuous integration, \docs.txt\ for documentation generation, \doctests.txt\ for running doctests, and \typing.txt\ for type checking. This change introduces updated version constraints for key dependencies, including upgrading PyTorch to 2.9.1, Mypy to 1.20.0, and pytest to 9.0.2, while also adding new tools like \lai-sphinx-theme\ for documentation and \pkginfo\ for CI. A new \collect\_env\_details.py\ script is included to help users diagnose system and package configurations for bug reporting.
requirements · high confidence
Housekeeping
Updated development version to 2.7.0.dev
The project's version identifier has been updated to 2.7.0.dev, signaling the start of the development cycle for the upcoming 2.7.0 release.
src · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 47 → 47 (+0.3)
- Rubric changed (rubric-2026.11.2 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 70 → 68 (-1.8)
- Architecture 90 → 90 (+0.7)
- Maturity 59 → 62 (+2.9)
- Readiness 59 → 59 (+0.0)
- Security 29 → 29 (+0.0)
Resolved (11)
- Duplicated block (10–11 lines × 2) (examples/fabric/reinforcement_learning/rl/utils.py)
- Duplicated block (11 lines × 2) (examples/fabric/reinforcement_learning/rl/utils.py)
- Duplicated block (13–20 lines × 2) (examples/fabric/reinforcement_learning/rl/utils.py)
- Duplicated block (18 lines × 2) (examples/fabric/tensor_parallel/model.py)
- Duplicated block (6 lines × 2) (examples/fabric/dcgan/train_fabric.py)
- Duplicated block (6 lines × 3) (src/lightning/fabric/_graveyard/tpu.py)
- Edited copy of a member (10 corresponding lines) (examples/fabric/tensor_parallel/model.py)
- Most significant orphaned file (src/lightning/fabric/connector.py)
- Most significant orphaned file (src/lightning/pytorch/loops/training_epoch_loop.py)
- Off-boarding risk: anonymized user #1
- Projects may be oversized for their cohesion
New (104)
- Edited copies of one member (3 members, 12+ corresponding lines) (src/lightning/fabric/strategies/ddp.py)
- Edited copies of one member (3 members, 16+ corresponding lines) (src/lightning/pytorch/strategies/deepspeed.py)
- Edited copies of one member (3 members, 17+ corresponding lines) (src/lightning/pytorch/loggers/wandb.py)
- Edited copies of one member (3 members, 18+ corresponding lines) (src/lightning/fabric/loggers/csv_logs.py)
- Edited copies of one member (3 members, 60+ corresponding lines) (src/lightning/pytorch/trainer/trainer.py)
- Edited copies of one member (3 members, 61+ corresponding lines) (src/lightning/setup.py)
- Edited copies of one member (4 members, 11+ corresponding lines) (src/lightning/pytorch/strategies/strategy.py)
- Edited copies of one member (4 members, 3+ corresponding lines) (src/lightning/fabric/strategies/fsdp.py)
- Edited copies of one member (4 members, 31+ corresponding lines) (src/lightning/pytorch/trainer/trainer.py)
- Edited copy of a member (1 corresponding lines) (src/lightning/pytorch/utilities/model_summary/model_summary.py)
- Edited copy of a member (10 corresponding lines) (examples/pytorch/domain_templates/computer_vision_fine_tuning.py)
- Edited copy of a member (10 corresponding lines) (src/lightning/pytorch/callbacks/model_checkpoint.py)
- Edited copy of a member (10 corresponding lines) (src/lightning/pytorch/strategies/xla.py)
- Edited copy of a member (11 corresponding lines) (src/lightning/pytorch/callbacks/weight_averaging.py)
- Edited copy of a member (12 corresponding lines) (src/lightning/fabric/strategies/deepspeed.py)
- Edited copy of a member (12 corresponding lines) (src/lightning/fabric/strategies/launchers/multiprocessing.py)
- Edited copy of a member (13 corresponding lines) (src/lightning/fabric/loggers/tensorboard.py)
- Edited copy of a member (13 corresponding lines) (src/lightning/fabric/plugins/precision/amp.py)
- Edited copy of a member (13 corresponding lines) (src/lightning/fabric/strategies/strategy.py)
- Edited copy of a member (14 corresponding lines) (src/lightning/fabric/strategies/fsdp.py)
- …and 84 more
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
Lightning-AI/pytorch-lightning was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 15 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 84df182f50ab34301aabb3c0eb4031815bfb413d — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.73+preprod-52de90b74216.