Skip to content

Commit b4c9e23

Browse files
authored
fix galore and peft finetune example (#12776)
1 parent c0d6b28 commit b4c9e23

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

python/llm/example/GPU/LLM-Finetuning/GaLore/README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ conda activate llm
1313
# below command will install intel_extension_for_pytorch==2.1.10+xpu as default
1414
pip install --pre --upgrade ipex-llm[xpu] --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
1515
pip install galore-torch
16-
pip install accelerate==0.28.0
17-
pip install bitsandbytes==0.43.0
18-
pip install datasets==2.18.0
19-
pip install transformers==4.39.1
20-
pip install trl==0.8.1
16+
pip install transformers==4.45.0 "trl<0.12.0" datasets
17+
pip install bitsandbytes==0.45.1
2118
```
2219

2320
### 2. GaLore Finetune

python/llm/example/GPU/LLM-Finetuning/HF-PEFT/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ conda create -n llm python=3.11
1414
conda activate llm
1515
# below command will install intel_extension_for_pytorch==2.1.10+xpu as default
1616
pip install --pre --upgrade ipex-llm[xpu] --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
17-
pip install transformers==4.36.0 datasets
17+
pip install transformers==4.45.0 "trl<0.12.0" datasets
18+
pip install bitsandbytes==0.45.1 scipy
1819
pip install fire peft==0.10.0
1920
pip install oneccl_bind_pt==2.1.100 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ # necessary to run distributed finetuning
20-
pip install bitsandbytes scipy
2121
```
2222

2323
### 2. Configures OneAPI environment variables

python/llm/example/GPU/LLM-Finetuning/HF-PEFT/alpaca-lora/finetune.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
LoraConfig,
5454
get_peft_model,
5555
get_peft_model_state_dict,
56-
prepare_model_for_int8_training,
56+
prepare_model_for_kbit_training,
5757
set_peft_model_state_dict,
5858
)
59-
from transformers import LlamaForCausalLM, LlamaTokenizer
59+
from transformers import AutoModelForCausalLM, AutoTokenizer
6060

6161
from utils.prompter import Prompter
6262

@@ -145,14 +145,14 @@ def train(
145145
if len(wandb_log_model) > 0:
146146
os.environ["WANDB_LOG_MODEL"] = wandb_log_model
147147

148-
model = LlamaForCausalLM.from_pretrained(
148+
model = AutoModelForCausalLM.from_pretrained(
149149
base_model,
150-
load_in_8bit=True,
150+
load_in_4bit=True,
151151
torch_dtype=torch.float16,
152152
device_map=device_map,
153153
)
154154

155-
tokenizer = LlamaTokenizer.from_pretrained(base_model)
155+
tokenizer = AutoTokenizer.from_pretrained(base_model)
156156

157157
tokenizer.pad_token_id = (
158158
0 # unk. we want this to be different from the eos token
@@ -207,7 +207,7 @@ def generate_and_tokenize_prompt(data_point):
207207
] # could be sped up, probably
208208
return tokenized_full_prompt
209209

210-
model = prepare_model_for_int8_training(model)
210+
model = prepare_model_for_kbit_training(model)
211211

212212
config = LoraConfig(
213213
r=lora_r,

0 commit comments

Comments
 (0)