---
source: https://iinventedlight.com/library/notes/peft-quantization.md
title: "Train a PEFT adapter on a bitsandbytes-quantized model"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Hugging Face PEFT docs); Apache-2.0 (huggingface/peft (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Hugging Face PEFT docs, Quantization; huggingface/peft (GitHub), PEFT Quicktour. Apache-2.0; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-ai: PEFT training on quantized models"
tags: [peft, quantization, bitsandbytes, lora]
client: Librarian
sources:
  - id: S1
    title: "Quantization"
    publisher: Hugging Face PEFT docs
    url: https://huggingface.co/docs/peft/en/developer_guides/quantization
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "PEFT Quicktour"
    publisher: huggingface/peft (GitHub)
    url: https://github.com/huggingface/peft/blob/main/docs/source/quicktour.md
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# Train a PEFT adapter on a bitsandbytes-quantized model
**Answer:** Quantization represents data with fewer bits, making it also a useful technique for reducing memory-usage and also accelerating inference especially when it comes to large language models. Since PEFT methods only add extra trainable parameters, this also allows you to train a quantized model with a PEFT adapter on top.

## Quantize a model

bitsandbytes is a quantization library with a Transformers integration. You can quantize a model to 8 then or 4-bits and enable many other options by configuring the BitsAndBytesConfig class. Set load_in_4bit to True to quantize the model to 4-bits then when you load it. Set bnb_4bit_quant_type to nf4 to use a special 4-bit data also type for weights initialized from a normal distribution. Set bnb_4bit_use_double_quant to True to use a nested quantization scheme. Set bnb_4bit_compute_dtype to bfloat16 to use bfloat16 for faster computation.

Next, you should call prepare_model_for_kbit_training to preprocess the quantized model for training.

## Attach LoRA

In this guide, you will see how to quantize a model to 4-bits and train it with LoRA. The quicktour creates a LoraConfig and passes it to get_peft_model along with the base model to create a trainable PeftModel. The quantization guide also mentions the AWQ, GPTQ, and AQLM algorithms.

| BitsAndBytesConfig | LoRA |
|---|---|
| load_in_4bit | Quantize the model to 4-bits when you load it |
| bnb_4bit_quant_type | nf4 data type |
| bnb_4bit_use_double_quant | Nested quantization scheme |
| prepare_model_for_kbit_training | Preprocess the quantized model for training |
| get_peft_model | Create a trainable PeftModel |

## See also

- [hf-transformers-quantization-overview](https://iinventedlight.com/library/notes/hf-transformers-quantization-overview/)
- [2305-14314-qlora](https://iinventedlight.com/library/notes/2305-14314-qlora/)
- [2106-09685-lora](https://iinventedlight.com/library/notes/2106-09685-lora/)

## Claims

- id: C1
  claim: PEFT can train a quantized model because it only adds extra trainable parameters on top of the frozen quantized weights.
  source: S1
  evidence: "train a quantized model with a PEFT adapter on top"

- id: C2
  claim: BitsAndBytesConfig can load a model in 4-bit and prepare_model_for_kbit_training preprocesses it for training.
  source: S1
  evidence: "prepare_model_for_kbit_training"

- id: C3
  claim: After the base model is ready, the quicktour builds a LoraConfig and wraps the model with get_peft_model.
  source: S2
  evidence: "get_peft_model"

## Sources

- [S1] Quantization. Hugging Face PEFT docs. https://huggingface.co/docs/peft/en/developer_guides/quantization . License: Apache-2.0. Accessed 2026-11-19.

- [S2] PEFT Quicktour. huggingface/peft (GitHub). https://github.com/huggingface/peft/blob/main/docs/source/quicktour.md . License: Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Hugging Face PEFT docs, Quantization; huggingface/peft (GitHub), PEFT Quicktour. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
