TuringLang / TuringLang/DynamicPPL.jl

Separate model-evaluation inputs from outputs

Open
#1,469 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

data-structures enhancement
Dominant language
Julia
Stars
286
Forks
41
Avg merge
1d 11h
Merged PRs (30d)
34

Description

This proposes a concrete end state for #895, #1184, and #1376 after the parent-context hierarchy is removed by #1468.

Model evaluation should have a one-way data flow:

┌────────────────────────────┐
│ Model                      │
└──────────────┬─────────────┘
               │
┌──────────────▼─────────────┐
│ Context: evaluation inputs │
│                            │
│ • RNG                      │
│ • initialization strategy  │
│ • transform strategy       │
└──────────────┬─────────────┘
               │
               ▼
┌────────────────────────────┐
│ Model evaluation           │
└──────────────┬─────────────┘
               │
      ┌────────┴────────┐
      │                 │
      ▼                 ▼
┌────────────┐   ┌───────────────────────────┐
│ Return     │   │ VarInfo                   │
│ value      │   │ (i.e. OnlyAccsVarInfo)    │
└────────────┘   │                           │
                 │ • evaluation outputs      │
                 │ • accumulators            │
                 └───────────────────────────┘

Context would be the sole evaluation context and contain every input needed by tilde evaluation. It would replace InitContext; the shorter name is appropriate once no alternative context types remain.

VarInfo would be the current OnlyAccsVarInfo: a collection of accumulators containing evaluation outputs. The current value-storing VarInfo and DefaultContext would be removed.

The governing invariant would be:

Reusing previous values would require an explicit output-to-input conversion:

context = Context(rng, InitFromParams(get_raw_values(vi)), transform_strategy)
retval, vi = evaluate!!(model, context, VarInfo(accumulators))

This builds on the accumulator framework from #744, the explicit initialisation path from #955, linked-value accumulators from #1212, and the migration toward explicit evaluation in #1264. The analysis in #836 explains why removing linked values from VarInfo ultimately requires removing the old VarInfo.

TuringLang/Turing.jl#2803 removed VarInfo from the Gibbs component interface. TuringLang/Turing.jl#2863 removes the remaining GibbsContext dependency, allowing #1468 to remove DynamicPPL’s parent contexts.

The transition should preserve aliases where practical, but the final API should not retain two VarInfo types with different responsibilities.

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 reading the existing Context, InitContext, VarInfo, OnlyAccsVarInfo, and DefaultContext implementations, along with evaluate!! and the linked accumulator and explicit-initialization work. Done means evaluation reads inputs only from Context and Model, writes outputs only to VarInfo, and the final API no longer retains two VarInfo responsibilities while preserving practical aliases where possible.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend-api-design
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.