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

Flaky test test/sample/test_sample.py::test_bridge_sampling #1461

Closed
dweindl opened this issue Sep 16, 2024 · 2 comments
Closed

Flaky test test/sample/test_sample.py::test_bridge_sampling #1461

dweindl opened this issue Sep 16, 2024 · 2 comments
Assignees
Labels
CI sampling Related to sampling

Comments

@dweindl
Copy link
Member

dweindl commented Sep 16, 2024

For example, in https://github.com/ICB-DCM/pyPESTO/actions/runs/10882550532/job/30193828221?pr=1459:

=================================== FAILURES ===================================
_____________________________ test_bridge_sampling _____________________________

    @pytest.mark.flaky(reruns=2)
    def test_bridge_sampling():
        tol = 2
        # define problem
        objective = Objective(
            fun=lambda x: -gaussian_llh(x),
            grad=gaussian_nllh_grad,
            hess=gaussian_nllh_hess,
        )
        prior_true = NegLogParameterPriors(
            [
                {
                    "index": 0,
                    "density_fun": lambda x: (1 / (10 + 10)),
                    "density_dx": lambda x: 0,
                    "density_ddx": lambda x: 0,
                },
            ]
        )
        problem = pypesto.Problem(
            objective=AggregatedObjective([objective, prior_true]),
            lb=[-10],
            ub=[10],
            x_names=["x"],
        )
    
        # run optimization and MCMC
        result = optimize.minimize(problem, progress_bar=False, n_starts=10)
        result = sample.sample(
            problem,
            n_samples=1000,
            result=result,
        )
    
        # compute the log evidence using harmonic mean
        bridge_log_evidence = sample.evidence.bridge_sampling_log_evidence(result)
        harmonic_evidence = sample.evidence.harmonic_mean_log_evidence(result)
>       assert np.isclose(bridge_log_evidence, harmonic_evidence, atol=tol)
E       assert False
E        +  where False = <function isclose at 0x7f3c1c042bf0>(0.2670074583034374, -3.788734352667505, atol=2)
E        +    where <function isclose at 0x7f3c1c042bf0> = np.isclose

test/sample/test_sample.py:969: AssertionError
----------------------------- Captured stderr call -----------------------------

Increase number of optimizations or samples or reduce the tolerance of increase number of trials.

@dweindl dweindl added CI sampling Related to sampling labels Sep 16, 2024
@PaulJonasJost
Copy link
Collaborator

in a quick test, neither increasing starts to 100 nor increasing samples to 5000 really helped. Results are also so far apart that no reasonable tolerance could be set IMO. Seems to be something deeper, @arrjon could you have a look at this?

@arrjon
Copy link
Contributor

arrjon commented Sep 20, 2024

I will have look!

@arrjon arrjon closed this as completed Sep 20, 2024
PaulJonasJost added a commit that referenced this issue Sep 26, 2024
* change test_bridge_sampling to laplace

* increase flaky

---------

Co-authored-by: Paul Jonas Jost <70631928+PaulJonasJost@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI sampling Related to sampling
Projects
None yet
Development

No branches or pull requests

3 participants