---
title: BitsandbytesPrecision
description: Plugin for quantizing weights with bitsandbytes.
canonical: >-
  https://lightning.ai/docs/pytorch/stable/optional-api/api/lightning.pytorch.plugins.precision.BitsandbytesPrecision
---
# BitsandbytesPrecision {#bitsandbytesprecision}

### `class lightning.pytorch.plugins.precision.BitsandbytesPrecision(mode, dtype=None, ignore_modules=None)` {#lightning.pytorch.plugins.precision.BitsandbytesPrecision}

Bases: [`Precision`](/docs/pytorch/2.6.6/optional-api/api/lightning.pytorch.plugins.precision.Precision.md#lightning.pytorch.plugins.precision.Precision "lightning.pytorch.plugins.precision.precision.Precision"), [`BitsandbytesPrecision`](/docs/fabric/stable/api/generated/lightning.fabric.plugins.precision.BitsandbytesPrecision#lightning.fabric.plugins.precision.BitsandbytesPrecision "(in lightning v2.7.0.dev)")

Plugin for quantizing weights with [bitsandbytes](https://github.com/bitsandbytes-foundation/bitsandbytes).

Warning

This is an [experimental](/docs/pytorch/2.6.6/reference/versioning.md#experimental-api) feature.

Note

The optimizer is not automatically replaced with `bitsandbytes.optim.Adam8bit` or equivalent 8-bit optimizers.

Parameters:

*   **mode** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'nf4'`, `'nf4-dq'`, `'fp4'`, `'fp4-dq'`, `'int8'`, `'int8-training'`\]) – The quantization mode to use.
    
*   **dtype** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`dtype`](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.dtype "(in PyTorch v2.15)")\]) – The compute dtype to use.
    
*   **ignore\_modules** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`set`](https://docs.python.org/3/builtins/stdtypes.html#set "(in Python v3.15)")\[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str "(in Python v3.15)")\]\]) – The submodules whose Linear layers should not be replaced, for example. `{"lm_head"}`. This might be desirable for numerical stability. The string will be checked in as a prefix, so a value like “transformer.blocks” will ignore all linear layers in all of the transformer blocks.

---

**Navigation**

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