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

MCMCThreads error #28

Closed
wupeifan opened this issue Dec 8, 2021 · 7 comments
Closed

MCMCThreads error #28

wupeifan opened this issue Dec 8, 2021 · 7 comments

Comments

@wupeifan
Copy link
Member

wupeifan commented Dec 8, 2021

Currently, I set the Turing sampler to be just sampling one chain and it can work, see https://github.com/HighDimensionalEconLab/HMCExamples.jl/blob/main/src/estimate_rbc_1_joint.jl#L34-L40

chain = sample(turing_model, NUTS(num_adapts, d.target_acceptance_rate; max_depth = d.max_depth),
        d.num_samples;
        init_params=[p_d..., ϵ0],
        progress=true,
        save_state=true,
        callback,
    )

If it is replaced by the MCMCThreads() version, i.e.,

julia>     chain = sample(turing_model, NUTS(num_adapts, d.target_acceptance_rate; max_depth = d.max_depth),                                                                                                                             
               MCMCThreads(),                                                                                                                                                                                                            
               d.num_samples,                                                                                                                                                                                                              
               d.num_chains;                                                                                                                                                                                                       
               init_params=[p_d..., ϵ0],                                                                                                                                                                                                     
               progress=true,                                                                                                                                                                                                                
               save_state=true,                                                                                                                                                                                                              
               callback,                                                                                                                                                                                                                     
           )
ERROR: deepcopy of Modules not supported
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] deepcopy_internal(x::Module, stackdict::IdDict{Any, Any})
    @ Base .\deepcopy.jl:33
  [3] deepcopy_internal(x::Any, stackdict::IdDict{Any, Any}) (repeats 3 times)
    @ Base .\deepcopy.jl:76
  [4] deepcopy
    @ .\deepcopy.jl:26 [inlined]
  [5] #28
    @ .\none:0 [inlined]
  [6] iterate
    @ .\generator.jl:47 [inlined]
...

@cpfiffer you can replicate this error by changing the codes in https://github.com/HighDimensionalEconLab/HMCExamples.jl/blob/main/src/estimate_rbc_1_joint.jl#L34-L40, and compile the package again, then run this https://github.com/HighDimensionalEconLab/HMCExamples.jl/blob/main/test/runtests.jl#L6 in parciular.

@cpfiffer
Copy link
Collaborator

cpfiffer commented Dec 9, 2021

Huh, can't replicate this on my desktop machine (using code from before df6521b). I'll roll my branch forward and see if I can trigger it with the new code.

@wupeifan
Copy link
Member Author

wupeifan commented Dec 9, 2021

Are we using the same manifest file? I'm using exactly what is in main branch.
If it only works for you, then could you please post the '] st' results so I check the difference?

@cpfiffer
Copy link
Collaborator

cpfiffer commented Dec 9, 2021

Are we using the same manifest file? I'm using exactly what is in main branch.
If it only works for you, then could you please post the '] st' results so I check the difference?

Yep, exactly the same manifest.

@cpfiffer
Copy link
Collaborator

cpfiffer commented Dec 9, 2021

Replicated using current main -- curious! Will investigate more.

@cpfiffer
Copy link
Collaborator

cpfiffer commented Dec 9, 2021

Found it, opened an issue TuringLang/AbstractMCMC.jl#89.

@wupeifan
Copy link
Member Author

wupeifan commented Dec 9, 2021

Is there anything we can do to avoid that?

@wupeifan
Copy link
Member Author

wupeifan commented Dec 9, 2021

A temporary solution in HighDimensionalEconLab/DifferentiableStateSpaceModels.jl#70 resolves this one

@wupeifan wupeifan closed this as completed Dec 9, 2021
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

No branches or pull requests

2 participants