---
title: LayerSync
description: >-
  Abstract base class for creating plugins that wrap layers of a model with
  synchronization logic for

  multiprocessing.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.plugins.LayerSync
---
# LayerSync {#layersync}

### `class lightning.pytorch.plugins.LayerSync` {#lightning.pytorch.plugins.LayerSync}

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC "(in Python v3.15)")

Abstract base class for creating plugins that wrap layers of a model with synchronization logic for multiprocessing.

#### `abstract apply(model)` {#lightning.pytorch.plugins.LayerSync.apply}

Override this method to apply synchronization to the layers of this model.

Return type:

[`Module`](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module "(in PyTorch v2.15)")

#### `abstract revert(model)` {#lightning.pytorch.plugins.LayerSync.revert}

Override this method to undo all modifications made in [`apply()`](#lightning.pytorch.plugins.LayerSync.apply "lightning.pytorch.plugins.LayerSync.apply").

Return type:

[`Module`](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module "(in PyTorch v2.15)")

---

**Navigation**

- Parent: [Api](/docs/pytorch/2.6.6/optional-api/api.md)
