|
95 | 95 | " IN_COLAB = False" |
96 | 96 | ] |
97 | 97 | }, |
| 98 | + { |
| 99 | + "cell_type": "markdown", |
| 100 | + "metadata": { |
| 101 | + "id": "D9ms-jTSZUQL" |
| 102 | + }, |
| 103 | + "source": [ |
| 104 | + "## Installation: MaxText and Post training Dependencies\n", |
| 105 | + "\n", |
| 106 | + "**Running the notebook on Visual Studio or JupyterLab:** Create an virtual environment and install post-training dependencies outside of the notebook using the commands in [MaxText installation and dependency setup guide](https://maxtext.readthedocs.io/en/latest/install_maxtext.html#from-pypi-recommended) before proceeding. And then run the notebook using that virtual environment." |
| 107 | + ] |
| 108 | + }, |
98 | 109 | { |
99 | 110 | "cell_type": "code", |
100 | 111 | "execution_count": null, |
101 | 112 | "metadata": {}, |
102 | 113 | "outputs": [], |
103 | 114 | "source": [ |
104 | | - "try:\n", |
105 | | - " import google.colab\n", |
106 | | - " print(\"Running the notebook in Google Colab\")\n", |
107 | | - " IN_COLAB = True\n", |
108 | | - "except ImportError:\n", |
109 | | - " print(\"Running the notebook on JupyterLab\")\n", |
110 | | - " IN_COLAB = False" |
| 115 | + "if IN_COLAB:\n", |
| 116 | + " # Install uv, a fast Python package installer\n", |
| 117 | + " !pip install uv\n", |
| 118 | + " \n", |
| 119 | + " # Install MaxText and post-training dependencies\n", |
| 120 | + " !uv pip install -e .[tpu-post-train] --resolution=lowest\n", |
| 121 | + " !python3 -m MaxText.install_maxtext_extra_deps" |
111 | 122 | ] |
112 | 123 | }, |
113 | 124 | { |
114 | 125 | "cell_type": "markdown", |
115 | | - "metadata": { |
116 | | - "id": "D9ms-jTSZUQL" |
117 | | - }, |
| 126 | + "metadata": {}, |
118 | 127 | "source": [ |
119 | | - "## Installation: MaxText and Post training Dependencies\n", |
120 | | - "\n", |
121 | | - "**Running the notebook on Visual Studio or JupyterLab:** Create an virtual environment and install dependencies outside of the notebook using the commands in [MaxText installation and dependency setup guide](../../../docs/guides/run_python_notebook.md#step-4-install-maxtext-and-dependencies) before proceeding. And then run the notebook using that virtual environment.\n", |
122 | | - "\n", |
123 | | - "\n", |
124 | | - "**Running the notebook on Google Colab:** Run the above-mentioned commands in the Colab and then restart session\n", |
125 | | - "\n", |
126 | 128 | "**Session restart Instructions for Colab:**\n", |
127 | 129 | "1. Navigate to the menu at the top of the screen.\n", |
128 | 130 | "2. Click on **Runtime**.\n", |
129 | 131 | "3. Select **Restart session** from the dropdown menu.\n", |
130 | 132 | "\n", |
131 | | - "You will be asked to confirm the action in a pop-up dialog. Click on **Yes**.\n" |
| 133 | + "You will be asked to confirm the action in a pop-up dialog. Click on **Yes**." |
132 | 134 | ] |
133 | 135 | }, |
134 | 136 | { |
|
168 | 170 | "from datetime import datetime\n", |
169 | 171 | "from flax import nnx\n", |
170 | 172 | "from huggingface_hub import login\n", |
| 173 | + "from jax import numpy as jnp\n", |
171 | 174 | "\n", |
172 | 175 | "print(f\"MaxText installation path: {MAXTEXT_PKG_DIR}\")" |
173 | 176 | ] |
|
192 | 195 | }, |
193 | 196 | "outputs": [], |
194 | 197 | "source": [ |
195 | | - "try:\n", |
196 | | - " from google.colab import userdata\n", |
| 198 | + "if IN_COLAB:\n", |
197 | 199 | " HF_TOKEN = userdata.get(\"HF_TOKEN\")\n", |
198 | | - "except ImportError:\n", |
| 200 | + "else:\n", |
199 | 201 | " HF_TOKEN = os.environ.get(\"HF_TOKEN\", \"\")\n", |
200 | 202 | "\n", |
201 | 203 | "# If not found in the environment, prompt the user for input securely\n", |
|
438 | 440 | " rollout_vllm_hbm_utilization=0.8,\n", |
439 | 441 | " rollout_vllm_init_with_random_weights=True,\n", |
440 | 442 | " rollout_vllm_tpu_backend_type=\"jax\",\n", |
| 443 | + " data_type=jnp.bfloat16,\n", |
441 | 444 | " ),\n", |
442 | 445 | ")" |
443 | 446 | ] |
|
0 commit comments