Spherical Fourier Neural Operators
Model Introduction
SFNO(Spherical Fourier Neural Operator)was proposed jointly by NVIDIA, Caltech, and other institutions,replaces the planar FFT in standard FNOs with spherical harmonic transforms (SHT), making spectral convolution respect spherical geometry and mitigating polar artifacts, spectral artifacts, and instability during long autoregressive rollouts.
Paper:Spherical Fourier Neural Operators: Learning Stable Dynamics on the Sphere
https://arxiv.org/abs/2306.03838
Model Description
SFNO is a deterministic, single-state global weather dynamics model: it takes the atmospheric state at one 6-hour time step and outputs the same set of variables at the next 6-hour time step. Longer lead times are obtained through autoregressive rollout.This repository is organized from the official reference implementation in NVIDIA/torch-harmonics and integrated with the OneScience data loading and training workflow.
Use Cases
| Scenario | Description |
|---|---|
| Global weather dynamics research | Train a spherical-equivariant neural operator forecasting model on ERA5 data. |
| Long-horizon autoregressive stability research | Evaluate polar artifacts and dissipation during multi-step rollout. |
| 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.
- The model depends on
torch-harmonics(spherical harmonic transforms),Confirm that its version matches PyTorch/CUDA before installation.
Download the Model Package
hf download OneScience-Group/SphericalFourierNeuralOperators --local-dir ./SphericalFourierNeuralOperators
cd SphericalFourierNeuralOperators
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] torch-harmonics -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] torch-harmonics -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]HDF5 data from the model configuration. The current small configuration uses 6 channels and a 32×64 grid, and automatically calculates a time length sufficient for the batch.
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. The paper does not clearly release weights for the 26/73-channel weather model; this repository does not currently provide official weights, and users may train the model using the paper configuration.
Inference
Inference reads data/checkpoints/model_bak.pth:
python scripts/inference.py
Prediction results are written 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 model implementation comes from the SFNO reference implementation in the official
NVIDIA/torch-harmonics(BSD-3-Clause). - Commit fetched for the current case directory:
49bac755cd8306fbd27a3604acafa65adf7ca202(2026-08-14). conf/config.yamluses a small configuration (img_size=[32, 64],embed_dim=16,num_layers=2) for connectivity validation by default; paper-level reproduction requires a 0.25° (721×1440) grid, 26/73 channels, and a larger network as specified in the paper.- The following details are not disclosed in the paper and are assumptions in this reproduction:the internal spectral downsampling factor of the weather model, the positional embedding form, per-variable normalization statistics, and training batch size.
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 organization and adaptation of SFNO. The model source is based on the official
torch-harmonicsimplementation by Bonev et al. (2023) and follows BSD-3-Clause. - Please cite:Bonev, Kurth, Hundt, Pathak, Baust, Kashinath, Anandkumar. Spherical Fourier Neural Operators: Learning Stable Dynamics on the Sphere. ICML 2023.
中文说明
模型简介
SFNO(球面傅里叶神经算子(Spherical Fourier Neural Operator))由 NVIDIA、Caltech 等机构联合提出,用球谐变换(SHT)替代标准 FNO 中的平面 FFT,使谱卷积遵循球面几何,减少极区伪影、谱伪影及长时自回归滚动预测中的不稳定性。
论文《球面傅里叶神经算子:学习球面上的稳定动力学》
https://arxiv.org/abs/2306.03838
模型描述
SFNO 是确定性的单状态全球天气动力学模型,接收某个 6-hour 时间步的大气状态,并在下一个 6-hour 时间步输出同一组变量。更长的预报时效通过自回归滚动预测获得。本仓库基于 NVIDIA/torch-harmonics 官方参考实现整理,并集成了 OneScience 的数据加载及训练工作流。
使用场景
| 场景 | 说明 |
|---|---|
| 全球天气动力学研究 | 使用 ERA5 数据训练球面等变神经算子预报模型。 |
| 长时自回归稳定性研究 | 评估多步滚动预测中的极区伪影和耗散。 |
| 本地快速验证 | 使用合成数据检查数据加载、训练、推理(inference)和结果处理脚本。 |
| 在 ModelScope/OneCode 中运行 | 下载模型包,安装依赖后直接运行脚本。 |
| 多卡训练 | 使用 torchrun 启动多进程训练。 |
使用方法
1. 使用 OneCode
通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议使用 GPU 或 DCU。
- 可使用 CPU 进行导入和小规模配置连通性验证,完整训练与推理的速度较慢。
- DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐且与当前集群匹配的版本。
- 模型依赖
torch-harmonics(球谐变换)。安装前请确认版本与 PyTorch/CUDA 匹配。
下载模型包
hf download OneScience-Group/SphericalFourierNeuralOperators --local-dir ./SphericalFourierNeuralOperators
cd SphericalFourierNeuralOperators
安装运行环境
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] torch-harmonics -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] torch-harmonics -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]HDF5 数据。当前小规模配置使用 6 个通道和 32×64 网格,并自动计算满足批次需求的时间长度。
训练
单卡
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/ 文件夹预留给模型权重。论文未明确发布 26/73 通道天气模型权重,本仓库当前也未提供官方权重。用户可按论文配置训练模型。
推理
推理读取 data/checkpoints/model_bak.pth。
python scripts/inference.py
预测结果写入以下位置。
result/output/
评估与可视化
python scripts/result.py
输出内容包括
result/rmse.npyresult/acc.npyresult/loss.png- 指定日期和变量的预报对比图
官方来源与复现说明
- 模型实现来自官方
NVIDIA/torch-harmonics的 SFNO 参考实现(BSD-3-Clause)。 - 当前案例目录获取的提交为
49bac755cd8306fbd27a3604acafa65adf7ca202(2026-08-14)。 conf/config.yaml默认使用小规模配置(img_size=[32, 64]、embed_dim=16、num_layers=2)验证连通性。论文级别的复现需要 0.25°(721×1440)网格、26/73 通道及论文所述的更大网络。- 论文未披露以下细节,本次复现对其作了假设,包括天气模型的内部谱降采样因子、位置嵌入形式、逐变量归一化统计量及训练批大小。
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 |
引用与许可证
- 本仓库是对 SFNO 的独立整理和适配。模型源代码基于 Bonev 等人(2023)的官方
torch-harmonics实现,遵循 BSD-3-Clause。 - 请引用 Bonev, Kurth, Hundt, Pathak, Baust, Kashinath, Anandkumar. Spherical Fourier Neural Operators: Learning Stable Dynamics on the Sphere. ICML 2023.
- Downloads last month
- 30