You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/checkpointing_solutions/convert_checkpoint.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,8 @@ You can find your converted checkpoint files under `${BASE_OUTPUT_DIRECTORY}/0/i
86
86
-`--hf_model_path` (Optional): Specifies a customized remote directory or local directory containing the model weights. If unspecified, we use the [default Hugging Face repository ID](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/utils/globals.py) (e.g., openai/gpt-oss-20b). This is necessary for locally dequantized models like GPT-OSS or DeepSeek.
87
87
-`--save_dtype` (Optional): Specifies the data type of saved model weights. Default to `bfloat16` to save memory.
88
88
89
+
(maxtext-to-hf)=
90
+
89
91
## MaxText to Hugging Face
90
92
91
93
Use the `to_huggingface.py` script to convert a MaxText checkpoint into the Hugging Face format. This is useful for sharing your models or integrating them with the Hugging Face ecosystem.
Copy file name to clipboardExpand all lines: docs/tutorials/posttraining/rl_gptoss_20b.md
+15-80Lines changed: 15 additions & 80 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@
17
17
# Reinforcement Learning with GPT-OSS 20B on Multi-Host TPUs
18
18
19
19
This tutorial provides step-by-step instructions for setting up the environment
20
-
and training the GPT-OSS 20B model on the [GSM8K dataset](https://huggingface.co/datasets/openai/gsm8k) on an Viperfish GKE cluster with `v5p-64` nodes.
20
+
and training the GPT-OSS 20B model on the [GSM8K dataset](https://huggingface.co/datasets/openai/gsm8k) on a GKE cluster with `v5p-64` nodes.
21
21
22
22
## Prerequisites
23
23
@@ -30,10 +30,6 @@ Before starting, ensure you have:
30
30
- A Pathways-ready GKE cluster (see [create GKE cluster](https://docs.cloud.google.com/ai-hypercomputer/docs/workloads/pathways-on-cloud/create-gke-cluster)).
31
31
-**Docker** installed and configured for sudoless use. Follow the steps to [configure sudoless Docker](https://docs.docker.com/engine/install/linux-postinstall/).
32
32
33
-
## Build and Upload MaxText Docker Image
34
-
35
-
For instructions on building and uploading the MaxText Docker image with post-training dependencies, please refer to the [official documentation](../../build_maxtext.md).
36
-
37
33
## Setup Environment Variables
38
34
39
35
Set up the following environment variables to configure your training run. Replace
### Option 2: Converting from a Hugging Face checkpoint
91
74
92
-
> **Note:** Converting the 20B model requires approximately 40 GB of free disk space to download its safetensors. Please verify you have sufficient space before running the conversion.
75
+
Refer to [Hugging Face to MaxText](hf-to-maxtext) to convert a Hugging Face checkpoint to MaxText format. After conversion finishes, set `MAXTEXT_CKPT_PATH` to the converted MaxText checkpoint path.
> **Note:** Converting the 20B model requires approximately 40 GB of free disk space to download its safetensors. Please verify you have sufficient space before running the conversion.
82
+
121
83
## Run RL Workload
122
84
85
+
### Build and Upload MaxText Docker Image
86
+
87
+
For instructions on building and uploading the MaxText Docker image with post-training dependencies, please refer to the [official documentation](../../build_maxtext.md).
88
+
123
89
### Submit your workload
124
90
125
91
```bash
126
-
# Create and activate a virtual environment
127
-
uv venv --python 3.12 --seed runner_venv
128
-
source runner_venv/bin/activate
129
-
uv pip install -e .[runner] --resolution=lowest
92
+
# The Docker image you pushed in the previous step
@@ -156,7 +117,7 @@ Alternatively, after running the bash script, you will also get a link to the Go
156
117
157
118
During RL training, you can monitor key metrics to track model convergence, reward trends, and hardware performance.
158
119
159
-
To enable Tunix-managed metrics measurement, set `enable_tunix_perf_metrics` to `true` in `src/maxtext/configs/post_train/rl.yml`. Note that this flag is already set to `True` by default in the [scripts/run_gptoss_20b_rl.sh](../../../scripts/run_gptoss_20b_rl.sh) script for this tutorial workload. When enabled, Tunix automatically collects and uploads these metrics to TensorBoard.
120
+
To enable Tunix-managed metrics measurement, set `enable_tunix_perf_metrics` to `true` in RL configurations. Note that this flag is already set to `True` by default for this tutorial workload. When enabled, Tunix automatically collects and uploads these metrics to TensorBoard.
160
121
161
122
For a complete list of collected metrics, see the [Tunix Metrics Documentation](https://tunix.readthedocs.io/en/latest/metrics.html). Key metrics to monitor include:
162
123
@@ -172,30 +133,4 @@ For a complete list of collected metrics, see the [Tunix Metrics Documentation](
172
133
173
134
## Convert Checkpoint to Hugging Face Format
174
135
175
-
After training, you may want to convert your MaxText checkpoint back to Hugging Face format. Use the following command to perform the conversion:
Copy file name to clipboardExpand all lines: docs/tutorials/posttraining/rl_qwen3_30b.md
+14-56Lines changed: 14 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,10 +30,6 @@ Before starting, ensure you have:
30
30
- A Pathways-ready GKE cluster (see [create GKE cluster](https://docs.cloud.google.com/ai-hypercomputer/docs/workloads/pathways-on-cloud/create-gke-cluster)).
31
31
-**Docker** installed and configured for sudoless use. Follow the steps to [configure sudoless Docker](https://docs.docker.com/engine/install/linux-postinstall/).
32
32
33
-
## Build and Upload MaxText Docker Image
34
-
35
-
For instructions on building and uploading the MaxText Docker image with post-training dependencies, please refer to the [official documentation](../../build_maxtext.md).
36
-
37
33
## Setup Environment Variables
38
34
39
35
Set up the following environment variables to configure your training run. Replace
### Option 2: Converting from a Hugging Face checkpoint
91
74
92
-
> **Note:** Converting the 30B model requires approximately 62 GB of free disk space to download its safetensors. Please verify you have sufficient space before running the conversion script.
75
+
Refer to [Hugging Face to MaxText](hf-to-maxtext) to convert a Hugging Face checkpoint to MaxText format. You can find an example script to convert `qwen3-30b-a3b-base`model to MaxText format [here](https://github.com/AI-Hypercomputer/maxtext/blob/main/tests/end_to_end/tpu/qwen3/30b/test_qwen3_to_mt.sh). After conversion finishes, set `MAXTEXT_CKPT_PATH` to the converted MaxText checkpoint path.
93
76
94
77
```bash
95
-
# Optional: If you run out of disk space when downloading Hugging Face safetensors,
96
-
# customize your "HF_HOME" to redirect the cache to a larger or mounted disk (e.g., on a TPU VM).
> **Note:** Converting the 30B model requires approximately 62 GB of free disk space to download its safetensors. Please verify you have sufficient space before running the conversion script.
103
82
104
-
# Run the conversion script to convert the Hugging Face checkpoint to MaxText format
105
-
bash scripts/run_qwen3_30b_hf_to_maxtext.sh
83
+
## Run RL Workload
106
84
107
-
# Deactivate the virtual environment
108
-
deactivate
109
-
rm -rf tpu_venv
110
-
```
85
+
### Build and Upload MaxText Docker Image
111
86
112
-
## Run RL Workload
87
+
For instructions on building and uploading the MaxText Docker image with post-training dependencies, please refer to the [official documentation](../../build_maxtext.md).
113
88
114
89
### Submit your workload
115
90
116
91
```bash
117
-
# Create and activate a virtual environment
118
-
uv venv --python 3.12 --seed runner_venv
119
-
source runner_venv/bin/activate
120
-
uv pip install -e .[runner] --resolution=lowest
92
+
# The Docker image you pushed in the previous step
@@ -147,7 +117,7 @@ Alternatively, after running the bash script, you will also get a link to the Go
147
117
148
118
During RL training, you can monitor key metrics to track model convergence, reward trends, and hardware performance.
149
119
150
-
To enable Tunix-managed metrics measurement, set `enable_tunix_perf_metrics` to `true` in `src/maxtext/configs/post_train/rl.yml`. Note that this flag is already set to `True` by default in the [scripts/run_qwen3_30b_rl.sh](../../../scripts/run_qwen3_30b_rl.sh) script for this tutorial workload. When enabled, Tunix automatically collects and uploads these metrics to TensorBoard.
120
+
To enable Tunix-managed metrics measurement, set `enable_tunix_perf_metrics` to `true` in RL configurations. Note that this flag is already set to `True` by default for this tutorial workload. When enabled, Tunix automatically collects and uploads these metrics to TensorBoard.
151
121
152
122
For a complete list of collected metrics, see the [Tunix Metrics Documentation](https://tunix.readthedocs.io/en/latest/metrics.html). Key metrics to monitor include:
153
123
@@ -163,18 +133,6 @@ For a complete list of collected metrics, see the [Tunix Metrics Documentation](
163
133
164
134
## Convert Checkpoint to Hugging Face Format
165
135
166
-
After training, you may want to convert your MaxText checkpoint back to Hugging Face format. Use the following script to perform the conversion:
167
-
168
-
```bash
169
-
# Create and activate a virtual environment
170
-
uv venv --python 3.12 --seed tpu_venv
171
-
source tpu_venv/bin/activate
172
-
uv pip install -e .[tpu] --resolution=lowest
173
-
174
-
# Run the conversion script to convert the MaxText checkpoint back to Hugging Face format
175
-
bash scripts/run_qwen3_30b_maxtext_to_hf.sh
136
+
## Convert Checkpoint to Hugging Face Format
176
137
177
-
# Deactivate the virtual environment
178
-
deactivate
179
-
rm -rf tpu_venv
180
-
```
138
+
Refer to [MaxText to Hugging Face](maxtext-to-hf) to convert a MaxText checkpoint back to Hugging Face format. You can find an example script to convert `qwen3-30b-a3b-base`model to Hugging Face format [here](https://github.com/AI-Hypercomputer/maxtext/blob/main/tests/end_to_end/tpu/qwen3/30b/test_qwen3_to_hf.sh).
0 commit comments