Skip to content

Commit 661d6df

Browse files
committed
move examples
1 parent eebf286 commit 661d6df

22 files changed

Lines changed: 130 additions & 88 deletions

.github/workflows/run_jupyter_notebooks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ jobs:
9090
HF_TOKEN: ${{ secrets.HF_TOKEN }}
9191
run: |
9292
MAXTEXT_REPO_ROOT=$(pwd)
93-
MAXTEXT_NOTEBOOKS_ROOT="$MAXTEXT_REPO_ROOT/src/MaxText/examples"
93+
MAXTEXT_NOTEBOOKS_ROOT="$MAXTEXT_REPO_ROOT/src/maxtext/examples"
9494
95+
shopt -s nullglob # Prevents loop from running if no files match
9596
for notebook in "$MAXTEXT_NOTEBOOKS_ROOT"/{sft,rl}*.ipynb; do
9697
filename=$(basename "$notebook")
9798
output_name="${filename%.ipynb}_output.ipynb"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ See our guide on running MaxText in decoupled mode, without any GCP dependencies
4343

4444
* \[December 22, 2025\] [Muon optimizer](https://kellerjordan.github.io/posts/muon) is now supported.
4545
* \[December 10, 2025\] DeepSeek V3.1 is now supported. Use existing configs for [DeepSeek V3 671B](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/configs/models/deepseek3-671b.yml) and load in V3.1 checkpoint to use model.
46-
* \[December 9, 2025\] [New RL and SFT Notebook tutorials](https://github.com/AI-Hypercomputer/maxtext/tree/main/src/MaxText/examples) are available.
46+
* \[December 9, 2025\] [New RL and SFT Notebook tutorials](https://github.com/AI-Hypercomputer/maxtext/tree/main/src/maxtext/examples) are available.
4747
* \[December 4, 2025\] The [ReadTheDocs documentation site](https://maxtext.readthedocs.io/en/latest/index.html) has been reorganized.
4848
* \[December 3, 2025\] Multi-host support for GSPO and GRPO is now available via [new RL tutorials](https://maxtext.readthedocs.io/en/latest/tutorials/posttraining/rl_on_multi_host.html).
4949
* \[November 20, 2025\] A new guide, [What is Post Training in MaxText?](https://maxtext.readthedocs.io/en/latest/tutorials/post_training_index.html), is now available.

codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fixes:
3434
ignore:
3535
- "src/MaxText/assets"
3636
- "src/MaxText/configs"
37-
- "src/MaxText/examples"
37+
- "src/maxtext/examples"
3838
- "src/MaxText/experimental"
3939
- "src/MaxText/inference"
4040
- "src/MaxText/inference_mlperf"

docs/guides/run_python_notebook.md

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Before starting, make sure you have:
1919
- ✅ Basic familiarity with Jupyter, Python, and Git
2020

2121
**For Method 2 (Visual Studio Code) and Method 3 (Local Jupyter Lab) only:**
22+
2223
- ✅ A Google Cloud Platform (GCP) account with billing enabled
2324
- ✅ TPU quota available in your region (check under IAM & Admin → Quotas)
2425
-`tpu.nodes.create` permission to create a TPU VM
@@ -36,16 +37,18 @@ Currently, this method only supports the **`sft_qwen3_demo.ipynb`** notebook, wh
3637

3738
Before proceeding, please verify that the specific notebook you are running works reliably on the free-tier TPU resources. If you encounter frequent disconnections or resource limitations, you may need to:
3839

39-
* Upgrade to a Colab Pro or Pro+ subscription for more stable and powerful TPU access.
40+
- Upgrade to a Colab Pro or Pro+ subscription for more stable and powerful TPU access.
4041

41-
* Move to local Jupyter Lab setup method with access to a powerful TPU machine.
42+
- Move to local Jupyter Lab setup method with access to a powerful TPU machine.
4243

4344
### Step 1: Choose an Example
44-
1.a. Visit the [MaxText examples directory](https://github.com/AI-Hypercomputer/maxtext/tree/main/src/MaxText/examples) on Github.
45+
46+
1.a. Visit the [MaxText examples directory](https://github.com/AI-Hypercomputer/maxtext/tree/main/src/maxtext/examples) on Github.
4547

4648
1.b. Find the notebook you want to run (e.g., `sft_qwen3_demo.ipynb`) and copy its URL.
4749

4850
### Step 2: Import into Colab
51+
4952
2.a. Go to [Google Colab](https://colab.research.google.com/) and sign in.
5053

5154
2.b. Select **File** -> **Open Notebook**.
@@ -63,9 +66,11 @@ Before proceeding, please verify that the specific notebook you are running work
6366
3.c. Click **Save**
6467

6568
### Step 4: Run the Notebook
69+
6670
Follow the instructions within the notebook cells to install dependencies and run the training/inference.
6771

6872
## Method 2: Visual Studio Code with TPU (Recommended)
73+
6974
Running Jupyter notebooks in Visual Studio Code (VS Code) provides a powerful, interactive environment that combines the flexibility of notebooks with the robust features of a code editor. Follow these steps to get your environment up and running.
7075

7176
### Step 1: Set Up TPU VM
@@ -75,9 +80,10 @@ In Google Cloud Console, create a standalone TPU VM:
7580
1.a. **Compute Engine****TPUs****Create TPU**
7681

7782
1.b. Example config:
78-
- **Name:** `maxtext-tpu-node`
79-
- **TPU type:** Choose your desired TPU type
80-
- **Runtime Version:** `tpu-ubuntu2204-base` (or other compatible runtime)
83+
84+
- **Name:** `maxtext-tpu-node`
85+
- **TPU type:** Choose your desired TPU type
86+
- **Runtime Version:** `tpu-ubuntu2204-base` (or other compatible runtime)
8187

8288
### Step 2: SSH to TPU-VM via VS Code
8389

@@ -86,11 +92,12 @@ In Google Cloud Console, create a standalone TPU VM:
8692
2.b. Follow [Connect to a remote host](https://code.visualstudio.com/docs/remote/ssh#_connect-to-a-remote-host) guide to connect to your TPU-VM via VS Code.
8793

8894
### Step 3. Install Necessary Extensions on VS Code
95+
8996
To enable notebook support, you must install two official extensions from the VS Code Marketplace:
9097

91-
* Python Extension: Provides support for the Python language.
98+
- Python Extension: Provides support for the Python language.
9299

93-
* Jupyter Extension: Enables you to create, edit, and run `.ipynb` files directly inside VS Code.
100+
- Jupyter Extension: Enables you to create, edit, and run `.ipynb` files directly inside VS Code.
94101

95102
To install, click the `Extensions` icon on the left sidebar (or press `Ctrl+Shift+X` or `Cmd+Shift+X`), search for `Jupyter` and `Python`, and click `Install`.
96103

@@ -99,6 +106,7 @@ To install, click the `Extensions` icon on the left sidebar (or press `Ctrl+Shif
99106
To execute post-training notebooks on your TPU-VM, follow the official [MaxText installation guides](https://maxtext.readthedocs.io/en/latest/tutorials/posttraining/rl.html#create-virtual-environment-and-install-maxtext-dependencies) to install MaxText and its dependencies inside a dedicated virtual environment.
100107

101108
### Step 5: Install the necessary library for Jupyter
109+
102110
Jupyter requires a kernel to execute code. This kernel is tied to a specific Python environment. Open your terminal inside VS Code and run:
103111

104112
```bash
@@ -110,9 +118,9 @@ uv pip install ipykernel
110118
Before you can run the notebook, you must tell VS Code which Python environment to use.
111119

112120
1. Look at the top-right corner of the notebook editor.
113-
2. Click `Select Kernel`.
114-
3. Choose Python Environments and select the virtual environment you created in Step 4.
115-
4. Open [available post-training notebooks in MaxText](#available-examples) inside VS Code and run the jupyter notebook cells.
121+
1. Click `Select Kernel`.
122+
1. Choose Python Environments and select the virtual environment you created in Step 4.
123+
1. Open [available post-training notebooks in MaxText](#available-examples) inside VS Code and run the jupyter notebook cells.
116124

117125
## Method 3: Local Jupyter Lab with TPU (Recommended)
118126

@@ -125,12 +133,15 @@ In Google Cloud Console, create a standalone TPU VM:
125133
1.a. **Compute Engine****TPUs****Create TPU**
126134

127135
1.b. Example config:
128-
- **Name:** `maxtext-tpu-node`
129-
- **TPU type:** Choose your desired TPU type
130-
- **Runtime Version:** `tpu-ubuntu2204-base` (or other compatible runtime)
136+
137+
- **Name:** `maxtext-tpu-node`
138+
- **TPU type:** Choose your desired TPU type
139+
- **Runtime Version:** `tpu-ubuntu2204-base` (or other compatible runtime)
131140

132141
### Step 2: Connect with Port Forwarding
142+
133143
Run the following command on your local machine:
144+
134145
> **Note**: The `--` separator before the `-L` flag is required. This tunnels the remote port 8888 to your local machine securely.
135146
136147
```bash
@@ -170,13 +181,15 @@ jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root
170181
```
171182

172183
### Step 7: Access the Notebook
184+
173185
7.a. Look at the terminal output for a URL that looks like: `http://127.0.0.1:8888/lab?token=...`.
174186

175187
7.b. Copy that URL.
176188

177189
7.c. Paste it into your **local computer's browser**.
178-
* **Important:** If you changed the port in Step 2 (e.g., to `9999`), you must manually replace `8888` in the URL with `9999`.
179-
* *Example:* `http://127.0.0.1:9999/lab?token=...`
190+
191+
- **Important:** If you changed the port in Step 2 (e.g., to `9999`), you must manually replace `8888` in the URL with `9999`.
192+
- *Example:* `http://127.0.0.1:9999/lab?token=...`
180193

181194
7.d. Once the interface opens in your browser, Click on the current kernel name (e.g., `Python 3 (ipykernel)`).
182195

@@ -197,13 +210,13 @@ jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root
197210

198211
## Common Pitfalls & Debugging
199212

200-
| Issue | Solution |
201-
|-------|----------|
202-
| ❌ TPU runtime mismatch | Check TPU runtime version matches VM image |
203-
| ❌ Colab disconnects | Save checkpoints to GCS or Drive regularly |
204-
| ❌ "RESOURCE_EXHAUSTED" errors | Use smaller batch size or v5e-8 instead of v5e-1 |
205-
| ❌ Firewall blocked | Ensure port 8888 open, or always use SSH tunneling |
206-
| ❌ Path confusion | In Colab use `/content/maxtext`; in TPU VM use `~/maxtext` |
213+
| Issue | Solution |
214+
| ------------------------------ | ---------------------------------------------------------- |
215+
| ❌ TPU runtime mismatch | Check TPU runtime version matches VM image |
216+
| ❌ Colab disconnects | Save checkpoints to GCS or Drive regularly |
217+
| ❌ "RESOURCE_EXHAUSTED" errors | Use smaller batch size or v5e-8 instead of v5e-1 |
218+
| ❌ Firewall blocked | Ensure port 8888 open, or always use SSH tunneling |
219+
| ❌ Path confusion | In Colab use `/content/maxtext`; in TPU VM use `~/maxtext` |
207220

208221
## Support and Resources
209222

@@ -217,9 +230,9 @@ jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --allow-root
217230
If you encounter issues or have improvements for this guide, please:
218231

219232
1. Open an issue on the MaxText repository
220-
2. Submit a pull request with your improvements
221-
3. Share your experience in the discussions
233+
1. Submit a pull request with your improvements
234+
1. Share your experience in the discussions
222235

223-
---
236+
______________________________________________________________________
224237

225-
**Happy Training! 🚀**
238+
**Happy Training! 🚀**

docs/tutorials/first_run.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ In the same TPU VM where you just installed all the dependencies of MaxText, You
7575

7676
#### Decoding in MaxText via notebook
7777

78-
You can use [demo_decoding.ipynb](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/examples/demo_decoding.ipynb) to try out decoding on MaxText's `Llama3.1-8b` model implementation. In this notebook, we give `"I love to"` as the prompt, and the greedily sampled first output token is `" cook"`. Please remember to provide the path to your `Llama3.1-8b` checkpoint for the `load_parameters_path` argument in the config inside the notebook. You can use [to_maxtext.py](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/utils/ckpt_conversion/to_maxtext.py) to create a MaxText/Orbax checkpoint from a Huggingface checkpoint.
78+
You can use [demo_decoding.ipynb](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/demo_decoding.ipynb) to try out decoding on MaxText's `Llama3.1-8b` model implementation. In this notebook, we give `"I love to"` as the prompt, and the greedily sampled first output token is `" cook"`. Please remember to provide the path to your `Llama3.1-8b` checkpoint for the `load_parameters_path` argument in the config inside the notebook. You can use [to_maxtext.py](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/utils/ckpt_conversion/to_maxtext.py) to create a MaxText/Orbax checkpoint from a Huggingface checkpoint.
79+
>>>>>>> fdeee6de (move examples)
80+
You can use [demo_decoding.ipynb](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/demo_decoding.ipynb) to try out decoding on MaxText's `Llama3.1-8b` model implementation. In this notebook, we give `"I love to"` as the prompt, and the greedily sampled first output token is `" cook"`. Please remember to provide the path to your `Llama3.1-8b` checkpoint for the `load_parameters_path` argument in the config inside the notebook. You can use [to_maxtext.py](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/utils/ckpt_conversion/to_maxtext.py) to create a MaxText/Orbax checkpoint from a Huggingface checkpoint.
81+
=======
82+
You can use [demo_decoding.ipynb](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/demo_decoding.ipynb) to try out decoding on MaxText's `Llama3.1-8b` model implementation. In this notebook, we give `"I love to"` as the prompt, and the greedily sampled first output token is `" cook"`. Please remember to provide the path to your `Llama3.1-8b` checkpoint for the `load_parameters_path` argument in the config inside the notebook. You can use [to_maxtext.py](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/utils/ckpt_conversion/to_maxtext.py) to create a MaxText/Orbax checkpoint from a Huggingface checkpoint.
83+
>>>>>>> fdeee6de (move examples)
7984
8085
### Run MaxText on NVIDIA GPUs
8186

docs/tutorials/posttraining/multimodal.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ This document provides a guide to use the multimodal functionalities in MaxText
66
- **Multimodal Decode**: Inference with text+images as input.
77
- **Supervised Fine-Tuning (SFT)**: Apply SFT to the model using a visual-question-answering dataset.
88

9-
We also provide a [colab](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/MaxText/examples/multimodal_gemma3_demo.ipynb) for multimodal features demonstration. The following table provides a list of models and modalities we currently support:
9+
We also provide a [colab](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/multimodal_gemma3_demo.ipynb) for multimodal features demonstration. The following table provides a list of models and modalities we currently support:
10+
>>>>>>> fdeee6de (move examples)
11+
We also provide a [colab](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/multimodal_gemma3_demo.ipynb) for multimodal features demonstration. The following table provides a list of models and modalities we currently support:
12+
=======
13+
We also provide a [colab](https://github.com/AI-Hypercomputer/maxtext/blob/main/src/maxtext/examples/multimodal_gemma3_demo.ipynb) for multimodal features demonstration. The following table provides a list of models and modalities we currently support:
14+
>>>>>>> fdeee6de (move examples)
1015
1116
| Models | Input Modalities | Output Modalities |
1217
| :--------------------------------------------- | :--------------- | :---------------- |

pedagogical_examples/__init__.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/MaxText/configs/rl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ reasoning_start_token: '<reasoning>'
166166
reasoning_end_token: '</reasoning>'
167167
solution_start_token: '<answer>'
168168
solution_end_token: '</answer>'
169-
chat_template_path: 'src/MaxText/examples/chat_templates/gsm8k_rl.json'
169+
chat_template_path: 'src/maxtext/examples/chat_templates/gsm8k_rl.json'
170170
skip_jax_distributed_system: True
171171

172172
# # TODO(@mazumdera): fix this

src/MaxText/maxtext_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
# pylint: disable=line-too-long, disable=bare-except, consider-using-generator
1616
""" Utils that are only interesting to MaxText. """
1717

18-
"""This is PR#3000!"""
19-
2018
import functools
2119
import pickle
2220
import os

src/maxtext/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2023–2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
MaxText is a high performance, highly scalable, open-source LLM written in pure Python/Jax and targeting Google Cloud
17+
TPUs and GPUs for training and inference. MaxText achieves high MFUs and scales from single host to very large clusters
18+
while staying simple and "optimization-free" thanks to the power of Jax and the XLA compiler.
19+
"""
20+
21+
__author__ = "Google LLC"
22+
__version__ = "0.1.1"
23+
__description__ = (
24+
"MaxText is a high performance, highly scalable, open-source LLM written in pure Python/Jax and "
25+
"targeting Google Cloud TPUs and GPUs for training and **inference."
26+
)
27+
28+
from MaxText.layers import models
29+
30+
Transformer = models.Transformer
31+
transformer_as_linen = models.transformer_as_linen

0 commit comments

Comments
 (0)