Skip to content

Add CPU multithreading for particle filters - #195

Merged
THargreaves merged 4 commits into
mainfrom
th/cpu-threading
Sep 30, 2026
Merged

THargreaves merged 4 commits into
mainfrom
th/cpu-threading

Conversation

@THargreaves

@THargreaves THargreaves commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #135. Supersedes th/parallel-pf.

Adds opt-in multithreading for particle filters via BF(N; execution=ThreadedExecution()). RBPF, APF and CSMC (including ancestor sampling and backward simulation weights) inherit the setting. Per-particle work runs in fixed-size blocks, each with its own RNG derived from the caller's, so results don't depend on the number of threads. SerialExecution() remains the default and is unchanged.

Introduce _predict_particles and _update_particles as the population
traversal boundary, matching the GPU RBPF work so both CPU threading and
batched storage dispatch at the same point.
ParticleFilter gains an execution option (SerialExecution by default,
ThreadedExecution opt-in), forwarded by RBPF and AuxiliaryParticleFilter.
Initialisation, prediction, updates and APF lookahead weights go through
a single population map. Threaded maps give each fixed-size block of
particles its own generator derived from one draw of the caller's rng,
so results do not depend on the number of threads or scheduling.
Route the refreshment weight maps through the particle filter's
execution. The weights draw no randomness, so threaded values equal
serial ones exactly. Closes #135.
@THargreaves
THargreaves merged commit a0011cc into main Sep 30, 2026
14 of 16 checks passed
@THargreaves
THargreaves deleted the th/cpu-threading branch September 30, 2026 19:50
@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.66%. Comparing base (b13280a) to head (57a3a90).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
GeneralisedFilters/src/execution.jl 96.22% 2 Missing ⚠️
GeneralisedFilters/test/support/type_stability.jl 0.00% 2 Missing ⚠️
GeneralisedFilters/src/algorithms/particles.jl 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #195      +/-   ##
==========================================
+ Coverage   78.88%   79.66%   +0.77%     
==========================================
  Files          77       80       +3     
  Lines        3386     3530     +144     
==========================================
+ Hits         2671     2812     +141     
- Misses        715      718       +3     
Flag Coverage Δ
GeneralisedFilters 80.44% <96.87%> (+0.76%) ⬆️
SSMProblems 56.14% <ø> (ø)

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.

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.

Add parallelisation to particle refreshment

1 participant