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
|
|
|
|
|
2021-04-14 20:53:21 +00:00
|
|
|
Plugins allow custom integrations to the internals of the Trainer such as a custom precision or
|
|
|
|
distributed 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
|
|
|
|
depending on the provided Trainer arguments. For example:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
# accelerator: GPUAccelerator
|
2021-12-22 20:23:30 +00:00
|
|
|
# training strategy: DDPStrategy
|
2021-04-14 20:53:21 +00:00
|
|
|
# precision: NativeMixedPrecisionPlugin
|
2022-03-23 19:52:12 +00:00
|
|
|
trainer = Trainer(accelerator="gpu", devices=4, precision=16)
|
2021-04-14 20:53:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
We expose Accelerators and Plugins mainly for expert users that want to extend Lightning for:
|
|
|
|
|
|
|
|
- New hardware (like TPU plugin)
|
|
|
|
- Distributed backends (e.g. a backend not yet supported by
|
|
|
|
`PyTorch <https://pytorch.org/docs/stable/distributed.html#backends>`_ itself)
|
|
|
|
- Clusters (e.g. customized access to the cluster's environment interface)
|
|
|
|
|
|
|
|
There are two types of Plugins in Lightning with different responsibilities:
|
|
|
|
|
2021-12-20 12:50:11 +00:00
|
|
|
Strategy
|
|
|
|
--------
|
2021-04-14 20:53:21 +00:00
|
|
|
|
|
|
|
- Launching and teardown of training processes (if applicable)
|
|
|
|
- Setup communication between processes (NCCL, GLOO, MPI, ...)
|
|
|
|
- Provide a unified communication interface for reduction, broadcast, etc.
|
|
|
|
- Provide access to the wrapped LightningModule
|
|
|
|
|
|
|
|
|
2022-02-17 01:27:51 +00:00
|
|
|
Furthermore, for multi-node training Lightning provides cluster environment plugins that allow the advanced user
|
2021-11-29 20:38:23 +00:00
|
|
|
to configure Lightning to integrate with a :ref:`custom-cluster`.
|
2021-04-21 23:38:16 +00:00
|
|
|
|
|
|
|
|
2021-04-14 20:53:21 +00:00
|
|
|
.. image:: ../_static/images/accelerator/overview.svg
|
|
|
|
|
|
|
|
|
|
|
|
The full list of built-in plugins is listed below.
|
|
|
|
|
|
|
|
|
|
|
|
.. warning:: The Plugin API is in beta and subject to change.
|
|
|
|
For help setting up custom plugins/accelerators, please reach out to us at **support@pytorchlightning.ai**
|
|
|
|
|
|
|
|
|
|
|
|
Precision Plugins
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
.. 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
|
|
|
|
|
|
|
|
|
|
|
Cluster Environments
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
.. currentmodule:: pytorch_lightning.plugins.environments
|
|
|
|
|
|
|
|
.. autosummary::
|
|
|
|
:nosignatures:
|
|
|
|
:template: classtemplate.rst
|
|
|
|
|
|
|
|
ClusterEnvironment
|
|
|
|
LightningEnvironment
|
2021-07-09 14:14:26 +00:00
|
|
|
LSFEnvironment
|
2021-04-14 20:53:21 +00:00
|
|
|
TorchElasticEnvironment
|
2021-05-17 08:05:24 +00:00
|
|
|
KubeflowEnvironment
|
2021-04-14 20:53:21 +00:00
|
|
|
SLURMEnvironment
|