Skip to content

Commit 7b444a6

Browse files
authored
supported dp and async generation for dataset regeneration (#306)
* supported dp and async generation for dataset regeneration * polihs * polish
1 parent a4453bf commit 7b444a6

3 files changed

Lines changed: 173 additions & 289 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# ↩️ Regenerate Datasets
2+
3+
## 📍 Overview
4+
5+
When training speculative decoding draft models for a specific target model, instead of using the original dataset, we can regenerate the assistant responses using the target model to better align the draft model with the target model's output distribution. This will improve the acceptance rate of the draft model and the overall performance of the speculative decoding. According to the [EAGLE1 paper](https://arxiv.org/pdf/2401.15077), the EAGLE method is not very sensitive to the dataset quality, which means the performance is still good even if you use the original dataset. However, if you are looking for optimal performance in the production environment, it is recommended to regenerate the dataset using the target model.
6+
7+
## 🔧 Regeneration Workflow
8+
9+
We can follow the following steps to regenerate the dataset. In the example below, we will use `meta-llama/Llama-3.1-8B-Instruct` as an example, you can replace it with your own target model.
10+
11+
1. Start the SGLang server for the target model.
12+
13+
```shell
14+
python3 -m sglang.launch_server \
15+
--model meta-llama/Llama-3.1-8B-Instruct \
16+
--cuda-graph-bs 1 2 4 8 16 32 64 128 \
17+
--dtype bfloat16 \
18+
--mem-frac=0.8 \
19+
--port 30000
20+
```
21+
22+
2. Regenerate the dataset using the `regenerate_train_data.py` script.
23+
24+
```shell
25+
python scripts/regenerate_train_data.py \
26+
--model meta-llama/Llama-3.1-8B-Instruct \
27+
--concurrency 128 \
28+
--max-tokens 98304 \
29+
--server-address localhost:30000 \
30+
--temperature 0.8 \
31+
--input-file-path ./cache/dataset/perfectblend_train.jsonl \
32+
--output-file-path ./cache/dataset/perfectblend_train_regen.jsonl
33+
```
34+
35+
For maximum performance, we recommend to scale the number of GPUs to regenerate the dataset in data parallel mode. To do this, you can simply add more server addresses to the `--server-address` argument, e.g. `--server-address localhost:30000 localhost:30001 localhost:30002 localhost:30003`.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ SpecForge is an ecosystem project developed by the SGLang team. It is a framewor
2929
:maxdepth: 1
3030
:caption: Advanced Features
3131

32+
advanced_features/regenerate_dataset.md
3233
advanced_features/customization.md

0 commit comments

Comments
 (0)