How b-rbmp/flowcast works
Purpose and execution model
FlowCast is a PyTorch-based probabilistic precipitation-nowcasting system. It forecasts SEVIR radar VIL sequences by learning conditional flow matching (CFM) in an autoencoder-compressed latent space. It is a batch/offline training and inference repository, not a serving application.
Primary entry points:
• Autoencoder training: experiments/sevir/autoencoder/dist_train_autoencoder_kl.py
• Latent-data generation: experiments/sevir/autoencoder/generate_static_dataset.py
• FlowCast distributed training: experiments/sevir/runner/flowcast/dist_train_flowcast.py
• Evaluation/inference: experiments/sevir/runner/flowcast/test_flowcast.py
1. SEVIR ingestion and dataset preparation
Raw SEVIR VIL data is downloaded from public AWS S3, then converted into train/validation/test HDF5 datasets plus metadata CSVs. The preprocessing split boundaries and downsampling are command-line controlled.
• datasets/sevir/sevir_preprocessing.py
• experiments/sevir/dataset/sevirfulldataset.py
• experiments/sevir/dataset/sevirfulldataset_autoencoder.py
This is the boundary from external radar files to model-ready sequence samples. AWS CLI/S3 is required only for initial SEVIR acquisition.
2. KL autoencoder stage
A KL-regularized autoencoder first compresses high-dimensional radar imagery into latent representations. Its distributed trainer consumes full-resolution SEVIR datasets, applies reconstruction/perceptual objectives, checkpoints the model, and uses early stopping.
• experiments/sevir/autoencoder/dist_train_autoencoder_kl.py
• experiments/sevir/autoencoder/autoencoder_kl_config.yaml
• common/autoencoder/losses/lpips.py
The trained encoder/decoder is a hard dependency for both latent-dataset creation and forecast visualization/evaluation.
3. Static latent dataset boundary
The generation script runs the pretrained encoder over full SEVIR train/validation inputs and persists latents as a separate HDF5-backed dataset. This decouples costly image encoding from CFM training and establishes the interface between the two model stages.
• experiments/sevir/autoencoder/generate_static_dataset.py
• experiments/sevir/dataset/sevirfulldataset_autoencoder.py
FlowCast training reads these latent files, while partial evaluation can still use the original full-resolution data for decoded forecast assessment.
4. Conditional flow-matching core
The CFM implementation defines the noise-to-data latent trajectory and training objective. The FlowCast runner conditions generation on observed radar-history latents, trains the latent dynamical/generative model under distributed execution, and saves model artifacts.
• common/cfm/cfm.py
• experiments/sevir/runner/flowcast/dist_train_flowcast.py
• experiments/sevir/runner/flowcast/flowcast_config.yaml
At inference, sampled noise is integrated/mapped to future latents conditioned on context; generated future latents are decoded by the autoencoder back to radar fields.
5. FlowCast neural architecture
The learned CFM vector field is implemented using cuboid-transformer and U-Net-style components, with explicit temporal embeddings and transformer attention-pattern definitions.
• common/models/flowcast/cuboid_transformer_unet.py
• common/models/flowcast/cuboid_transformer.py
• common/models/flowcast/time_embed.py
This layer is model-specific infrastructure beneath the trainer: it receives latent spatiotemporal tensors plus conditioning/time information and produces flow predictions.
6. Evaluation, metrics, and outputs
Testing restores autoencoder and FlowCast checkpoints, generates forecasts over the held-out full SEVIR test set, decodes results, and computes deterministic/probabilistic nowcasting quality measures.
• experiments/sevir/runner/flowcast/test_flowcast.py
• common/metrics/metrics_streaming_probabilistic.py
• common/metrics/fss.py
Display utilities support geographic/image presentation but are downstream of inference.
• experiments/sevir/display/display.py
Runtime and artifact dependencies
Python 3.10 with PyTorch/TorchVision and CUDA is the primary runtime. Training uses torchrun multi-process distributed execution; documented workloads target multi-H100 nodes. Persistent artifacts include preprocessed/latent HDF5 and CSV data, autoencoder and FlowCast checkpoints under saved_models/, and optional pretrained checkpoints from Hugging Face Hub.
Main entry points: test_flowcast.py FlowCast inference and test · dist_train_flowcast.py FlowCast trainer · dist_train_autoencoder_kl.py KL autoencoder trainer · sevirfulldataset.py Full SEVIR datasets
Components 21
SEVIR data pipeline
- Public SEVIR S3 · Raw radar VIL files acquired with AWS CLI.
- SEVIR preprocessing · Splits and downsamples raw SEVIR into HDF5 and metadata.
datasets/sevir/sevir_preprocessing.py - Full SEVIR datasets · Model-ready full-resolution train, validation, and test sequences.
experiments/sevir/dataset/sevirfulldataset.py - Autoencoder dataset loader · Loads full SEVIR samples for encoding and autoencoder training.
experiments/sevir/dataset/sevirfulldataset_autoencoder.py
Latent autoencoder
- KL autoencoder trainer · Trains and checkpoints the radar latent encoder/decoder.
experiments/sevir/autoencoder/dist_train_autoencoder_kl.py - Autoencoder config
experiments/sevir/autoencoder/autoencoder_kl_config.yaml - Perceptual loss
common/autoencoder/losses/lpips.py - Autoencoder checkpoint · Required to encode latent data and decode forecasts.
- Static latent generation · Encodes train and validation sequences into persistent latents.
experiments/sevir/autoencoder/generate_static_dataset.py
FlowCast training
- Latent HDF5 dataset · Precomputed representation boundary for FlowCast training.
- FlowCast trainer · Trains the conditional latent flow model with torchrun.
experiments/sevir/runner/flowcast/dist_train_flowcast.py - FlowCast config
experiments/sevir/runner/flowcast/flowcast_config.yaml - Conditional flow matching · Defines noise-to-data paths and the vector-field objective.
common/cfm/cfm.py - Cuboid Transformer U-Net · Predicts latent flow from context and time conditioning.
common/models/flowcast/cuboid_transformer_unet.py - Cuboid transformer
common/models/flowcast/cuboid_transformer.py - Time embeddings
common/models/flowcast/time_embed.py - FlowCast checkpoint · Saved latent forecasting model.
Forecast evaluation
- FlowCast inference and test · Samples future latents, decodes forecasts, and evaluates held-out SEVIR.
experiments/sevir/runner/flowcast/test_flowcast.py - Probabilistic metrics
common/metrics/metrics_streaming_probabilistic.py - Fraction skill score
common/metrics/fss.py - Forecast display
experiments/sevir/display/display.py
Connections 23
- Public SEVIR S3 → SEVIR preprocessing: raw VIL
- SEVIR preprocessing → Full SEVIR datasets: HDF5 sequences
- Full SEVIR datasets → Autoencoder dataset loader: full-resolution samples
- Autoencoder dataset loader → KL autoencoder trainer: training batches
- Autoencoder config → KL autoencoder trainer: configures
- Perceptual loss → KL autoencoder trainer: perceptual objective
- KL autoencoder trainer → Autoencoder checkpoint: saves
- Autoencoder dataset loader → Static latent generation: train/validation samples
- Autoencoder checkpoint → Static latent generation: pretrained encoder
- Static latent generation → Latent HDF5 dataset: encoded latents
- Latent HDF5 dataset → FlowCast trainer: latent batches
- FlowCast config → FlowCast trainer: configures
- Conditional flow matching → FlowCast trainer: training objective
- Cuboid Transformer U-Net → FlowCast trainer: learned vector field
- Cuboid transformer → Cuboid Transformer U-Net: attention layers
- Time embeddings → Cuboid Transformer U-Net: time conditioning
- FlowCast trainer → FlowCast checkpoint: saves
- Full SEVIR datasets → FlowCast inference and test: held-out radar sequences
- Autoencoder checkpoint → FlowCast inference and test: decodes forecasts
- FlowCast checkpoint → FlowCast inference and test: samples future latents
- FlowCast inference and test → Probabilistic metrics: forecast scores
- FlowCast inference and test → Fraction skill score: spatial scores
- FlowCast inference and test → Forecast display: decoded forecasts