TuringLang / TuringLang/DynamicPPL.jl

Full specification for `@model` syntax and associated model operations

Open
#1,390 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Julia
Stars
286
Forks
41
Avg merge
1d 11h
Merged PRs (30d)
34

Description

It would be useful to write down a complete specification of the @model syntax, which is now supported by both DynamicPPL and JuliaBUGS, together with the associated model operations such as condition, fix, rand, and predict.

This would improve clarity for users and maintainers and make it easier for other packages to implement a @model interface compatible with Turing.jl. For example, an alternative implementation might support a more
restricted subset of Julia syntax and libraries while being more friendly to automatic differentiation or GPU execution.

It may also be helpful to categorise these features and specify a core set of behaviours that all @model implementations need to support, with additional behaviours marked as optional or implementation-specific.

The specification could cover, for example:

  • supported syntax inside @model, noting which parts are shared across implementations and which may vary. For example, DynamicPPL supports nearly the full Julia language, while JuliaBUGS intentionally supports a more restricted
    subset.
  • semantics of ~ statements, including the distinction between latent variables, observed variables, model arguments, conditioned variables, and fixed variables.
  • handling of arguments, keyword arguments, defaults, splatting, closures, interpolation, and return values.
  • variable naming and addressing, including VarNames, indexed variables, partial observations, and nested variable names.
  • conditioning and deconditioning behaviour, including the | shorthand and inspection of conditioned values.
  • fixing and unfixing behaviour, and how this differs from conditioning in log-probability calculations.
  • prior simulation and prior predictive behaviour via rand.
  • posterior prediction behaviour via predict.
  • return-value / generated-quantity behaviour, including returned.
  • log-probability operations, including logprior, loglikelihood, logjoint, pointwise log densities, and sampler-facing log-density interfaces.
  • vectorised log-density interfaces, including LogDensityFunction, parameter flattening/unflattening, transformations, and Jacobian conventions.
  • model evaluation operations such as init!!, evaluate!!, initialisation strategies, transform strategies, and accumulators.
  • marginalisation via marginalize.
  • nested models, i.e. using models defined with @model inside other @model definitions, including to_submodel and variable prefixing.
  • manual log-probability adjustments via @addlogprob!.
  • prior extraction via extract_priors.
  • compatibility expectations for alternative implementations, including which behaviours are required for Turing.jl compatibility and which are optional or implementation-specific.

This would provide a shared reference for DynamicPPL, JuliaBUGS, Turing.jl, and future implementations.

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 by inventorying the listed @model syntax and operations, then compare the behaviours described for DynamicPPL and JuliaBUGS. Done means a shared specification that separates required, optional, and implementation-specific behaviours for Turing.jl-compatible implementations.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.