2021-04-10 06:55:07 +00:00
.. _plugins:
2020-10-22 09:15:51 +00:00
#######
Plugins
#######
2021-09-06 12:49:09 +00:00
.. include :: ../links.rst
2022-03-29 12:09:41 +00:00
Plugins allow custom integrations to the internals of the Trainer such as custom precision, checkpointing or
cluster environment implementation.
2020-10-22 09:15:51 +00:00
2021-04-14 20:53:21 +00:00
Under the hood, the Lightning Trainer is using plugins in the training routine, added automatically
2022-03-29 12:09:41 +00:00
depending on the provided Trainer arguments.
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
There are three types of Plugins in Lightning with different responsibilities:
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
- Precision Plugins
- CheckpointIO Plugins
- Cluster Environments
2021-04-14 20:53:21 +00:00
2022-04-05 18:39:35 +00:00
You can make the Trainer use one or multiple plugins by adding it to the `` plugins `` argument like so:
.. code-block :: python
trainer = Trainer(plugins=[plugin1, plugin2, ...])
By default, the plugins get selected based on the rest of the Trainer settings such as the `` strategy `` .
-----------
2022-04-19 18:15:47 +00:00
.. _precision-plugins:
2021-04-21 23:38:16 +00:00
2022-03-29 12:09:41 +00:00
***** ***** ***** **
Precision Plugins
***** ***** ***** **
2021-04-21 23:38:16 +00:00
2022-03-29 12:09:41 +00:00
We provide precision plugins for you to benefit from numerical representations with lower precision than
32-bit floating-point or higher precision, such as 64-bit floating-point.
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
.. code-block :: python
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
# Training with 16-bit precision
trainer = Trainer(precision=16)
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
The full list of built-in precision plugins is listed below.
2021-04-14 20:53:21 +00:00
.. currentmodule :: pytorch_lightning.plugins.precision
.. autosummary ::
:nosignatures:
:template: classtemplate.rst
ApexMixedPrecisionPlugin
DeepSpeedPrecisionPlugin
DoublePrecisionPlugin
2021-10-19 17:48:57 +00:00
FullyShardedNativeMixedPrecisionPlugin
2022-03-25 10:24:52 +00:00
HPUPrecisionPlugin
2021-10-19 17:48:57 +00:00
IPUPrecisionPlugin
2022-03-25 10:24:52 +00:00
MixedPrecisionPlugin
NativeMixedPrecisionPlugin
PrecisionPlugin
ShardedNativeMixedPrecisionPlugin
TPUBf16PrecisionPlugin
TPUPrecisionPlugin
2021-04-14 20:53:21 +00:00
2022-04-19 18:15:47 +00:00
More information regarding precision with Lightning can be found :ref: `here <precision>`
2022-03-29 12:09:41 +00:00
-----------
2022-04-05 18:39:35 +00:00
.. _checkpoint_io_plugins:
2022-03-29 12:09:41 +00:00
***** ***** ***** *****
CheckpointIO Plugins
***** ***** ***** *****
2021-04-14 20:53:21 +00:00
2022-03-29 12:09:41 +00:00
As part of our commitment to extensibility, we have abstracted Lightning's checkpointing logic into the :class: `~pytorch_lightning.plugins.io.CheckpointIO` plugin.
With this, you have the ability to customize the checkpointing logic to match the needs of your infrastructure.
Below is a list of built-in plugins for checkpointing.
.. currentmodule :: pytorch_lightning.plugins.io
.. autosummary ::
:nosignatures:
:template: classtemplate.rst
CheckpointIO
HPUCheckpointIO
TorchCheckpointIO
XLACheckpointIO
2022-04-19 18:15:47 +00:00
Learn more about custom checkpointing with Lightning :ref: `here <checkpointing_expert>` .
2022-03-29 12:09:41 +00:00
-----------
2022-04-05 18:39:35 +00:00
.. _cluster_environment_plugins:
2022-03-29 12:09:41 +00:00
***** ***** ***** *****
2021-04-14 20:53:21 +00:00
Cluster Environments
2022-03-29 12:09:41 +00:00
***** ***** ***** *****
You can define the interface of your own cluster environment based on the requirements of your infrastructure.
2021-04-14 20:53:21 +00:00
.. currentmodule :: pytorch_lightning.plugins.environments
.. autosummary ::
:nosignatures:
:template: classtemplate.rst
ClusterEnvironment
2022-03-29 12:09:41 +00:00
KubeflowEnvironment
2021-04-14 20:53:21 +00:00
LightningEnvironment
2021-07-09 14:14:26 +00:00
LSFEnvironment
2021-04-14 20:53:21 +00:00
SLURMEnvironment
2022-03-29 12:09:41 +00:00
TorchElasticEnvironment
2022-06-22 08:57:50 +00:00
XLAEnvironment