-
Notifications
You must be signed in to change notification settings - Fork 37
Allow forcing ~ to be an observe-statement
#275
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
Conversation
|
@phipsgabler and I have talked about more flexible conditioning via providing a model API, i.e. |
|
I 100% agree that this PR doesn't provide a complete fix and there definitively should be a better approach to doing this, but I think this is unfortunately a bit further off into the future. Hence the It's similar to |
|
Overall, we'd like to stick to the principle of minimising the use of macros in modelling syntax. If we want to temporarily support this, maybe replacing |
Hmm, not too big of a fan as it introduces new syntax. The idea of the Agree with minimizing usage of macros, but I think they're useful for these "not officially encouraged usage but if you really want this feature right now, here it is", e.g. |
|
bors try |
|
Pretty certain we need to also upper-bound Distributions in DPPL tests until we've updated the tests. |
tryBuild failed: |
| return sym | ||
| end | ||
| function generate_mainbody!(mod, found, expr::Expr, warn) | ||
| function generate_mainbody!(mod, found, expr::Expr, warn; tilde_kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the new kwargs always tilde_kwargs? If yes, I'd suggest consistently using the latter name, also in the above methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is right now yes
I can think of multiple ways to rewrite the compiler code so that it looks a bit like Cassette overdubbed code -- very compositional, and ever place we call a Also, these contexts would need to be updated and threaded through, to allow information to propagate. On the other hand, if we do have such a modularized system, it'd be much easier to write abstract interpreters and other fancy stuff with it. And I also prefer |
|
bors try |
tryBuild failed: |
|
Closed in favour of TuringLang/Turing.jl#1736 (comment) |
We've received multiple requests to allow observing on something that isn't part of the arguments, e.g.
We cannot currently support exactly this, but now that we have proper macro-handling with
@modelwe can easily support something likeThis PR introduces such an
@observe.It does so by passing keyword arguments through all the
generate_mainbody!calls eventually making it's way to thegenerate_tildemethods, which is really what we want to alter. I do this because it allows us to re-use thegenerate_mainbody!, thus ensuring that we generate code that@modelwould have.I'm generally not a big fan of the "pass kwargs around like there's no tomorrow!!!"-approach, hence I'm happy to hear suggestions of how we can do this in a better way. I think it would be nice to be able to do this in a bit more extensible manner so that we can write macros that only alter the
~without having to copy-paste the entire definition ofgenerate_mainbody.