Laplace approximation methods and predictive conventions¶
The reproducibility contract identifies the historical settings and paper/code differences. This document defines the corrected research target and its approximations. Method labels identify numerical conventions; they do not assert calibrated uncertainty or reproduced published benchmarks. Models may have configurable depth, width and activation, or custom differentiable pointwise scalar forwards. Generic Jacobian methods do not depend on the notebook network. Structured jet methods require a declared compatible model adapter.
Residual target and precision¶
For parameters θ, coordinates q=(z,x), travel time Tθ(q), velocity v(q) and observed receiver time t, use scalar residuals
Write the objective as
With unit family weights this matches the notebook means, including its positivity penalty. The positivity residual is nonsmooth at zero; derivative checks avoid that kink. Weights use global family counts, before chunking. Replaying a weighted residual set must leave the estimator unchanged when chunk boundaries change. A residual plan fixes selections or deterministic replay state; all passes of a structured method use the same rows.
Let J have rows ∂rᵢ/∂θ. The corrected generalized Gauss–Newton (GGN) data target is
Rows carry √αᵢ, not residual values. This PSD matrix excludes the \(\sum_i\alpha_i r_i\nabla^2r_i\) term in the exact nonlinear-loss Hessian. It can represent Gaussian residual-likelihood curvature under an explicitly specified likelihood model; it is not automatically an empirical Fisher or a calibrated physical likelihood.
The interface calls λ prior_precision and s scale. Describe λ as a Gaussian
prior only when training included the matching L2 objective and likelihood scale;
otherwise it is post-hoc damping. Training prior defaults to zero. Never add the
training prior twice. A Gaussian centered at the final trained iterate is a local
approximation; with post-hoc damping that iterate need not be the MAP of the
regularized posterior being sampled.
For structured affine layers, parameters use row-major vectorization of augmented
matrices [W|b], concatenated by layer; consequently Kronecker ordering is G ⊗ A.
Custom parameter mappings use explicit recorded flatten/unflatten order.
Historical diagonal and direct GGN methods¶
legacy_diagonal preserves the archived estimator
Each loss is the total of the notebook's mean PDE, receiver and positivity terms. It includes cross-residual and cross-family effects from squaring the summed loss gradient. It is not the diagonal of corrected F, a per-observation Fisher, or an exact Hessian. Its dependence on the number/size of resampled batches is part of compatibility. Draw independent layerwise Gaussian perturbations around the same saved final parameters. Preserve the combined weight/bias noise layout when comparing against the archived implementation.
| Identifier | Approximation to corrected F | Limitation |
|---|---|---|
diagonal |
diag(F) | Discards all parameter correlations |
block_diagonal |
Exact blocks Fℓℓ per affine layer | Discards correlations between layers; custom mappings need an explicit partition |
full |
Complete dense F | Quadratic storage and cubic factorization; reference use with an explicit memory budget |
A full float64 2,737² matrix alone occupies about 57.2 MiB; factorization temporaries require additional memory. The default per-allocation diagnostic guard is 256 MiB. This is a budget, not a maximum supported model size. For dense precision P=CCᵀ with lower-triangular Cholesky C, draw δ=C⁻ᵀξ. Solving Cδ=ξ would give the wrong covariance in general.
First-order coordinate jets and KFAC¶
Ordinary forward/backward hooks do not capture mixed coordinate/parameter partials in the eikonal residual. Propagate value and coordinate-derivative channels s∈{0,z,x} through each affine/Mish layer:
Here primes denote the next layer, not differentiation of an entire vector. For a compatible alternative pointwise activation, replace Mish and its derivative with that activation and its derivative; an unsupported adapter must fail explicitly. Augment value-channel activations by 1 and derivative channels by 0 for biases. For residual i let bᵢₛ=∂rᵢ/∂zₛ. Its exact layer Jacobian matrix is
Receiver and positivity rows use the value channel; PDE rows use all three. Independent examples permit batched adjoints via an autograd call on the sum of residuals. Mixed derivatives and this layer Jacobian must agree with a complete autograd Jacobian reference.
kfac applies the explicit weight-sharing approximation
where cᵢ is the number of active channels. This separates activation/adjoint moments and drops same-point cross-channel terms; it is a jet-aware adaptation, not exact GGN. It reduces to the ordinary single-channel formula for receiver-only networks. Across layers, precision remains block diagonal.
With eigenvalues gⱼ,aₖ, add isotropic regularization exactly as
s*g_j*a_k + prior_precision. Independently damping the two factors produces a
different approximation. The conceptual source is Martens and Grosse (2015),
Optimizing Neural Networks with Kronecker-factored Approximate Curvature.
That source does not establish this PINN jet adaptation or benchmark equivalence.
EFB and sparse information form¶
efb freezes KFAC eigenvectors QG, QA, then replays the same residuals to compute
Flattening Λ in canonical order equals diag(QᵀFℓℓQ). Thus EFB retains exact GGN diagonal entries in this fixed basis, including the channel cross terms omitted by KFAC, while discarding off-diagonal entries in that basis. Neither reinitializing the accumulator per batch nor changing the basis during a pass is valid. This is an EKFAC-style correction; see George et al. (2018), Fast Approximate Natural Gradient Descent in a Kronecker Factored Eigenbasis. It is not a reimplementation of the faulty archived hook outputs.
inf retains at most the requested number of largest EFB eigenpairs per layer.
Build only the selected paired Kronecker vectors U, not the Cartesian closure of
selected factor vectors. With retained eigenvalues Λᵣ,
The package's sparse information form follows the diagonal-plus-low-rank structure in archived INF, with the exact maintained definition in the methods addendum. Negative d need not be roundoff: EFB already discards off-diagonal information. Clipping is an explicit PSD approximation. Report count and total magnitude of clipped entries and requested/effective rank; retain raw statistics unchanged. Add damping separately. INF does not generally recover dense F even at full rank, because its EFB basis representation is diagonal.
For INF, and also VaLLA below, write precision P=D+BBᵀ with strictly positive diagonal D. Whiten the columns C=D⁻¹ᐟ²B and cache a raw Householder QR decomposition C=Q[R;0], followed by the small SVD R=U diag(s) Vᵀ. For a standard normal parameter vector ξ, apply the inverse precision root:
Then Cov(δ)=P⁻¹. Householder transforms apply Q and Qᵀ without materializing
a full parameter-space basis. The implementation scales informed components
directly using 1/hypot(1,s), preserving small variances without subtracting
nearly equal vectors or squaring large singular values. Factorization and
transforms use the declared dtype; no promotion or truncation is implicit.
Rank-deficient B and rank zero are valid. With k=min(parameter count, rank),
cache storage is O(parameter count × rank + k²); it is reused across draws.
Scale and regularization belong in D and B before sampling. Diagnostic dense
covariance roots apply this same transform only after the dense-memory guard.
VaLLA: fixed-inducing PINN residual adaptation¶
valla adapts Luis A. Ortega, Simon Rodriguez-Santana and Daniel Hernandez-Lobato
(2024), Variational Linearized Laplace Approximation for Bayesian Deep Learning,
ICML, PMLR 235. The authors' implementation
is an additional equation source. Publication year is 2024; the preprint appeared
in 2023. This is the one newer extension in the maintained method inventory,
not an exhaustive survey of Laplace algorithms through 2026.
Fix the trained center, λ, likelihood weights and inducing functions. Whiten residuals and their complete Jacobians by √(sαᵢ). Select distinct inducing residual rows deterministically, recording family and source index. This differs from ordinary network-output inducing variables in the publication.
For inducing Jacobians Jz and a learned lower-triangular factor L, define
For query Jacobians Jx,
The mean remains the trained network output. The covariance-dependent KL is ½(logdet(H)−tr(Kzz A)); omitted mean terms are constant with the center/prior fixed. These are mathematical covariance identities. The implementation avoids the subtraction of large kernel terms, which can erase finite variances and variational gradients in strongly informed directions.
Instead, compact Householder QR gives Jz.T/sqrt(λ) = Q[R;0]. Apply its
reflectors to each streamed query Jacobian divided by √λ, retaining the first
k=min(parameter count, inducing count) coordinates u and the squared norm of the
remaining coordinates. For core=R@L, QR of the small augmented matrix
[core.T; I] gives an upper triangular root U with
U.T@U = I + core@core.T. Evaluate variance as the positive sum
||u_perp||² + ||solve(U.T,u)||², and KL as
½(2*sum(log(abs(diag(U)))) - k + ||solve(U,I)||_F²).
This preserves prior directions for rank-deficient inducing features without
forming a full parameter-space orthogonal matrix or a grid covariance.
VaLLA explicitly uses float64 for these fixed QR/projection caches and small variational calculations on the original device, including with float32 models. Returned variances, KL and posterior tensors retain the model dtype, with gradients propagated through the work precision. Metadata records this policy. The allocation guard counts float64 work bytes, including the augmented QR; only inducing Jacobians, residual statistics, cross-kernel rows and compact query features are cached. Full residual Jacobian chunks are discarded.
For each whitened residual mean r and variance v, sum one of these terms and add KL:
αV is VaLLA's divergence setting, distinct from residual weights αᵢ. Only 0 (ELBO limit) and 1 are supported initially. Initialize L to identity: a zero factor can have zero gradient. The research defaults are 32 inducing rows (capped by available distinct residuals), 200 variational Adam steps, learning rate .01 and αV=0. These are configurable budgets, not publication reproduction settings. Inducing locations, prior precision and noise are fixed; no hyperparameter optimization or learned inducing inputs is implied.
Equivalent parameter-perturbation covariance is
Use the same low-rank precision sampler with D=λI and B=JzᵀL. Reuse one δ
across every chunk of a sampled grid and evaluate the linearized prediction
T_MAP(q) + J_T(q) δ, e.g. by JVP. Independent per-cell draws destroy the spatial
covariance required for localization; nonlinear evaluation at perturbed weights
is a different predictive convention. With every residual inducing, αV=0 and
L=I, the covariance equals (λI + J.T@J)^-1; optimization may change L.
Numerical and interpretation limits¶
Symmetrize PSD estimates before eigendecomposition. Clamp only roundoff-scale negative eigenvalues with recorded tolerance/correction; reject material negative or nonfinite inputs. Use triangular solves with Cholesky or QR precision roots and exact additive damping, with explicit memory/chunk budgets. No silent device/dtype fallback or unrecorded jitter is part of these definitions. Dense float64 algebraic identities, jet/autograd comparisons, transformed-GGN EFB checks, small dense INF/VaLLA covariance and KL checks, and chunk-coherent draws are the relevant numerical oracles; finite samples alone do not establish correctness. A smoke run does not establish method quality.
All approximations are local to a trained center and chosen residual/likelihood scales. Except for VaLLA's stated linearized convention, posterior parameter draws are evaluated through the nonlinear model. Neither these methods nor the legacy statistic by themselves establish calibrated uncertainty in seismic velocity, arrival picks, or source location. Compare such claims against separate empirical validation with recorded data and configuration.