Hapi: A Multivariable Land-Surface Transformer for Medium-Range Hydrological Forecasting at Continental Scale

Hong Zhang, John K. Hutchison, Rao Kotamarthi, Jeremy Feinstein, Haiwen Guan, Romit Maulik, Vijay P. Ramalingam, Jason Stock, Tom WallarXiv 2026

TL;DR

Hapi is a novel hierarchical deep learning model (a U-Net Swin Transformer) designed for high-resolution, continental-scale hydrological forecasting. By predicting multiple land-surface variables simultaneously, it outperforms both traditional physics-based operational models and state-of-the-art AI baselines in flood detection. Remarkably, Hapi can generate a 72-hour forecast across the entire contiguous United States in just 0.11 seconds on a single GPU.

What Problem Does This Paper Address?

Predicting floods days in advance requires balancing local hydrological details (like narrow river channels) with massive, continental-scale weather systems. Historically, operational systems have relied on physics-based simulators. While accurate, these simulators consume millions of CPU hours annually, require meticulous regional hand-tuning, and take months to adapt to new variables or regions.

Conversely, recent deep learning approaches have shown promise but typically treat rivers as isolated basins or individual gauges. This pointwise focus ignores explicit spatial interactions across a continuous domain. The authors introduce Hapi to bridge this gap, providing a computationally efficient, gridded AI model capable of forecasting multiple coupled land-surface states across an entire continent.

Methods

Hapi’s architecture integrates a U-Net encoder-decoder with Swin Transformer V2 blocks, utilizing 2D rotary position embeddings (RoPE) and gated attention mechanisms.

Figure 2: Hapi architecture. The encoder on the left downsamples through patch merging across N stages; each Swin block uses 2D rotary position embeddings and gated attention, both described below. The decoder on the right upsamples through patch unmerging, with skip connections transferring fine- grained features from matching encoder stages. During autoregressive rollout, prognostic channels are predicted and fed back, forcing channels are supplied externally, and static channels remain fixed, as described in Section 3.2.

Key methodological innovations include:

  • Fine 3D Patching: Hapi uses small $2 \times 2$ spatial patches to prevent the early loss of local hydrological details during downsampling.
  • Hierarchical Shifted-Window Attention: This allows the model to scale its spatial context dynamically, expanding from local river channels up to synoptic weather scales.
  • Learned Laplacian Task Weighting: Hydrological variables span multiple orders of magnitude and contain frequent zeros (e.g., snow water equivalent). Instead of hand-tuning loss weights, the authors adapted an uncertainty-based loss formulation into a Laplacian form using Mean Absolute Error (MAE), allowing the model to automatically balance heterogeneous targets during training.
  • Prognostic–Forcing Separation: During autoregressive rollout, the model feeds its own prognostic predictions (discharge, runoff, snow, soil wetness) back into the next step while updating meteorological forcing (precipitation, temperature) from external weather data.

Datasets

The model was trained and evaluated on a daily gridded dataset spanning 20 years (2005–2024) over the contiguous United States (CONUS) at a high-resolution 0.05° grid (~5 km).

Table 1: The 12 model inputs, grouped by their role in the autoregressive rollout. ERA5-Land fields come from the Copernicus Climate Change Service Climate Data Store [Copernicus Climate Change Service, 2019]; upstream drainage area comes from the GloFAS v4.0 auxiliary data [ECMWF, 2023]. DEM denotes digital elevation model.
  • Targets (Prognostic): River discharge, runoff water equivalent, snow water equivalent, and soil wetness index from the GloFAS reanalysis.
  • Forcing Inputs: Total runoff, precipitation, evaporation, soil water, solar radiation, and 2m air temperature from ERA5-Land.
  • Static Inputs: Elevation (DEM) and upstream drainage area.
  • Observational Validation: Independent daily discharge data from 3,881 U.S. Geological Survey (USGS) gauges.

Key Insights and Ideas

  • The Power of Joint Prediction: Modeling multiple coupled land-surface variables (like soil moisture and runoff alongside river discharge) provides positive transfer, improving the accuracy of the primary target—river discharge.
  • Adaptive Loss Balancing is Crucial for Extremes: Controlled ablation experiments showed that uniform task weighting severely degrades performance. Learning the task scales dynamically yields the lowest errors and significantly boosts the detection of rare, extreme flood events.
  • Standard Metrics Can Mask Flood Failures: Through precipitation-perturbation experiments, the authors found that overall continuous metrics like the Nash–Sutcliffe Efficiency (NSE) can remain deceptively stable even when the model's ability to detect rare, threshold-crossing floods degrades sharply. This underscores the importance of evaluating models using threshold-based flood metrics.

Key Results

  • Superior Flood Detection: Hapi achieved the highest flood-detection F1 score in 20 out of 21 lead–threshold comparisons, outperforming the operational physics-based GloFAS model and the state-of-the-art AI model, RiverMamba.
  • Better Local Skill: Hapi achieved a higher median per-cell NSE than GloFAS and persistence at all forecast leads (24, 48, and 72 hours). Independent validation against 3,881 USGS gauges confirmed that this advantage holds true against real-world observations.
Figure 1: Continental illustration of a Hapi discharge forecast. a, Discharge at initialization on 20 June 2024, represented by the field carried forward in the persistence forecast. b, Hapi’s 72-h discharge forecast valid on 23 June. c, GloFAS reanalysis for the same valid date. d, Correctly predicted exceedances (hits), missed exceedances, and false alarms at each cell’s local 2-year return level; cells with no forecast or reference exceedance are shown in grey. The valid date was selected independently of Hapi as the 2024 test date with the largest number of reference 2-year-threshold exceedances over CONUS. The discharge maps share a logarithmic colour scale.
  • Blazing Fast Inference: Hapi generates a 72-hour continental forecast in an average of 0.11 seconds on a single NVIDIA A100 GPU, demonstrating a normalized throughput that is 5.1× faster than RiverMamba.

Limitations and Future Work

  • Reanalysis Dependency: This study conditioned forecasts on reconstructed weather fields (ERA5-Land). Future work must evaluate Hapi using actual operational Numerical Weather Prediction (NWP) forecasts to account for real-world atmospheric forecast errors.
  • Deterministic Framework: Hapi is currently deterministic. The authors note it should be extended to probabilistic predictions or calibrated ensembles to better characterize forecast uncertainty.
  • Human Interference: The model struggles with heavily regulated rivers. Because Hapi does not currently ingest reservoir storage states, dam operating rules, or release schedules, human-managed water systems remain a distinct forecasting challenge.

Summary updated

BibTeX
@misc{zhang2026hapi,
  author = {Hong Zhang and John K. Hutchison and Rao Kotamarthi and Jeremy Feinstein and Haiwen Guan and Romit Maulik and Vijay P. Ramalingam and Jason Stock and Tom Wall},
  title = {{Hapi: A Multivariable Land-Surface Transformer for Medium-Range Hydrological Forecasting at Continental Scale}},
  year = {2026},
  eprint = {2609.22702},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.22702},
}
Figure