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

AbstractMCMC.step interface broken #350

Open
devmotion opened this issue Sep 28, 2023 · 4 comments · Fixed by #359
Open

AbstractMCMC.step interface broken #350

devmotion opened this issue Sep 28, 2023 · 4 comments · Fixed by #359

Comments

@devmotion
Copy link
Member

#332 broke the AbstractMCMC.step interface: It's not possible anymore to initialize the sampler, obtain the initial state, and then continue sampling with AbstractMCMC.step.

The problem is

n_adapts = kwargs[:n_adapts]

It assumes that nadapts is provided as a keyword argument to the step function by the user. This is not part of the AbstractMCMC.step interface requirements. If AdvancedHMC wants to use such a keyword argument in the function body it should be possible to omit it and have a default value. I think that's still a bad idea though since then users/developers have to know about how AdvancedHMC internally (ab)uses keyword arguments to be able to pass around this information in the same way. IMO it would be better to put this into the state of the sampler if it's not intended to be fixed a priori when constructing the sampler.

@devmotion
Copy link
Member Author

Just remembered TuringLang/AbstractMCMC.jl#124.

I still think this should be fixed in AdvancedHMC rather than AbstractMCMC - we can't add all downstream options to AbstractMCMC and it means that custom implementations based on step (as in my use case) will always use a default value of 0, if they don't know about and reimplement the logic in AdvancedHMC.

This was referenced Nov 3, 2023
@yebai
Copy link
Member

yebai commented Nov 7, 2023

@devmotion @torfjelde @JaimeRZP do we have a default mechanism for users to pass warmup strategy somewhere? If not, it would be good to introduce an AbstractWarmUp type in AbstractMCMC so we have a consistent interface for passing warmup strategies in AbstractMCMC.step functions.

@devmotion
Copy link
Member Author

TuringLang/AbstractMCMC.jl#117 will allow samplers to specify behaviour of warm-up steps. AdvancedHMC would specialize step_warmup, possibly depending on a warm-up algorithm instance stored in the sampler.

@yebai yebai closed this as completed in #359 Oct 3, 2024
@devmotion
Copy link
Member Author

I'll re-open because I think it would be better for interoperability with other packages to avoid "magic" keyword arguments.

@devmotion devmotion reopened this Oct 3, 2024
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 a pull request may close this issue.

2 participants