|
89 | 89 | "source": [ |
90 | 90 | "## Installation: MaxText and Post training Dependencies\n", |
91 | 91 | "\n", |
92 | | - "**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", |
93 | | - "\n", |
94 | | - "\n", |
95 | | - "**Running the notebook on Google Colab:** Run the above-mentioned commands in the Colab and then restart session\n", |
| 92 | + "**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-source) before proceeding. And then run the notebook using that virtual environment." |
| 93 | + ] |
| 94 | + }, |
| 95 | + { |
| 96 | + "cell_type": "code", |
| 97 | + "execution_count": null, |
| 98 | + "metadata": {}, |
| 99 | + "outputs": [], |
| 100 | + "source": [ |
| 101 | + "if IN_COLAB:\n", |
| 102 | + " # Clone the MaxText repository\n", |
| 103 | + " !git clone https://github.com/AI-Hypercomputer/maxtext.git\n", |
| 104 | + " %cd maxtext\n", |
96 | 105 | "\n", |
| 106 | + " # Install uv, a fast Python package installer\n", |
| 107 | + " !pip install uv\n", |
| 108 | + " \n", |
| 109 | + " # Install MaxText and post-training dependencies\n", |
| 110 | + " !uv pip install -e .[tpu-post-train] --resolution=lowest\n", |
| 111 | + " !install_maxtext_tpu_post_train_extra_deps" |
| 112 | + ] |
| 113 | + }, |
| 114 | + { |
| 115 | + "cell_type": "markdown", |
| 116 | + "metadata": {}, |
| 117 | + "source": [ |
97 | 118 | "**Session restart Instructions for Colab:**\n", |
98 | 119 | "1. Navigate to the menu at the top of the screen.\n", |
99 | 120 | "2. Click on **Runtime**.\n", |
100 | 121 | "3. Select **Restart session** from the dropdown menu.\n", |
101 | 122 | "\n", |
102 | | - "You will be asked to confirm the action in a pop-up dialog. Click on **Yes**.\n" |
| 123 | + "You will be asked to confirm the action in a pop-up dialog. Click on **Yes**." |
103 | 124 | ] |
104 | 125 | }, |
105 | 126 | { |
|
119 | 140 | "import os\n", |
120 | 141 | "import sys\n", |
121 | 142 | "from pathlib import Path\n", |
122 | | - "import MaxText\n", |
123 | 143 | "from huggingface_hub import login\n", |
124 | 144 | "from etils import epath\n", |
125 | 145 | "import jax\n", |
126 | 146 | "\n", |
127 | 147 | "from maxtext.trainers.post_train.rl.train_rl import rl_train, setup_configs_and_devices\n", |
| 148 | + "from maxtext.utils.globals import MAXTEXT_REPO_ROOT, MAXTEXT_PKG_DIR\n", |
128 | 149 | "\n", |
129 | 150 | "os.environ[\"TF_CPP_MIN_LOG_LEVEL\"] = \"0\"\n", |
130 | 151 | "os.environ[\"SKIP_JAX_PRECOMPILE\"] = \"1\" # Faster startup for vLLM\n", |
131 | 152 | "# Suppress vLLM logging with a severity level below ERROR\n", |
132 | 153 | "os.environ[\"VLLM_LOGGING_LEVEL\"] = \"ERROR\"\n", |
133 | 154 | "\n", |
134 | | - "MAXTEXT_PKG_DIR = os.path.dirname(MaxText.__file__)\n", |
135 | | - "MAXTEXT_REPO_ROOT = os.sep.join([\"maxtext\" if p == \"MaxText\" else p for p in MAXTEXT_PKG_DIR.split(os.sep)])\n", |
| 155 | + "\n", |
136 | 156 | "print(f\"MaxText installation path: {MAXTEXT_PKG_DIR}\")" |
137 | 157 | ] |
138 | 158 | }, |
|
154 | 174 | "metadata": {}, |
155 | 175 | "outputs": [], |
156 | 176 | "source": [ |
157 | | - "if IN_COLAB:\n", |
| 177 | + "try:\n", |
| 178 | + " from google.colab import userdata\n", |
158 | 179 | " HF_TOKEN = userdata.get(\"HF_TOKEN\")\n", |
159 | | - "else:\n", |
| 180 | + "except ImportError:\n", |
160 | 181 | " HF_TOKEN = os.environ.get(\"HF_TOKEN\", \"\")\n", |
161 | 182 | "\n", |
162 | 183 | "# If not found in the environment, prompt the user for input securely\n", |
|
0 commit comments