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

Fix for pickling an MCMC object with HMCGibbs (and MixedHMC) samplers and parallel chains #1746

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions numpyro/infer/hmc_gibbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ def potential_fn(z_gibbs, z_hmc):

return HMCGibbsState(z, hmc_state, rng_key)

def __getstate__(self):
state = self.__dict__.copy()
state["_prototype_trace"] = None
return state


def _discrete_gibbs_proposal_body_fn(
z_init_flat, unravel_fn, pe_init, potential_fn, idx, i, val
Expand Down
2 changes: 2 additions & 0 deletions numpyro/infer/mixed_hmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,6 @@ def body_fn(i, vals):
def __getstate__(self):
state = self.__dict__.copy()
state["_wa_update"] = None
state["_prototype_trace"] = None
fehiepsi marked this conversation as resolved.
Show resolved Hide resolved
state["_support_sizes_flat"] = None
return state
Loading