A model loaded in 4-bit cannot compute gradients directly through its weights. Prepare it with PEFT’s `prepare_model_for_kbit_training` before QLoRA adapter training; the base model stays frozen while adapters train. section 7.3.3
Listing 7.9 Preparing the quantized model to receive gradients
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training model = prepare_model_for_kbit_training(model)
See the PEFT call used to prepare a quantized model for gradient-based training. section 7.3.3

