You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GeneralisedFilters: Stratified resampler is exported but has no CPU method #187
Stratified is exported from GeneralisedFilters, but sample_ancestors has no method for a plain Vector, so any CPU use of it fails with a MethodError.
Reproducer
using Random, GeneralisedFilters
using GeneralisedFilters: Stratified, Systematic, Multinomial, Metropolis, Rejection,
sample_ancestors
w = [0.25, 0.25, 0.25, 0.25]
sample_ancestors(Random.default_rng(), Stratified(), w)
ERROR: MethodError: no method matching sample_ancestors(::TaskLocalRNG, ::Stratified, ::Vector{Float64})
The other four exported resamplers all work on the same input:
Resampler
sample_ancestors(rng, r, w)
Systematic()
[1, 2, 3, 4]
Stratified()
MethodError
Multinomial()
[4, 2, 3, 4]
Metropolis()
[2, 1, 3, 3]
Rejection()
[1, 2, 3, 4]
It surfaces the same way through a filter, so BF(64; resampler = Stratified()) fails while the other four return a log-likelihood.
Cause
Stratified is defined as a bare struct, and its only sample_ancestors and sample_offspring methods are typed on CuVector. On 0.4.2 those sit at src/resamplers.jl:281-292; on 0.5.0 the struct is at src/resamplers.jl:240 and the CuVector methods have moved to ext/CUDAExt.jl:61-69. Either way there is no CPU implementation, so the exported name only works on GPU arrays.
Version
GeneralisedFilters 0.4.2, Julia 1.12, macOS. Read from the source, 0.5.0 looks the same in this respect, though I have not run it.
This was opened by a bot. Please ping @seabbs for any questions.
Thanks for the report — this was a genuine gap in 0.4.x. It's fixed in GeneralisedFilters 0.5.0 (#192), which adds CPU sample_ancestors and conditional_sample_ancestors methods for Stratified (src/resamplers.jl), with a corresponding CPU test.
Activity
seabbs commentedon Sep 11, 2026
Oops sorry bot escape here but the issue checks out I think.
THargreaves commentedon Sep 28, 2026
Thanks for the report — this was a genuine gap in 0.4.x. It's fixed in GeneralisedFilters 0.5.0 (#192), which adds CPU sample_ancestors and conditional_sample_ancestors methods for Stratified (src/resamplers.jl), with a corresponding CPU test.