Learning in Integer Latent Variable Models with Nested Automatic Differentiation

Daniel Sheldon, Kevin Winner, Debora Sujono

Introduction

Modeling populations that change over time is a fundamental task in fields like ecology and epidemiology. These dynamics are frequently represented using Hidden Markov Models (HMMs) where the hidden state is an integer, such as the number of individuals in a colony. However, standard inference techniques struggle with these models because the hidden state can technically be any non-negative integer. Marginalizing out these variables requires summing over an infinite support—an impossible task for traditional algorithms.

While previous work suggested using Probability Generating Functions (PGFs) to represent these distributions compactly, evaluating them involves computing deeply nested, high-order derivatives. This introduces two major hurdles: computational complexity (naive differentiation is exponentially slow) and numerical instability (high-order derivatives easily exceed standard 64-bit floating-point limits, causing overflow or underflow).

This paper introduces a robust and efficient framework combining nested high-order automatic differentiation (AD) with a logarithmic number system to achieve polynomial-time gradients for these previously intractable models.

Methodology: Nested AD and LNS

To overcome the exponential scaling of nested derivatives, the authors propose a suite of AD algorithms specifically designed for "nested" differentiation.

First, they extend the standard AD computation graph to include "nested derivative nodes." These nodes represent the derivative of a function that is itself defined by another computation graph, managed by a simple adapter that handles the change of scope between inner and outer functions.

Nested AD Computation Graph

To evaluate these graphs efficiently, they employ a Higher-Order Forward Mode using Taylor series composition (specifically the BK 2.1 algorithm) to propagate dual numbers. This reduces the complexity of computing $p$-th order derivatives to $O(d^{2.5})$ time, where $d$ is the total order, shifting the paradigm from exponential to polynomial time. Furthermore, to support parameter estimation, they develop a Forward-Over-Reverse AD algorithm to compute exact gradients of the log-likelihood, which is significantly more efficient than numerical finite differences.

Crucially, to solve the numerical stability issue inherent in high-order derivatives, the core AD operations are implemented using a Logarithmic Number System (LNS). Instead of storing a number $X$, the system stores its sign and $\log(|X|)$. This "secret sauce" allows the algorithm to represent the massive dynamic range required by high-order derivatives without losing precision or crashing.

Experimental Results

The proposed methods were evaluated using simulated data from integer HMMs, testing both Bernoulli (survival) and Poisson (reproduction) offspring distributions, alongside Poisson immigration distributions. The AD-LNS approach was benchmarked against standard AD and current industry-standard "Truncation" methods (TRUNC and TRUNC-FFT), which require manual tuning of an upper bound.

Performance and Stability Results

The results demonstrate significant improvements in both stability and speed:

  • Unmatched Stability: Standard floating-point AD failed due to overflow once the immigration parameter $\Lambda$ exceeded 100. The AD-LNS method remained completely stable and accurate across all tested ranges.
  • Superior Speed: AD-LNS consistently outperformed the TRUNC-FFT method. For Bernoulli offspring models, AD-LNS was exceptionally fast because the linear nature of the PGF leads to many zero coefficients, which the LNS system handles efficiently.
  • Exact Accuracy: Unlike truncation methods that lose accuracy if the arbitrary bound is too low, the AD-LNS method provides exact results up to machine precision. Furthermore, the exact gradient method proved several times faster than numerical gradients for model fitting.

Limitations and Future Directions

While highly effective, the current theoretical framework restricts the nested derivatives to univariate functions. Although this covers many standard population models, it limits applicability to more complex multivariate latent variables. Additionally, while LNS provides necessary stability, addition and subtraction in log-space carry more computational overhead than standard floating-point arithmetic.

Future work will focus on extending this framework to multivariate nested derivatives, opening the door to a much wider class of probabilistic models.

Summary updated

BibTeX
@inproceedings{sheldon2018learning,
  author = {Daniel Sheldon and Kevin Winner and Debora Sujono},
  title = {{Learning in Integer Latent Variable Models with Nested Automatic Differentiation}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
  url = {https://openreview.net/forum?id=HJbOIiWO-S},
}
Figure