Skip to content

Commit 5162576

Browse files
Merge pull request #2755 from AI-Hypercomputer:hengtaoguo-rl
PiperOrigin-RevId: 837317146
2 parents 797cc65 + a5608d5 commit 5162576

File tree

4 files changed

+48
-19
lines changed

4 files changed

+48
-19
lines changed

docs/guides/install_maxtext.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ This document discusses how to install MaxText. We recommend installing MaxText
2222
This is the easiest way to get started with the latest stable version.
2323

2424
```bash
25-
# 1. Create virtual environment
25+
# 1. Install uv, a fast Python package installer
26+
pip install uv
27+
28+
# 2. Create virtual environment
2629
uv venv --python 3.12 --seed maxtext_venv
2730
source maxtext_venv/bin/activate
2831

29-
# 2. Install uv, a fast Python package installer
30-
pip install uv
31-
3232
# 3. Install MaxText and its dependencies
3333
uv pip install maxtext --resolution=lowest
3434
install_maxtext_github_deps
@@ -46,11 +46,11 @@ git clone https://github.com/AI-Hypercomputer/maxtext.git
4646
cd maxtext
4747

4848
# 2. Create virtual environment
49+
pip install uv
4950
uv venv --python 3.12 --seed maxtext_venv
5051
source maxtext_venv/bin/activate
5152

5253
# 3. Install dependencies in editable mode
53-
pip install uv
5454
# install the tpu package
5555
uv pip install -e .[tpu] --resolution=lowest
5656
# or install the gpu package by running the following line

docs/tutorials/grpo.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,22 @@ And we use vLLM as the library for efficient model inference and generation.
2626
In this tutorial we use a single host TPUVM such as `v6e-8/v5p-8`. Let's get started!
2727

2828
## Create virtual environment and Install MaxText dependencies
29-
Follow instructions in [Install MaxText](https://github.com/AI-Hypercomputer/maxtext/blob/main/docs/guides/install_maxtext.md), but
30-
recommend creating the virtual environment outside the `maxtext` directory.
29+
If you have already completed the [MaxText installation](https://github.com/AI-Hypercomputer/maxtext/blob/main/docs/guides/install_maxtext.md), you can skip to the next section for vLLM and tpu-inference installations. Otherwise, please install MaxText using the following commands before proceeding.
30+
```bash
31+
# 1. Clone the repository
32+
git clone https://github.com/AI-Hypercomputer/maxtext.git
33+
cd maxtext
34+
35+
# 2. Create virtual environment
36+
export VENV_NAME=<your virtual env name> # e.g., maxtext_venv
37+
pip install uv
38+
uv venv --python 3.12 --seed $VENV_NAME
39+
source $VENV_NAME/bin/activate
40+
41+
# 3. Install dependencies in editable mode
42+
uv pip install -e .[tpu] --resolution=lowest
43+
install_maxtext_github_deps
44+
```
3145

3246
## vLLM and tpu-inference installations
3347

docs/tutorials/grpo_with_pathways.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,20 @@ python3 -m MaxText.utils.ckpt_conversion.to_maxtext MaxText/configs/base.yml \
8282
```
8383

8484
## Build and Upload MaxText Docker Image with Tunix, vLLM, tpu-inference dependencies
85+
Before building the Docker image, authenticate to [Google Artifact Registry](https://docs.cloud.google.com/artifact-registry/docs/docker/authentication#gcloud-helper) for permission to push your images and other access.
86+
```bash
87+
# Authenticate your user account for gcloud CLI access
88+
gcloud auth login
89+
# Configure application default credentials for Docker and other tools
90+
gcloud auth application-default login
91+
# Configure Docker credentials and test your access
92+
gcloud auth configure-docker
93+
docker run hello-world
94+
```
95+
96+
You can install the required dependencies using either of the following two options:
8597

86-
### Installing stable releases of tunix and vllm-tpu
98+
### Option 1: Installing stable releases of tunix and vllm-tpu
8799
Run the following bash script to create a docker image with all the dependencies of MaxText, Tunix, vLLM and tpu-inference installed.
88100

89101
In addition to MaxText dependencies, primarily, it installs `vllm-tpu` which is [vllm](https://github.com/vllm-project/vllm) and [tpu-inference](https://github.com/vllm-project/tpu-inference) and thereby providing TPU inference for vLLM, with unified JAX and PyTorch support.
@@ -92,9 +104,9 @@ In addition to MaxText dependencies, primarily, it installs `vllm-tpu` which is
92104
bash dependencies/scripts/docker_build_dependency_image.sh MODE=post-training
93105
```
94106

95-
You can also use `bash dependencies/scripts/docker_build_dependency_image.sh MODE=post-training-experimental` to try out new features via experimental dependencies such as improved pathwaysutils resharding API
107+
You can also use `bash dependencies/scripts/docker_build_dependency_image.sh MODE=post-training-experimental` to try out new features via experimental dependencies such as improved pathwaysutils resharding API.
96108

97-
### Install from locally git cloned repo's
109+
### Option 2: Install from locally git cloned repositories
98110

99111
You can also locally git clone [tunix](https://github.com/google/tunix), [tpu-inference](https://github.com/vllm-project/tpu-inference), [vllm](https://github.com/vllm-project/vllm.git) and then use the following command to build a docker image using them:
100112
```
@@ -106,7 +118,7 @@ bash dependencies/scripts/docker_build_dependency_image.sh MODE=post-training PO
106118
bash dependencies/scripts/docker_upload_runner.sh CLOUD_IMAGE_NAME=${CLOUD_IMAGE_NAME}
107119
```
108120

109-
### Submit your jobs
121+
## Submit your jobs
110122

111123
Please create a pathways ready GKE cluster as described [here](https://docs.cloud.google.com/ai-hypercomputer/docs/workloads/pathways-on-cloud/create-gke-cluster), and you can submit the `train_rl.py` script via [XPK](https://github.com/AI-Hypercomputer/xpk)
112124
```
@@ -123,10 +135,3 @@ python3 -m src.MaxText.rl.train_rl src/MaxText/configs/rl.yml \
123135
base_output_directory=${BASE_OUTPUT_DIRECTORY} \
124136
hf_access_token=$HF_TOKEN"
125137
```
126-
127-
The overview of the demo script ~/maxtext/src/MaxText/examples/grpo_llama3_1_70b_demo_pw.py` is as follows:
128-
129-
1. We load a policy model and a reference model. Both are copies of `Llama3.1-70b-Instruct`.
130-
2. Evaluate the policy model's performance on GSM8K math reasoning benchmark.
131-
3. Train the policy model using GRPO with potentially different meshes for trainer and rollout depending on the parameters `TRAINER_DEVICES_FRACTION` and `SAMPLER_DEVICES_FRACTION`. If we set both of these to `1.0`, the entire (same) mesh will be used for both trainer and rollout. If we set say `TRAINER_DEVICES_FRACTION=0.5` and `SAMPLER_DEVICES_FRACTION=0.5`, the first half of the devices will be used for trainer and the second half will be used for rollout
132-
4. Evaluate the policy model's performance on GSM8K math reasoning benchmark after the post-training with GRPO.

docs/tutorials/sft_on_multi_host.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,20 @@ cd maxtext
3333
```
3434

3535
### 1.2. Build MaxText Docker image
36+
Before building the Docker image, authenticate to [Google Artifact Registry](https://docs.cloud.google.com/artifact-registry/docs/docker/authentication#gcloud-helper) for permission to push your images and other access.
37+
```bash
38+
# Authenticate your user account for gcloud CLI access
39+
gcloud auth login
40+
# Configure application default credentials for Docker and other tools
41+
gcloud auth application-default login
42+
# Configure Docker credentials and test your access
43+
gcloud auth configure-docker
44+
docker run hello-world
45+
```
46+
Then run the following command to create a local Docker image named `maxtext_base_image`.
3647
```bash
3748
bash dependencies/scripts/docker_build_dependency_image.sh MODE=post-training
3849
```
39-
This creates a local Docker image named `maxtext_base_image`.
4050

4151
### 1.3. Upload the Docker image to Artifact Registry
4252
```bash

0 commit comments

Comments
 (0)