WeatherNext2 · FGN
Model Introduction
FGN (Functional Generative Networks) was proposed by Google DeepMind and is the probabilistic global weather forecasting model in the WeatherNext series (WeatherNext2). FGN uses the fair continuous ranked probability score (fair CRPS) of the marginal distribution as its training objective. It models aleatoric uncertainty by injecting a global noise vector into conditional normalization layers and epistemic uncertainty through an ensemble of independently trained models. In this way, it captures the joint spatial structure of ensemble forecasts while optimizing only pointwise marginal objectives, and surpasses GenCast and ECMWF ENS across 15-day medium-range forecasts.
Paper:Skilful joint probabilistic weather forecasting from marginals
https://arxiv.org/abs/2506.14285
Model Description
FGN uses a GNN encoder-processor-decoder architecture consistent with the GenCast denoiser: a sparse GNN encoder maps latitude-longitude grid inputs to a latent space on a six-times-subdivided icosahedral grid, a graph-transformer processor advances the atmospheric state on that grid, and a GNN decoder maps the latent grid back to the output grid. Each forecast samples a 32-dimensional global noise vector, embeds it with a single matrix multiplication, and injects it into all conditional LayerNorm layers (equivalent to applying a learned functional perturbation to the network parameters) as the source of ensemble spread. Under a second-order Markov assumption (using the two previous frames), the model generates forecasts autoregressively at 6-hour intervals. This repository is a minimal reproduction based on the paper and is integrated with the OneScience data loading and training workflow.
Use Cases
| Scenario | Description |
|---|---|
| Probabilistic/ensemble medium-range weather forecasting research | Learn pointwise marginal distributions with CRPS and generate joint ensemble forecasts. |
| Uncertainty modeling research | Reproducible parameter-space noise injection (conditional normalization) and deep ensemble mechanisms. |
| Graph + Transformer latent-space model research | Encoder-processor-decoder architecture and fair CRPS objective. |
| Local quick validation | Use synthetic data to check data loading, training, inference, and result scripts. |
| ModelScope/OneCode execution | Download the model package, install dependencies, and run the scripts directly. |
| Multi-card training | Launch multi-process training with torchrun. |
Usage
1. OneCode Usage
Use the OneCode online environment for intelligent one-click AI4S programming:
Try intelligent one-click AI4S programming
2. Manual Installation and Usage
Hardware Requirements
- GPU or DCU is recommended.
- CPU can be used for imports and small-configuration connectivity validation, but full training and inference are slower.
- DCU users must install DTK beforehand. DTK 25.04.2 or later, or the OneScience-recommended version matching the current cluster, is recommended.
Download the Model Package
hf download OneScience-Group/WeatherNext2 --local-dir ./WeatherNext2
cd WeatherNext2
Install the Runtime Environment
DCU Environment
# 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
# 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
Training Data
The OneScience community provides ERA5 data for training (the current repository contains complete data slices subject to data-file size limits). Download it with the command below and confirm that the data path in conf/config.yaml is correct:
hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data
For a quick workflow validation, run the synthetic data script first:
python scripts/fake_data.py
Note:
scripts/fake_data.pygenerates[T, C, H, W]data from second-order Markov inputs, forecast steps, batch size, andgrid_shape. The current small configuration uses 6 channels and a 32×32 grid.
Training
Single card:
python scripts/train.py
Multiple cards:
torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py
Training outputs:
data/checkpoints/model_bak.pth
data/checkpoints/trloss.npy
data/checkpoints/valoss.npy
Training Weights
The weight/ folder is reserved for model weights. Pretrained weights are not provided by default; users may train the model using the paper configuration. The paper model (per-seed latent dimension 768, 24 processor layers, an ensemble of 4 model seeds, and approximately 490 TPU-days of total computation) has no publicly released weights.
Inference
Inference reads data/checkpoints/model_bak.pth by default, generates num_members ensemble members for each initialization time (independently sampling global noise for each), and uses the member mean as the deterministic forecast output:
python scripts/inference.py
Prediction results are written frame by frame to:
result/output/
Evaluation and Visualization
python scripts/result.py
Outputs include:
result/rmse.npyresult/acc.npyresult/loss.png- Forecast comparison plots for the specified date and variables
Official Source and Reproduction Notes
- The paper is a Google DeepMind preprint (© 2025 Google DeepMind. All rights reserved.), and no official implementation or weights are publicly available. This repository's
model/fgn.pyis a pure PyTorch minimal reproduction that preserves the paper's encoder-processor-decoder GNN structure, conditional LayerNorm global-noise injection, and fair CRPS objective (with N=2 ensemble samples during training). - Differences from the paper (due to the OneScience gridded data pipeline and connectivity-validation scale): the paper uses a six-times-subdivided icosahedral latent grid (approximately 40k nodes) and a 0.25° (1440×721) output grid, with approximately 180M parameters per seed. This reproduction uses a fixed regular 8-neighbor latent grid (
mesh_shape), ERA5 gridded h5 channels as input placeholders, and a default latent dimension of 64. The number of latent-grid nodes and edge features are determined by themesh_shapeandchannel_weightsconfigurations. - The following details are not disclosed in the paper and are assumptions in this reproduction:the specific projection from noise to each layer's scale/shift in conditional LayerNorm (currently implemented with per-layer linear projections initialized to zero so the initial behavior is standard LayerNorm); per-channel weights for the multi-task loss (currently all 1 by default); and the evaluation convention of using the ensemble mean as the deterministic forecast for probabilistic output.
- Paper-level reproduction requires the four-stage training procedure in the paper (ERA5 1°12h → 1°6h → 0.25°6h → HRES-fc0 0.25° AR fine-tuning);
conf/config.yamluses a small configuration for connectivity validation by default.
Official OneScience Information
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- This repository is an independent FGN (WeatherNext2) reproduction (the model code is an original minimal implementation), with the architecture design based on the paper by Alet et al. (2025).
- Please cite:Alet, F., Price, I., El-Kadi, A., Masters, D., Markou, S., Andersson, T. R., Stott, J., Lam, R., Willson, M., Sanchez-Gonzalez, A. and Battaglia, P. Skilful joint probabilistic weather forecasting from marginals. arXiv:2506.14285, 2025.
中文说明
模型简介
FGN(Functional Generative Networks)由 Google DeepMind 提出,是 WeatherNext 系列(WeatherNext2)的全球概率天气预报(weather forecasting)模型。FGN 以边缘分布的公平连续分级概率评分(fair CRPS)为训练目标。它将全局噪声向量注入条件归一化层来建模偶然不确定性,并以独立训练的模型集合建模认知不确定性。这样,模型只需优化逐点边缘目标即可捕捉集合预报(ensemble forecasts)的联合空间结构,并在 15 天中期预报(medium-range forecasts)中超越 GenCast 和 ECMWF ENS。
论文《从边缘分布实现有技巧的联合概率天气预报》
https://arxiv.org/abs/2506.14285
模型描述
FGN 使用与 GenCast 去噪器一致的 GNN 编码器–处理器–解码器架构。稀疏 GNN 编码器将经纬度网格输入映射到经过六次细分的二十面体网格上的潜空间,图 Transformer 处理器推进该网格上的大气状态,GNN 解码器将潜网格映射回输出网格。每次预报采样一个 32 维全局噪声向量,通过一次矩阵乘法进行嵌入,并将其注入所有条件 LayerNorm 层,作为集合离散度的来源。这相当于将学习到的函数扰动施加到网络参数上。在二阶马尔可夫假设下,模型利用此前两帧,以 6 小时间隔自回归地生成预报。本仓库是基于论文的最小实现,已集成 OneScience 数据加载和训练流程。
使用场景
| 场景 | 说明 |
|---|---|
| 概率和集合中期天气预报研究 | 使用 CRPS 学习逐点边缘分布,并生成联合集合预报。 |
| 不确定性建模研究 | 可复现的参数空间噪声注入(条件归一化)和深度集成机制。 |
| 图与 Transformer 潜空间模型研究 | 编码器–处理器–解码器架构与公平 CRPS 目标。 |
| 本地快速验证 | 使用合成数据检查数据加载、训练、推理(inference)和结果处理脚本。 |
| 在 ModelScope/OneCode 中运行 | 下载模型包,安装依赖后直接运行脚本。 |
| 多卡训练 | 使用 torchrun 启动多进程训练。 |
使用方法
1. OneCode 使用方法
通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议使用 GPU 或 DCU。
- CPU 可用于导入与小配置的连通性验证,但完整训练和推理速度较慢。
- DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或 OneScience 推荐的与当前集群匹配的版本。
下载模型包
hf download OneScience-Group/WeatherNext2 --local-dir ./WeatherNext2
cd WeatherNext2
安装运行环境
DCU 环境
# 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 环境
# 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
训练数据
OneScience 社区提供用于训练的 ERA5 数据(受数据文件大小限制,当前仓库包含完整的数据切片)。使用以下命令下载数据,并确认 conf/config.yaml 中的数据路径正确。
hf download --repo-type dataset OneScience-Group/ERA5 --local-dir ./data
如需快速验证流程,先运行合成数据脚本。
python scripts/fake_data.py
注,
scripts/fake_data.py生成[T, C, H, W]数据,依据包括二阶马尔可夫输入、预报步数、批大小和grid_shape。当前小配置使用 6 个通道和 32×32 网格。
训练
单卡
python scripts/train.py
多卡
torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py
训练输出
data/checkpoints/model_bak.pth
data/checkpoints/trloss.npy
data/checkpoints/valoss.npy
训练权重
weight/ 文件夹预留给模型权重。默认不提供预训练权重,用户可以使用论文配置训练模型。论文模型(每个种子的潜空间维度为 768,处理器包含 24 层,由 4 个模型种子组成集合,总计算量约为 490 TPU-days)未公开发布权重。
推理
推理默认读取 data/checkpoints/model_bak.pth,为每个起报时间生成 num_members 个集合成员(分别独立采样全局噪声),并使用集合成员的平均值作为确定性预报输出。
python scripts/inference.py
预报结果逐帧写入以下位置。
result/output/
评估与可视化
python scripts/result.py
输出内容包括
result/rmse.npyresult/acc.npyresult/loss.png- 指定日期和变量的预报对比图
官方来源与复现说明
- 论文是 Google DeepMind 的预印本(© 2025 Google DeepMind. All rights reserved.),官方实现和权重均未公开。仓库中的
model/fgn.py是纯 PyTorch 最小复现,保留了论文中的编码器–处理器–解码器 GNN 架构、条件 LayerNorm 全局噪声注入和公平 CRPS 目标(训练期间使用 N=2 个集合样本)。 - 受 OneScience 网格化数据流程和连通性验证规模影响,复现与论文存在差异。论文使用经过六次细分的二十面体潜网格(约 40k 个节点)和 0.25°(1440×721)的输出网格,每个种子约有 180M 个参数。本次复现使用固定的规则 8 邻域潜网格(
mesh_shape),以 ERA5 网格化 h5 通道作为占位输入,默认潜空间维度为 64。潜网格节点数量和边特征由mesh_shape和channel_weights配置决定。 - 论文未公开以下细节,本次复现据此作出假设。条件 LayerNorm 中噪声到每一层缩放量和偏移量的具体投影方式(当前采用逐层线性投影并初始化为零,使初始行为与标准 LayerNorm 一致),多任务损失的逐通道权重(当前默认为 1),以及在概率输出评估中采用集合平均值作为确定性预报的约定。
- 论文级复现需要遵循论文中的四阶段训练流程(ERA5 1°12h → 1°6h → 0.25°6h → HRES-fc0 0.25° AR 微调(fine-tuning))。
conf/config.yaml默认使用小配置进行连通性验证。
OneScience 官方信息
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
- 本仓库是 FGN(WeatherNext2)的独立复现(模型代码为原创的最小实现),架构设计源自 Alet 等人(2025)的论文。
- 请引用 Alet, F., Price, I., El-Kadi, A., Masters, D., Markou, S., Andersson, T. R., Stott, J., Lam, R., Willson, M., Sanchez-Gonzalez, A. and Battaglia, P. Skilful joint probabilistic weather forecasting from marginals. arXiv:2506.14285, 2025.
- Downloads last month
- 17