Skip to content

AdvancedPS v0.7 (and thus Libtask v0.9) support #2585

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mhauru
Copy link
Member

@mhauru mhauru commented Jun 6, 2025

The complement PR of TuringLang/AdvancedPS.jl#114, which adds support for the newly rewritten Libtask.

Work in progress, currently blocked by TuringLang/Libtask.jl#186

@mhauru
Copy link
Member Author

mhauru commented Jun 19, 2025

The tests that I had the patience to run locally now pass. Waiting for the AdvancedPS release to be able to run the full test suite on CI.

Some indicators of speed:

julia> module MWE

       using Turing

       @model function gdemo(x, y)
           s ~ InverseGamma(2, 3)
           m ~ Normal(0, sqrt(s))
           x ~ Normal(m, sqrt(s))
           y ~ Normal(m, sqrt(s))
           return s, m
       end

       @time chn = sample(gdemo(2.5, 1.0), PG(10), 10_000)
       describe(chn)

       end

On main:

104.715858 seconds (58.48 M allocations: 13.259 GiB, 1.10% gc time, 1.20% compilation time)

On this branch:

 16.612050 seconds (116.52 M allocations: 16.296 GiB, 8.27% gc time, 5.91% compilation time)
julia> module MWE

       using Turing

       @model function f(dim=20, ::Type{T}=Float64) where T
           s = Vector{Bool}(undef, dim)
           x = Vector{T}(undef, dim)
           for i in 1:dim
               s[i] ~ Bernoulli()
               if s[i]
                   x[i] ~ Normal()
                else
                   x[i] ~ Beta()
                end
                0.0 ~ Normal(x[i])
           end
           return nothing
       end

       alg = Gibbs(
           @varname(s)=>PG(10),
           @varname(x)=>HMC(0.1, 5),
       )
       @time chn = sample(f(), alg, 1_000)

       end

On main:

 49.682945 seconds (65.43 M allocations: 9.463 GiB, 1.79% gc time, 8.23% compilation time)

On this branch:

  9.180071 seconds (61.58 M allocations: 4.028 GiB, 4.04% gc time, 55.49% compilation time)

Obviously the speed gains are all due to @willtebbutt's fantastic work on Libtask, everything else is just wrapping that work.

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.

1 participant