Earthformer

Model Introduction

Earthformer was proposed by researchers from Amazon Web Services (AWS) in collaboration with the Hong Kong University of Science and Technology. It aims to address the prohibitive computational cost of conventional Transformers when processing high-dimensional geophysical data.

Earthformer: Exploring Space-Time Transformers for Earth System Forecasting

https://arxiv.org/abs/2207.05833

Model Description

Earthformer is a space-time Transformer model designed for Earth system forecasting, such as weather and climate. Its core component is a novel attention mechanism called Cuboid Attention.

Use Cases

Scenario Description
Weather Forecast Training Train the Earthformer weather forecasting model using SEVIR structured data.
Local Quick Validation Use synthetic data to verify data loading, model training, inference, and inference result visualization.
ModelScope / OneCode Execution Download as a standalone model package, install dependencies, and run scripts directly.
Multi-GPU Training Launch multi-process training via torchrun.

Usage Guide

1. OneCode Usage

Experience intelligent one-click AI4S programming through the OneCode online environment:

Click to Experience Intelligent One-Click AI4S Programming

2. Manual Installation and Usage

The commands below assume they are run from the Earthformer project root directory.

Hardware Requirements

  • Training and inference require a GPU or DCU recognized by PyTorch; CPU can be used to generate synthetic data and verify configuration, but cannot run the current training and inference scripts.
  • Multi-GPU training uses the NCCL backend. Please make sure the device driver, communication libraries, and PyTorch version are compatible.
  • DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching your cluster, is recommended.

Download the Model Package

hf download OneScience-Group/Earthformer --local-dir ./Earthformer
cd Earthformer

Install the Runtime Environment

DCU Environment

# Please activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU Environment

# Please activate CONDA first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

Generate Synthetic Data

Synthetic data is only used to verify the data protocol and program flow; it does not represent real SEVIR data or the model's forecast quality:

python script/fake_data.py

By default this generates data/synthetic_sevir/{train,val,test}.npz and metadata.json. To generate synthetic data matching the official SEVIR spatial size:

python script/fake_data.py --output-dir data/synthetic_sevir_384 --height 384 --width 384

Training

Single GPU:

python script/train.py

Multi-GPU:

torchrun --nproc_per_node=8 script/train.py

Training starts from random initialization and saves to data/checkpoint/earthformer.pt by default.

Training Weights

This repository provides weights trained on SEVIR data in the weights/ folder. The weight files will be uploaded soon and are expected to be available in the near future.

Inference

Inference reads the training checkpoint by default and writes the output to output/predictions.npz.

python script/inference.py

Evaluation and Visualization

python script/result.py

OneScience Official Information

Citation & License

  • This repository is the OneScience reproduction of the original Earthformer paper. The official Earthformer implementation is released under the Apache License 2.0; the use of this repository's code and the SEVIR data remains subject to the licenses and terms of use of the respective projects.

中文说明

模型简介

Earthformer 由 Amazon Web Services(AWS)与香港科技大学的研究人员合作提出,旨在解决传统 Transformer 处理高维地球物理数据时计算成本过高的问题。

Earthformer:探索用于地球系统预报的时空 Transformer

https://arxiv.org/abs/2207.05833

模型描述

Earthformer 是一种面向天气和气候等地球系统预报的时空 Transformer 模型。其核心组件是名为 Cuboid Attention 的新型注意力机制。

使用场景

场景 说明
天气预报(weather forecasting)训练 使用 SEVIR 结构化数据训练 Earthformer 天气预报模型。
本地快速验证 使用合成数据验证数据加载、模型训练、推理(inference)及推理结果可视化。
在 ModelScope / OneCode 中运行 下载独立模型包,安装依赖后直接运行脚本。
多 GPU 训练 通过 torchrun 启动多进程训练。

使用指南

1. 使用 OneCode

通过 OneCode 在线环境体验智能一键 AI4S 编程。

点击体验智能一键 AI4S 编程

2. 手动安装与使用

以下命令均假定从 Earthformer 项目根目录运行。

硬件要求

  • 训练与推理需要 PyTorch 可识别的 GPU 或 DCU。CPU 可用于生成合成数据和核对配置,无法运行当前的训练和推理脚本。
  • 多 GPU 训练使用 NCCL 后端。请确保设备驱动、通信库与 PyTorch 版本相互兼容。
  • DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐且与所在集群匹配的版本。

下载模型包

hf download OneScience-Group/Earthformer --local-dir ./Earthformer
cd Earthformer

安装运行环境

DCU 环境

# Please activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

GPU 环境

# Please activate CONDA first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/  --trusted-host mirrors.onescience.ai

生成合成数据

合成数据仅用于验证数据规约和程序流程,不代表真实 SEVIR 数据或模型预报质量。

python script/fake_data.py

默认情况下,此命令生成 data/synthetic_sevir/{train,val,test}.npz 和 metadata.json。使用以下命令生成与官方 SEVIR 空间尺寸一致的合成数据。

python script/fake_data.py --output-dir data/synthetic_sevir_384 --height 384 --width 384

训练

单 GPU

python script/train.py

多 GPU

torchrun --nproc_per_node=8 script/train.py

训练从随机初始化开始,默认保存到 data/checkpoint/earthformer.pt。

训练权重

本仓库在 weights/ 目录提供使用 SEVIR 数据训练的权重。权重文件即将上传,预计近期可用。

推理

推理默认读取训练模型权重(检查点)(checkpoint),将输出写入 output/predictions.npz。

python script/inference.py

评估与可视化

python script/result.py

OneScience 官方信息

引用与许可证

  • 本仓库是 OneScience 对 Earthformer 原始论文的复现。Earthformer 官方实现采用 Apache License 2.0 发布。本仓库代码与 SEVIR 数据的使用仍受各自项目的许可证和使用条款约束。
Downloads last month
22
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for OneScience-Group/Earthformer