TuringLang / TuringLang/DynamicPPL.jl
`pointwise_logdensities`, `returned`, `logjoint`, etc. APIs are weird
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 286
- Forks
- 41
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 34
Description
Fundamentally all of these functions take some input, run the model, collect some accumulator's output (or the return value), and then give that back to the user.
Traditionally these have all taken a VarInfo argument. That's because they all used to call evaluate!!(model, varinfo). This makes little sense nowadays. It should take an AbstractInitStrategy argument, with some common overloads for parameter types that wrap them in InitFromParams before calling the main function. For example, logjoint(model, ...) already follows this pattern, along with returned; so the point would be to unify all of these things into a single internal method, and have logjoint, ... etc defined in terms of that method.
I think there's a reasonable amount of code duplication that could be reduced in this too. Because at the end of the day really all you're saying is: this is my model, these are my params, I want these accumulators, I want to evaluate the model and return this thing.
We could even keep the VarInfo methods; they just need to dispatch to InitFromParams(vi.values).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the existing pointwise_logdensities, returned, and logjoint APIs and their evaluate!!(model, varinfo) calls. Compare the existing logjoint and returned overloads, then determine how a shared internal method can accept AbstractInitStrategy while preserving VarInfo compatibility. Done means the APIs share the intended implementation, support InitFromParams overloads, and retain equivalent behavior.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100