Skip to content

[BUG] Probabilistic predictions suffer from variance underflow and ignore pred_std during ensemble generation #526

Description

@Panchadip-128

Title: [BUG] Probabilistic predictions suffer from variance underflow and ignore pred_std during ensemble generation

Description:

Description

While reviewing the probabilistic forecasting (--output_std) logic and verification pathways, I identified two critical bugs where the network's uncertainty predictions produce NaN mathematical collapses or are silently discarded during evaluation.

1. softplus Variance Underflow Leading to NaN Losses

In neural_lam/models/base_graph_model.py, the standard deviation is computed natively as:

pred_std = torch.nn.functional.softplus(pred_std_raw)

PyTorch's softplus evaluates to exactly 0.0 for sufficiently negative inputs (e.g., softplus(-100) == 0.0). When pred_std underflows to zero, it causes division-by-zero operations when calculating standard scores for nll or crps_gauss targets, producing cascading NaNs that irreversibly crash training.

2. Degenerate Ensembles Discarding True Uncertainty

In neural_lam/models/ar_model.py, the _sample_ensemble method hardcodes the generation of Gaussian noise to a static 0.01 standard deviation:

noise = torch.randn(...) * 0.01

Because this method ignores the model's dynamically predicted uncertainty map (pred_std), running an ensemble inference on a properly trained probabilistic model throws away the highly detailed uncertainty predictions and relies entirely on an arbitrary 0.01 fallback jitter.

Reproduction

  1. Manually inject a highly negative tensor (e.g. [-100.0]) into pred_std_raw during a forward pass and evaluate mse/nll, resulting in a NaN crash.
  2. Run inference with output_mode="ensemble" and --output_std, and observe that the variance of the resulting ensemble instances remains ~0.01 regardless of the model's actual confidence regarding the weather state.

Expected behavior

  1. pred_std should be safely clamped to a small epsilon (e.g. 1e-6) to guarantee numerical stability during metrics computation.
  2. _sample_ensemble should physically draw its noise distribution from the dynamically calculated pred_std matrix if it is available.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions