How yuangao-yg/oneforecast works
Purpose and execution surface
OneForecast is a GPU-oriented deep-learning framework for global and nested regional Earth/weather forecasting. Its primary model is graph-based and supports one-step training, multi-step rollout fine-tuning, global inference, and regional inference driven by a pretrained global forecast.
Entrypoints are train.py, train_nng.py, inference.py, and inference_nng.py; shell launchers select standard, fine-tuning, or neural-nested-grid workflows: train.sh, train_finetune.sh, train_nng.sh, inference.sh, and inference_finetune.sh.
Configuration and experiment boundary
YAML model configurations define the global and regional/NNG runs: config/Model.yaml and config/Model_nng.yaml. Runtime parameters are loaded through my_utils/YParams.py.
Experiments are organized under timestamped directories, holding resolved configs and checkpoint trees, e.g. exp/OneForecast/20241008-171138/config.yaml, exp/OneForecast/20241008-171138/training_checkpoints, and exp/OneForecast/20241008-171138/NNG/.
Global data pipeline
The global pipeline consumes yearly HDF5 tensors under data/global/train, data/global/valid, and data/global/test; each sample represents 69 atmospheric variables on a global grid. Dataset iteration and batching belong to my_utils/data_loader.py.
Normalization is a separate data/model boundary: global mean and standard-deviation arrays live at data/global/mean.npy and data/global/std.npy, with transforms implemented in my_utils/norm.py. Training/inference should preserve the channel ordering and normalized tensor contract.
Global forecasting model
models/OneForecast.py is the principal OneForecast implementation. It embodies the multiscale graph and adaptive message-passing architecture used to map current global atmospheric fields to forecast fields.
The repository also contains alternative/reference forecasting architectures—models/GraphCast.py, models/Fengwu.py, and models/Pangu.py—but the main launch and experiment layout center on OneForecast.
Training and rollout control flow
train.py orchestrates supervised global training: load configuration, construct normalized global data, instantiate OneForecast, optimize, validate, log, and write checkpoints. my_utils/logging_utils.py supports run logging; my_utils/darcy_loss.py provides a specialized loss utility.
Fine-tuning changes the supervisory horizon rather than the core model: train_finetune.sh launches the global training path with multi-step settings from config/Model.yaml, initializing from prior global checkpoints in exp/OneForecast/.../training_checkpoints.
Regional neural nested grid flow
Regional forecasting requires both global and regional HDF5 inputs. train_nng.py and inference_nng.py coordinate this coupled path; my_utils/data_loader_nng.py and my_utils/norm_nng.py define its distinct input/normalization handling.
models/NNG.py implements the neural nested-grid stage. It consumes pretrained global-model forcing plus high-resolution regional fields, producing regional forecasts while addressing regional boundary-information loss. Its configuration is isolated in config/Model_nng.yaml, and checkpoints are stored beneath exp/OneForecast/.../NNG/.
Runtime and external dependencies
The project targets CUDA 11.8 with a Conda environment specified in environment.yml, and is designed for multi-node, multi-GPU training. It uses local HDF5 weather datasets and filesystem checkpoints; pretrained weights and complete datasets are distributed externally via Hugging Face. No serving layer or online API is present.
Main entry points: train.py Global training · train_nng.py NNG training · training_checkpoints Global checkpoints · norm.py Global normalization
Components 20
Global forecasting
- Global model config
config/Model.yaml - Runtime parameters
my_utils/YParams.py - Global HDF5 datasets · Yearly 69-channel global atmospheric tensors.
data/global/train - Global dataset loader
my_utils/data_loader.py - Global normalization stats
data/global/mean.npy - Global normalization · Preserves channel ordering and normalized tensor contract.
my_utils/norm.py - OneForecast · Multiscale adaptive message-passing global forecaster.
models/OneForecast.py - Global training · Supervised one-step training and validation orchestration.
train.py - Global inference
inference.py - Rollout fine-tuning · Runs the global path with multi-step supervision.
train_finetune.sh
Neural nested grid
- NNG model config
config/Model_nng.yaml - Regional HDF5 inputs · High-resolution regional fields coupled with global inputs.
- NNG data pipeline
my_utils/data_loader_nng.py - NNG normalization
my_utils/norm_nng.py - Neural nested grid · Combines pretrained global forcing and regional fields.
models/NNG.py - NNG training
train_nng.py - NNG inference
inference_nng.py
Experiment artifacts
- Global checkpoints · Prior global weights initialize rollout and regional workflows.
exp/OneForecast/20241008-171138/training_checkpoints - NNG artifacts
- Run logging
my_utils/logging_utils.py
Connections 20
- Global model config → Runtime parameters: loaded by
- Runtime parameters → Global training: configures
- Global HDF5 datasets → Global dataset loader: iterated and batched
- Global normalization stats → Global normalization: mean/std
- Global dataset loader → Global normalization: tensors
- Global normalization → Global training: normalized batches
- Global training → OneForecast: optimizes
- OneForecast → Global inference: forecast model
- Global training → Global checkpoints: writes
- Global checkpoints → Rollout fine-tuning: initializes from
- Rollout fine-tuning → Global training: multi-step settings
- Global training → Run logging: logs runs
- NNG model config → NNG training: configures
- Regional HDF5 inputs → NNG data pipeline: regional fields
- NNG data pipeline → NNG normalization: coupled inputs
- NNG normalization → NNG training: normalized inputs
- Global checkpoints → Neural nested grid: pretrained global forcing
- NNG training → Neural nested grid: trains
- Neural nested grid → NNG inference: regional forecasts
- NNG training → NNG artifacts: writes