Skip to content
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

bump compat of AdvancedHMC #2050

Merged
merged 20 commits into from
Jul 29, 2023
Merged

bump compat of AdvancedHMC #2050

merged 20 commits into from
Jul 29, 2023

Conversation

JaimeRZP
Copy link
Member

@JaimeRZP JaimeRZP commented Jul 24, 2023

Bump compatibility of AdvancedHMC to include the latest version that includes the interface with external samplers.

Closes #2054

@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (75961e7) 0.00% compared to head (2bf8beb) 0.00%.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #2050   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files          22      22           
  Lines        1458    1458           
======================================
  Misses       1458    1458           
Files Changed Coverage Δ
src/inference/hmc.jl 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JaimeRZP
Copy link
Member Author

Failing because of Optimizers.

@JaimeRZP JaimeRZP marked this pull request as ready for review July 24, 2023 15:54
Project.toml Outdated Show resolved Hide resolved
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
@devmotion
Copy link
Member

Tests use AdvancedHMC 0.4 it seems.

@JaimeRZP
Copy link
Member Author

Tests use AdvancedHMC 0.4 it seems.

image

I think it is fixed!

@github-actions
Copy link
Contributor

github-actions bot commented Jul 27, 2023

Pull Request Test Coverage Report for Build 5700989848

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/inference/hmc.jl 0 1 0.0%
Totals Coverage Status
Change from base Build 5671848158: 0.0%
Covered Lines: 0
Relevant Lines: 1458

💛 - Coveralls

@JaimeRZP
Copy link
Member Author

TuringLang/AdvancedHMC.jl#342
Will not run until we merge the bug fixed in this PR.

Project.toml Outdated Show resolved Hide resolved
src/inference/Inference.jl Outdated Show resolved Hide resolved
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
src/inference/Inference.jl Outdated Show resolved Hide resolved
@@ -189,10 +189,10 @@ function AbstractMCMC.sample(
kwargs...
)
if resume_from === nothing
return AbstractMCMC.mcmcsample(rng, model, sampler, N;
chain_type=chain_type, progress=progress, kwargs...)
return AbstractMCMC.mcmcsample(rng, model, sampler, N + min(div(N, 10), 1_000);
Copy link
Member

Choose a reason for hiding this comment

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

This means users will get more than the requested N samples - I think this should be reverted?

Copy link
Member

Choose a reason for hiding this comment

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

There is a change in how the number of adaptions is handled in the external sampler interface. Instead of storing n_adapts in the sampling algorithm (see here), we now only pass them in the AbstractMCMC.sample call. This means there is no adaption by default if the change is reverted.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can set disgard_initial = n_adapts here so we have a default adaption but will return the same number of MCMC samples. In addition, we can allow the user to pass a n_adapt argument to override the default adaption settings.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, we have to take into account the adaption steps - but changing this line here means that a call such as sample(model, NUTS(), 10) will return not 10 but 1010 samples? These discarded steps only have to be specified as keyword argument but not added to the positional argument (number of samples). AbstractMCMC will added discard_initial to these internally to the requested number of samples automatically.

Copy link
Member

@yebai yebai Jul 29, 2023

Choose a reason for hiding this comment

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

It turns out we have a typo in tests: we already explicitly pass the n_adapts argument to the sample function. Due to the typo, AHMC complains about missing n_adapts. After correcting this typo, these default values are no longer necessary. More generally, we should introduce default options for n_adapts in the AbstractMCMC package; see this PR.

Project.toml Outdated Show resolved Hide resolved
@yebai yebai merged commit fa3a6c1 into master Jul 29, 2023
13 checks passed
@yebai yebai deleted the bump_AdvancedHMC branch July 29, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants