What Is the google-deepmind/weathernext Repository? A Deep Dive into AI Weather Forecasting
The google-deepmind/weathernext repository is an open-source research platform that provides reproducible implementations of state-of-the-art AI weather forecasting models including WeatherNext 2, GraphCast, and GenCast, along with pretrained checkpoints and inference utilities.
Developed by Google DeepMind and Google Research, this codebase serves as a complete toolkit for medium-range atmospheric and tropical cyclone prediction. It bundles JAX/Haiku-based model implementations, shared utilities for meteorological data manipulation, and production-ready inference pipelines that enable researchers to run global forecasts on TPUs or GPUs without training from scratch.
Core Purpose and Architecture
The repository centralizes three generations of weather forecasting systems under a unified modular architecture. According to the source code, its primary goal is to democratize access to AI-driven meteorological models that previously required significant computational resources and internal infrastructure to reproduce.
WeatherNext 2 (WN2): The Flagship Model
WeatherNext 2 represents the latest generation—a global, medium-range forecasting system implemented in weathernext/weathernext2/architecture.py. The core model definition resides in the ForwardPass class, which orchestrates latent dense layers, spatial feature extraction, and mesh-based graph processing.
The architecture supports auto-regressive rollout for extended forecasts, processing inputs through configurable mesh splits (typically mesh_num_splits=4) and converting between grid and mesh representations. In weathernext/weathernext2/architecture.py (lines 15-78), the model constructor accepts parameters for point-to-mesh, mesh-to-mesh, and mesh-to-grid transformations, enabling flexible graph neural network configurations.
Predecessor Models: GraphCast and GenCast
The repository maintains backward compatibility with earlier breakthrough models:
-
GraphCast: A deterministic forecasting system based on graph neural networks, defined in
weathernext/weathernext1_graph/graphcast.py. This model processes atmospheric variables as nodes on a spherical mesh, offering 10-day predictions with computational efficiency superior to traditional numerical weather prediction. -
GenCast: A diffusion-based ensemble model located in
weathernext/weathernext1_gen/gencast.py. Unlike the deterministic GraphCast, GenCast generates probabilistic forecasts by sampling from learned distributions, providing uncertainty quantification critical for operational meteorology.
Key Components and File Structure
The codebase organizes functionality into model-specific directories and shared utilities:
weathernext/weathernext2/architecture.py: Core WeatherNext 2 model definition and forward pass implementationweathernext/weathernext1_graph/graphcast.py: GraphCast deterministic baseline architectureweathernext/weathernext1_gen/gencast.py: Diffusion-based ensemble modelweathernext/utils/rollout.py: Auto-regressive rollout utilities for multi-step inferenceweathernext/utils/data_modalities.py: Definitions for atmospheric data types (global, mesh, grid)weathernext/utils/autoregressive.py: Helper functions for auto-regressive loss computation and training loops
These modules rely on JAX for automatic differentiation and Haiku for neural network parameter management, facilitating both research experimentation and production deployment.
Running Inference: Code Examples
The following examples demonstrate common workflows for installing the package and running forecasts using pretrained weights.
Installation
Install directly from the GitHub repository to access the latest stable release:
pip install git+https://github.com/google-deepmind/weathernext.git@v0.3.0
Loading Pretrained Weights
The repository distributes checkpoints via Google Cloud Storage. As documented in the README, weights are accessible from public buckets (e.g., gs://dm_graphcast/), eliminating the need for extensive training runs.
Running a WeatherNext 2 Rollout
The following snippet illustrates loading a checkpoint and executing a 10-day forecast using the auto-regressive utilities:
import jax
import haiku as hk
import xarray as xr
import numpy as np
from weathernext.weathernext2 import architecture
from weathernext.utils import rollout
# Load pretrained checkpoint
ckpt_path = "gs://dm_graphcast/WeatherNext2_<2025_model1>.npz"
params = hk.data_structures.from_numpy(np.load(ckpt_path))
# Prepare input data (ERA5/HRES datasets in production)
inputs = xr.Dataset() # Initial atmospheric conditions
forcings = xr.Dataset() # Solar radiation, topography, etc.
targets_template = xr.Dataset() # Output structure definition
# Initialize model
model = architecture.ForwardPass(
latent_dense_kwargs=dict(),
output_dense_kwargs=dict(output_size=...),
spatial_features_kwargs=dict(),
mesh_num_splits=4,
points_to_mesh_model_ctor=...,
mesh_model_ctor=...,
mesh_to_grid_model_ctor=...,
)
# Define prediction step
def predict_step(state):
return model.apply(params, inputs=state, targets_template=targets_template,
forcings=forcings, is_training=False)
# Run 10-day forecast (40 steps × 6 hours)
predicted = rollout.auto_regressive(
predict_step,
initial_state=inputs,
num_steps=40
)
Using GraphCast and GenCast
For deterministic forecasting with GraphCast:
from weathernext.weathernext1_graph.graphcast import GraphCast
graphcast = GraphCast(...)
output = graphcast.apply(graphcast_params, inputs, forcings, is_training=False)
For probabilistic ensemble forecasting with GenCast:
from weathernext.weathernext1_gen.gencast import GenCast
from weathernext.weathernext1_gen.samplers_utils import sample_ensemble
gencast = GenCast(...)
samples = sample_ensemble(gencast, num_ensembles=32, ...)
Data Handling and Utilities
Effective weather forecasting requires robust data pipelines for handling multi-dimensional atmospheric fields. The weathernext/utils/ directory provides standardized tools for these operations.
Data modalities defined in data_modalities.py handle the conversion between irregular geospatial grids and uniform mesh representations required by graph neural networks. This includes normalization constants for variables like temperature, wind velocity, and pressure at various atmospheric levels.
The rollout utilities in rollout.py manage the auto-regressive feedback loop where model outputs become subsequent inputs, enabling iterative forecasting beyond single time steps. This implementation handles boundary conditions and forcing data injection at each step, critical for maintaining physical consistency across 10-day predictions.
Summary
- The google-deepmind/weathernext repository provides open-source implementations of WeatherNext 2, GraphCast, and GenCast—state-of-the-art AI models for global weather prediction.
- Core architecture is implemented in JAX/Haiku within
architecture.py,graphcast.py, andgencast.py, supporting both deterministic and probabilistic forecasting paradigms. - Pretrained checkpoints are publicly available, allowing immediate inference on TPUs or GPUs without training from scratch.
- Modular utilities in
weathernext/utils/handle data modalities, auto-regressive rollout, and mesh-based graph processing for meteorological datasets. - Extensible design enables researchers to modify graph structures, incorporate new atmospheric variables, or benchmark against ERA5 and HRES datasets.
Frequently Asked Questions
What hardware requirements does the google-deepmind/weathernext repository require?
The codebase is optimized for TPU accelerators but supports GPU execution for inference. Training requires substantial computational resources typical of large-scale transformer or graph neural network workloads, while the provided pretrained checkpoints allow researchers to run 10-day forecasts on modest single-GPU setups using the JAX-compiled models.
How does WeatherNext 2 differ from GraphCast?
WeatherNext 2 represents the next-generation architecture with improved spatial feature extraction and mesh processing capabilities compared to GraphCast. While GraphCast provides deterministic predictions using graph neural networks, WeatherNext 2 incorporates advances in latent dense architectures and multi-scale modeling. Both are maintained in the repository to enable direct benchmarking and ablation studies.
Can I train my own model using this repository?
Yes. The repository exposes training loops and loss functions in weathernext/utils/autoregressive.py and supports customization of the ForwardPass architecture. Users can train on standard meteorological datasets like ERA5 by implementing the data modalities specified in data_modalities.py, though training requires access to substantial computational resources for global atmospheric modeling.
Where can I download pretrained checkpoints for weathernext models?
Pretrained weights are distributed through public Google Cloud Storage buckets referenced in the repository README. The documentation provides direct links to checkpoints for WeatherNext 2, GraphCast, and GenCast models, including specific versions optimized for tropical cyclone forecasting and medium-range weather prediction.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →