Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@leoglonz
Copy link
Member

@leoglonz leoglonz commented Oct 27, 2025

Issue Addressed

This update adds persistent internal state caching of storages for all HBV physical models, thereby enabling these models to be run sequentially in time (critical in scenarios that forbid running a model on all timesteps simultaneously in a batched fashion).

Description

This is the sister PR to mhpi/generic_deltamodel/pull/73 which supports the changes made to physical models here. We would advise checking this to contextualize the necessity of these changes. TLDR; we add persistent caching and methods .get_states() and .load_states(<your states>) to both fetch and load states to these models, respectively. These methods connect to dMG and will eventually enable natively saving states to, and loading states from, a file so that they may persist after a runtime has completed.

Furthermore, the changes here support of simplifying sequential modeling applications like NOAA's NextGen and CIROH-UA's NGIAB.

Note we only consider the models storage states here. In the second part of this update, parameter caching and saving will also be added for native access in dMG.

Note Pt2: it is yet unclear if caching states at every forward call adds nontrivial overhead from IO -- of course this will not be evident in minimal test cases and will require field testing. In particular, state tensors are always converted to CPU memory when cached, and converted back to the model's target device if using cache_states; hence the overhead.

Inspiration

These additions were motivated in part by the state loading work @ZhennanShi1 first introduced for HydroDL and later PR, as well as #72 (for which I hope this begins to enable use in sequential applications). Furthermore, this work was motivate to, and makes great strides towards, simplifying dMG model applications in NOAA's NextGen national water modeling framework and CIROH-UA's NGIAB.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code cleanup/refactor
  • Documentation update

Other (please specify):

Checklist

  • Branch is up to date with master
  • Updated tests or added new tests
  • Tests & pre-commit hooks pass
  • Updated documentation (if applicable)
  • Code follows established style and conventions

@leoglonz leoglonz self-assigned this Oct 27, 2025
@leoglonz leoglonz added the enhancement New feature or request label Oct 27, 2025
@leoglonz leoglonz linked an issue Oct 27, 2025 that may be closed by this pull request
@leoglonz leoglonz closed this in ce2458f Oct 27, 2025
leoglonz added a commit that referenced this pull request Oct 27, 2025
@leoglonz leoglonz reopened this Oct 27, 2025
@leoglonz leoglonz closed this in 1e56603 Oct 27, 2025
@leoglonz leoglonz deleted the ngiab branch October 27, 2025 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorporate State-Saving HBV

2 participants