hamel commited on
Commit
8b12468
1 Parent(s): 0976781

Add QLoRA + FSDP Docs (#1403)

Browse files

* pre commit

* Update fsdp_qlora.md

Files changed (2) hide show
  1. README.md +4 -0
  2. docs/fsdp_qlora.md +37 -0
README.md CHANGED
@@ -1080,6 +1080,10 @@ fsdp_config:
1080
  fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer
1081
  ```
1082
 
 
 
 
 
1083
  ##### Weights & Biases Logging
1084
 
1085
  Make sure your `WANDB_API_KEY` environment variable is set (recommended) or you login to wandb with `wandb login`.
 
1080
  fsdp_transformer_layer_cls_to_wrap: LlamaDecoderLayer
1081
  ```
1082
 
1083
+ ##### FSDP + QLoRA
1084
+
1085
+ Axolotl supports training with FSDP and QLoRA, see [these docs](docs/fsdp_qlora.md) for more information.
1086
+
1087
  ##### Weights & Biases Logging
1088
 
1089
  Make sure your `WANDB_API_KEY` environment variable is set (recommended) or you login to wandb with `wandb login`.
docs/fsdp_qlora.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FDSP + QLoRA
2
+
3
+ ## Background
4
+
5
+ Using FSDP with QLoRA is essential for **fine-tuning larger (70b+ parameter) LLMs on consumer GPUs.** For example, you can use FSDP + QLoRA to train a 70b model on two 24GB GPUs[^1].
6
+
7
+ Below, we describe how to use this feature in Axolotl.
8
+
9
+ ## Usage
10
+
11
+ To enable `QLoRA` with `FSDP`, you need to perform the following steps:
12
+
13
+ > ![Tip]
14
+ > See the [example config](#example-config) file in addition to reading these instructions.
15
+
16
+ 1. Set `adapter: qlora` in your axolotl config file.
17
+ 2. Enable FSDP in your axolotl config, as [described here](https://github.com/OpenAccess-AI-Collective/axolotl?tab=readme-ov-file#fsdp).
18
+ 3. Use one of the supported model types: `llama`, `mistral` or `mixtral`.
19
+
20
+ ## Example Config
21
+
22
+ [examples/llama-2/qlora-fsdp.yml](../examples/llama-2/qlora-fsdp.yml) contains an example of how to enable QLoRA + FSDP in axolotl.
23
+
24
+ ## References
25
+
26
+ - [PR #1378](https://github.com/OpenAccess-AI-Collective/axolotl/pull/1378) enabling QLoRA in FSDP in Axolotl.
27
+ - [Blog Post](https://www.answer.ai/posts/2024-03-06-fsdp-qlora.html) from the [Answer.AI](https://www.answer.ai/) team describing the work that enabled QLoRA in FSDP.
28
+ - Related HuggingFace PRs Enabling FDSP + QLoRA:
29
+ - Accelerate [PR#2544](https://github.com/huggingface/accelerate/pull/2544 )
30
+ - Transformers [PR#29587](https://github.com/huggingface/transformers/pull/29587)
31
+ - TRL [PR#1416](https://github.com/huggingface/trl/pull/1416)
32
+ - PEFT [PR#1550](https://github.com/huggingface/peft/pull/1550)
33
+
34
+
35
+
36
+
37
+ [^1]: This was enabled by [this work](https://www.answer.ai/posts/2024-03-06-fsdp-qlora.html) from the Answer.AI team.