Skip to content

Commit eabac7f

Browse files
Merge pull request #2349 from AI-Hypercomputer:sft_e2e_update
PiperOrigin-RevId: 807416863
2 parents 04329ee + bd9600e commit eabac7f

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

docs/tutorials/sft.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Supervised fine-tuning (SFT) is a process where a pre-trained large language mod
2020
This tutorial demonstrates step-by-step instructions for setting up the environment and then training the Llama3.1 8B model on the [HuggingFaceH4/ultrachat_200k](https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k) dataset using SFT. If you wish to use a different dataset, you can [update the dataset configurations](https://github.com/AI-Hypercomputer/maxtext/blob/main/MaxText/configs/sft.yml).
2121

2222
We use [Tunix](https://github.com/google/tunix), a JAX-based library designed for post-training tasks, to perform SFT.
23-
23+
2424
In this tutorial we use a single host TPU VM such as `v6e-8/v5p-8`. Let's get started!
2525

2626
## Setup virtual environment
@@ -44,18 +44,17 @@ bash setup.sh
4444

4545
## Run SFT
4646
There are two scenarios supported for running SFT:
47-
1. **Run SFT on Hugging Face checkpoint**
47+
1. **Run SFT on Hugging Face checkpoint**
4848
Download the checkpoint directly from Hugging Face and fine-tune it using SFT.
4949

50-
2. **Run SFT on MaxText checkpoint**
50+
2. **Run SFT on MaxText checkpoint**
5151
Use a checkpoint generated by MaxText and fine-tune it using SFT.
5252

5353
Choose the scenario that matches your workflow and follow the corresponding instructions below.
5454

5555
### Run SFT on Hugging Face checkpoint
5656
* The script will first convert a Hugging Face checkpoint to a MaxText checkpoint.
5757
* It then runs SFT on this converted checkpoint.
58-
* After fine-tuning, the script converts the resulting checkpoint back to the Hugging Face format.
5958

6059
#### Setup environment variables
6160
```
@@ -75,7 +74,6 @@ bash ~/maxtext/end_to_end/tpu/llama3.1/8b/run_sft.sh
7574

7675
### Run SFT on MaxText checkpoint
7776
* The script directly runs SFT on MaxText checkpoint.
78-
* After fine-tuning, the script converts the resulting checkpoint back to the Hugging Face format.
7977

8078
#### Setup environment variables
8179
```

end_to_end/tpu/llama3.1/8b/run_sft.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,3 @@ sorted_dirs=($(printf '%s\n' "${integer_dirs[@]}" | sort -n))
7878
largest_dir="${sorted_dirs[-1]}"
7979
FINE_TUNED_MODEL_CKPT_PATH=${CHECKPOINTS_PATH}/${largest_dir}
8080
echo "Fine-tuned model checkpoint: ${FINE_TUNED_MODEL_CKPT_PATH}"
81-
82-
# Convert the fine-tuned MaxText checkpoint to Hugging Face checkpoint
83-
export LOCAL_PATH=./tmp/hf/${PRE_TRAINED_MODEL}/${RUN_NAME}
84-
python3 -m MaxText.utils.ckpt_conversion.to_huggingface "${MAXTEXT_PKG_DIR:-${MAXTEXT_REPO_ROOT:-$PWD}/src/MaxText}"/configs/base.yml \
85-
model_name=${PRE_TRAINED_MODEL} \
86-
hf_access_token=${HF_TOKEN} \
87-
load_parameters_path=${FINE_TUNED_MODEL_CKPT_PATH}/model_params \
88-
base_output_directory=${LOCAL_PATH} \
89-
scan_layers=False
90-
echo "Converted Hugging Face checkpoint saved to: ${LOCAL_PATH}"

0 commit comments

Comments
 (0)