Open EliasRas opened 8 months ago
]
:tada: Welcome to PyMC! :tada: We're really excited to have your input into the project! :sparkling_heart:
If you haven't done so already, please make sure you check out our Contributing Guidelines and Code of Conduct.
I tested pm.sample_smc(cores=1)
and got no error which made me dig a bit deeper. If I understood correctly, the error with multiple processes happens because e.g. logp
gets registered only in the main process. Would it be possible to make a initializer for the pool used in pm.smc.sampling.run_chains_parallel
which ensures that the methods are registered properly?
As mentioned in the linked PR, I cannot reproduce the problem locally or on Google Colab, so it may not be a bug but an issue with how it was installed / VSCode: https://colab.research.google.com/drive/1I1n6c9IlmXknIfhxC5s7sAQghv0vfRSY?usp=sharing
Can you try to test with latest PyMC and directly from the terminal?
Could also be a Windows-only bug, so perhaps someone with a Windows machine can try to reproduce. We can run the new test on the Windows job if it's not running right now
I encountered the same exception below and confirmed the following facts.
NotImplementedError: Logprob method not implemented for CustomDist_mu_rv{"()->()"}
The code mentioned above https://colab.research.google.com/drive/1I1n6c9IlmXknIfhxC5s7sAQghv0vfRSY?usp=sharing reproduces the exception with PyMC 5.18.0 and Python 3.12.7 on Windows 11, while the same code works well with PyMC 5.18.0 and Python 3.12.2 on Ubuntu-22.04 (WSL2).
So, I suspect the problem may be platform-dependent, something like a "cloudpickle on Windows" problem.
Describe the issue:
pymc.sample_smc
raises aNotImplementedError
due to a missing logp method if apymc.CustomDist
is used in a model withoutdist
argument. In addition to usingdist
, switching topm.Potential
works.Reproduceable code example:
Error message:
PyMC version information:
Context for the issue:
I'm testing a model which suffers from slow sampling, possibly due to expensive gradient calculations. I tested SMC as a possible solution as suggested on the forums but got this error message.
Using the
dist
argument could work in most cases, but there's cases when the distributions provided bypymc
are not enough. Usingpm.Potential
could help with sampling but that would in turn make forward sampling less straightforward.