Skip to content

Commit 60b1f1b

Browse files
Merge pull request #2536 from AI-Hypercomputer:bvandermoon-version-doc
PiperOrigin-RevId: 826182333
2 parents 3b22b3d + 73d2586 commit 60b1f1b

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

docs/guides.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ guides/xprof_user_guide.md
3333
guides/checkpointing_solutions.md
3434
guides/megascale_hang_playbook.md
3535
guides/multimodal.md
36+
guides/update_dependencies.md
3637
```

docs/guides/update_dependencies.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!--
2+
Copyright 2023-2025 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
# How to update MaxText dependencies using seed-env
18+
19+
## Introduction
20+
21+
This document provides a guide to updating dependencies in MaxText using the `seed-env` tool. `seed-env` helps generate deterministic and reproducible Python environments by creating fully-pinned `requirements.txt` files from a base set of requirements.
22+
23+
## Overview of the Process
24+
25+
To update dependencies, you will follow these general steps:
26+
27+
1. **Modify Base Requirements**: Update the desired dependencies in `base_requirements/requirements.txt` or the hardware-specific files (`base_requirements/tpu-base-requirements.txt`, `base_requirements/gpu-base-requirements.txt`).
28+
2. **Generate New Files**: Run the `seed-env` CLI tool to generate new, fully-pinned requirements files based on your changes.
29+
3. **Update Project Files**: Copy the newly generated files into the `generated_requirements/` directory.
30+
4. **Handle GitHub Dependencies**: Move any dependencies that are installed directly from GitHub from the generated files to `src/install_maxtext_extra_deps/extra_deps_from_github.txt`.
31+
5. **Verify**: Test the new dependencies to ensure the project installs and runs correctly.
32+
33+
The following sections provide detailed instructions for each step.
34+
35+
## Step 1: Install seed-env
36+
37+
First, you need to install the `seed-env` command-line tool by running `pip install seed-env uv`. Or follow the instructions in the
38+
[seed-env repository](https://github.com/google-ml-infra/actions/tree/main/python_seed_env#install-the-seed-env-tool) if you want to build `seed-env` from source.
39+
40+
## Step 2: Find the JAX Build Commit Hash
41+
42+
The dependency generation process is pinned to a specific nightly build of JAX. You need to find the commit hash for the desired JAX build.
43+
44+
You can find the latest commit hashes in the [JAX `build/` folder](https://github.com/jax-ml/jax/commits/main/build). Choose a recent, successful build and copy its full commit hash.
45+
46+
## Step 3: Generate the Requirements Files
47+
48+
Next, run the `seed-env` CLI to generate the new requirements files. You will need to do this separately for the TPU and GPU environments. The generated files will be placed in a directory specified by `--output-dir`.
49+
50+
### For TPU
51+
52+
Run the following command, replacing `<jax-build-commit-hash>` with the hash you copied in the previous step.
53+
54+
```bash
55+
seed-env \
56+
--local-requirements=base_requirements/tpu-base-requirements.txt \
57+
--host-name=MaxText \
58+
--seed-commit=<jax-build-commit-hash> \
59+
--python-version=3.12 \
60+
--requirements-txt=tpu-requirements.txt \
61+
--output-dir=generated_tpu_artifacts
62+
```
63+
64+
### For GPU
65+
66+
Similarly, run the command for the GPU requirements.
67+
68+
```bash
69+
seed-env \
70+
--local-requirements=base_requirements/cuda12-base-requirements.txt \
71+
--host-name=MaxText \
72+
--seed-commit=<jax-build-commit-hash> \
73+
--python-version=3.12 \
74+
--requirements-txt=cuda12-requirements.txt \
75+
--hardware=cuda12 \
76+
--output-dir=generated_gpu_artifacts
77+
```
78+
79+
## 4. Update Project Files
80+
81+
After generating the new requirements, you need to update the files in the MaxText repository.
82+
83+
1. **Copy the generated files:**
84+
- Move `generated_tpu_artifacts/tpu-requirements.txt` to `generated_requirements/tpu-requirements.txt`.
85+
- Move `generated_gpu_artifacts/cuda12-requirements.txt` to `generated_requirements/cuda12-requirements.txt`.
86+
87+
2. **Update `extra_deps_from_github.txt` (if necessary):**
88+
Currently, MaxText uses a few dependencies, such as `mlperf-logging` and `google-jetstream`, that are installed directly from GitHub source. These are defined in `base_requirements/requirements.txt`, and the `seed-env` tool will carry them over to the generated requirements files.
89+
90+
## 5. Verify the New Dependencies
91+
92+
Finally, test that the new dependencies install correctly and that MaxText runs as expected.
93+
94+
1. **Create a clean environment:** It's best to start with a fresh Python virtual environment.
95+
96+
```bash
97+
uv venv --python 3.12 --seed maxtext_venv
98+
source maxtext_venv/bin/activate
99+
```
100+
101+
2. **Run the setup script:** Execute `bash setup.sh` to install the new dependencies.
102+
103+
```bash
104+
pip install uv
105+
# install the tpu package
106+
uv pip install -e .[tpu] --resolution=lowest
107+
# or install the gpu package by running the following line:
108+
# uv pip install -e .[cuda12] --resolution=lowest
109+
install_maxtext_github_deps
110+
```
111+
112+
3. **Run tests:** Run MaxText tests to ensure there are no regressions.

0 commit comments

Comments
 (0)