Skip to content

Commit 6e06c51

Browse files
SurbhiJainUSCGoogle-ML-Automation
authored andcommitted
Update checkpoint conversion documentation
PiperOrigin-RevId: 888829289
1 parent e6cd443 commit 6e06c51

6 files changed

Lines changed: 11 additions & 16 deletions

File tree

docs/guides/checkpointing_solutions/convert_checkpoint.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,8 @@ Use the `to_maxtext.py` script to convert a Hugging Face model into a MaxText ch
3434
### Usage
3535

3636
First, make sure python3 virtual environment for MaxText is set up and enabled.
37-
38-
```bash
39-
export VENV_NAME=<your virtual env name> # e.g., maxtext_venv
40-
pip install uv
41-
uv venv --python 3.12 --seed ${VENV_NAME?}
42-
source ${VENV_NAME?}/bin/activate
43-
```
37+
For instructions on installing MaxText on your VM, please refer to the [official documentation] and use the
38+
maxtext[tpu-post-train] installation path to include all necessary post-training dependencies.
4439

4540
Second, ensure you have the necessary dependencies installed (e.g., install PyTorch for checkpoint conversion and logit check).
4641

@@ -52,7 +47,7 @@ Third, setup following environment variables for conversion script
5247

5348
```bash
5449
# -- Model configuration --
55-
export MODEL_NAME=<Hugging Face Model to be converted to MaxText> # e.g. 'llama3.1-8b-Instruct'
50+
export MODEL=<Hugging Face Model to be converted to MaxText> # e.g. 'llama3.1-8b-Instruct'
5651
export HF_TOKEN=<Hugging Face access token> # your token to access gated HF repos
5752

5853
# -- MaxText configuration --
@@ -70,7 +65,7 @@ Finally, run below command to complete the conversion
7065
# customize your "HF_HOME" to redirect the cache to a larger or mounted disk (e.g., on a TPU VM).
7166
# export HF_HOME="/dev/shm/huggingface_tmp"
7267
python3 -m maxtext.checkpoint_conversion.to_maxtext \
73-
model_name=${MODEL_NAME?} \
68+
model_name=${MODEL?} \
7469
hf_access_token=${HF_TOKEN?} \
7570
base_output_directory=${MODEL_CHECKPOINT_DIRECTORY?} \
7671
scan_layers=True \
@@ -105,7 +100,7 @@ The following command converts a MaxText checkpoint and saves it locally, to GCS
105100

106101
```bash
107102
python3 -m maxtext.checkpoint_conversion.to_huggingface \
108-
model_name=<MODEL_NAME> \
103+
model_name=<MODEL> \
109104
load_parameters_path=<path-to-maxtext-checkpoint> \
110105
base_output_directory=<path-to-save-converted-checkpoint> \
111106
scan_layers=false \
@@ -134,7 +129,7 @@ To ensure the conversion was successful, you can use the [`tests/utils/forward_p
134129
python3 -m tests.utils.forward_pass_logit_checker src/maxtext/configs/base.yml \
135130
tokenizer_path=<tokenizer> \
136131
load_parameters_path=<path-to-maxtext-checkpoint> \
137-
model_name=<MODEL_NAME> \
132+
model_name=<MODEL> \
138133
scan_layers=false \
139134
max_prefill_predict_length=4 \
140135
max_target_length=8 \

docs/tutorials/posttraining/full_finetuning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export MODEL_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucket/
6767

6868
### Option 2: Converting a Hugging Face checkpoint
6969

70-
Refer the steps in [Hugging Face to MaxText](../../guides/checkpointing_solutions/convert_checkpoint.md#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
70+
Refer the steps in [Hugging Face to MaxText](https://maxtext.readthedocs.io/en/maxtext-v0.2.1/guides/checkpointing_solutions/convert_checkpoint.html#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
7171

7272
```bash
7373
export MODEL_CKPT_PATH=<gcs path for MaxText checkpoint> # gs://my-bucket/my-checkpoint-directory/0/items

docs/tutorials/posttraining/rl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucke
8787

8888
### Option 2: Converting from a Hugging Face checkpoint
8989

90-
Refer the steps in [Hugging Face to MaxText](../../guides/checkpointing_solutions/convert_checkpoint.md#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
90+
Refer the steps in [Hugging Face to MaxText](https://maxtext.readthedocs.io/en/maxtext-v0.2.1/guides/checkpointing_solutions/convert_checkpoint.html#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
9191

9292
```bash
9393
export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucket/my-model-checkpoint/0/items

docs/tutorials/posttraining/rl_on_multi_host.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucke
101101

102102
### Option 2: Converting from a Hugging Face checkpoint
103103

104-
Refer the steps in [Hugging Face to MaxText](../../guides/checkpointing_solutions/convert_checkpoint.md#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
104+
Refer the steps in [Hugging Face to MaxText](https://maxtext.readthedocs.io/en/maxtext-v0.2.1/guides/checkpointing_solutions/convert_checkpoint.html#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
105105

106106
```bash
107107
export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucket/my-model-checkpoint/0/items

docs/tutorials/posttraining/sft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucke
6868

6969
### Option 2: Converting a Hugging Face checkpoint
7070

71-
Refer the steps in [Hugging Face to MaxText](../../guides/checkpointing_solutions/convert_checkpoint.md#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
71+
Refer the steps in [Hugging Face to MaxText](https://maxtext.readthedocs.io/en/maxtext-v0.2.1/guides/checkpointing_solutions/convert_checkpoint.html#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
7272

7373
```sh
7474
export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # e.g., gs://my-bucket/my-model-checkpoint/0/items

docs/tutorials/posttraining/sft_on_multi_host.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ checkpoint_storage_use_ocdbt=$((1 - USE_PATHWAYS))
9292

9393
### Option 2: Converting a Hugging Face checkpoint
9494

95-
Refer the steps in [Hugging Face to MaxText](../../guides/checkpointing_solutions/convert_checkpoint.md#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
95+
Refer the steps in [Hugging Face to MaxText](https://maxtext.readthedocs.io/en/maxtext-v0.2.1/guides/checkpointing_solutions/convert_checkpoint.html#hugging-face-to-maxtext) to convert a hugging face checkpoint to MaxText. Make sure you have correct checkpoint files converted and saved. Similar as Option 1, you can set the following environment and move on.
9696

9797
```bash
9898
export MAXTEXT_CKPT_PATH=<gcs path for MaxText checkpoint> # gs://my-bucket/my-checkpoint-directory/0/items

0 commit comments

Comments
 (0)