Skip to content

Commit 46d8300

Browse files
authored
bugfix for qlora finetuning on GPU (#12298)
* bugfix for qlora 100 step error * indent fix * annotation fix
1 parent 70037ad commit 46d8300

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

python/llm/example/GPU/LLM-Finetuning/QLoRA/alpaca-qlora/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pip install bitsandbytes scipy
2323
source /opt/intel/oneapi/setvars.sh # necessary to run before installing deepspeed
2424
pip install git+https://github.com/microsoft/DeepSpeed.git@78c518e
2525
pip install git+https://github.com/intel/intel-extension-for-deepspeed.git@ec33277
26+
# (optional) install mpirun to run multi-card finetuning
27+
sudo apt install openmpi-bin
2628
```
2729

2830
### 2. Configures OneAPI environment variables

python/llm/src/ipex_llm/transformers/low_bit_linear.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,12 @@ def forward(self, x: torch.Tensor):
794794
self.weight.qtype, input_seq_size)
795795
result = result.to(x.dtype)
796796
else:
797-
result = xe_linear.forward_new(x_2d, self.weight.data,
798-
self.weight.qtype, input_seq_size)
797+
if self.weight.qtype == NF4:
798+
result = xe_linear.forward_new(x_2d, self.weight.data.view(torch.uint8),
799+
self.weight.qtype, input_seq_size)
800+
else:
801+
result = xe_linear.forward_new(x_2d, self.weight.data,
802+
self.weight.qtype, input_seq_size)
799803

800804
if do_empty_cache:
801805
torch.xpu.empty_cache()

0 commit comments

Comments
 (0)