General adjoint-differentiated Laplace approximation

Charles C. MargossianarXiv 2023 · DOI

Abstract

The hierarchical prior used in Latent Gaussian models (LGMs) induces a posterior geometry prone to frustrate inference algorithms. Marginalizing out the latent Gaussian variable using an integrated Laplace approximation removes the offending geometry, allowing us to do efficient inference on the hyperparameters. To use gradient-based inference we need to compute the approximate marginal likelihood and its gradient. The adjoint-differentiated Laplace approximation differentiates the marginal likelihood and scales well with the dimension of the hyperparameters. While this method can be applied to LGMs with any prior covariance, it only works for likelihoods with a diagonal Hessian. Furthermore, the algorithm requires methods which compute the first three derivatives of the likelihood with current implementations relying on analytical derivatives. I propose a generalization which is applicable to a broader class of likelihoods and does not require analytical derivatives of the likelihood. Numerical experiments suggest the added flexibility comes at no computational cost: on a standard LGM, the new method is in fact slightly faster than the existing adjoint-differentiated Laplace approximation. I also apply the general method to an LGM with an unconventional likelihood. This example highlights the algorithm's potential, as well as persistent challenges.

Introduction

Latent Gaussian Models (LGMs) are fundamental to Bayesian statistics, finding applications in spatial modeling, time-series analysis, and neural networks. However, sampling from LGMs using standard Markov Chain Monte Carlo (MCMC) is often difficult. The hierarchical structure creates challenging posterior geometries—often described as "funnels"—where the curvature changes rapidly, causing sampling algorithms like Hamiltonian Monte Carlo (HMC) to struggle or fail.

A robust solution is to marginalize out the latent variables using the Laplace approximation. This transformation smooths the geometry, facilitating more efficient estimation of hyperparameters. To leverage gradient-based inference for these hyperparameters, we require the gradient of the approximate marginal likelihood. Existing "adjoint-differentiation" methods, while scalable, have been limited by two significant constraints: they typically require likelihoods with diagonal Hessians and necessitate the manual derivation and coding of the first three derivatives of the likelihood.

The General Adjoint-Differentiated Framework

This work introduces a generalized adjoint-differentiated Laplace approximation that overcomes these limitations through three primary innovations.

1. Automatic Differentiation (AD) Integration

By integrating automatic differentiation, the need for manual analytical derivatives is eliminated. The method employs "contraction" and "linearization" techniques to compute necessary higher-order derivatives efficiently. Instead of constructing full Jacobian matrices, it computes derivatives along specific directions, significantly reducing computational overhead.

2. The Abstract Newton Solver

The paper identifies that most specialized solvers for Laplace approximations share a common mathematical foundation. By introducing an abstract "B-matrix" framework, the author provides a unified algorithm capable of switching between different matrix decomposition strategies (e.g., Cholesky or LU) based on the model's structure.

Algorithm 1: Abstract Newton solver, providing a unified framework for the Laplace approximation.

3. Sparsity and Scalability

The algorithm is designed to exploit the sparsity of local interactions. Its complexity scales with the block size of the Hessian rather than the total number of parameters, making it suitable for large-scale LGMs.

Experimental Results

The proposed method was evaluated using two benchmarks: a Sparse Kernel Interaction Model (SKIM) and a Pharmacokinetic (PK) model.

Performance Benchmarking

In the SKIM benchmark, the general method was compared against the standard adjoint method. Surprisingly, the AD-based general method was consistently faster. This speedup occurs because the AD framework can bypass certain terms required in analytical expressions that are ultimately unnecessary for the final gradient.

Comparison of differentiation time between the standard adjoint method and the proposed general adjoint method across hyperparameter dimensions.

Handling Complex Likelihoods

The PK model served as a "stress test," featuring a non-log-concave likelihood and a block-diagonal Hessian. These characteristics violate the assumptions of traditional Laplace implementations. The general method successfully handled this model, producing hyperparameter posterior estimates that closely matched those from "Full HMC," the gold standard for accuracy.

Discussion and Limitations

While the general adjoint-differentiated Laplace approximation offers significant flexibility and efficiency, some challenges remain. The quality of the Laplace approximation depends on the posterior being approximately Gaussian; for highly skewed or multimodal distributions, the approximation may fail. Additionally, for non-log-concave likelihoods, finding the mode becomes a non-convex optimization problem, which can be computationally intensive.

Despite these hurdles, the unification of Newton solvers via linear algebra and the demonstration that AD can outperform hand-coded derivatives represent a significant step forward in making complex Bayesian inference more accessible and efficient.

Summary updated

BibTeX
@misc{margossian2023general,
  author = {Charles C. Margossian},
  title = {{General adjoint-differentiated Laplace approximation}},
  year = {2023},
  eprint = {2306.14976},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.14976},
}
Figure