---
title: DeepSpeedPrecision
description: Precision plugin for DeepSpeed integration.
canonical: >-
  https://lightning.ai/docs/fabric/stable/full-api-reference/api/generated/lightning.fabric.plugins.precision.DeepSpeedPrecision
---
# DeepSpeedPrecision {#deepspeedprecision}

### `class lightning.fabric.plugins.precision.DeepSpeedPrecision(precision)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision}

Bases: [`Precision`](/docs/fabric/2.6.6/full-api-reference/api/generated/lightning.fabric.plugins.precision.Precision.md#lightning.fabric.plugins.precision.Precision "lightning.fabric.plugins.precision.precision.Precision")

Precision plugin for DeepSpeed integration.

Parameters:

**precision** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'32-true'`, `'16-true'`, `'bf16-true'`, `'16-mixed'`, `'bf16-mixed'`\]) – Full precision (32-true), half precision (16-true, bf16-true) or mixed precision (16-mixed, bf16-mixed).

Raises:

[**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If unsupported `precision` is provided.

#### `backward(tensor, model, *args, **kwargs)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.backward}

Performs back-propagation using DeepSpeed’s engine.

Return type:

[`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")

#### `convert_input(data)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.convert_input}

Convert model inputs (forward) to the floating point precision type of this plugin.

This is a no-op in the base precision plugin, since we assume the data already has the desired type (default is torch.float32).

Return type:

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

#### `convert_module(module)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.convert_module}

Convert the module parameters to the precision type this plugin handles.

This is optional and depends on the precision limitations during optimization.

Return type:

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

#### `convert_output(data)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.convert_output}

Convert outputs to the floating point precision type expected after model’s forward.

This is a no-op in the base precision plugin, since we assume the data already has the desired type (default is torch.float32).

Return type:

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

#### `module_init_context()` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.module_init_context}

Instantiate module parameters or tensors in the precision type this plugin handles.

This is optional and depends on the precision limitations during optimization.

Return type:

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

#### `optimizer_step(optimizer, **kwargs)` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.optimizer_step}

Hook to run the optimizer step.

Return type:

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

#### `tensor_init_context()` {#lightning.fabric.plugins.precision.DeepSpeedPrecision.tensor_init_context}

Controls how tensors get created (device, dtype).

Return type:

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

---

**Navigation**

- Parent: [Generated](/docs/fabric/2.6.6/full-api-reference/api/generated.md)
