feat(plot): add exclude_keys to filter trace plots (closes #730)#1074
Open
christianescamilla15-cell wants to merge 1 commit intobilby-dev:mainfrom
Open
feat(plot): add exclude_keys to filter trace plots (closes #730)#1074christianescamilla15-cell wants to merge 1 commit intobilby-dev:mainfrom
christianescamilla15-cell wants to merge 1 commit intobilby-dev:mainfrom
Conversation
) Issue bilby-dev#730 reports that bilby_mcmc / dynesty checkpoint trace plots with ~20 * Ndet axes can balloon in size and cause memory issues on long runs, particularly for runs with many calibration parameters (e.g. recalib_* nodes). Adds an exclude_keys parameter to Chain.plot() accepting glob-style patterns via fnmatch. Keys matching any pattern are omitted from both the trace and histogram sub-plots, and the figure height is computed from the filtered count. The parameter is threaded through from the Bilby_MCMC sampler as plot_exclude_keys, so users can configure it at the run level: bilby.run_sampler( sampler="bilby_mcmc", plot_exclude_keys=["recalib_*"], ... ) As @ColmTalbot noted in the discussion, calibration traces can still be diagnostically useful. This is opt-in — default behaviour is unchanged. Inspired by arviz's var_names / filter_vars selection for plot_trace.
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.
Summary
Addresses #730 by adding an opt-in way to filter nuisance parameters out of the checkpoint trace plots produced by `bilby_mcmc`. The motivation in the issue is that with ~20 calibration parameters per detector, trace plots can easily hit 60+ axes and blow up memory on long runs.
Closes #730.
Design
Rather than hard-removing calibration parameters (which @ColmTalbot correctly pointed out can still be diagnostically useful), this is opt-in with glob-style patterns, matching the spirit of arviz's `var_names` / `filter_vars` selection.
```python
bilby.run_sampler(
sampler="bilby_mcmc",
plot_exclude_keys=["recalib_*"],
...
)
```
Changes
`bilby/bilby_mcmc/chain.py`
`bilby/bilby_mcmc/sampler.py`
Backwards compatibility
Future work (not in this PR)
The dynesty sampler's trace plotting is generated via dynesty's own machinery and would need a separate adapter to accept `exclude_keys`. Happy to follow up in a separate PR once this approach is approved.
Test plan
References