Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-Initialize model xarray with timesteps #77

Merged
merged 19 commits into from
Mar 15, 2024
Merged

Conversation

sjordan29
Copy link
Contributor

Closes #68

This PR adds a new required time_steps parameter for instantiation of the base model class. Writing to a pre-initialized array rather than continuously concatenating arrays has speed advantages, particularly for large model grids and a large number of model timesteps -- as shown in #68, for models with > 100 iterations and >10 model cells, we see performance gains which become substantial as the number of iterations/grid sizes grows (>14x improvement at best). Additional memory management improvements will help address minor slowdowns for single-cell models.

@sjordan29 sjordan29 linked an issue Mar 14, 2024 that may be closed by this pull request
Copy link
Member

@aufdenkampe aufdenkampe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjordan29, Nice work! I looked over your code carefully, and I'm quite impressed (although I didn't run anything). I love the new examples/dev_sandbox/performance_profiling_tsm.py and its sister notebook. The plots are quite compelling, and it will be great to continue to add to it.

I'm also impressed with your work in src/clearwater_modules/base.py to properly set up the pre-initialized xarray datasets with all their coords. I imagine that sets us up nicely to tackle #69.

Thanks for updating and rerunning examples/model_architecture.ipynb.

Let's merge this!

@sjordan29
Copy link
Contributor Author

@imscw95, @kewalak - FYI - merging this to main. Changes require models to have a time_steps input parameter during instantiation to initialize the xarray dataset we're running and improve performance.

@sjordan29 sjordan29 merged commit 368bddc into main Mar 15, 2024
1 check passed
@sjordan29 sjordan29 deleted the performance-pre-init branch March 15, 2024 14:04
@sjordan29 sjordan29 mentioned this pull request Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pre-initialize output xarray time coordinates and variables
2 participants