-
Notifications
You must be signed in to change notification settings - Fork 162
Trace Translators and new Trace Transform DSL #290
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
… backward proposal
One thing I just ran into while using this DSL was that I was getting a cryptic error about how the "Jacobian is 0x1 and is not square". I eventually realized this is because I was looking up a continuous return value of a subtrace in my model in the involution I had written. It was something along the lines of: # `:vals => i` points to a subtrace which samples `:val ~ ...` then returns this value
@read(model_tr[:vals => 1], :cont) Would it be easy to throw a custom error if a user tries to read a continuous value from a subtrace return like this, so it's clear to the user how to fix this? |
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.
Love this new abstraction, as well as the new syntax! I can totally see how this helps provide a unifying formalism for various operations used in both SMC and MCMC, like we discussed previously.
One limitation of the Trace Transform DSL though, as compared to the Involution DSL, is it that it seems like TraceTransformDSLProgram
s no longer have access to the model and proposal arguments, whereas InvolutionDSLPrograms
did? If I'm right about that, then it seems harder to write trace transforms parameterized by various model arguments, which might be useful sometimes (e.g. in the example I gave for the use of ExtendingTraceTranslators
in SMC), because the trace address you want to read / write from could depend on model arguments, and not just previously sampled values. Would be curious to hear more of your thoughts about this @marcoct!
@ztangent That is still supported, but with a different syntax that better matches the idea that |
Nice, that's right! Perhaps all that's needed then is an example within the docs / tutorials of that -- or maybe there already is, and I just missed it. |
As another suggestion for an improvement, I think the documentation for the
I'm not 100% sure 2 is true--it is true in my fork where I redid the @transform .....
@write(new_tr[:top => :value => 1], some_value, :disc)
# say the proposal proposes some addresses in `:top => :space1` and `:top => :space2`, but not in `:top => :value`
@copy(proposal_tr[:top], new_tr[:top])
end Ie. we may want to write to some addresses in namespace To prevent this type of overwriting should be pretty easy, we just need to change a call to |
This PR makes several changes related to Gen's support for involution MCMC and SMC:
What was previously called the "involution DSL" has now been generalized to become a "Trace Transform DSL", for transforming between arbitrary spaces of traces or pairs of traces. Whereas the involution DSL was previously restricted to the setting when the previous model and the new model were the same generative function, this DSL also can be used to define transformations when the previous model and the new model are different generative functions.
There are many syntax improvements to the Trace Transform DSL, which is now documented here.
The Trace Transform DSL can now read and write to multivariate (vector-valued) continuous random choices, and compute Jacobians appropriately.
There is a new abstraction called "Trace Translators", that unifies patterns of computation that occur within involutive MCMC with patterns of computation occuring within SMC algorithms. This PR includes documentation for several types of Trace Translators, including General Trace Translators (the most general type, which can be used in constructing SMC samplers that use arbitrary sequences of models), Symmetric Trace Translators (used in involutive MCMC), Deterministic Trace Translators (primarily for pedagogical purposes), and Simple Extending Trace Translators (corresponding to a variant of SMC where the model is extended with new random choices at each step, that are sampled from a proposal distribution).
Some of these item were part of this issue: #230