Overview
[This doc is under construction]
MaxText
MaxText is high performance scalable LLM framework by Google written in Python and JAX. We support the upstream maxtext and have containers that can support the MaxText main branch out-of-the-box. While training, we strongly recommend to use propoer XLA flags pointed below.
Hardware and Software Specifications
Functionality and performance have been validated on NVIDIA DGX H100 (8x H100 80G) nodes; please refer to the Configs section below for some initial configs and performance numbers. We will continue to populate it with more models and configs. We provide both singlenode and multinode pre-training support. If running on a machine with less than 80G memory, some of the default configurations may run out of memory; if you run out of memory and have more GPUs available, increase your GPU count and decrease your batch size per GPU.
The NVIDIA Container Toolkit is required to run the subsequent commands with GPU support. Ensure the NVIDIA Container Toolkit is installed before proceeding.
Containers
We provide a fully built and ready-to-use multi-arch container which includes the latest optimizations, experimental features, and examples benchmarked for multi-node, multi-GPU training: nvcr.io/nvidia/jax:25.10-maxtext-py3 (amd64 support). Verified containers will be updated periodically, but if you wish to use the bleeding edge (which may come with unexpected behavior), please use ghcr.io/nvidia/jax:maxtext. We also provide nightly dated images with the naming pattern ghcr.io/nvidia/jax:maxtext-YYYY-MM-DD, but we encourage you to use the latest ones for the best performance.
Note: All paths mentioned in subsequent sections are relative to the top-level directory of the MaxText repository. When working interactively with containers, make sure you navigate to /opt/maxtext before running any commmands.
Downloading the C4 dataset
You can use download_dataset.sh script to download the C4 dataset. For details regarding the dataset download please see these guidelines. Alternatively, you can pass set this argument dataset_type=synthetic while launching the training script to use a synthetic dataset which is quite helpful to debug the initial performance.
Launching a container
Use the following command to launch a container:
where WORKSPACE_PATH is the path to the directory where you would like to store any persistent files and container is the name of the maxtext container. You can additionally add dataset and vocab paths with the -v flag.
Running a job
Quick Runs
Interactive: Single node
Once the container is up and running, you can quickly launch a job with the following command
You can similarly launch a llama2-7b training job with following command:
Running with Flash Attention
Currently, MaxText offers flash attention through Transformer Engine. In order to use flash attention, please select the proper attention type through attention=cudnn_flash_te argument. Additionally you need to set export NVTE_FUSED_ATTN=1. Also if you are interested in using minimal remat policy, for flash attention, please specify remat_policy=minimal_flash. This optionally saves the flash attention output tensor named 'context'.
Running a multinode job
Please see the example_slurm.sub for a multinode multiprocess job. For a single node (8 GPUs) llama2-7b run, the command should look like:
If can edit the script to add necessary mounts and paths or you can also pass them with the command line like this:
In order to obtain the best performance, please set the appropriate XLA flags. We further discuss it below:
XLA Flags
The GPU Performance document provides a detailed description of the XLA flags that can be set to optimize performance. These are the recommended XLA flags to get good performance for MaxText.
Configs
LLaMA
We have run some intial performance and functionality tests with LLaMA2-7B model. The table below shows the current performance of the given configs. Experiments were run using NVIDIA DGX H100 80G nodes.
Please refer to the example run script for more details. We will continue to add more models and associated performance metrics.
Notes
-
The only changes we need to support multiprocessing is to pin tensorflow and tensorflow-text to 2.18.0 version or higher.
-
In order to remove extra copies introduced by DUS (dynamic update slice) when used in conjunction with custom NVIDIA kernels (like cuBLAS for GEMMs), the
--xla_gpu_enable_custom_fusionsand--xla_gpu_enable_address_computation_fusionflags were introduced. However, the current XLA has some limitation and sometimes using these flags lead to error. So, in this release, it is advised to turn off these two flags:- —xla_gpu_enable_custom_fusions=false
- —xla_gpu_enable_address_computation_fusion=false
In addtion to the above XLA flags, you may need to add these two flags.