Skip to content

PR Review for #62 - #65

Open
rsenne wants to merge 3 commits into
mainfrom
PR-Fixes
Open

PR Review for #62#65
rsenne wants to merge 3 commits into
mainfrom
PR-Fixes

Conversation

@rsenne

@rsenne rsenne commented Aug 6, 2026

Copy link
Copy Markdown
Owner

This PR is for fixing things I didn't address because i accidentally merged #63 and #62.

Copilot AI lite review requested due to automatic review settings August 6, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR completes and stabilizes the work from #62 by allowing DensityModel derivative slots to accept AD backends, preparing those backends once per chain (cached in sampler state), and adjusting DEER/HVP logic and related extensions/docs/tests accordingly.

Changes:

  • Add AD-backend-or-callable support for DensityModel derivative slots and introduce PreppedDensityModel with per-chain preparation reuse.
  • Rework DEER HVP strategy/normalization and add second-order HVP support that routes through DI’s SecondOrder where appropriate.
  • Expand test coverage and update extensions + documentation to reflect the new slot semantics and optional ParallelMALASampler(…; backend=…).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/test-Turing-Integration.jl Adds integration tests for SecondOrder HVP on Turing/DynamicPPL models and for batched-slot routing to the batched DEER path.
test/test-HVP-Strategy.jl Adds regression tests for backend normalization and SecondOrder normalization preserving DI-resolved composition.
test/test-GPU-DEER.jl Adjusts GPU backend collection (notably Enzyme) for DEER GPU tests.
test/test-DEER-Interface.jl Updates DEER interface tests to use _prepare_model and pass prepped models to DEER recursion builders.
test/test-ADType-Slots.jl New comprehensive test suite for AD-backend slots, preparation semantics, and state/model reuse behavior.
src/ParallelMCMC.jl Introduces module-level DI aliasing and imports needed for AD-backend slot support.
src/interface.jl Implements PreppedDensityModel, slot validation, backend resolution, per-chain preparation caching in states, and makes ParallelMALASampler.backend optional.
src/DEER/DEER.jl Refactors backend normalization and adds DI SecondOrder HVP helpers; adjusts HVP fallback routing and preparation paths.
ext/LogDensityProblemsExt.jl Forwards batched slots and documents SecondOrder requirement for AD HVP on prepared-gradient LDP models.
ext/EnzymeExt.jl Updates normalization hook to only fill function_annotation=Enzyme.Const without forcing a mode.
ext/DynamicPPLExt.jl Forwards batched slots and documents SecondOrder requirement for AD HVP on DynamicPPL-prepared gradients.
docs/src/90-contributing.md Fixes list formatting in contributing guide.
docs/src/15-gpu.md Updates GPU guidance around log-density-only models, second-order limitations, and optional sampler backend.
docs/src/10-getting-started.md Adds a new section documenting AD backends in derivative slots and clarifying HVP semantics.
CHANGELOG.md Adds a detailed changelog entry describing the new slot semantics, caching behavior, and backend normalization changes.
Suppressed comments (1)

src/interface.jl:710

  • Changing _build_mala_deer_rec to require a PreppedDensityModel breaks existing internal callers that still pass a DensityModel with backend= (e.g. benchmark scripts under benchmarks/ParallelMCMCBenchmarks/scripts/*), causing a MethodError. Consider keeping a thin wrapper method that accepts DensityModel + backend and forwards to the prepped-model method.
function _build_mala_deer_rec(
    model::PreppedDensityModel,
    ε::Real,
    tape::Vector{<:MALATapeElement},
    x0_like::AbstractVector;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.05%. Comparing base (b43b16e) to head (ad1f64c).

Files with missing lines Patch % Lines
src/DEER/DEER.jl 87.50% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (87.50%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
- Coverage   92.07%   92.05%   -0.03%     
==========================================
  Files           7        7              
  Lines        1173     1170       -3     
==========================================
- Hits         1080     1077       -3     
  Misses         93       93              

☔ 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.

@rsenne
rsenne requested a review from gdalle August 7, 2026 01:22
@rsenne

rsenne commented Aug 7, 2026

Copy link
Copy Markdown
Owner Author

@gdalle this is to address your concerns on #62 that i merged by mistake

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