Commit 4593dbc
Add parallel MALA sampler (Phase 3)
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>1 parent 656fd8a commit 4593dbc
File tree
4 files changed
+748
-13
lines changed- docs
- src/parallel
- test/parallel
4 files changed
+748
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
197 | 199 | | |
198 | 200 | | |
199 | 201 | | |
200 | | - | |
| 202 | + | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
207 | | - | |
| 209 | + | |
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
252 | 258 | | |
253 | 259 | | |
254 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| |||
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
0 commit comments