Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c2690f4

Browse files
committed
Update readme for falcon-llm
1 parent 83d1e44 commit c2690f4

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

falcon-llm/README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Fine-tuning Falcon LLM 7B/40B
22

3+
Running state-of-the-art language models (LLMs) on a single GPU with [LoRA](https://arxiv.org/abs/2106.09685) and [quantization](https://github.com/TimDettmers/bitsandbytes) is extremely impressive. This is especially true with the recent emergence of commercially viable models like [Faclon](https://falconllm.tii.ae/) and [MPT](https://www.mosaicml.com/blog/mpt-30b). For instance, you can perform inference using the Falcon 40B model in 4-bit mode with approximately 27 GB of GPU RAM, making a single A100 or A6000 GPU sufficient. Additionally, you can fine-tune the same model using PEFT (Parameter-Efficient Fine-Tuning) in 4-bit mode with around 62 GB of GPU RAM, requiring a single A100 80GB card.
34

4-
Running SOTA LLMs on a single GPU with LoRA and quantization is super cool. But don't forget the good old data parallelism!
5+
The ability to fine-tune these models on a single GPU allows us to employ traditional data parallelism and linearly scale training throughput with more GPUs. This blog post provides instructions on how to achieve that on Lambda Cloud. The same instructions can be applied to multi-GPU Linux workstations or servers, assuming they have the latest NVIDIA driver installed (which can be done using [Lambda Stack](https://lambdalabs.com/lambda-stack-deep-learning-software)).
56

6-
📢 Check out how to linearly scale Falcon 7B/40B fine-tuning across 8x A100 80GB GPUs on Lambda Cloud.
7-
87
## Installation on Lambda Cloud
98

10-
From a clean [Lambda cloud instance](https://cloud.lambdalabs.com/):
9+
As of the writing of this tutorial (June 28, 2023), Lambda Cloud provides different versions of PyTorch for different instances (e.g., version 2.0.1 for H100 and version 1.3.1 for other instances). During our tests, we encountered some issues when running `Falcon`/`bitsandbytes` on specific GPUs within these environments. To maintain a clean setup, we have decided to write this tutorial using a conda environment and install PyTorch 2.0.1, built with CUDA 11.8, across all types of GPU instances, including H100, A100, A6000, and A10.
10+
11+
Here are the steps to set up the conda environment on a fresh new Lambda Cloud instance, based on the [instructions](https://huggingface.co/tiiuae/falcon-40b/discussions/18#647939c2c68a021fbba88182) provided by Huggingface community contributors:
1112

1213
**Install miniconda**
1314

@@ -28,11 +29,14 @@ printf '\neval "$(/home/ubuntu/miniconda3/bin/conda shell.bash hook)"' >> ~/.bas
2829
**Setup env**
2930

3031
Install using the yaml file:
32+
3133
```
3234
conda env create -f falcon-env.yaml
3335
conda activate falcon-env
3436
```
37+
3538
or manually:
39+
3640
```
3741
# Create and activate env. -y skips confirmation prompt.
3842
conda create -n falcon-env python=3.9 -y
@@ -49,6 +53,10 @@ pip install scipy datasets bitsandbytes wandb
4953

5054
## Usage
5155

56+
We provide a fine-tuning script that is written based on this [Colab notebook](https://colab.research.google.com/drive/1BiQiw31DT7-cDp1-0ySXvvhzqomTdI-o?usp=sharing). We modified the original script so it is data parallelized for better scaling across multiple GPUs. In particular, we launch the script with `torchrun` and use `device_map={"": Accelerator().process_index}` to allocate each replicate of the model on the correct device.
57+
58+
Now, we are ready to fine-tune the models. Here are some example commands:
59+
5260
```
5361
eval "$(/home/ubuntu/miniconda3/bin/conda shell.bash hook)"
5462
conda activate falcon-env
@@ -68,27 +76,33 @@ ft.py \
6876

6977
# Results
7078

79+
We benchmarked the training throughput across multiple popular GPU instances. Here is the training throughputs measured by samples/sec:
80+
7181
## Falcon 7B
7282

7383
| Config | samples/sec 4bit | samples/sec 8bit |
74-
|------------------|------------------|------------------|
84+
| ---------------- | ---------------- | ---------------- |
7585
| 1xA100 80GB SXM4 | 5.024 | 1.923 |
7686
| 8xA100 80GB SXM4 | 39.535 | 15.241 |
87+
| 1xH100 80GB SXM5 | 6.7 | - |
88+
| 8xH100 80GB SXM5 | 55.423 | - |
7789
| 1xA100 40GB SXM4 | 3.9 | 1.688 |
7890
| 1xA6000 | 1.895 | 1.513 |
79-
| 1xA10 | 1.45 | - |
80-
91+
| 1xA10 | 1.45 | OOM |
8192

8293
## Falcon 40B
8394

84-
| Config | samples/sec 4bit | samples/sec 8bit |
85-
| ----------- | ----------- |----------- |
86-
| 1xA100 80GB SXM4 | 1.111 | 0.36 |
87-
| 8xA100 80GB SXM4 | 8.705 | 2.85 |
95+
| Config | samples/sec 4bit | samples/sec 8bit |
96+
| ---------------- | ---------------- | ---------------- |
97+
| 1xA100 80GB SXM4 | 1.111 | 0.36 |
98+
| 8xA100 80GB SXM4 | 8.705 | 2.85 |
8899

100+
As the table shows, training throughput scales nearly perfectly (over 7.8x speedup from 1x to 8x GPUs). However, at the moment we are still experiencing some CUDA errors with H100 for some specific configurations. Here are some potentially related [discussions](https://github.com/search?q=repo%3ATimDettmers%2Fbitsandbytes+h100&type=issues) that we follow up on closely.
89101

90102
# Credits
91103

104+
Tim Dettmers's [bitsandbytes](https://github.com/TimDettmers/bitsandbytes) library and HuggingFace's [PEFT](https://github.com/huggingface/peft) library make it possible to fine-tune these models on a single GPU.
105+
92106
The fine-tuning script is based on this [Colab notebook](https://colab.research.google.com/drive/1BiQiw31DT7-cDp1-0ySXvvhzqomTdI-o?usp=sharing) from Huggingface's blog: [The Falcon has landed in the Hugging Face ecosystem](https://huggingface.co/blog/falcon#fine-tuning-with-peft). We modified the original script so it is data parallelized for better scaling across multiple GPUs.
93107

94-
The installation steps are based on naterw's [instructions](https://huggingface.co/tiiuae/falcon-40b/discussions/18#647939c2c68a021fbba88182).
108+
The installation steps are based on the [instructions](https://huggingface.co/tiiuae/falcon-40b/discussions/18#647939c2c68a021fbba88182) from Huggingface community contributors.

0 commit comments

Comments
 (0)