Skip to content

Speed up generation depletion draws - #1267

Merged
sbfnk merged 4 commits into
mainfrom
issue-1266-draw-the-depletion-binomial-of-a-generat
Nov 27, 2026
Merged

sbfnk merged 4 commits into
mainfrom
issue-1266-draw-the-depletion-binomial-of-a-generat

Conversation

@sbfnk-bot

Copy link
Copy Markdown
Collaborator

Use inversion and rejection sampling for single-type depletion binomials at smaller means within PerContactDepletion, retaining the standard sampler for larger means and populations. Timing comparisons showed faster draws at the smaller means tested.

Binomial mean and variance checks, generation-count tests and formatting checks passed.

This PR closes #1266.

sbfnk-bot and others added 3 commits November 26, 2026 21:36
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark comparison vs base

Minimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:

Group 🟢 <50% 🟢 50–75% 🟢 75–95% ⚪ 95–105% 🔴 105–125% 🔴 125–150% 🔴 >150%
Evaluation · · · 19 · · ·
Evaluation — 19 benchmarks (by time change)
Benchmark base PR time memory
simulation: households 822.52 μs 796.12 μs ⚪ 0.97× ⚪ 1.0×
simulation: branching process, HeldCapacity with DeferRefused 909.12 ms 883.73 ms ⚪ 0.97× ⚪ 1.0×
simulation: homogeneous 25.69 ms 25.01 ms ⚪ 0.97× ⚪ 1.0×
simulation: homogeneous SI, max_time 18.41 ms 18.85 ms ⚪ 1.02× ⚪ 1.0×
simulation: network, live kernel 3.21 ms 3.17 ms ⚪ 0.99× ⚪ 1.0×
simulation: branching process 1.14 ms 1.16 ms ⚪ 1.01× ⚪ 1.0×
simulation: homogeneous, susceptibility trait 32.25 ms 31.82 ms ⚪ 0.99× ⚪ 1.0×
simulation: network, live kernel with policy 3.3 ms 3.27 ms ⚪ 0.99× ⚪ 1.0×
simulation: network, shared kernel 130.53 μs 131.66 μs ⚪ 1.01× ⚪ 1.0×
simulation: branching process, interventions 12.1 μs 12.05 μs ⚪ 1.0× ⚪ 1.0×
evaluation: compile_contact_pairs 20.87 μs 20.95 μs ⚪ 1.0× ⚪ 1.0×
evaluation: pairwise_surv_loglik 19.28 μs 19.33 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonLognormal pdf 28.07 μs 28.01 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonWeibull pdf, large count 36.15 μs 36.12 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonLognormal pdf, large count 29.05 μs 29.03 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonWeibull pdf 37.18 μs 37.2 μs ⚪ 1.0× ⚪ 1.0×
evaluation: ChainSizes loglikelihood 340.0 ns 340.0 ns ⚪ 1.0× —
evaluation: chain size loglikelihood 1.36 μs 1.36 μs ⚪ 1.0× —
evaluation: extinction_probability 761.0 ns 761.0 ns ⚪ 1.0× ⚪ 1.0×
AD gradients — 0 benchmarks (by time change)

none

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.80%. Comparing base (759ea53) to head (a3ae45d).

Files with missing lines Patch % Lines
src/models/generation_counts.jl 97.82% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1267      +/-   ##
==========================================
- Coverage   97.80%   97.80%   -0.01%     
==========================================
  Files         104      104              
  Lines       11852    11895      +43     
==========================================
+ Hits        11592    11634      +42     
- Misses        260      261       +1     
Flag Coverage Δ
epibranch-ad 29.24% <0.00%> (-0.12%) ⬇️
epibranch-analytical 40.28% <0.00%> (-0.17%) ⬇️
epibranch-engine 52.17% <0.00%> (-0.21%) ⬇️
epibranch-inference 44.04% <0.00%> (-0.18%) ⬇️
epibranch-interventions 54.26% <97.82%> (+0.17%) ⬆️
epibranch-population 53.95% <97.82%> (+0.17%) ⬆️
epihouseholds 96.94% <ø> (ø)
epinetwork 95.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@sbfnk-bot

Copy link
Copy Markdown
Collaborator Author

Added the final return required by Runic in the depletion sampler. The Runic check and generation-count tests pass.

@sbfnk-bot
sbfnk-bot marked this pull request as ready for review November 26, 2026 23:16
@sbfnk-bot
sbfnk-bot requested a review from sbfnk as a code owner November 26, 2026 23:16
@sbfnk
sbfnk merged commit 9690136 into main Nov 27, 2026
29 checks passed
@sbfnk
sbfnk deleted the issue-1266-draw-the-depletion-binomial-of-a-generat branch November 27, 2026 09:24
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.

Draw the depletion binomial of a generation faster

2 participants