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

Implement marginalization as a model transformation and deprecate MarginalModel #388

Merged
merged 2 commits into from
Jan 3, 2025

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Nov 1, 2024

Closes #360
Closes #383

Depends on pymc-devs/pymc#7568
Depends on pymc-devs/pymc#7569

@ricardoV94 ricardoV94 changed the title Implement marginalizaton as model transformation and deprecate MarginalModel Implement marginalization as a model transformation and deprecate MarginalModel Nov 3, 2024
@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch from 3177640 to 6eb8af1 Compare November 4, 2024 12:37
@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch from 6eb8af1 to 47b4259 Compare November 11, 2024 12:21
@ricardoV94
Copy link
Member Author

The marginalization part is working. Missing the recover_marginals refactor now

@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch 3 times, most recently from d837e26 to d8c93e5 Compare November 11, 2024 14:27
@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch 2 times, most recently from 3b11a34 to 047c682 Compare December 9, 2024 15:30
@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch from 047c682 to 33f94d9 Compare December 30, 2024 21:47
@ricardoV94 ricardoV94 force-pushed the refactor_marginal_model branch from 33f94d9 to 49d6682 Compare January 2, 2025 07:40
@ricardoV94 ricardoV94 marked this pull request as ready for review January 2, 2025 12:49
Copy link
Contributor

@zaxtax zaxtax left a comment

Choose a reason for hiding this comment

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

I have a small concern about the __hash__ and __eq__ methods on MarginalRV

Those can hide bugs that are later hard to find. Do we really need it? Other than that LGTM!

other.inner_inputs,
)

def __hash__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this. Would it be possible to move this logic into equal_computations or a similar place? Also is this actually used anywhere as is?

Copy link
Member Author

Choose a reason for hiding this comment

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

As the comment mentions this will be moved to the base class in PyTensor. It's used for the equal computations check that make one/two tests much more straightforward to write.

@zaxtax
Copy link
Contributor

zaxtax commented Jan 3, 2025 via email

@ricardoV94
Copy link
Member Author

That's mixing concerns. Ops are supposed to be comparable on equality. That also allows cache/merge optimizations elsewhere.

@zaxtax
Copy link
Contributor

zaxtax commented Jan 3, 2025 via email

@zaxtax zaxtax self-requested a review January 3, 2025 17:57
Copy link
Contributor

@zaxtax zaxtax left a comment

Choose a reason for hiding this comment

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

LGTM!

@ricardoV94 ricardoV94 merged commit 1b10334 into pymc-devs:main Jan 3, 2025
5 checks passed
@fonnesbeck
Copy link
Member

What about the example in pymc-examples? Do we need an issue to update that?

@zaxtax
Copy link
Contributor

zaxtax commented Jan 4, 2025 via email

@zaxtax
Copy link
Contributor

zaxtax commented Jan 4, 2025

Should we do a version bump and release first?

@ricardoV94
Copy link
Member Author

Should we do a version bump and release first?

Yup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marginalization is reset by freeze_dims_and_data Get rid of MarginalModel
3 participants