Install MaxText

Install MaxText#

This document discusses how to install MaxText.

We recommend installing MaxText inside a Python virtual environment and using the uv package manager following uv’s official installation instructions.

Note

MaxText is only tested on Linux during releases.

From source#

If you plan to contribute to MaxText or need the latest unreleased features, install from source.

Important

If you want to switch to a different installation option (e.g., from [tpu] to [tpu-post-train]), we strongly recommend starting with a fresh virtual environment to avoid dependency conflicts.

  1. Clone the repository:

    git clone https://github.com/AI-Hypercomputer/maxtext.git
    cd maxtext
    

By default, cloning the repository provides the latest version (HEAD). If you wish to use the latest features, please follow the latest guide. If you want to ensure compatibility with the specific version of the documentation you are currently viewing, you must checkout the corresponding tag for that version before proceeding with the installation.

git checkout latest
  1. Create virtual environment:

    uv venv --python 3.12 --seed <virtual env name>
    source <virtual env name>/bin/activate
    
  2. Install dependencies in editable mode. Choose a single installation option from this list to fit your use case.

    • Option 1: Install .[tpu]:

      uv pip install -e .[tpu] --resolution=lowest
      install_tpu_pre_train_extra_deps
      
    • Option 2: Install .[cuda12]

      uv pip install -e .[cuda12] --resolution=lowest
      install_cuda12_pre_train_extra_deps
      
    • Option 3: Install .[tpu-post-train]

      uv pip install -e .[tpu-post-train] --resolution=lowest
      install_tpu_post_train_extra_deps
      
    • Option 4: Install .[runner]

      uv pip install -e .[runner] --resolution=lowest
      

After installation, you can verify the package is available with python3 -c "import maxtext" and run training jobs with python3 -m maxtext.trainers.pre_train.train ....