Skip to content

Reactant integration - #66

Open
rsenne wants to merge 12 commits into
PR-Fixesfrom
reactant-integration
Open

Reactant integration#66
rsenne wants to merge 12 commits into
PR-Fixesfrom
reactant-integration

Conversation

@rsenne

@rsenne rsenne commented Aug 13, 2026

Copy link
Copy Markdown
Owner
  • Adds support for Reactant.jl
  • Adds tests for Reactant.jl
  • Also fixes some text here and there. Probably should be its own PR but well.

Resolves #37 for real, though its limited to Reactant for GPU (as of now)

Copilot AI lite review requested due to automatic review settings August 13, 2026 01:40
@rsenne
rsenne force-pushed the reactant-integration branch from 3bea841 to 3e4447b Compare August 13, 2026 01:40

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 adds a Reactant-based derivative/HVP path (ADTypes.AutoReactant()) to enable true second-order HVPs via Reactant/XLA (bypassing DifferentiationInterface) and updates docs/tests to cover pairing rules, limitations, and opt-in test execution. It primarily targets unblocking GPU second-order behavior discussed in #37 by providing a non-DI route.

Changes:

  • Adds ReactantExt to compile gradients/HVPs with Reactant (@compile) and introduces load-hint fallbacks when Reactant isn’t loaded.
  • Adds extensive tests for Reactant pairing rules, error surfacing (pre-compile), analytic correctness, and end-to-end sampling (opt-in).
  • Updates docs and changelog to document Reactant behavior, caveats, and GPU guidance.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test-Reactant-HVP.jl New opt-in test suite covering Reactant pairing/error behavior and correctness.
test/test-HVP-Strategy.jl Adds strategy-selection test ensuring AutoReactant bypasses DI.hvp_mode.
test/runtests.jl Gates Reactant tests behind PARALLELMCMC_TEST_REACTANT env var.
test/Project.toml Adds Reactant as a test extra (not default-installed).
src/ParallelMCMC.jl Adds shared _REACTANT_LOAD_HINT constant for consistent error messaging.
src/interface.jl Adds Reactant gradient hooks, pairing checks, and second-order backend composition for Reactant.
src/DEER/DEER.jl Adds ReactantHVP strategy + load-hint fallbacks for missing Reactant extension.
Project.toml Registers ReactantExt extension and adds Reactant as a weak dependency with compat.
ext/ReactantExt.jl Implements compiled gradient/HVP factories using Reactant + Enzyme-MLIR tracing.
ext/LogDensityProblemsExt.jl Documents that AutoReactant cannot trace LDP/DynamicPPL machinery.
ext/EnzymeExt.jl Documentation edits clarifying normalization behavior (no mode forcing).
ext/DynamicPPLExt.jl Documentation edits clarifying HVP expectations and Reactant incompatibility.
docs/src/95-reference.md Adds Reactant section to the API reference pointing to GPU docs/caveats.
docs/src/15-gpu.md Documents Reactant path, caveats, pairing rules, and relation to #37.
docs/src/10-getting-started.md Updates backend pairing guidance to include AutoReactant exception on GPU.
CHANGELOG.md Records Reactant integration and related behavior changes/fixes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/interface.jl
Comment thread ext/ReactantExt.jl Outdated
Comment thread src/interface.jl Outdated
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.69%. Comparing base (949a3dd) to head (4dc9a62).

Files with missing lines Patch % Lines
ext/ReactantExt.jl 0.00% 61 Missing ⚠️
src/interface.jl 57.14% 21 Missing ⚠️
src/DEER/DEER.jl 20.00% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           PR-Fixes      #66      +/-   ##
============================================
- Coverage     92.05%   85.69%   -6.36%     
============================================
  Files             7        8       +1     
  Lines          1170     1279     +109     
============================================
+ Hits           1077     1096      +19     
- Misses           93      183      +90     

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

Comment thread src/DEER/DEER.jl Outdated
Comment thread src/DEER/DEER.jl Outdated
Comment thread docs/src/15-gpu.md Outdated
Comment thread src/DEER/DEER.jl Outdated
Comment thread src/interface.jl Outdated
Comment thread ext/ReactantExt.jl
Comment thread ext/ReactantExt.jl Outdated
Comment thread ext/ReactantExt.jl
Comment thread test/test-Reactant-HVP.jl
Comment thread test/test-Reactant-HVP.jl Outdated
@gdalle

gdalle commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

How's that working out?

@rsenne

rsenne commented Aug 13, 2026

Copy link
Copy Markdown
Owner Author

So far so good? I've tried it on some mundane models (e.g., MvNormal, LinReg) and am now trying to get it to work for more complicated models (LogReg, Banana shaped Posterior) and currently performance is pretty good so generally very encouraging

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.

Use second order AD directly

3 participants