Skip to content

Performance improvements - #139

Draft
BSchilperoort wants to merge 3 commits into
WUR-AI:mainfrom
BSchilperoort:perf/leaf-accumulators
Draft

BSchilperoort wants to merge 3 commits into
WUR-AI:mainfrom
BSchilperoort:perf/leaf-accumulators

Conversation

@BSchilperoort

Copy link
Copy Markdown

This PR makes the model up to 16x faster on my GPU (AMD 7800 XT). The context was discussed in #138

The main performance improvements stem from:

  • Keeping leaf classes as running totals, instead of computing a cumulative sum every time step
  • Defer condition checking to end-of-day, instead of mid-step so they can be computed with only a single host-device sync (Carbon-balance, partitioning, latitude and vernalisation checks currently queue a device-side flag)
  • Stop traitlets comparing every assigned tensor (Every state assignment ran bool(old == new). On a multi-element tensor this launches a comparison kernel and then fails silently; on one-element tensors it forces a sync)
  • Move sets of operations into a single function, and compile these functions (e.g. in root_dynamics move computation of calc_rates into a separate compilable function)

In addition, the tests are sped up a bit too.

Disclaimer: the modifications were fully written by an LLM, and I did not go over every line of code. Tests were basically untouched in 5972458 (only 2 vars renamed), and all tests still seem to pass.

I am not in a hurry to merge this, and can wait for #137 to be merged first.

This branch has not been deployed

No deployments
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.

2 participants