# ai-hypercomputer/maxtext architecture

> Architecture diagram of the GitHub repository ai-hypercomputer/maxtext, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ai-hypercomputer/maxtext
- Repository: https://github.com/ai-hypercomputer/maxtext

## Overview

MaxText is a JAX-based LLM library for scalable TPU/GPU training and inference. The main workflow is to configure a run, load and prepare data, construct a supported model, train it, and save checkpoints; post-training, serving, evaluation, and checkpoint conversion are distinct branches. The graph combines sampled source relationships and README-documented capabilities. Several important subsystems are represented from the file tree and README without claiming their unsampled internals were inspected.

Main entry points: [`src/maxtext/configs/pyconfig.py`](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/configs/pyconfig.py) (Run configuration), [`src/maxtext/training_engine/maxtext_engine.py`](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/training_engine/maxtext_engine.py) (Training engine), [`src/maxtext/trainers/pre_train/train.py`](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/trainers/pre_train/train.py) (Pre-training), [`src/maxtext/utils/model_creation_utils.py`](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/utils/model_creation_utils.py) (Model construction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Training"]
  node_config["Run configuration<br/>[pyconfig.py]"]
  node_train_engine["Training engine<br/>[maxtext_engine.py]"]
  node_pretraining["Pre-training<br/>[train.py]"]
  node_posttraining["Post-training"]
  node_diloco["DiLoCo training<br/>[diloco.py]"]
end

subgraph group_models["Models and compute"]
  node_model_factory["Model construction"]
  node_model_families["Model families<br/>[models.py]"]
  node_layers["Model layers"]
  node_kernels["Accelerator kernels"]
  node_sharding["Device sharding<br/>[sharding.py]"]
end

subgraph group_serving["Inference and evaluation"]
  node_inference["Generation engine<br/>[maxengine.py]"]
  node_serving_api["Serving entrypoint"]
  node_evaluation["Evaluation framework<br/>[run.py]"]
  node_vllm["vLLM integration"]
end

subgraph group_lifecycle["Checkpoint lifecycle"]
  node_checkpointing[("Checkpointing<br/>[checkpointing.py]")]
  node_conversion["Checkpoint conversion"]
end

subgraph group_data["Data and modalities"]
  node_data_pipeline["Input pipeline"]
  node_data_processing["Data processing"]
  node_multimodal["Multimodal processing<br/>[processor.py]"]
end

node_user(("Engineer"))
node_external_storage[("Cloud storage")]

node_user -->|"configures run"| node_config
node_config -.->|"selects dataset"| node_data_pipeline
node_data_pipeline -->|"builds iterators"| node_data_processing
node_data_processing -->|"uses processors"| node_multimodal
node_config -->|"configures model"| node_model_factory
node_model_factory -->|"constructs models"| node_model_families
node_model_families -.->|"uses layers"| node_layers
node_layers -.->|"uses kernels"| node_kernels
node_train_engine -->|"builds model"| node_model_factory
node_train_engine -->|"reads settings"| node_config
node_train_engine -->|"uses shardings"| node_sharding
node_pretraining -->|"runs training"| node_train_engine
node_pretraining -.->|"loads batches"| node_data_pipeline
node_pretraining -.->|"saves state"| node_checkpointing
node_user -->|"starts training"| node_pretraining
node_user -->|"starts fine-tuning"| node_posttraining
node_user -->|"starts distributed run"| node_diloco
node_checkpointing -.->|"stores checkpoints"| node_external_storage
node_user -.->|"converts checkpoint"| node_conversion
node_user -.->|"requests generation"| node_serving_api
node_serving_api -->|"dispatches requests"| node_inference
node_inference -->|"creates model"| node_model_factory
node_inference -->|"loads settings"| node_config
node_evaluation -.->|"manages server"| node_serving_api
node_evaluation -->|"integrates runtime"| node_vllm
node_user -.->|"evaluates model"| node_evaluation

click node_config "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/configs/pyconfig.py"
click node_data_pipeline "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/input_pipeline/input_pipeline_interface.py"
click node_data_processing "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/input_pipeline/input_pipeline_utils.py"
click node_multimodal "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/multimodal/processor.py"
click node_model_factory "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/utils/model_creation_utils.py"
click node_model_families "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/models/models.py"
click node_layers "https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/layers"
click node_kernels "https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/kernels"
click node_sharding "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/utils/sharding.py"
click node_train_engine "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/training_engine/maxtext_engine.py"
click node_pretraining "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/trainers/pre_train/train.py"
click node_posttraining "https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/trainers/post_train"
click node_diloco "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/trainers/diloco/diloco.py"
click node_checkpointing "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/common/checkpointing.py"
click node_conversion "https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/checkpoint_conversion"
click node_inference "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/inference/maxengine/maxengine.py"
click node_serving_api "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/inference/maxengine/maxengine_server.py"
click node_evaluation "https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/eval/runner/run.py"
click node_vllm "https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/integration/vllm"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_config,node_train_engine,node_pretraining,node_posttraining,node_diloco toneBlue
class node_model_factory,node_model_families,node_layers,node_kernels,node_sharding,node_external_storage toneAmber
class node_inference,node_serving_api,node_evaluation,node_vllm toneMint
class node_checkpointing,node_conversion toneRose
class node_data_pipeline,node_data_processing,node_multimodal,node_user toneIndigo
```

## Components

### Training

- [Run configuration](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/configs/pyconfig.py): `src/maxtext/configs/pyconfig.py`
- [Training engine](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/training_engine/maxtext_engine.py): `src/maxtext/training_engine/maxtext_engine.py`
- [Pre-training](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/trainers/pre_train/train.py): `src/maxtext/trainers/pre_train/train.py`
- [Post-training](https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/trainers/post_train): `src/maxtext/trainers/post_train`
- [DiLoCo training](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/trainers/diloco/diloco.py): `src/maxtext/trainers/diloco/diloco.py`

### Models and compute

- [Model construction](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/utils/model_creation_utils.py): `src/maxtext/utils/model_creation_utils.py`
- [Model families](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/models/models.py): `src/maxtext/models/models.py`
- [Model layers](https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/layers): `src/maxtext/layers`
- [Accelerator kernels](https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/kernels): `src/maxtext/kernels`
- [Device sharding](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/utils/sharding.py): `src/maxtext/utils/sharding.py`

### Inference and evaluation

- [Generation engine](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/inference/maxengine/maxengine.py): `src/maxtext/inference/maxengine/maxengine.py`
- [Serving entrypoint](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/inference/maxengine/maxengine_server.py): `src/maxtext/inference/maxengine/maxengine_server.py`
- [Evaluation framework](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/eval/runner/run.py): `src/maxtext/eval/runner/run.py`
- [vLLM integration](https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/integration/vllm): `src/maxtext/integration/vllm`

### Checkpoint lifecycle

- [Checkpointing](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/common/checkpointing.py): `src/maxtext/common/checkpointing.py`
- [Checkpoint conversion](https://github.com/ai-hypercomputer/maxtext/tree/main/src/maxtext/checkpoint_conversion): `src/maxtext/checkpoint_conversion`

### Data and modalities

- [Input pipeline](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/input_pipeline/input_pipeline_interface.py): `src/maxtext/input_pipeline/input_pipeline_interface.py`
- [Data processing](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/input_pipeline/input_pipeline_utils.py): `src/maxtext/input_pipeline/input_pipeline_utils.py`
- [Multimodal processing](https://github.com/ai-hypercomputer/maxtext/blob/main/src/maxtext/multimodal/processor.py): `src/maxtext/multimodal/processor.py`

### Other components

- **Engineer**
- **Cloud storage**

## Connections

- Engineer → Run configuration: configures run (evidence: `README.md`)
- Run configuration → Input pipeline: selects dataset (evidence: `src/maxtext/input_pipeline/input_pipeline_interface.py`)
- Input pipeline → Data processing: builds iterators (evidence: `src/maxtext/input_pipeline/input_pipeline_interface.py`)
- Data processing → Multimodal processing: uses processors (evidence: `src/maxtext/input_pipeline/input_pipeline_utils.py`)
- Run configuration → Model construction: configures model (evidence: `src/maxtext/utils/model_creation_utils.py`)
- Model construction → Model families: constructs models (evidence: `src/maxtext/utils/model_creation_utils.py`)
- Model families → Model layers: uses layers
- Model layers → Accelerator kernels: uses kernels
- Training engine → Model construction: builds model (evidence: `src/maxtext/training_engine/maxtext_engine.py`)
- Training engine → Run configuration: reads settings (evidence: `src/maxtext/training_engine/maxtext_engine.py`)
- Training engine → Device sharding: uses shardings (evidence: `src/maxtext/training_engine/maxtext_engine.py`)
- Pre-training → Training engine: runs training (evidence: `src/maxtext/training_engine/maxtext_engine.py`)
- Pre-training → Input pipeline: loads batches
- Pre-training → Checkpointing: saves state
- Engineer → Pre-training: starts training (evidence: `README.md`)
- Engineer → Post-training: starts fine-tuning (evidence: `README.md`)
- Engineer → DiLoCo training: starts distributed run (evidence: `README.md`)
- Checkpointing → Cloud storage: stores checkpoints
- Engineer → Checkpoint conversion: converts checkpoint
- Engineer → Serving entrypoint: requests generation
- Serving entrypoint → Generation engine: dispatches requests (evidence: `src/maxtext/inference/maxengine/maxengine_server.py`)
- Generation engine → Model construction: creates model (evidence: `src/maxtext/inference/maxengine/maxengine.py`)
- Generation engine → Run configuration: loads settings (evidence: `src/maxtext/inference/maxengine/maxengine.py`)
- Evaluation framework → Serving entrypoint: manages server
- Evaluation framework → vLLM integration: integrates runtime
- Engineer → Evaluation framework: evaluates model
