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/run_python_notebook.md
+39-26Lines changed: 39 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,7 @@ Before starting, make sure you have:
19
19
- ✅ Basic familiarity with Jupyter, Python, and Git
20
20
21
21
**For Method 2 (Visual Studio Code) and Method 3 (Local Jupyter Lab) only:**
22
+
22
23
- ✅ A Google Cloud Platform (GCP) account with billing enabled
23
24
- ✅ TPU quota available in your region (check under IAM & Admin → Quotas)
24
25
- ✅ `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
36
37
37
38
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:
38
39
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.
40
41
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.
42
43
43
44
### Step 1: Choose an Example
45
+
44
46
1.a. Visit the [MaxText examples directory](https://github.com/AI-Hypercomputer/maxtext/tree/main/src/MaxText/examples) on Github.
45
47
46
48
1.b. Find the notebook you want to run (e.g., `sft_qwen3_demo.ipynb`) and copy its URL.
47
49
48
50
### Step 2: Import into Colab
51
+
49
52
2.a. Go to [Google Colab](https://colab.research.google.com/) and sign in.
50
53
51
54
2.b. Select **File** -> **Open Notebook**.
@@ -63,9 +66,11 @@ Before proceeding, please verify that the specific notebook you are running work
63
66
3.c. Click **Save**
64
67
65
68
### Step 4: Run the Notebook
69
+
66
70
Follow the instructions within the notebook cells to install dependencies and run the training/inference.
67
71
68
72
## Method 2: Visual Studio Code with TPU (Recommended)
73
+
69
74
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.
70
75
71
76
### Step 1: Set Up TPU VM
@@ -75,9 +80,10 @@ In Google Cloud Console, create a standalone TPU VM:
-**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)
81
87
82
88
### Step 2: SSH to TPU-VM via VS Code
83
89
@@ -86,11 +92,12 @@ In Google Cloud Console, create a standalone TPU VM:
86
92
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.
87
93
88
94
### Step 3. Install Necessary Extensions on VS Code
95
+
89
96
To enable notebook support, you must install two official extensions from the VS Code Marketplace:
90
97
91
-
* Python Extension: Provides support for the Python language.
98
+
- Python Extension: Provides support for the Python language.
92
99
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.
94
101
95
102
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`.
96
103
@@ -99,6 +106,7 @@ To install, click the `Extensions` icon on the left sidebar (or press `Ctrl+Shif
99
106
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.
100
107
101
108
### Step 5: Install the necessary library for Jupyter
109
+
102
110
Jupyter requires a kernel to execute code. This kernel is tied to a specific Python environment. Open your terminal inside VS Code and run:
103
111
104
112
```bash
@@ -110,9 +118,9 @@ uv pip install ipykernel
110
118
Before you can run the notebook, you must tell VS Code which Python environment to use.
111
119
112
120
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.
116
124
117
125
## Method 3: Local Jupyter Lab with TPU (Recommended)
118
126
@@ -125,12 +133,15 @@ In Google Cloud Console, create a standalone TPU VM:
0 commit comments