Conversation
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement the foundation for parallelizing MCMC across sequence length
based on Zoltowski et al. "Parallelizing MCMC Across the Sequence Length".
Core components:
- Parallel scan solving linear recurrences s_t = J_t * s_{t-1} + u_t
- Three affine transform types for different DEER variants:
- MatrixAffineTransform (full Jacobian for DEER)
- DiagonalAffineTransform (diagonal approx for Quasi-DEER)
- Block2x2AffineTransform (2x2 blocks for leapfrog/Block Quasi-DEER)
- Associative composition operator enabling O(log T) parallel time
- Method types: FullDEER, QuasiDEER, StochasticQuasiDEER, BlockQuasiDEER
Files added:
- src/parallel/Parallel.jl - Module definition
- src/parallel/types.jl - Type definitions
- src/parallel/scan.jl - Parallel scan implementation
- test/parallel/test_scan.jl - 141 tests
- docs/parallel_mcmc_implementation_plan.md - Implementation tracker
- docs/parallel_mcmc_implementation_note.md - Algorithm reference
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement utilities for computing Jacobians and their approximations, completing Phase 1 (Core Infrastructure) of the parallel MCMC implementation. New utilities in src/parallel/jacobian.jl: - jacobian_fd: Full Jacobian via finite differences - jacobian_diagonal_full: Extract Jacobian diagonal - jvp_fd / vjp_fd: Jacobian-vector and vector-Jacobian products - rademacher_vector: Generate ±1 random vectors - hutchinson_diagonal: Stochastic diagonal estimator using Hutchinson's method - hessian_diagonal: Hessian diagonal for leapfrog integration - Batch versions for all operations (batch_jacobians, batch_hutchinson_diagonals, etc.) The implementation is AD-agnostic with finite difference fallbacks. Users can plug in ForwardDiff/Zygote/Enzyme-based implementations. Tests: 57 new tests for Jacobian utilities (all passing) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement the main DEER (Doubly Efficient Estimation via Recursion)
algorithm that solves MCMC chains in parallel via Newton's method.
Core algorithm in src/parallel/deer.jl:
- deer(): Main entry point with method dispatch
- DEERResult: Result type with trajectory, convergence info, residual history
- sequential_mcmc(): Reference implementation for testing
Three DEER variants implemented:
- FullDEER: Full D×D Jacobian matrices, O(T*D²) memory
- QuasiDEER: Diagonal Jacobian approximation, O(T*D) memory
- StochasticQuasiDEER: Hutchinson estimator for diagonal, only needs JVPs
The algorithm:
1. Initialize trajectory (forward pass or zeros)
2. Newton iteration loop:
- Evaluate f_t at all timesteps (parallelizable)
- Compute Jacobians (method-dependent)
- Compute offsets u_t = f_t(s_{t-1}) - J_t * s_{t-1}
- Solve linear system via parallel scan
- Check convergence (max absolute difference)
3. Return DEERResult with trajectory and diagnostics
Tests: 67 new tests covering linear/nonlinear systems, all variants,
convergence tracking, edge cases, and numerical stability.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement parallelized Metropolis-Adjusted Langevin Algorithm using DEER. MALA components in src/parallel/mala.jl: - MALARandomInputs: Pre-sampled (ξ, u) pairs for proposals and accept-reject - MALAConfig: Configuration struct with step size, log density, gradient - mala_proposal(): Langevin proposal x̃ = x + ε∇log p(x) + √(2ε)ξ - mala_log_acceptance_ratio(): MH ratio with forward/backward densities - soft_gate(): Differentiable accept-reject using sigmoid + straight-through - mala_transition(): Complete MALA step combining proposal and accept-reject - parallel_mala(): Run full MALA chain in parallel via DEER - sequential_mala(): Reference implementation for testing The stop-gradient trick enables computing Jacobians through the non-differentiable accept-reject step by using a soft sigmoid gate in the backward pass while keeping hard decisions in the forward pass. Tests: 31 new tests covering proposal mechanics, sequential/parallel equivalence, various target distributions, acceptance behavior, and sample statistics. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 243 to 245 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 382 to 385 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 391 to 392 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 397 to 398 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 401 to 403 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 408 to 409 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 420 to 421 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 439 to 441 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 444 to 445 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 451 to 453 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 465 to 469 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 479 to 485 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 492 to 496 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 22 to 44 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 47 to 60 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 62 to 69 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 74 to 80 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 82 to 90 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 97 to 122 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 127 to 140 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 145 to 159 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 161 to 164 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 169 to 179 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 181 to 188 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 218 to 219 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 222 to 224 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 230 to 236 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 242 to 259 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 263 to 272 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 280 to 283 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 109 to 110 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 142 to 145 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 149 to 152 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 157 to 158 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 161 to 162 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 179 to 183 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 230 to 234 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 307 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 340 to 345 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 348 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 352 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 363 to 368 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 118 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 210 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 241 to 245 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 275 to 279 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 311 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 327 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 40 to 43 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 48 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 50 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 70 to 73 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 102 to 106 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 197 to 201 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 381 to 386 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/scan.jl
Line 262 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 138 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 142 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 238 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 241 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 77 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 100 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 125 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 129 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 204 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 207 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 274 in 4593dbc
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_scan.jl
Line 284 in 4593dbc
| ## Common Commands | ||
|
|
||
| ### Testing | ||
| ```bash |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| Tests use ReTest.jl. Test files are in `test/` and cover: metric, hamiltonian, integrator, trajectory, adaptation, sampler, abstractmcmc, mcmcchains, constructors. | ||
|
|
||
| ### Code Formatting | ||
| ```bash |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| ```bash | |
| ```bash |
| ```bash | ||
| julia -e 'using JuliaFormatter; format(".")' | ||
| ``` | ||
| Uses Blue style (see `.JuliaFormatter.toml`). |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| Uses Blue style (see `.JuliaFormatter.toml`). | |
| Uses Blue style (see `.JuliaFormatter.toml`). |
| - `src/metric.jl` - Metric types: `UnitEuclideanMetric`, `DiagEuclideanMetric`, `DenseEuclideanMetric` | ||
| - `src/hamiltonian.jl` - `Hamiltonian`, `PhasePoint`, `DualValue` (caches value+gradient) | ||
| - `src/integrator.jl` - `Leapfrog`, `JitteredLeapfrog`, `TemperedLeapfrog` | ||
| - `src/trajectory.jl` - Termination criteria (`ClassicNoUTurn`, `GeneralisedNoUTurn`, `FixedNSteps`) and trajectory samplers (`EndPointTS`, `SliceTS`, `MultinomialTS`) | ||
| - `src/adaptation/` - Step size (`NesterovDualAveraging`), mass matrix (`WelfordVar`, `WelfordCov`, `NutpieVar`), composite (`StanHMCAdaptor`, `NaiveHMCAdaptor`) | ||
| - `src/constructors.jl` - Convenience constructors: `NUTS`, `HMC`, `HMCDA` | ||
| - `src/abstractmcmc.jl` - AbstractMCMC.jl interface implementation | ||
| - `src/riemannian/` - Riemannian manifold support with `GeneralizedLeapfrog` |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - `src/metric.jl` - Metric types: `UnitEuclideanMetric`, `DiagEuclideanMetric`, `DenseEuclideanMetric` | |
| - `src/hamiltonian.jl` - `Hamiltonian`, `PhasePoint`, `DualValue` (caches value+gradient) | |
| - `src/integrator.jl` - `Leapfrog`, `JitteredLeapfrog`, `TemperedLeapfrog` | |
| - `src/trajectory.jl` - Termination criteria (`ClassicNoUTurn`, `GeneralisedNoUTurn`, `FixedNSteps`) and trajectory samplers (`EndPointTS`, `SliceTS`, `MultinomialTS`) | |
| - `src/adaptation/` - Step size (`NesterovDualAveraging`), mass matrix (`WelfordVar`, `WelfordCov`, `NutpieVar`), composite (`StanHMCAdaptor`, `NaiveHMCAdaptor`) | |
| - `src/constructors.jl` - Convenience constructors: `NUTS`, `HMC`, `HMCDA` | |
| - `src/abstractmcmc.jl` - AbstractMCMC.jl interface implementation | |
| - `src/riemannian/` - Riemannian manifold support with `GeneralizedLeapfrog` | |
| - `src/metric.jl` - Metric types: `UnitEuclideanMetric`, `DiagEuclideanMetric`, `DenseEuclideanMetric` | |
| - `src/hamiltonian.jl` - `Hamiltonian`, `PhasePoint`, `DualValue` (caches value+gradient) | |
| - `src/integrator.jl` - `Leapfrog`, `JitteredLeapfrog`, `TemperedLeapfrog` | |
| - `src/trajectory.jl` - Termination criteria (`ClassicNoUTurn`, `GeneralisedNoUTurn`, `FixedNSteps`) and trajectory samplers (`EndPointTS`, `SliceTS`, `MultinomialTS`) | |
| - `src/adaptation/` - Step size (`NesterovDualAveraging`), mass matrix (`WelfordVar`, `WelfordCov`, `NutpieVar`), composite (`StanHMCAdaptor`, `NaiveHMCAdaptor`) | |
| - `src/constructors.jl` - Convenience constructors: `NUTS`, `HMC`, `HMCDA` | |
| - `src/abstractmcmc.jl` - AbstractMCMC.jl interface implementation | |
| - `src/riemannian/` - Riemannian manifold support with `GeneralizedLeapfrog` |
| - `AdvancedHMCOrdinaryDiffEqExt` - DiffEqIntegrator support | ||
| - `AdvancedHMCMCMCChainsExt` - MCMCChains.jl integration | ||
| - `AdvancedHMCCUDAExt` - CUDA array support | ||
| - `AdvancedHMCComponentArraysExt` - ComponentArrays support | ||
| - `AdvancedHMCADTypesExt` - ADTypes.jl integration |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - `AdvancedHMCOrdinaryDiffEqExt` - DiffEqIntegrator support | |
| - `AdvancedHMCMCMCChainsExt` - MCMCChains.jl integration | |
| - `AdvancedHMCCUDAExt` - CUDA array support | |
| - `AdvancedHMCComponentArraysExt` - ComponentArrays support | |
| - `AdvancedHMCADTypesExt` - ADTypes.jl integration | |
| - `AdvancedHMCOrdinaryDiffEqExt` - DiffEqIntegrator support | |
| - `AdvancedHMCMCMCChainsExt` - MCMCChains.jl integration | |
| - `AdvancedHMCCUDAExt` - CUDA array support | |
| - `AdvancedHMCComponentArraysExt` - ComponentArrays support | |
| - `AdvancedHMCADTypesExt` - ADTypes.jl integration |
| function hmc_step(x_prev, ω_momentum, ω_leapfrog, u_accept, ε, L, ∇logp) | ||
| # Sample momentum | ||
| v = ω_momentum # ~ N(0, I) | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| # Leapfrog integration (sequential within this step) | ||
| x, v = leapfrog(x_prev, v, ε, L, ∇logp) | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| # Accept-reject (with stop-gradient trick as in MALA) | ||
| # ... | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - Parallelize across T HMC samples | ||
| - Each parallel iteration evaluates L leapfrog steps sequentially | ||
| - Good when T >> L |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - Parallelize across T HMC samples | |
| - Each parallel iteration evaluates L leapfrog steps sequentially | |
| - Good when T >> L | |
| - Parallelize across T HMC samples | |
| - Each parallel iteration evaluates L leapfrog steps sequentially | |
| - Good when T >> L |
| Run HMC steps sequentially, but parallelize the inner leapfrog loop: | ||
|
|
||
| **Leapfrog step** (Equation 8): | ||
| ``` |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| ``` | |
| ``` |
|
AdvancedHMC.jl documentation for PR #487 is available at: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #487 +/- ##
===========================================
- Coverage 77.71% 53.75% -23.96%
===========================================
Files 21 28 +7
Lines 1270 1836 +566
===========================================
Hits 987 987
- Misses 283 849 +566 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implements parallel HMC using DEER algorithm with two approaches: Approach A - Parallelize across HMC steps: - parallel_hmc() runs T HMC steps in parallel - hmc_transition_soft() with soft MH gating for differentiability Approach B - Parallelize leapfrog integration: - parallel_leapfrog() parallelizes L leapfrog steps - leapfrog_transition() as DEER transition function Block Quasi-DEER for leapfrog: - BlockQuasiDEER type exploiting 2x2 block Jacobian structure - _deer_iteration_block() for efficient block-diagonal Newton - parallel_scan_block() using Block2x2AffineTransform 49 new tests (345 total parallel tests) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 465 to 469 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 479 to 485 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_note.md
Lines 492 to 496 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 22 to 44 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 47 to 60 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 62 to 69 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 74 to 80 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 82 to 90 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 97 to 122 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 127 to 140 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 145 to 159 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 161 to 164 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 169 to 179 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 181 to 188 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 218 to 219 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 222 to 224 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 230 to 236 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 242 to 259 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 263 to 272 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 280 to 283 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 109 to 110 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 142 to 145 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 149 to 152 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 157 to 158 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 161 to 162 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 179 to 183 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 230 to 234 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 307 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 333 to 334 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 337 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 340 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 409 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 412 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 421 to 424 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 428 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 436 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 460 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 488 to 493 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 496 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 500 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 511 to 516 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 41 to 44 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 353 to 356 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Line 366 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 414 to 415 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Line 490 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 600 to 604 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 118 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 210 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 241 to 245 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 275 to 279 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 311 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 327 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 40 to 43 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 48 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 50 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 70 to 73 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 102 to 106 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 197 to 201 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 381 to 386 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/scan.jl
Line 262 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 138 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 142 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 238 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 241 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 167 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 193 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 211 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 214 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 256 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 291 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 339 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 380 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 445 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 481 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 77 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 100 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 125 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 129 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 204 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 207 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 274 in 5036586
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_scan.jl
Line 284 in 5036586
| - Good when L is large | ||
| - Use **block quasi-DEER** for this (Section 2.4) | ||
| - Convergence in ~L/2 iterations typically |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - Good when L is large | |
| - Use **block quasi-DEER** for this (Section 2.4) | |
| - Convergence in ~L/2 iterations typically | |
| - Good when L is large | |
| - Use **block quasi-DEER** for this (Section 2.4) | |
| - Convergence in ~L/2 iterations typically |
|
|
||
| Note: The update for coordinate d does **not** depend on `x_{t-1,d}`, which affects the Jacobian structure. | ||
|
|
||
| --- |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| --- | |
| * * * |
| T: number of samples | ||
| method: :deer, :quasi_deer, :stochastic_quasi_deer, :block_quasi_deer | ||
| """ | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| """ | ||
|
|
||
| D = length(s0) | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
|
|
||
| # Pre-sample all random inputs | ||
| ω = sample_random_inputs(T) # Shape: (T, ...) | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - **ForwardDiff.jl** for full Jacobians (small D) | ||
| - **Zygote.jl** or **Enzyme.jl** for JVPs in stochastic quasi-DEER |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - **ForwardDiff.jl** for full Jacobians (small D) | |
| - **Zygote.jl** or **Enzyme.jl** for JVPs in stochastic quasi-DEER | |
| - **ForwardDiff.jl** for full Jacobians (small D) | |
| - **Zygote.jl** or **Enzyme.jl** for JVPs in stochastic quasi-DEER |
| - Use `CUDA.jl` with `@cuda` kernels | ||
| - Or `KernelAbstractions.jl` for portable GPU code | ||
| - Ensure f is GPU-compatible (no scalar indexing, etc.) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - Use `CUDA.jl` with `@cuda` kernels | |
| - Or `KernelAbstractions.jl` for portable GPU code | |
| - Ensure f is GPU-compatible (no scalar indexing, etc.) | |
| - Use `CUDA.jl` with `@cuda` kernels | |
| - Or `KernelAbstractions.jl` for portable GPU code | |
| - Ensure f is GPU-compatible (no scalar indexing, etc.) |
| - Implement custom CUDA kernel for efficiency | ||
| - Or use `Transducers.jl` with GPU support |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - Implement custom CUDA kernel for efficiency | |
| - Or use `Transducers.jl` with GPU support | |
| - Implement custom CUDA kernel for efficiency | |
| - Or use `Transducers.jl` with GPU support |
| 1. **New sampler type**: `ParallelHMC` or `DEER_HMC` | ||
| 2. **Modify `Leapfrog` integrator**: Add parallel mode | ||
| 3. **New `sample` method**: Returns full chain in one call |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| 1. **New sampler type**: `ParallelHMC` or `DEER_HMC` | |
| 2. **Modify `Leapfrog` integrator**: Add parallel mode | |
| 3. **New `sample` method**: Returns full chain in one call | |
| 1. **New sampler type**: `ParallelHMC` or `DEER_HMC` | |
| 2. **Modify `Leapfrog` integrator**: Add parallel mode | |
| 3. **New `sample` method**: Returns full chain in one call |
| method::Symbol # :deer, :quasi_deer, :stochastic_quasi_deer | ||
| tol::Float64 | ||
| max_iters::Int | ||
| window_size::Union{Int, Nothing} # for sliding window |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| window_size::Union{Int, Nothing} # for sliding window | |
| window_size::Union{Int,Nothing} # for sliding window |
Implements parallel sampler types for AbstractMCMC-compatible interface: - ParallelHMCSampler / ParallelHMC - ParallelMALASampler / ParallelMALA - ParallelSamplerState with trajectory and convergence info - parallel_sample() for batch sampling with LogDensityProblems - SimpleLogDensity wrapper for easy testing 75 new tests (420 total parallel tests) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 234 to 240 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 246 to 273 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 277 to 286 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/docs/parallel_mcmc_implementation_plan.md
Lines 294 to 297 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/Parallel.jl
Lines 54 to 55 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/Parallel.jl
Line 59 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Lines 46 to 48 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Lines 102 to 104 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 247 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 270 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 274 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 286 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 308 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 328 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 332 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 343 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 373 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Lines 399 to 402 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/abstractmcmc.jl
Line 432 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 109 to 110 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 142 to 145 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 149 to 152 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 157 to 158 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 161 to 162 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 179 to 183 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 230 to 234 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 307 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 333 to 334 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 337 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 340 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 409 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 412 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 421 to 424 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 428 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 436 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 460 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 488 to 493 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 496 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Line 500 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/deer.jl
Lines 511 to 516 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 41 to 44 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 353 to 356 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Line 366 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 414 to 415 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Line 490 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/hmc.jl
Lines 600 to 604 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 118 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 210 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 241 to 245 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Lines 275 to 279 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 311 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/jacobian.jl
Line 327 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 40 to 43 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 48 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Line 50 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 70 to 73 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 102 to 106 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 197 to 201 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/mala.jl
Lines 381 to 386 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/src/parallel/scan.jl
Line 262 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_abstractmcmc.jl
Lines 42 to 46 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_abstractmcmc.jl
Lines 72 to 75 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_abstractmcmc.jl
Lines 129 to 131 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_abstractmcmc.jl
Lines 149 to 151 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 138 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 142 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 238 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_deer.jl
Line 241 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 167 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 193 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 211 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 214 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 256 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 291 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 339 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 380 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 445 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_hmc.jl
Line 481 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 77 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 100 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 125 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 129 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 204 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 207 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_mala.jl
Line 274 in c041fe9
[JuliaFormatter] reported by reviewdog 🐶
AdvancedHMC.jl/test/parallel/test_scan.jl
Line 284 in c041fe9
| rng::AbstractRNG, | ||
| model, | ||
| sampler::ParallelHMC, | ||
| n_samples::Int; | ||
| initial_θ = nothing |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| rng::AbstractRNG, | |
| model, | |
| sampler::ParallelHMC, | |
| n_samples::Int; | |
| initial_θ = nothing | |
| rng::AbstractRNG, model, sampler::ParallelHMC, n_samples::Int; initial_θ=nothing |
| end | ||
| ``` | ||
|
|
||
| --- |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| --- | |
| * * * |
| | Scenario | Recommended Method | | ||
| |----------|-------------------| | ||
| | Low-D, need fastest convergence | DEER (full Jacobian) | | ||
| | High-D, memory-constrained | Stochastic quasi-DEER | | ||
| | HMC with many leapfrog steps | Block quasi-DEER on leapfrog | | ||
| | Very long chains | Add sliding window | | ||
| | Approximate samples OK | Early stopping | |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| | Scenario | Recommended Method | | |
| |----------|-------------------| | |
| | Low-D, need fastest convergence | DEER (full Jacobian) | | |
| | High-D, memory-constrained | Stochastic quasi-DEER | | |
| | HMC with many leapfrog steps | Block quasi-DEER on leapfrog | | |
| | Very long chains | Add sliding window | | |
| | Approximate samples OK | Early stopping | | |
| | Scenario | Recommended Method | | |
| |:--------------------------------- |:------------------------------- | | |
| | Low-D, need fastest convergence | DEER (full Jacobian) | | |
| | High-D, memory-constrained | Stochastic quasi-DEER | | |
| | HMC with many leapfrog steps | Block quasi-DEER on leapfrog | | |
| | Very long chains | Add sliding window | | |
| | Approximate samples OK | Early stopping | |
| | Approximate samples OK | Early stopping | | ||
| | MALA with known Hessian structure | Quasi-DEER with preconditioning | | ||
|
|
||
| --- |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| --- | |
| * * * |
| - **Paper**: Zoltowski et al., "Parallelizing MCMC Across the Sequence Length", NeurIPS 2025 | ||
| - **Code**: https://github.com/lindermanlab/parallel-mcmc | ||
| - **DEER theory**: Lim et al. [7], Danieli et al. [6] | ||
| - **Quasi-DEER**: Gonzalez et al. [8] | ||
| - **Stochastic diagonal estimation**: Hutchinson [22], Bekas et al. [20] |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - **Paper**: Zoltowski et al., "Parallelizing MCMC Across the Sequence Length", NeurIPS 2025 | |
| - **Code**: https://github.com/lindermanlab/parallel-mcmc | |
| - **DEER theory**: Lim et al. [7], Danieli et al. [6] | |
| - **Quasi-DEER**: Gonzalez et al. [8] | |
| - **Stochastic diagonal estimation**: Hutchinson [22], Bekas et al. [20] | |
| - **Paper**: Zoltowski et al., "Parallelizing MCMC Across the Sequence Length", NeurIPS 2025 | |
| - **Code**: https://github.com/lindermanlab/parallel-mcmc | |
| - **DEER theory**: Lim et al. [7], Danieli et al. [6] | |
| - **Quasi-DEER**: Gonzalez et al. [8] | |
| - **Stochastic diagonal estimation**: Hutchinson [22], Bekas et al. [20] |
| - [ ] **7.3 Statistical Validation** | ||
| - [ ] Samples match target distribution (known distributions) | ||
| - [ ] Compare sample quality metrics (ESS, R-hat) to sequential | ||
|
|
||
| - [ ] **7.4 Performance Benchmarks** | ||
| - [ ] Wall-clock time vs sequential | ||
| - [ ] Scaling with chain length T | ||
| - [ ] Memory usage profiling |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - [ ] **7.3 Statistical Validation** | |
| - [ ] Samples match target distribution (known distributions) | |
| - [ ] Compare sample quality metrics (ESS, R-hat) to sequential | |
| - [ ] **7.4 Performance Benchmarks** | |
| - [ ] Wall-clock time vs sequential | |
| - [ ] Scaling with chain length T | |
| - [ ] Memory usage profiling | |
| > Ensure correctness and performance |
| - [ ] Scaling with chain length T | ||
| - [ ] Memory usage profiling | ||
|
|
||
| --- |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| --- | |
| - [ ] **7.1 Unit Tests** | |
| + [ ] Parallel scan correctness (compare to sequential) | |
| + [ ] Jacobian computation accuracy | |
| + [ ] Hutchinson estimator convergence | |
| - [ ] **7.2 Integration Tests** | |
| + [ ] DEER converges to sequential MALA trace | |
| + [ ] DEER converges to sequential HMC trace | |
| + [ ] Quasi-DEER matches DEER (eventually) | |
| - [ ] **7.3 Statistical Validation** | |
| + [ ] Samples match target distribution (known distributions) | |
| + [ ] Compare sample quality metrics (ESS, R-hat) to sequential | |
| - [ ] **7.4 Performance Benchmarks** | |
| + [ ] Wall-clock time vs sequential | |
| + [ ] Scaling with chain length T | |
| + [ ] Memory usage profiling | |
| * * * |
| │ └── test_abstractmcmc.jl # ✅ 75 tests passing | ||
| ``` | ||
|
|
||
| --- |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| --- | |
| * * * |
| - ForwardDiff.jl - Jacobian computation | ||
| - LinearAlgebra - Matrix operations |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - ForwardDiff.jl - Jacobian computation | |
| - LinearAlgebra - Matrix operations | |
| - ForwardDiff.jl - Jacobian computation | |
| - LinearAlgebra - Matrix operations |
| - CUDA.jl - GPU acceleration | ||
| - Zygote.jl / Enzyme.jl - Alternative AD for JVPs | ||
| - ChainRulesCore.jl - Custom rrules for stop-gradient |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| - CUDA.jl - GPU acceleration | |
| - Zygote.jl / Enzyme.jl - Alternative AD for JVPs | |
| - ChainRulesCore.jl - Custom rrules for stop-gradient |
Parallel MCMC Implementation (DEER Algorithm)
Implements parallel MCMC sampling based on:
Status: Phases 1-5 Complete (420 tests passing)
Completed Phases
Phase 1: Core Infrastructure ✅
Phase 2: DEER Algorithm Core ✅
Phase 3: MALA Integration ✅
Phase 4: HMC Integration ✅
Phase 5: AdvancedHMC.jl Integration ✅
ParallelHMCSampler/ParallelHMCParallelMALASampler/ParallelMALAparallel_sample()with LogDensityProblems interfaceParallelSamplerStatewith trajectory and convergence infoRemaining Phases
Usage Example
Test Summary