-
Notifications
You must be signed in to change notification settings - Fork 37
Threaded assume #1154
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
Draft
penelopeysm
wants to merge
4
commits into
breaking
Choose a base branch
from
py/novarinfo
base: breaking
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Threaded assume #1154
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11319c0 to
dd9389f
Compare
Contributor
Benchmark Report
Computer InformationBenchmark Results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following the plan outlined in #1153, this PR removes the need for a VarInfo when generating a LogDensityFunction, thus allowing us to run models with threaded assume.
Demo (run with 4 threads):
I don't claim that this code is the cleanest (I'm starting to get fed up of the NT/Dict code, and would be very happy to hide it away behind an abstraction). It's probably also very not-performant, but I don't really care because it's a one-time setup cost.
There's also a stray
@info. The point of the info is to demonstrate above that the ranges are disjoint, even though there are multiple threads collatingRangeAndLinkedat the same time. (Obviously, they will in general not be in order because there is no guarantee which index ofxis generated first.) This is because TSVI makes the accumulators threadsafe*, and as long as we make sure they don't step on each other's toes when wecombinethem , the end result will be valid.* ignoring the
threadidindexing issueI think an atomic accumulator approach (#1137) would certainly be cleaner for this accumulator, but that's orthogonal to the point of this PR.
I tried to use it for NUTS sampling, but the problem is that the NUTS code in Turing itself still needs to generate a VarInfo. That could be refactored along very similar lines to what this PR does, but I didn't do it. In principle, once that is done, it should be 100% possible to sample from this model with NUTS, and also decondition
yand dopredicton the chain. In effect, pretty much everything should work with threaded assume, except for samplers that require a full VarInfo.