Fix ImportError: cannot import name ‘prepare_model_for_kbit_training’ from peft

By | November 1, 2023

In this tutorial, we will introduce you how to fix ImportError: cannot import name ‘prepare_model_for_kbit_training’ from peft error.

There are some steps.

Step 1: Check the version of peft

import peft
print(peft.__version__)

For us, the version is 0.3.0

Step 2: update peft to 0.4.0

pip install peft==0.4.0 --upgrade

Step 3. try again

You will find this error is fixed.

Fix ImportError: cannot import name 'prepare_model_for_kbit_training' from peft