API Reference
This page documents all public types and functions exported by ParallelMCMC.jl.
Extension constructors
DensityModel also has extension constructors for common probabilistic-programming interfaces:
DensityModel(ld; param_names=nothing)forLogDensityProblemsmodels with gradientsDensityModel(turing_model)forDynamicPPL/ Turing models when the relevant extension packages are loaded
See Getting Started for end-to-end examples of both.
Model
ParallelMCMC.DensityModel — Type
DensityModel(logdensity, grad_logdensity, dim; param_names, logdensity_batch, grad_logdensity_batch, hvp, hvp_batch)Wraps a log-density function, its gradient, and optional Hessian-vector product helpers for use with ParallelMCMC samplers.
logdensity(x::AbstractVector) -> Realgrad_logdensity(x::AbstractVector) -> AbstractVectorhvp(x::AbstractVector, v::AbstractVector) -> AbstractVector— optional model-specific Hessian-vector product used by DEER to avoid AD through problematic kernels when available. If omitted, the sampler differentiateslogdensitydirectly via DifferentiationInterface.logdensity_batch(X::AbstractMatrix) -> AbstractVector— optional batched log-density over columns.grad_logdensity_batch(X::AbstractMatrix) -> AbstractMatrix— optional batched gradient over columns.hvp_batch(X::AbstractMatrix, V::AbstractMatrix) -> AbstractMatrix— optional batched Hessian-vector product over columns. If omitted, the sampler can differentiategrad_logdensity_batchto keep the batched DEER path enabled.dim::Int— dimensionality of the parameter spaceparam_names— optionalVector{Symbol}of parameter names used inMCMCChainsoutput. Ifnothing(the default), names fall back tox[1], x[2], ....
When logdensity_batch and grad_logdensity_batch are provided, ParallelMALASampler enables the batched DEER update path.
Samplers
ParallelMCMC.MALASampler — Type
MALASampler(epsilon; cholM=nothing)Metropolis-Adjusted Langevin Algorithm sampler with step size epsilon.
Optionally pass cholM = cholesky(M) to use a mass matrix M as a preconditioner. The proposal becomes y = x + ε M ∇logp(x) + √(2ε) L ξ where L is the Cholesky factor of M.
ParallelMCMC.AdaptiveMALASampler — Type
AdaptiveMALASampler(epsilon_init; n_warmup, target_accept, gamma, t0, kappa, cholM)ParallelMCMC.ParallelMALASampler — Type
ParallelMALASampler(epsilon; T, maxiter, tol_abs, tol_rel, jacobian, damping, probes, cholM, backend)DEER-parallelized MALA sampler.
Supported Jacobian modes are :stoch_diag (the default Hutchinson diagonal estimator) and :diag (exact diagonal via D JVPs).
Internal types
These types appear in MCMCChains internals and in the AbstractMCMC state/transition protocol. You generally do not need to construct them directly.
ParallelMCMC.MALATapeElement — Type
MALATapeElement(ξ, u)One element of the MALA noise tape: a noise vector ξ ~ N(0,I) and a uniform scalar u ~ Uniform(0,1). Stored with a concrete vector type V for type stability inside DEER.TapedRecursion.
ParallelMCMC.MALAState — Type
State for a MALASampler chain.
ParallelMCMC.MALATransition — Type
One MALASampler sample: parameter vector x, its log-density logp, and an accept/reject flag.
ParallelMCMC.AdaptiveMALAState — Type
State for an AdaptiveMALASampler chain, including dual-averaging adaptation statistics.
ParallelMCMC.AdaptiveMALATransition — Type
One AdaptiveMALASampler sample: parameter vector x, its log-density logp, the step size used for that transition, and whether the sample came from warmup.
ParallelMCMC.ParallelMALAState — Type
State for a ParallelMALASampler chain.
ParallelMCMC.ParallelMALATransition — Type
One ParallelMALASampler sample: parameter vector x and its log-density logp.
Low-level namespaces
These lower-level building blocks power the public samplers and are useful if you want to work with taped recursions or the diagonal affine scan directly.
ParallelMCMC.DEER.TapedRecursion — Type
Deterministic recursion driven by a pre-generated tape.
step_fwd(x, tape_t): exact forward transition (may include MH accept/reject).jvp(x, tape_t, v): explicit JVP(x, tape_t, v) -> J·vof the differentiable surrogate step. Required; must not call AD throughstep_fwd's control flow.fwd_and_jvp(x, tape_t, v): optional fused function-> (x_next, J·v).fwd_and_jvp_batch(Xbar, Z): optional batched function-> (FT, Jt).
ParallelMCMC.DEER.DEERWorkspace — Type
Reusable buffers for allocation-light DEER updates and solves.
All buffers are created with the same array type / device placement as S_template (or s0_template for vector buffers), so the workspace is GPU-compatible when constructed from CuArray templates.
ParallelMCMC.DEER.solve — Function
Run DEER iterations until convergence.
When no workspace is supplied, one is created automatically. Supplying a pre-allocated DEERWorkspace is the intended path for repeated GPU solves.
If workspace is supplied, copy_result defaults to true so the returned trajectory is owned by the caller and will not be overwritten by a later solve using the same workspace. Set copy_result=false for allocation-sensitive internal loops; in that mode the returned trajectory may alias workspace-owned buffers such as workspace.S_tmp.
ParallelMCMC.DEERScan.AffineScanWorkspace — Type
Reusable workspace for the diagonal affine scan.
Buffers are allocated with the same array type / device placement as the template matrix used to construct the workspace, so this is GPU-compatible for CuArray inputs and CPU-compatible for standard arrays.
ParallelMCMC.MALA.mala_step_surrogate_sigmoid — Function
Stop-gradient surrogate step used for Jacobians.
The diagonal scan implementation itself lives in ParallelMCMC.DEERScan.solve_affine_scan_diag!.
Index
ParallelMCMC.AdaptiveMALASamplerParallelMCMC.AdaptiveMALAStateParallelMCMC.AdaptiveMALATransitionParallelMCMC.DEER.DEERWorkspaceParallelMCMC.DEER.TapedRecursionParallelMCMC.DEERScan.AffineScanWorkspaceParallelMCMC.DensityModelParallelMCMC.MALASamplerParallelMCMC.MALAStateParallelMCMC.MALATapeElementParallelMCMC.MALATransitionParallelMCMC.ParallelMALASamplerParallelMCMC.ParallelMALAStateParallelMCMC.ParallelMALATransitionParallelMCMC.DEER.solveParallelMCMC.MALA.mala_step_surrogate_sigmoid