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

Sampling with generators as seeding no longer deterministic #7612

Open
ricardoV94 opened this issue Dec 13, 2024 · 2 comments · May be fixed by #7540
Open

Sampling with generators as seeding no longer deterministic #7612

ricardoV94 opened this issue Dec 13, 2024 · 2 comments · May be fixed by #7540

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Dec 13, 2024

Description

This was revealed in pymc-labs/pymc-marketing#1269

import numpy as np
import pymc as pm

with pm.Model() as m:
    x = pm.Normal("x")

    post1 = pm.sample(tune=10, draws=10, random_seed=np.random.default_rng(42)).posterior
    post2 = pm.sample(tune=10, draws=10, random_seed=np.random.default_rng(42)).posterior
assert post1.equals(post2), (post1["x"].mean().item(), post2["x"].mean().item())
# AssertionError: (0.22006495904628473, -0.31090965213192406)
@ricardoV94
Copy link
Member Author

@lucianopaz seems to be caused by #7508

@lucianopaz
Copy link
Contributor

lucianopaz commented Dec 13, 2024

This might be fixed by the second, third, and fourth commits from #7540. This might be caused by that bug from numpy<2.0 where the random generator was not copied properly.

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

Successfully merging a pull request may close this issue.

2 participants