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

Optimise convolutions #745

Merged
merged 10 commits into from
Aug 28, 2024
Merged

Optimise convolutions #745

merged 10 commits into from
Aug 28, 2024

Conversation

seabbs
Copy link
Contributor

@seabbs seabbs commented Aug 14, 2024

Description

This PR is unlinked to an issue but applies some optimises to speed up convolutions (a key pain point of the stan code base). It also replaces the custom reverse_mf function with the new reverse built in.

Initial submission checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have tested my changes locally (using devtools::test() and devtools::check()).
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required and rebuilt docs if yes (using devtools::document()).
  • I have followed the established coding standards (and checked using lintr::lint_package()).
  • I have added a news item linked to this PR.

After the initial Pull Request

  • I have reviewed Checks for this PR and addressed any issues as far as I am able.

@seabbs seabbs marked this pull request as ready for review August 14, 2024 15:57
@seabbs

This comment was marked as outdated.

This comment was marked as outdated.

@seabbs
Copy link
Contributor Author

seabbs commented Aug 14, 2024

Slightly surprisingly this doesn't seem to make a great deal of difference. Regardless I think it should be more stable and is definitely easier to test.

@jamesmbaazam
Copy link
Contributor

Thanks for this, Sam. I'll review it today.

@seabbs
Copy link
Contributor Author

seabbs commented Aug 15, 2024

How did you get on with this?

@seabbs seabbs requested a review from sbfnk August 19, 2024 20:43
@jamesmbaazam
Copy link
Contributor

Sorry, I missed this notification. I'll finish reviewing all your PRs by close of Thursday. I'm prioritising the GP vectorisations PR due to the speed gains.

Copy link
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 781a930 is merged into main:

  • ✔️default: 43.4s -> 45.7s [-17.64%, +28.28%]
  • ✔️no_delays: 50s -> 54.8s [-15.39%, +34.66%]
  • ✔️random_walk: 9.74s -> 9.88s [-7.47%, +10.45%]
  • ✔️stationary: 27.6s -> 22.1s [-64.09%, +24.42%]
  • ✔️uncertain: 1.14m -> 1.18m [-18.52%, +26.04%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

Co-authored-by: James Azam <james.azam@lshtm.ac.uk>
Copy link
Contributor

@jamesmbaazam jamesmbaazam left a comment

Choose a reason for hiding this comment

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

This all looks good to me. The code is more readable now.

@seabbs
Copy link
Contributor Author

seabbs commented Aug 28, 2024

Nice and I agree. Thanks for the review. This is just waiting on our decisions in the conversations. My vote is leave as is for this PR and if we feel strongly move to a new issue to refactor? It could be a good issue for someone new to stan to tackle if we decide to go that way

Copy link
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if 500924f is merged into main:

  • ✔️default: 58.8s -> 49.7s [-55.3%, +24.34%]
  • ✔️no_delays: 50.3s -> 51.4s [-15.61%, +19.71%]
  • ✔️random_walk: 9.74s -> 58.8s [-655.79%, +1662.54%]
  • ✔️stationary: 22.7s -> 22.7s [-9.86%, +9.69%]
  • ✔️uncertain: 1.09m -> 1.16m [-4.87%, +17.24%]
    Further explanation regarding interpretation and methodology can be found in the documentation.

@seabbs seabbs added this pull request to the merge queue Aug 28, 2024
Merged via the queue into main with commit 903cc8b Aug 28, 2024
15 checks passed
@seabbs seabbs deleted the optimise-convolutions branch August 28, 2024 18:27
@jamesmbaazam
Copy link
Contributor

I don't feel strongly about it.

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