Repository navigation
Take exactly num_warmup warm-up steps when resuming from initial_state - #221
Merged
Merged
Conversation
…tate` A chain resumed from `initial_state` has no initialisation step, but `mcmcsample` counted its first transition as step 0, so it took `num_warmup + 1` warm-up transitions, one even with `num_warmup = 0`. Pass a `resumed` flag to `_step_or_step_warmup` and shift the warm-up comparison by one for resumed chains. `nsteps` itself is unchanged, so progress reporting, discarding and thinning behave as before. Fixes TuringLang#220 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
@thevolatilebit thanks! this looks good. You are welcome to mark it ready when you're ready! |
thevolatilebit
marked this pull request as ready for review
October 17, 2026 00:06
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #221 +/- ##
===========================
===========================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
Thank you! I have marked it ready. Let me know if any further action is needed from my side! |
sunxd3
approved these changes
Oct 17, 2026
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
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.
Fixes #220.
A chain resumed from
initial_statehas no initialisation step: its first call already takes a transition.mcmcsamplestill counted that call as step 0, so resumed chains tooknum_warmup + 1warm-up transitions, including one whennum_warmup = 0. Thenum_warmup = 0case dates from #194 (v5.13.0). #220 has the details and a reproducer.Change
_step_or_step_warmuptakes aresumed::Booland callsstep_warmupwhilensteps + resumed <= num_warmup.mcmcsamplemethods (fixedNandisdone) setresumed = initial_state !== nothing. The ensemble methods go through them, so they need no change.num_warmupwarm-up steps, as discussed in num_warmup off by one error #195.nstepsitself is unchanged, so progress reporting,discard_initialandthinningbehave as before.step_warmupis the defaultstepsee no change at all. Samplers that adapt instep_warmup, such asAdvancedMH.RobustAdaptiveMetropolis, no longer adapt once more on resume.Tests
initial_state" intest/sample.jl. Its sampler's state counts warm-up and regular transitions.num_warmup ∈ {0, 1, 3}×discard_initial ∈ {0, 2}, and checks fresh chains plus resumed chains through both the fixed-Nandisdonemethods.mainall 12 resumed assertions fail; with this change they pass.sample.jl,chains.jl,stepper.jlandlogdensityproblems.jlpass, 328/328. I couldn't run the callback tests offline (they need OnlineStats and TensorBoardLogger).Docs and version
docs/src/api.md:initial_stateis now described as going to the firststep_warmupcall (orstepifnum_warmup == 0), with no initialisation step.HISTORY.mdentry.🤖 Generated with Claude Code