A 4-bit model’s weights do not support direct gradient computation. Applying prepare_model_for_kbit_training enables gradients so the model can learn; the workflow then adds LoRA adapters for parameter-efficient training. 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)
The PEFT call used to prepare the quantized model before configuring LoRA. section 7.3.3
