Skip to content

Conversation

@penelopeysm
Copy link
Member

@penelopeysm penelopeysm commented Aug 1, 2025

v0.39.5 #2616 inadvertently changed the required interface for external samplers to include

AbstractMCMC.getparams(::DynamicPPL.Model, ::SamplerState)

rather than

Turing.Inference.getparams(::DynamicPPL.Model, ::SamplerTransition)

which is what came before it. Note that Turing.Inference.getparams serves a different purpose compared to AbstractMCMC.getparams and the external sampler interface should really use AbstractMCMC.getparams.

Furthermore, Turing.Inference.getparams is an internal function so in principle changing it should not require a breaking release --- but unfortunately I didn't catch that this internal function was part of the external sampler interface. So it was a mistake to make this change in a patch release. (Sorry.) This PR therefore reverts the change.

On top of that, the existing externalsampler tests did not catch this because they only tested on AdvancedMH and AdvancedHMC, for which both methods are overloaded.

So this PR also adds a test with a external sampler that satisfies the minimal interface as specified in the ExternalSampler docstring. This ensures that if we change the interface this test will break. See e.g. 'The Test Fake' in https://invenia.github.io/blog/2020/11/06/interfacetesting/.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2025

Turing.jl documentation for PR #2640 is available at:
https://TuringLang.github.io/Turing.jl/previews/PR2640/

@penelopeysm penelopeysm requested a review from sunxd3 August 1, 2025 10:58
@codecov
Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.88%. Comparing base (d0510b1) to head (4b92f18).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2640   +/-   ##
=======================================
  Coverage   84.88%   84.88%           
=======================================
  Files          22       22           
  Lines        1475     1475           
=======================================
  Hits         1252     1252           
  Misses        223      223           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@sunxd3 sunxd3 left a comment

Choose a reason for hiding this comment

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

@penelopeysm
Copy link
Member Author

Yeahh, just noticed that too. It's been happening a few times and we're not sure what triggered it although rerunning CI tends to make it pass, so it's not fully deterministic.

@penelopeysm
Copy link
Member Author

It might be this? JuliaLang/julia#54840

@penelopeysm
Copy link
Member Author

penelopeysm commented Aug 1, 2025

I think that's the offending bug. The stack trace shows speccache_eq, and the segfault only happens with 2 threads, and it only happens sometimes, which all lines up with the fact that the issue is about data races. I checked the Julia source code and this bugfix doesn't seem to have been backported to 1.10.

In fact it wasn't backported to 1.11 either but I suppose it's possible that other changes were made to 1.11 that made the race conditions less likely to happen.

FYI @mhauru @AoifeHughes

@penelopeysm penelopeysm merged commit e26820f into main Aug 1, 2025
79 of 91 checks passed
@penelopeysm penelopeysm deleted the py/extspl branch August 1, 2025 12:30
@coveralls
Copy link

coveralls commented Aug 1, 2025

Pull Request Test Coverage Report for Build 16673713759

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage remained the same at 84.997%

Files with Coverage Reduction New Missed Lines %
src/mcmc/external_sampler.jl 2 91.49%
Totals Coverage Status
Change from base Build 16566258730: 0.0%
Covered Lines: 1252
Relevant Lines: 1473

💛 - Coveralls

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.

3 participants