Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Performance optimization

Open
#138 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
12/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Active
Tech stack
python
Domain
performance

Research direction

This is an open proposal, not a concrete task: the author asks whether maintainers want performance changes such as running totals for leaf classes, deferred end-of-day condition checks, and compiled step functions. The payload names no files or tests in diffWOFOST. Start by reading the thread and the linked mGV issue, then wait for a maintainer decision. Done would mean a maintainer has agreed on scope and the work is split into smaller issues.

Written by the indexing model from the issue text.

Description

I have performed some performance benchmarks, and found that diffWOFOST main performs similarly at large vector sizes (e.g., many crops simulated at once under different weather conditions) to the non-vectorized WOFOST C port.

However, for coupling WOFOST to the hydrological model we are developing, this performance is likely insufficient compared to mGV and MODFLOW 6. To avoid this bottleneck we would require either diffWOFOST to be more performant, or write our own WOFOST implementation in Julia. Of course we would prefer to tag along with the developments of diffWOFOST.

With an LLM I was able to get diffWOFOST performant enough (WOFOST-72 at least) that there was only a minor difference between diffWOFOST and an optimized Julia GPU port.

The main performance improvements stemmed 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)

For the tests I did add a copy to/from the device to simulate exchanging variables every time step in a coupled model setup.

Would you be interested in (at some point) improving the performance of diffWOFOST with these strategies, or is this out of scope for the current work?

Dominant language
Python
Stars
25
Forks
7
Avg merge
14d 3h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WUR-AI/diffWOFOST

All issues in WUR-AI/diffWOFOST

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.