Skip to content

GeneralisedFilters: Stratified resampler is exported but has no CPU method #187

Closed

Description

@seabbs-bot

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.

Activity

  1. seabbs commented on Sep 11, 2026

    @seabbs

    Oops sorry bot escape here but the issue checks out I think.

  2. THargreaves commented on Sep 28, 2026

    @THargreaves
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions