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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register the overloads added by CustomDist in worker processes #7241

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

EliasRas
Copy link

@EliasRas EliasRas commented Apr 6, 2024

Description

Currently sample_smc can fail due to a NotImplementedError if it's used with a model defined usingCustomDist. If a CustomDist is used without dist parameter, the overloads for _logprob, _logcdf and _support_point are registered only in the main process.

This PR adds an initializer which registers the overloads in the worker processes of the pool used in sample_smc.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

馃摎 Documentation preview 馃摎: https://pymc--7241.org.readthedocs.build/en/7241/

Copy link

welcome bot commented Apr 6, 2024

Thank You Banner]
馃挅 Thanks for opening this pull request! 馃挅 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

custom_methods = {}
for rv in model.free_RVs + model.observed_RVs:
cls = rv.owner.op.__class__
if hasattr(cls, "_random_fn"):
Copy link
Author

Choose a reason for hiding this comment

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

The way I'm checking if the rv is from CustomDist feels kind dirty. Is there a better way? I couldn't come up with anything better after _print_name was changed in aa679f3

@ricardoV94
Copy link
Member

Hi @EliasRas, I'll need some time to review this one properly. Thanks for taking the initiative

@ricardoV94 ricardoV94 self-assigned this Apr 9, 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 this pull request may close these issues.

BUG: pymc.sample_smc fails with pymc.CustomDist
2 participants