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

Make initial_state as a keyword argument #557

Conversation

yebai
Copy link
Member

@yebai yebai commented Nov 8, 2023

@devmotion, maybe this will do the trick? The advantage is it allows one to override the initial_state argument while keeping it backwards compatible for now. We can remove resume_from in the next breaking release.

@yebai yebai requested a review from sunxd3 November 9, 2023 11:56
Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

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

I had the same solution, but unsure of the dynamics of the AbstractMCMC interface changes, so maybe wait for @devmotion?

@@ -87,9 +87,9 @@ function AbstractMCMC.sample(
N::Integer;
chain_type=default_chain_type(sampler),
resume_from=nothing,
Copy link
Member

Choose a reason for hiding this comment

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

Do you know where resume_from is documented?

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

keeping it backwards compatible for now.

AFAICT we have to tag a breaking release of DynamicPPL anyway, regardless of initial_state/resume_from since init_params does not work anymore.

initial_state and resume_from are a bit different though, initial_state is supposed to be an actual state/transition of the sampler whereas currently for resume_from we support Chains objects (which potentially store the final state of the sampler as metadata). I'm not sure though if maybe we should just demand that users extract the state manually (possibly with some helper function) in the future.

I think there was some reason for why I did not add it as a keyword argument but right now I don't remember and I don't see an immediate problem.

@yebai yebai merged commit 3687ebe into compathelper/new_version/2023-10-26-00-09-06-954-01573151329 Nov 9, 2023
@yebai yebai deleted the yebai-patch-1 branch November 9, 2023 12:47
github-merge-queue bot pushed a commit that referenced this pull request Nov 9, 2023
…t) (#551)

* CompatHelper: bump compat for AbstractMCMC to 5, (keep existing compat)

* CompatHelper: bump compat for AbstractMCMC to 5 for package test, (keep existing compat) (#552)

Co-authored-by: CompatHelper Julia <[email protected]>

* Update to AbstractMCMC 5

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update sampler.jl

* CompatHelper: bump compat for AbstractMCMC to 5 for package test, (keep existing compat) (#553)

* Fix for `rand` + replace overloads of `rand` with `rand_prior_true` for testing models (#541)

* preserve context from model in `rand`

* replace rand overloads in TestUtils with definitions of
rand_prior_true so we can properly test rand

* removed NamedTuple from signature of TestUtils.rand_prior_true

* updated references to previous overloads of rand to now use rand_prior_true

* test rand for DEMO_MODELS

* formatting

* fixed tests for rand for DEMO_MODELS

* fixed linkning tests

* added missing impl of rand_prior_true for demo_static_transformation

* formatting

* fixed rand_prior_true for demo_static_transformation

* bump minor version as this will be breaking

* bump patch version

* fixed old usage of rand

* Update test/varinfo.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* fixed another usage of rand

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Remove `tonamedtuple` (#547)

* Remove dependencies to `tonamedtuple`

* Remove `tonamedtuple`s

* Minor version bump

---------

Co-authored-by: Hong Ge <[email protected]>

* CompatHelper: bump compat for AbstractMCMC to 5 for package test, (keep existing compat)

---------

Co-authored-by: Tor Erlend Fjelde <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Xianda Sun <[email protected]>
Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: CompatHelper Julia <[email protected]>

* bump AbstractPPL version to 0.7

* Update AbstractPPL test dependency

* add `Random.AbstractRNG`

* Update sampler.jl (#557)

* Update src/sampler.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: CompatHelper Julia <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David Widmann <[email protected]>
Co-authored-by: Tor Erlend Fjelde <[email protected]>
Co-authored-by: Xianda Sun <[email protected]>
Co-authored-by: Hong Ge <[email protected]>
Co-authored-by: Xianda Sun <[email protected]>
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