Skip to content

Add Corrdiff-era5-hrrr - #2088

Open
Dibyajyoti-Chakraborty wants to merge 12 commits into
NVIDIA:mainfrom
Dibyajyoti-Chakraborty:corrdiff-era5-hrrr
Open

Dibyajyoti-Chakraborty wants to merge 12 commits into
NVIDIA:mainfrom
Dibyajyoti-Chakraborty:corrdiff-era5-hrrr

Conversation

@Dibyajyoti-Chakraborty

@Dibyajyoti-Chakraborty Dibyajyoti-Chakraborty commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Adds flow matching as a configuration option of examples/weather/regional_weather_diffusion using the CorrDiff-ERA5-HRRR recipe: ERA5 → HRRR (3 km, CONUS) downscaling with x-prediction rectified flow matching. Inference is with the Earth2Studio wrapper.

  • training.loss.type: edm (unchanged default) or flow_matching, which trains with RectifiedFlowNoiseScheduler(t_min, t_max) and WeightedFlowMatchingLoss.
  • training.loss.prediction_type: x0, epsilon, score, or flow. Both losses take it directly; for rectified flow the sampler converts the prediction to the ODE flow with the scheduler's helpers (finite at the pure-noise start t = 1).
  • model.preconditioner: edm (EDMPreconditioner, requires prediction_type: x0) or time_scaled (TimeScaledModel, multiplies the times by model.time_scale). Either combines with either loss type.

Other changes: the DiT builder accepts attention_backend (natten2d_rope); sampler/rectified_flow.yaml adds a resolution-dependent time_shift and the churn options.

CorrDiff-ERA5-HRRR recipe (corrdiff_era5_hrrr.yaml): dataset data_loader_corrdiff_era5_hrrr.py (same-time ERA5/HRRR pairs over the 1024 × 1792 CONUS domain, random 256 × 256 patches, zenith angle and static fields in the background, droppable inputs with presence flags as scalar conditions), model model/corrdiff_era5_hrrr.yaml (678M-parameter DiT, NATTEN + RoPE, QK normalization, time_scaled preconditioner), x-prediction with t ~ U[0, 1] in a single stage, AdamW with warmup and cosine decay, bf16. The config matches the released checkpoint, which loads unchanged.

Testing: new tests for flow-matching training (DiT and U-Net; x0, epsilon, flow prediction; fp32 and bf16), the EDM loss with the time-scaled preconditioner, the preconditioner/prediction-type validation, pure-noise sampling with and without time shift, and the CONUS dataset on synthetic files. They pass together with the existing EDM tests (test_model_types, DiT checkpointing, 2-GPU domain-parallel training). A 20-step real-data run of corrdiff_era5_hrrr on 8 GPUs trains (loss 0.89 → 0.37, 64 GB per GPU at 2 patches per GPU).

Checklist

Dependencies

No new library dependencies. The example's requirements.txt lists natten, matplotlib, tensorboard, xarray, zarr, netCDF4, and pandas. The QK normalization uses NVIDIA Apex, which ships in the PhysicsNeMo and NGC PyTorch containers.

@copy-pr-bot

copy-pr-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS review map

Current for commit b0d4b81f06b1. An approval covers every file listed for that owner; one owner is sufficient for shared files.

No CODEOWNER

  • examples/weather/corrdiff-era5-hrrr/.gitignore
  • examples/weather/corrdiff-era5-hrrr/README.md
  • examples/weather/corrdiff-era5-hrrr/config/corrdiff_inference.yaml
  • examples/weather/corrdiff-era5-hrrr/config/dataset/hrrr_era5.yaml
  • examples/weather/corrdiff-era5-hrrr/config/dataset/mock.yaml
  • examples/weather/corrdiff-era5-hrrr/config/diffusion.yaml
  • examples/weather/corrdiff-era5-hrrr/config/diffusion_lite.yaml
  • examples/weather/corrdiff-era5-hrrr/config/hydra/default.yaml
  • examples/weather/corrdiff-era5-hrrr/config/inference/default.yaml
  • examples/weather/corrdiff-era5-hrrr/config/model/dit.yaml
  • examples/weather/corrdiff-era5-hrrr/config/sampler/rectified_flow.yaml
  • examples/weather/corrdiff-era5-hrrr/config/test_diffusion.yaml
  • examples/weather/corrdiff-era5-hrrr/config/training/default.yaml
  • examples/weather/corrdiff-era5-hrrr/datasets/init.py
  • examples/weather/corrdiff-era5-hrrr/datasets/dataset.py
  • examples/weather/corrdiff-era5-hrrr/datasets/hrrr_era5.py
  • examples/weather/corrdiff-era5-hrrr/datasets/mock.py
  • examples/weather/corrdiff-era5-hrrr/inference.py
  • examples/weather/corrdiff-era5-hrrr/outputs/refc.png
  • examples/weather/corrdiff-era5-hrrr/outputs/t2m.png
  • examples/weather/corrdiff-era5-hrrr/outputs/u10m.png
  • examples/weather/corrdiff-era5-hrrr/requirements.txt
  • examples/weather/corrdiff-era5-hrrr/test_training.py
  • examples/weather/corrdiff-era5-hrrr/train.py
  • examples/weather/corrdiff-era5-hrrr/utils/nn.py
  • examples/weather/corrdiff-era5-hrrr/utils/plots.py
  • examples/weather/corrdiff-era5-hrrr/utils/trainer.py

Comment /codeowners-info to refresh.

@Dibyajyoti-Chakraborty Dibyajyoti-Chakraborty changed the title Add Corrdiff-era5-hrrr example Add Corrdiff-era5-hrrr Oct 12, 2026
@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[Low impact] Adds a weather model example with configs and sample code.

Satisfy the model interface requirements before merging; the other findings are non-blocking improvements.

Findings

  1. P2 Restart repeats used batches ▶
  2. P2 Checkpoints consume terabytes ▶
  3. P2 Unused channels fill memory ▶
  4. P2 Real data lacks tests ▶
  5. P2 Wrapper lacks required interface checks ▶

Summary

Adds an ERA5-to-HRRR downscaling example using clean-state prediction and rectified flow.

  • The example turns paired ERA5 and HRRR files into model-ready weather samples.
  • The trainer learns clean HRRR weather states from noise.
  • Inference turns ERA5 conditions into saved HRRR forecast ensembles.

Reviews (1) · Last reviewed commit: "Corrdiff-era5-hrrr initial commit" · Reviewed by Greptile

@CharlelieLrt

Copy link
Copy Markdown
Collaborator

Only my 2 cents there, and @pzharrington would know better, but I'm not sure we want to have another recipe in addition of the unified one for regional weather models. I haven't looked in detail, but it does feel like a lot of duplication

@Dibyajyoti-Chakraborty

Copy link
Copy Markdown
Collaborator Author

@CharlelieLrt @pzharrington I can add it to the regional_weather_diffusion example, but it will be a lot of refactoring. NN, flow matching training, inference, etc. there are several new things here. It will get very ugly. Also, the README will be confusing with so many different models. Another option is to have subfolders inside regional_weather_diffusion. What do you suggest?

@CharlelieLrt

Copy link
Copy Markdown
Collaborator

I'm not sure it would be so much refactoring. The inference doesn't really matter (and maybe doesn't eevn need to part of the PR), since the recommended way to do inference is the E2S wrapper.
For flow matching the regional recipe is already based entirely on physicsnemo.diffusion, so it should just be a matter of swapping the noise schedules and losses at the config.yaml level (mostly).

@pzharrington

Copy link
Copy Markdown
Collaborator

For flow matching the regional recipe is already based entirely on physicsnemo.diffusion, so it should just be a matter of swapping the noise schedules and losses at the config.yaml level (mostly).

This was my thinking as well, I didn't know you were making this as a separate recipe. The SAs strongly prefer one centralized recipe to train all these regional weather diffusion models. So if this can be shepherded under that one without too much difficulty/messiness then I think that's a better approach. Sorry I know a bit annoying since you already have this one but I think it makes sense to de-fragment if we can.

@Dibyajyoti-Chakraborty

Copy link
Copy Markdown
Collaborator Author

Got it. Let me combine it and update the PR.

sampling always agree. Unlike the ``EDMPreconditioner``, this wrapper
does not scale the inputs and outputs: the network output is the
prediction itself (``training.loss.prediction_type``), with any noise
schedule.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, wouldn't this be generally useful? Not just for this recipe but across flow-matching use-cases? i.e., why here and not in phyiscsnemo.diffusion?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya, I had a discussion with @CharlelieLrt back in the flow matching PR. The time scaling was found to be too specific to our timestep embedder in DiT/Unet. So not generally applicable. It is put as a note in the FM docstring. @CharlelieLrt ?

For the EDMPreconditioner, it needs to be ablated. FM is variance-preserving and typically more stable in training. But idk, maybe useful in FM too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants