Skip to content

tests: transform shared sampler positions without mutation - #537

Merged
yebai merged 1 commit into
mainfrom
amcmcfix
Nov 8, 2026
Merged

yebai merged 1 commit into
mainfrom
amcmcfix

Conversation

@yebai

@yebai yebai commented Nov 8, 2026

Copy link
Copy Markdown
Member

Consecutive NUTS transitions can share one parameter array: the failing run has 745 adjacent shared pairs among 15,000 draws. test/abstractmcmc.jl applied invlink_gdemo in place to each transition, so a shared array was transformed more than once. The gdemo mean then came out as [1695.78, 1.16] instead of about [49/24, 7/6]. The tests now apply the transform inside mean, without mutating the samples.

The defect predates ForwardDiff 1.4.7, which only exposed it: the new division-derivative formula rounds differently and changes the sampled path. With everything else fixed, 1.4.6 passes and 1.4.7 fails, and both pass once the mutation is removed. This is the AdvancedHMC failure in AbstractMCMC's integration tests, on main and on TuringLang/AbstractMCMC.jl#228. The full suite passes locally against both.

Repeated transitions can share parameter arrays. Transforming them in
place applies the inverse link repeatedly and corrupts posterior means.
ForwardDiff 1.4.7 exposes this with the existing gdemo regression.

Assisted-by: Codex <codex@openai.com>
@yebai
yebai requested a review from sunxd3 November 8, 2026 20:23
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

AdvancedHMC.jl documentation for PR #537 is available at:
https://TuringLang.github.io/AdvancedHMC.jl/previews/PR537/

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.15%. Comparing base (7127da6) to head (e9e876c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #537   +/-   ##
=======================================
  Coverage   78.15%   78.15%           
=======================================
  Files          21       21           
  Lines        1332     1332           
=======================================
  Hits         1041     1041           
  Misses        291      291           

☔ View full report in Codecov by Harness.
📢 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.

@yebai
yebai merged commit bdfcf18 into main Nov 8, 2026
18 of 21 checks passed
@yebai
yebai deleted the amcmcfix branch November 8, 2026 22:40
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.

2 participants