Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] submodel explorations #815

Draft
wants to merge 17 commits into
base: release-0.35
Choose a base branch
from
Draft

[wip] submodel explorations #815

wants to merge 17 commits into from

Conversation

penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Feb 17, 2025

This PR is a very minimalistic sketch of how to implement the original proposal in TuringLang/Turing.jl#2485:

@model inner() = a ~ Normal()

@model function f()
    x ~ Normal()
    y ~ inner() --> z
end

Please see the tests for examples of its behaviour.

Note: If you'd like to discuss what syntax / features should be present please head over there :) please restrict comments on this PR to the 'how' i.e. the implementation

I have arbitrarily implemented the syntax in the original proposal because I had to have something to work with, and I like this. However, note that it's very likely that regardless of the form of the final user interface, a lot of the code changes here will be the same.

For example if we want to distinguish between to_sampleable (lhs is return value) and to_distribution (lhs is latents) then it's just a case of checking the wrapper type and changing the expression at the very end of tilde_assume!! such that the lhs is associated with the correct output. The rest of the newly added code in tilde_assume!! will remain the same, and the considerations of OrderedDict vs NamedTuple will remain the same.

The main difference will lie in the DPPL compiler. The above syntax requires some small modifications to the compiler, whereas something like to_foo won't.

TODO

  • Implement syntax in compiler
  • submodel assume (one layer deep)
  • submodel assume (nested)
  • 'extended varnames' on lhs of tilde (e.g. x.a or x[1])
  • submodel observe (one layer deep)
  • submodel observe (nested)
  • noprefix option
  • condition behaviour
  • fix behaviour
  • other tests

Base automatically changed from mhauru/dot-tilde-to-loops to release-0.35 February 18, 2025 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants