Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,59 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
|
5 |
+
[Optimum Habana](https://github.com/huggingface/optimum-habana) is the interface between the Hugging Face Transformers and Diffusers libraries and Habana's Gaudi processor (HPU).
|
6 |
+
It provides a set of tools enabling easy and fast model loading, training and inference on single- and multi-HPU settings for different downstream tasks.
|
7 |
+
Learn more about how to take advantage of the power of Habana HPUs to train and deploy Transformers and Diffusers models at [hf.co/hardware/habana](https://huggingface.co/hardware/habana).
|
8 |
+
|
9 |
+
## Llama model HPU configuration
|
10 |
+
|
11 |
+
This model only contains the `GaudiConfig` file for running [Llama models](https://huggingface.co/meta-llama) on Habana's Gaudi processors (HPU).
|
12 |
+
|
13 |
+
**This model contains no model weights, only a GaudiConfig.**
|
14 |
+
|
15 |
+
This enables to specify:
|
16 |
+
- `use_fused_adam`: whether to use Habana's custom AdamW implementation
|
17 |
+
- `use_fused_clip_norm`: whether to use Habana's fused gradient norm clipping operator
|
18 |
+
- `use_torch_autocast`: whether to use PyTorch's autocast mixed precision
|
19 |
+
|
20 |
+
## Usage
|
21 |
+
|
22 |
+
The model is instantiated the same way as in the Transformers library.
|
23 |
+
The only difference is that there are a few new training arguments specific to HPUs.
|
24 |
+
|
25 |
+
[Here](https://github.com/huggingface/optimum-habana/blob/main/examples/language-modeling/run_clm.py) is a causal language modeling example script to pre-train/fine-tune a model. You can run it with Llama with the following command:
|
26 |
+
```bash
|
27 |
+
python3 run_lora_clm.py \
|
28 |
+
--model_name_or_path huggyllama/llama-7b \
|
29 |
+
--dataset_name tatsu-lab/alpaca \
|
30 |
+
--bf16 True \
|
31 |
+
--output_dir ./model_lora_llama \
|
32 |
+
--num_train_epochs 3 \
|
33 |
+
--per_device_train_batch_size 16 \
|
34 |
+
--evaluation_strategy "no" \
|
35 |
+
--save_strategy "no" \
|
36 |
+
--learning_rate 1e-4 \
|
37 |
+
--warmup_ratio 0.03 \
|
38 |
+
--lr_scheduler_type "constant" \
|
39 |
+
--max_grad_norm 0.3 \
|
40 |
+
--logging_steps 1 \
|
41 |
+
--do_train \
|
42 |
+
--do_eval \
|
43 |
+
--use_habana \
|
44 |
+
--use_lazy_mode \
|
45 |
+
--throughput_warmup_steps 3 \
|
46 |
+
--lora_rank=8 \
|
47 |
+
--lora_alpha=16 \
|
48 |
+
--lora_dropout=0.05 \
|
49 |
+
--lora_target_modules "q_proj" "v_proj" \
|
50 |
+
--dataset_concatenation \
|
51 |
+
--max_seq_length 512 \
|
52 |
+
--low_cpu_mem_usage True \
|
53 |
+
--validation_split_percentage 4 \
|
54 |
+
--adam_epsilon 1e-08
|
55 |
+
```
|
56 |
+
|
57 |
+
You will need to install the [PEFT](https://huggingface.co/docs/peft/index) library with `pip install peft` to run the command above.
|
58 |
+
|
59 |
+
Check the [documentation](https://huggingface.co/docs/optimum/habana/index) out for more advanced usage and examples.
|