-
Notifications
You must be signed in to change notification settings - Fork 223
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
Make Gibbs work with step_warmup #2502
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2502 +/- ##
==========================================
+ Coverage 84.59% 84.88% +0.29%
==========================================
Files 21 21
Lines 1597 1628 +31
==========================================
+ Hits 1351 1382 +31
Misses 246 246 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Pull Request Test Coverage Report for Build 13704498769Details
💛 - Coveralls |
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.
Generally looks very good. One concern: from the coverage, repeat_sampler
is not tested, is it worthwhile to add a test?
""" | ||
function gibbs_step_recursive( | ||
rng::Random.AbstractRNG, | ||
model::DynamicPPL.Model, | ||
step_function::Function, |
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.
would this create some kind of type instability? my first order thought is that Function
is abstract type
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.
I think it should be fine, since each function has its own type. E.g.
julia> typeof(identity)
typeof(identity) (singleton type of function identity, subtype of Function)
julia> typeof(sin)
typeof(sin) (singleton type of function sin, subtype of Function)
The ::Function
bit just enforces that you can't pass as the step_function
argument anything that isn't of type Function
, but the compiler will still see the concrete type of the argument. I also checked that making this change didn't have a substantial impact on runtime.
Hmm, I'm confused by the coverage complaint, I thought these lines from num_reps = 2
wuc = WarmupCounter()
sample(m, Gibbs(:x => RepeatSampler(wuc, num_reps)), num_samples; num_warmup=num_warmup)
@test wuc.warmup_init_count == 1
@test wuc.non_warmup_init_count == 0
@test wuc.warmup_count == num_warmup * num_reps
@test wuc.non_warmup_count == (num_samples - 1) * num_reps Need to check this next week. |
Gibbs used to just ignore warm-up as a concept, and always called
step
rather thanstep_warmup
. This was discussed in #2493. This PR makes Gibbs respectnum_warmup
by callingstep_warmup
on the component samplers whenever Gibbs itself is called withstep_warmup
. It also does the same thing forRepeatSampler
. Note that this means that e.g. if you useRepeatSampler(spl, 3)
andnum_warmup=100
spl
will take 300 warm-up steps.#2493 should be left open for now, because we might want to improve this so that one could specify different amounts of warm-up for different component samplers. This is just a stop-gap bug fix to at least do the minimal sensible thing.