# microsoft/climax architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/climax
- Repository: https://github.com/microsoft/climax

## Overview

ClimaX is a foundation-model codebase for weather and climate tasks. The principal workflow is preparing gridded climate data, assembling training batches, and training or evaluating a task-specific model: self-supervised pretraining, global forecasting, regional forecasting, or ClimateBench projection. Shared transformer architecture and utilities support these task stages. The README identifies the product but does not document detailed runtime wiring; connections below rely on source-index references and the shown excerpts, so unverified links are omitted.

Main entry points: [`src/climax/arch.py`](https://github.com/microsoft/climax/blob/main/src/climax/arch.py) (ClimaX backbone), [`src/climax/pretrain/module.py`](https://github.com/microsoft/climax/blob/main/src/climax/pretrain/module.py) (Pretraining task), [`src/climax/global_forecast/module.py`](https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/module.py) (Global forecast), [`src/climax/regional_forecast/module.py`](https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/module.py) (Regional forecast)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared model"]
  node_core_model["ClimaX backbone<br/>[arch.py]"]
  node_patch_embed["Patch embedding"]
  node_position["Position embeddings<br/>[pos_embed.py]"]
  node_metrics["Climate metrics<br/>[metrics.py]"]
  node_scheduler["LR scheduler<br/>[lr_scheduler.py]"]
end

subgraph group_tasks["Climate tasks"]
  node_pretrain_task["Pretraining task<br/>[module.py]"]
  node_pretrain_run["Pretraining entry<br/>[train.py]"]
  node_global_task["Global forecast<br/>[module.py]"]
  node_global_run["Global training<br/>[train.py]"]
  node_regional_arch["Regional architecture<br/>[arch.py]"]
  node_regional_task["Regional forecast<br/>[module.py]"]
  node_regional_run["Regional training<br/>[train.py]"]
  node_projection_arch["Projection architecture<br/>[arch.py]"]
  node_projection_task["Climate projection<br/>[module.py]"]
  node_projection_run["Projection training<br/>[train.py]"]
end

subgraph group_data["Data pipeline"]
  node_pretrain_data["Pretraining data<br/>[datamodule.py]"]
  node_forecast_dataset["Forecast dataset<br/>[dataset.py]"]
  node_global_data["Global data<br/>[datamodule.py]"]
  node_regional_data["Regional data<br/>[datamodule.py]"]
  node_projection_data["Projection data<br/>[datamodule.py]"]
  node_projection_dataset["Projection dataset<br/>[dataset.py]"]
end

subgraph group_support["Data preparation"]
  node_data_utils["Climate data utilities<br/>[data_utils.py]"]
  node_preprocess["Data conversion"]
  node_era_convert["ERA5 conversion"]
  node_regrid["Climate regridding<br/>[regrid.py]"]
  node_bench_regrid["Benchmark regridding"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts training"| node_pretrain_run
node_researcher -->|"starts training"| node_global_run
node_researcher -->|"starts training"| node_regional_run
node_researcher -->|"starts training"| node_projection_run
node_pretrain_run -->|"sets up data"| node_pretrain_data
node_pretrain_run -->|"trains task"| node_pretrain_task
node_global_run -->|"sets up data"| node_global_data
node_global_run -->|"trains task"| node_global_task
node_regional_run -->|"sets up data"| node_regional_data
node_regional_run -->|"trains task"| node_regional_task
node_projection_run -->|"sets up data"| node_projection_data
node_projection_run -->|"trains task"| node_projection_task
node_pretrain_data -->|"builds batches"| node_forecast_dataset
node_global_data -->|"uses dataset"| node_forecast_dataset
node_regional_data -->|"uses dataset"| node_forecast_dataset
node_projection_data -->|"loads examples"| node_projection_dataset
node_pretrain_task -->|"trains backbone"| node_core_model
node_global_task -->|"runs backbone"| node_core_model
node_regional_arch -->|"extends backbone"| node_core_model
node_regional_task -->|"trains architecture"| node_regional_arch
node_projection_arch -->|"extends backbone"| node_core_model
node_projection_task -->|"trains architecture"| node_projection_arch
node_core_model -->|"uses embedding"| node_patch_embed
node_core_model -->|"uses embeddings"| node_position
node_projection_arch -->|"uses embeddings"| node_position
node_pretrain_task -->|"computes metrics"| node_metrics
node_pretrain_task -->|"configures schedule"| node_scheduler
node_global_task -->|"computes metrics"| node_metrics
node_global_task -->|"configures schedule"| node_scheduler
node_regional_task -->|"computes metrics"| node_metrics
node_regional_task -->|"configures schedule"| node_scheduler
node_projection_task -->|"computes metrics"| node_metrics
node_projection_task -->|"configures schedule"| node_scheduler
node_preprocess -->|"uses mappings"| node_data_utils
node_era_convert -->|"uses mappings"| node_data_utils

click node_core_model "https://github.com/microsoft/climax/blob/main/src/climax/arch.py"
click node_patch_embed "https://github.com/microsoft/climax/blob/main/src/climax/parallelpatchembed.py"
click node_position "https://github.com/microsoft/climax/blob/main/src/climax/utils/pos_embed.py"
click node_pretrain_data "https://github.com/microsoft/climax/blob/main/src/climax/pretrain/datamodule.py"
click node_forecast_dataset "https://github.com/microsoft/climax/blob/main/src/climax/pretrain/dataset.py"
click node_pretrain_task "https://github.com/microsoft/climax/blob/main/src/climax/pretrain/module.py"
click node_pretrain_run "https://github.com/microsoft/climax/blob/main/src/climax/pretrain/train.py"
click node_global_data "https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/datamodule.py"
click node_global_task "https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/module.py"
click node_global_run "https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/train.py"
click node_regional_arch "https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/arch.py"
click node_regional_data "https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/datamodule.py"
click node_regional_task "https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/module.py"
click node_regional_run "https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/train.py"
click node_projection_arch "https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/arch.py"
click node_projection_data "https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/datamodule.py"
click node_projection_dataset "https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/dataset.py"
click node_projection_task "https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/module.py"
click node_projection_run "https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/train.py"
click node_metrics "https://github.com/microsoft/climax/blob/main/src/climax/utils/metrics.py"
click node_scheduler "https://github.com/microsoft/climax/blob/main/src/climax/utils/lr_scheduler.py"
click node_data_utils "https://github.com/microsoft/climax/blob/main/src/climax/utils/data_utils.py"
click node_preprocess "https://github.com/microsoft/climax/blob/main/src/data_preprocessing/nc2np_equally_cmip6.py"
click node_era_convert "https://github.com/microsoft/climax/blob/main/src/data_preprocessing/nc2np_equally_era5.py"
click node_regrid "https://github.com/microsoft/climax/blob/main/src/data_preprocessing/regrid.py"
click node_bench_regrid "https://github.com/microsoft/climax/blob/main/src/data_preprocessing/regrid_climatebench.py"

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_core_model,node_patch_embed,node_position,node_metrics,node_scheduler toneBlue
class node_pretrain_task,node_pretrain_run,node_global_task,node_global_run,node_regional_arch,node_regional_task,node_regional_run,node_projection_arch,node_projection_task,node_projection_run toneAmber
class node_pretrain_data,node_forecast_dataset,node_global_data,node_regional_data,node_projection_data,node_projection_dataset toneMint
class node_data_utils,node_preprocess,node_era_convert,node_regrid,node_bench_regrid toneRose
class node_researcher toneIndigo
```

## Components

### Shared model

- [ClimaX backbone](https://github.com/microsoft/climax/blob/main/src/climax/arch.py): `src/climax/arch.py`
- [Patch embedding](https://github.com/microsoft/climax/blob/main/src/climax/parallelpatchembed.py): `src/climax/parallelpatchembed.py`
- [Position embeddings](https://github.com/microsoft/climax/blob/main/src/climax/utils/pos_embed.py): `src/climax/utils/pos_embed.py`
- [Climate metrics](https://github.com/microsoft/climax/blob/main/src/climax/utils/metrics.py): `src/climax/utils/metrics.py`
- [LR scheduler](https://github.com/microsoft/climax/blob/main/src/climax/utils/lr_scheduler.py): `src/climax/utils/lr_scheduler.py`

### Climate tasks

- [Pretraining task](https://github.com/microsoft/climax/blob/main/src/climax/pretrain/module.py): `src/climax/pretrain/module.py`
- [Pretraining entry](https://github.com/microsoft/climax/blob/main/src/climax/pretrain/train.py): `src/climax/pretrain/train.py`
- [Global forecast](https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/module.py): `src/climax/global_forecast/module.py`
- [Global training](https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/train.py): `src/climax/global_forecast/train.py`
- [Regional architecture](https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/arch.py): `src/climax/regional_forecast/arch.py`
- [Regional forecast](https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/module.py): `src/climax/regional_forecast/module.py`
- [Regional training](https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/train.py): `src/climax/regional_forecast/train.py`
- [Projection architecture](https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/arch.py): `src/climax/climate_projection/arch.py`
- [Climate projection](https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/module.py): `src/climax/climate_projection/module.py`
- [Projection training](https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/train.py): `src/climax/climate_projection/train.py`

### Data pipeline

- [Pretraining data](https://github.com/microsoft/climax/blob/main/src/climax/pretrain/datamodule.py): `src/climax/pretrain/datamodule.py`
- [Forecast dataset](https://github.com/microsoft/climax/blob/main/src/climax/pretrain/dataset.py): `src/climax/pretrain/dataset.py`
- [Global data](https://github.com/microsoft/climax/blob/main/src/climax/global_forecast/datamodule.py): `src/climax/global_forecast/datamodule.py`
- [Regional data](https://github.com/microsoft/climax/blob/main/src/climax/regional_forecast/datamodule.py): `src/climax/regional_forecast/datamodule.py`
- [Projection data](https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/datamodule.py): `src/climax/climate_projection/datamodule.py`
- [Projection dataset](https://github.com/microsoft/climax/blob/main/src/climax/climate_projection/dataset.py): `src/climax/climate_projection/dataset.py`

### Data preparation

- [Climate data utilities](https://github.com/microsoft/climax/blob/main/src/climax/utils/data_utils.py): `src/climax/utils/data_utils.py`
- [Data conversion](https://github.com/microsoft/climax/blob/main/src/data_preprocessing/nc2np_equally_cmip6.py): `src/data_preprocessing/nc2np_equally_cmip6.py`
- [ERA5 conversion](https://github.com/microsoft/climax/blob/main/src/data_preprocessing/nc2np_equally_era5.py): `src/data_preprocessing/nc2np_equally_era5.py`
- [Climate regridding](https://github.com/microsoft/climax/blob/main/src/data_preprocessing/regrid.py): `src/data_preprocessing/regrid.py`
- [Benchmark regridding](https://github.com/microsoft/climax/blob/main/src/data_preprocessing/regrid_climatebench.py): `src/data_preprocessing/regrid_climatebench.py`

### Other components

- **Researcher**

## Connections

- Researcher → Pretraining entry: starts training (evidence: `src/climax/pretrain/train.py`)
- Researcher → Global training: starts training (evidence: `src/climax/global_forecast/train.py`)
- Researcher → Regional training: starts training (evidence: `src/climax/regional_forecast/train.py`)
- Researcher → Projection training: starts training (evidence: `src/climax/climate_projection/train.py`)
- Pretraining entry → Pretraining data: sets up data (evidence: `src/climax/pretrain/train.py`)
- Pretraining entry → Pretraining task: trains task (evidence: `src/climax/pretrain/train.py`)
- Global training → Global data: sets up data (evidence: `src/climax/global_forecast/train.py`)
- Global training → Global forecast: trains task (evidence: `src/climax/global_forecast/train.py`)
- Regional training → Regional data: sets up data (evidence: `src/climax/regional_forecast/train.py`)
- Regional training → Regional forecast: trains task (evidence: `src/climax/regional_forecast/train.py`)
- Projection training → Projection data: sets up data (evidence: `src/climax/climate_projection/train.py`)
- Projection training → Climate projection: trains task (evidence: `src/climax/climate_projection/train.py`)
- Pretraining data → Forecast dataset: builds batches (evidence: `src/climax/pretrain/datamodule.py`)
- Global data → Forecast dataset: uses dataset (evidence: `src/climax/global_forecast/datamodule.py`)
- Regional data → Forecast dataset: uses dataset (evidence: `src/climax/regional_forecast/datamodule.py`)
- Projection data → Projection dataset: loads examples (evidence: `src/climax/climate_projection/datamodule.py`)
- Pretraining task → ClimaX backbone: trains backbone (evidence: `src/climax/pretrain/module.py`)
- Global forecast → ClimaX backbone: runs backbone (evidence: `src/climax/global_forecast/module.py`)
- Regional architecture → ClimaX backbone: extends backbone (evidence: `src/climax/regional_forecast/arch.py`)
- Regional forecast → Regional architecture: trains architecture (evidence: `src/climax/regional_forecast/module.py`)
- Projection architecture → ClimaX backbone: extends backbone (evidence: `src/climax/climate_projection/arch.py`)
- Climate projection → Projection architecture: trains architecture (evidence: `src/climax/climate_projection/module.py`)
- ClimaX backbone → Patch embedding: uses embedding (evidence: `src/climax/arch.py`)
- ClimaX backbone → Position embeddings: uses embeddings (evidence: `src/climax/arch.py`)
- Projection architecture → Position embeddings: uses embeddings (evidence: `src/climax/climate_projection/arch.py`)
- Pretraining task → Climate metrics: computes metrics (evidence: `src/climax/pretrain/module.py`)
- Pretraining task → LR scheduler: configures schedule (evidence: `src/climax/pretrain/module.py`)
- Global forecast → Climate metrics: computes metrics (evidence: `src/climax/global_forecast/module.py`)
- Global forecast → LR scheduler: configures schedule (evidence: `src/climax/global_forecast/module.py`)
- Regional forecast → Climate metrics: computes metrics (evidence: `src/climax/regional_forecast/module.py`)
- Regional forecast → LR scheduler: configures schedule (evidence: `src/climax/regional_forecast/module.py`)
- Climate projection → Climate metrics: computes metrics (evidence: `src/climax/climate_projection/module.py`)
- Climate projection → LR scheduler: configures schedule (evidence: `src/climax/climate_projection/module.py`)
- Data conversion → Climate data utilities: uses mappings (evidence: `src/data_preprocessing/nc2np_equally_cmip6.py`)
- ERA5 conversion → Climate data utilities: uses mappings (evidence: `src/data_preprocessing/nc2np_equally_era5.py`)
