Skip to content

Conversation

@eclipse1605
Copy link

Description

I tried to make “tuning vs draws” a driver owned concept again. Right now, parts of sampling/postprocessing infer warmup length from a per-step "tune" sampler stat, which can get out of sync (e.g. a step method returning "tune": False everywhere makes PyMC think n_tune == 0, so warmup isn’t discarded and the logs look wrong).

Related Issues

Fixes: #7997
Context: #7776 (progressbar/stat refactor that exposed the mismatch)
Related discussion/attempts: #7730, #7721, #7724, #8014

@ricardoV94
Copy link
Member

@OriolAbril / @aloctavodia does any part of Arviz require the step samples to have a tune flag? Is it enough that we have warmup / posterior distinction, each with their number of draws?

return steps


def check_step_emits_tune(step: CompoundStep | BlockedStep):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this ends up working without tune, remove this function as well

) -> tuple[mcb.RunMeta, PointFunc]:
variables, point_fn = get_variables_and_point_fn(model, initial_point)

check_step_emits_tune(step)
Copy link
Member

@ricardoV94 ricardoV94 Dec 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelosthege what's the requirement here? Can we change things on mcbackend to not expect tune info attached to the steps?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we can not change that tune info must be attached to a step. See my comment in #7997 (comment).

@staticmethod
def _progressbar_config(n_chains=1):
columns = [
TextColumn("{task.fields[tune]}", table_column=Column("Tuning", ratio=1)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need a work-around for this, as we still want to show whether we're in tuning or not in the progressbar

@ricardoV94
Copy link
Member

ricardoV94 commented Dec 21, 2025

Taking a step back, would it make sense for a tune=None mode where the sampler(s) decide how much tune they need? In that case it would make sense for the individual steps to report back whether they're tuning or not.

Even if that's the case, I think it still makes sense to remove this currently useless stat and reintroduce in a separate PR (provided nobody finds a reason why it is actually useful/needed).

CC @aloctavodia, @lucianopaz @aseyboldt

@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.85%. Comparing base (cadb97a) to head (0e890b0).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
pymc/step_methods/metropolis.py 80.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8015      +/-   ##
==========================================
+ Coverage   90.22%   90.85%   +0.63%     
==========================================
  Files         116      116              
  Lines       18972    18961      -11     
==========================================
+ Hits        17117    17227     +110     
+ Misses       1855     1734     -121     
Files with missing lines Coverage Δ
pymc/backends/mcbackend.py 99.24% <ø> (-0.01%) ⬇️
pymc/sampling/mcmc.py 91.29% <100.00%> (+5.85%) ⬆️
pymc/step_methods/compound.py 95.23% <100.00%> (-2.64%) ⬇️
pymc/step_methods/hmc/base_hmc.py 92.25% <ø> (ø)
pymc/step_methods/hmc/hmc.py 94.59% <ø> (ø)
pymc/step_methods/hmc/nuts.py 97.61% <ø> (ø)
pymc/step_methods/slicer.py 96.26% <100.00%> (-0.94%) ⬇️
pymc/step_methods/metropolis.py 74.29% <80.00%> (-18.50%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelosthege
Copy link
Member

Taking a step back, would it make sense for a tune=None mode where the sampler(s) decide how much tune they need? In that case it would make sense for the individual steps to report back whether they're tuning or not.

Automatically stopping the warmup early would be nice. I think we should agree on cleanly separated definitions of warmup, burn-in and tuning. Samplers not needing to tune parameters doesn't mean that there's no need for a warmup phase of burn-in iterations (however one might call it).

Our current implementation is bad because it doesn't separate the concepts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: CategoricalGibbsMetropolis doesn't respect the tune parameter

3 participants