Differentiable Hydrological Pipelines Made Easy
DiffHydro is a research-oriented Python library for building, assembling, and training fully differentiable hydrological modeling pipelines using PyTorch.
DiffHydro formulates hydrological models as pipelines of operators (catchment interpolation, runoff generation, routing, dams, indundation modules, etc.). If each operator is differentiable, the entire hydrological system can be trained end-to-end using gradient-based optimization.
DiffHydro provides the building blocks and reference pipelines to make this practical, modular, and extensible.
⚠️ Status: DiffHydro is in early development. APIs may change, and the library is primarily intended for research and experimentation.
- End-to-end differentiable hydrological pipelines
- Modular design: compose models from reusable operators
- Learnable physical parameters (routing, response functions, etc.)
- PyTorch-native (GPU-friendly, autograd-compatible)
- Scalability Important efforts have been put to make very large problem sizes fit into GPU memories.
- Reference pipelines for common hydrological learning setups
- Examples on real datasets, from toy problems to larger-scale cases
DiffHydro is organized around four main components:
diffhydro/
├── structs/ # Core data structures
├── modules/ # Individual differentiable operators
├── pipelines/ # High-level model & training pipelines
examples/ # End-to-end usage examples
Defines the core data structures manipulated throughout the library.
Contains individual differentiable operators. The current releases includes three main components:
- Catchment Interpolation
- Runoff Generation
- Routing Operator
Each module is designed to be:
- Differentiable
- Composable
- Reusable across pipelines
Expect more components to be added soon.
Provides high-level abstractions for assembling and training models.
This includes:
- Models: containers that assemble multiple modules and expose learnable parameters
- Modules: utilities that orchestrate data loading, scheduling, and optimization
Pipelines illustrate typical and recommended usage patterns, but they are not restrictive: advanced users are encouraged to assemble their own pipelines directly from modules.
Example notebooks demonstrating how to use DiffHydro on actual hydrological problems, covering:
- Different spatial scales
- Different levels of physical complexity
- Both small and large datasets
If you are new to DiffHydro, start here.
Install from pip:
pip install diffhydroOr install the latest version directly from source:
git clone https://github.com/TristHas/DiffHydro.git
cd DiffHydro
pip install -e .