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
    
  2. Create virtual environment:

    uv venv --python 3.12 --seed <VENV_NAME>
    source <VENV_NAME>/bin/activate
    
  3. 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_TORCH_BACKEND=cpu 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
      

Verify installation#

After installing MaxText (either from PyPI or from source), verify that your virtual environment is healthy and free of package version conflicts:

  1. Verify the environment has no dependency conflicts:

    uv pip check
    

    Note

    If uv pip check reports any package version conflicts, they can usually be resolved by starting with a fresh virtual environment (see above) and reinstalling using the platform-specific target and the --resolution=lowest flag to ensure all dependencies resolve to their verified versions.

  2. Verify MaxText is importable and runnable:

    python3 -c "import maxtext"
    python3 -m maxtext.trainers.pre_train.train --help