TuringLang / TuringLang/DynamicPPL.jl

Replace `missing`-based latent selection with preallocation and conditioning

Open
#1,464 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

breaking-change missing-values modelling-syntax
Dominant language
Julia
Stars
286
Forks
41
Avg merge
1d 11h
Merged PRs (30d)
34

Description

DynamicPPL uses missing in model arguments and conditions to decide whether a tilde statement is latent or observed. This couples stochastic role to mutable runtime data. Scalar missing can denote a latent aggregate draw, while arrays containing missing may instead reach loglikelihood and fail.

Deprecate and remove missing as a latent-variable marker. Models should be unconditioned by default. Structured variables can use ordinary preallocation, which current main supports, and observations should use condition:

@model function f(n, ::Type{T}=Float64) where {T<:Real}
    x = Vector{T}(undef, n)
    x ~ product_distribution(fill(Normal(), n))
end

latent_model = f(n)
observed_model = condition(latent_model, x=data)

Passing missing to a stochastic site should eventually raise a migration error.

Open issues #969, #1361, #944, and #273 show that missing-specific failures span aggregate observations, mutation, copying, and submodels. Closed issue #641 and earlier fixes #191 and #617 show that this mechanism has repeatedly required special cases. Replacing it would address their shared cause while complementing the explicit-role direction discussed in #519 and #965.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the model and condition entry points, then trace how missing reaches stochastic sites, aggregate observations, mutation, copying, and submodels. Use the behavior described in issues #969, #1361, #944, and #273 to identify affected paths. Done means ordinary preallocation and condition handle observations, while passing missing produces the planned migration error.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
machine-learning
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.