CorrDiff

Model Introduction

CorrDiff is a two-stage generative model for kilometer-scale atmospheric downscaling. It first predicts a high-resolution mean with conditional regression and then uses a residual diffusion model to generate local stochastic details and ensemble forecasts.

Paper: Residual Corrective Diffusion Modeling for Km-scale Atmospheric Downscaling
https://arxiv.org/abs/2309.15214

Model Description

CorrDiff was proposed by an NVIDIA research team. The model is trained using ERA5 reanalysis data and high-resolution regional CWA-WRF simulation data, and performs weather-field downscaling through regression and residual diffusion. It is suitable for high-resolution weather-field generation, kilometer-scale downscaling, and ensemble uncertainty analysis.

Use Cases

Scenario Description
Weather downscaling Downscale 36x36 coarse-resolution condition fields to 448x448.
Ensemble forecasting Generate multiple possible high-resolution results through diffusion sampling.
Radar reflectivity generation Generate high-resolution maximum radar reflectivity that is absent from the ERA5 condition fields, supporting analysis of fine-scale precipitation-system structures.
Extreme-weather risk analysis Use ensemble members and spatial uncertainty to characterize the possible evolution of local heavy precipitation and other high-impact weather.
Local engineering validation Use a small amount of synthetic data to check training, inference, and evaluation workflows.
Multi-GPU training Launch distributed training with torchrun.

Usage Guide

1.OneCode

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

Click to Experience Intelligent One-Click AI4S Programming

2.Download and Installation

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

Environment Dependencies

Hardware Requirements

  • A GPU or DCU is recommended.
  • CPU can be used for connectivity validation with a small configuration; full training and inference are slower.
  • DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience-recommended version matching the current cluster, is recommended.

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

Training Data Introduction

By default, two synthetic samples following the same protocol are used to validate the engineering workflow. The data are saved as data/corrdiff.npz, and the synthetic data do not represent real weather distributions.

The synthetic data retain the input and output specifications of the Taiwan downscaling experiment in the paper: 12-channel 36x36 condition fields and 4-channel 448x448 target fields.

Real data must be preprocessed and converted to the following NPZ training protocol. This protocol is consistent with the model input specification but is not equivalent to the original datasets' download format.

input: float32 [N,12,36,36]
target: float32 [N,4,448,448]

fake_data.py automatically writes the protocol and data_source protocol metadata. These fields must be retained when using real data.

python scripts/fake_data.py

Training

python scripts/train.py

Multi-GPU training can use:

torchrun --nproc_per_node=8 scripts/train.py

Training sequentially optimizes the conditional-regression and residual-diffusion stages and saves a checkpoint and overall training metrics. The default configuration is intended for quick workflow validation. Formal experiments should use the data scale, model configuration, and training schedule corresponding to the paper.

result/checkpoints/corrdiff.pt
result/training/metrics.json

Training Weights

This repository will provide CorrDiff training weights in the weight/ folder. The weight files will be uploaded soon and are expected to be available in the near future.

Inference

python scripts/inference.py

Inference loads the training checkpoint, generates high-resolution ensemble forecasts according to the configuration, and saves the results to:

result/output/predictions.npz

Evaluation and Visualization

python scripts/result.py

Evaluation reports overall MAE, RMSE, ensemble CRPS, and ensemble spread, and generates an ensemble diagnostic figure. Synthetic-data results are only for validating the engineering workflow and do not represent the full performance reported in the paper.

result/evaluation/metrics.json
result/evaluation/ensemble_diagnostics.png

Official OneScience Resources

Citation and License

This repository is a reproduction of the original CorrDiff paper.

The use of the code and data in this repository remains subject to the licenses and terms of use of their respective projects.


中文说明

模型简介

CorrDiff 是一个用于公里级大气降尺度(downscaling)的两阶段生成模型。它先通过条件回归预测高分辨率均值,随后使用残差扩散模型生成局地随机细节和集合预报(ensemble forecasts)。

论文《用于公里级大气降尺度的残差校正扩散建模》
https://arxiv.org/abs/2309.15214

模型描述

CorrDiff 由 NVIDIA 研究团队提出。模型使用 ERA5 再分析(reanalysis)数据和高分辨率区域 CWA-WRF 模拟数据训练,通过回归和残差扩散对天气场降尺度。它适用于高分辨率天气场生成、公里级降尺度和集合不确定性分析。

使用场景

场景 说明
天气场降尺度 将 36x36 的粗分辨率条件场降尺度至 448x448。
集合预报 通过扩散采样生成多种可能的高分辨率结果。
雷达反射率生成 生成 ERA5 条件场中缺少的高分辨率最大雷达反射率,以分析精细尺度的降水系统结构。
极端天气风险分析 使用集合成员和空间不确定性描述局地强降水及其他高影响天气的可能演变。
本地工程验证 使用少量合成数据检查训练、推理(inference)和评估流程。
多 GPU 训练 使用 torchrun 启动分布式训练。

使用指南

1.OneCode

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

点击体验智能一键 AI4S 编程

2.下载和安装

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

环境依赖

硬件要求

  • 建议使用 GPU 或 DCU。
  • 可使用 CPU 在小规模配置下验证连通性,完整训练和推理的速度较慢。
  • DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐且与当前集群匹配的版本。

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

训练数据简介

默认使用两个符合相同规约的合成样本验证工程工作流。数据保存为 data/corrdiff.npz,合成数据不代表真实天气分布。

合成数据保留论文中台湾降尺度实验的输入和输出规格,包含 12 通道的 36x36 条件场和 4 通道的 448x448 目标场。

真实数据必须预处理并转换为以下 NPZ 训练规约。该规约与模型输入规格一致,与原始数据集的下载格式不同。

input: float32 [N,12,36,36]
target: float32 [N,4,448,448]

fake_data.py 会自动写入 protocol 和 data_source 规约元数据。使用真实数据时必须保留这些字段。

python scripts/fake_data.py

训练

python scripts/train.py

多 GPU 训练可使用以下命令。

torchrun --nproc_per_node=8 scripts/train.py

训练依次优化条件回归和残差扩散阶段,并保存模型权重(检查点)(checkpoint)以及总体训练指标。默认配置用于快速验证工作流。正式实验应使用论文对应的数据规模、模型配置和训练计划。

result/checkpoints/corrdiff.pt
result/training/metrics.json

训练权重

本仓库将在 weight/ 文件夹中提供 CorrDiff 的训练权重。权重文件即将上传,预计近期可用。

推理

python scripts/inference.py

推理加载训练模型权重(检查点),按配置生成高分辨率集合预报,并将结果保存至以下位置。

result/output/predictions.npz

评估与可视化

python scripts/result.py

评估报告总体 MAE、RMSE、集合 CRPS 和集合离散度,并生成集合诊断图。合成数据结果仅用于验证工程工作流,不代表论文报告的完整性能。

result/evaluation/metrics.json
result/evaluation/ensemble_diagnostics.png

OneScience 官方资源

引用与许可证

本仓库复现了 CorrDiff 原始论文。

本仓库的代码和数据的使用仍受各自项目的许可证和使用条款约束。

Downloads last month
23
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for OneScience-Group/CorrDiff