-
Notifications
You must be signed in to change notification settings - Fork 35
Give user an option to use SimpleVarInfo
with sample
function
#606
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
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
An alternative approach I can envision is fully adopting Also for DynamicPPL.jl/src/simple_varinfo.jl Lines 62 to 65 in 48487cc
This also means, when SimpleVarInfo through the changes proposed in this PR may be less performant.
|
@torfjelde @yebai @devmotion does this PR make sense? If this is desirable, then I'll extend tests in https://github.com/TuringLang/DynamicPPL.jl/blob/master/test/sampler.jl. |
Pull Request Test Coverage Report for Build 9092154133Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9116442883Details
💛 - Coveralls |
cc @willtebbutt |
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.
Yes, let's push this through @sunxd3!
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@willtebbutt can you help review this PR? |
Having a look @sunxd3 👍 |
end | ||
if tracetype === VarInfo | ||
# Sample initial values. | ||
vi = default_varinfo(rng, model, spl) |
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.
This doesn't quite make sense because default_varinfo
can also return SimpleVarInfo
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.
This is cool -- thanks for doing this.
More feedback:
- the tests introduce a lot of copy + paste. Could you please reformat to avoid the copy + paste by using the looping option available for
@testset
? i.e. apply to same set of tests toVarInfo
andSimpleVarInfo
. - please bump the patch version so that we can tag a release :)
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.
What it is the purpose of using SimpleVarInfo{<:AbstractDict}
vs. VarInfo
? I can see a clear purpose if we support SimpleVarInfo{<:NamedTuple}
, but this is not the case here.
IMO, for it to make sense to expose SimpleVarInfo
, we need to make it possible to use the NamedTuple
version, which can provide performance improvements over VarInfo
, but the AbstractDict
version will be much, much worse than the current VarInfo
is performance-wise.
This should work with Turing's Inference pipeline with almost no modification
If you do a search for VarInfo
throughout the Turing codebase, you'll find several explicit mentions of it, e.g. in Gibbs or MH, so it will require some effort.
Note that the default_varinfo
used in the initial step was meant to be a way of exposing this experimentally (you can overload it for a specific model + sampler combo), but I do agree that this is annoying vs. simply passing it as an argument.
Co-authored-by: Will Tebbutt <wt0881@my.bristol.ac.uk>
@torfjelde is my understanding of SimpleVarInfo with NamedTuple correct at #606 (comment)? |
I agree. Other than performance, I thought SimpleVarInfo is also less error-prone for AD (correct me if wrong), but I am unsure if AbstractDict version of SimpleVarInfo works better than VarInfo. |
Yep! If you don't "seed"
Not really. Or rather, I don't think |
Let me look into it and see if I can make NamedTuple variant of SimpleVarInfo work, or at least a clear TODOs |
Lovely:) And I don't mean to be negative about this btw. I'm just not a huge fan of adding additional kwargs, etc. unless there's a clear reason to use them (because otherwise nobody will ever use them until they suddenly are riddled with uncaught bugs because nobody uses it). So if we're going to add an additional kwarg to use
|
Sounds good. I started this as a quick and dirty prototype, it definitely needs more work, until we can justify complicating the interface. |
This is no longer necessary since Tapir now works with all tracing types. |
Partially address TuringLang/Turing.jl#2213
An example
Work with Turing
This should work with Turing's
Inference
pipeline with almost no modification, the only change is https://github.com/TuringLang/Turing.jl/blob/56f64ec5909cec4a5ded4e28555c2b289020bbe1/src/mcmc/Inference.jl#L319 toThis allows
bundle_samples
to use this function.Then