Skip to content

Caution with unused variables in SimpleVarInfo #358

@yebai

Description

@yebai

The new VarInfo #309 introduced many nice new features and significant performance improvements. However, it needs to be used with caution at the moment. For example, we can easily introduce spurious variables into SimpleVarInfo which does not influence logdensity evaluation, but would subtly change HMC behaviour (for good or bad). It is because the spurious variables (i.e. x[3:4]) would introduce additional momentum variables. Since these variables do not have a prior on them, the sampling results would become slightly tricky to analyse.

julia> using DynamicPPL, StableRNGs, Distributions

julia> @model function demo()
           m ~ Normal()
           x = Vector{Float64}(undef, 2)
           for i in eachindex(x)
               x[i] ~ Normal()
           end
           return x
       end

julia> _, vi = DynamicPPL.evaluate!!(m, SimpleVarInfo((x = ones(2), )), ctx);

julia> _, vi = DynamicPPL.evaluate!!(m, SimpleVarInfo((x = ones(4), )), ctx); # Note the spurious x variables x[3:4]

julia> vi
SimpleVarInfo((x = [-1.6438528680920432, 0.7944393211208289, 1.0, 1.0], m = 1.2973461452176338), -5.265062153308225)

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