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) for LogDensityProblems models with gradients
  • DensityModel(turing_model) for DynamicPPL / Turing models when the relevant extension packages are loaded

See Getting Started for end-to-end examples of both.

Model

ParallelMCMC.DensityModelType
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) -> Real
  • grad_logdensity(x::AbstractVector) -> AbstractVector
  • hvp(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 differentiates logdensity directly 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 differentiate grad_logdensity_batch to keep the batched DEER path enabled.
  • dim::Int — dimensionality of the parameter space
  • param_names — optional Vector{Symbol} of parameter names used in MCMCChains output. If nothing (the default), names fall back to x[1], x[2], ....

When logdensity_batch and grad_logdensity_batch are provided, ParallelMALASampler enables the batched DEER update path.

source

Samplers

ParallelMCMC.MALASamplerType
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.

source
ParallelMCMC.ParallelMALASamplerType
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).

source

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

source

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

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·v of the differentiable surrogate step. Required; must not call AD through step_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).
source
ParallelMCMC.DEER.DEERWorkspaceType

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.

source
ParallelMCMC.DEER.solveFunction

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.

source
ParallelMCMC.DEERScan.AffineScanWorkspaceType

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.

source

The diagonal scan implementation itself lives in ParallelMCMC.DEERScan.solve_affine_scan_diag!.

Index