You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SBBRMI: no embedded Laplace (Stan laplace_marginal) for @plate cell latents, blocked upstream on stan-dev/math#3438 #3
BRM has no spelling that integrates a @plate cell latent out with Stan's embedded Laplace approximation (laplace_marginal, Stan 2.37 or later), so cell latents are always sampled. An opt-in SBBRMI lowering was investigated and is on hold: on a synthetic model it does not run with the Stan that BRM compiles against, and it could not be sampled even with the pending upstream fix.
Model
Synthetic: 18 cells with 8 to 16 Gaussian latents each, log_T ~ Normal(location, scale), where location and scale depend on 56 population parameters. The latents are observed through T = exp(log_T): by noisy counts on about 70 % of the entries, and by the cell total with a 0.2 % relative standard deviation.
Findings
With BridgeStan 2.9.0 (Stan 2.39, Stan Math 5.3.0):
laplace_marginal returns NaN for 17 of the 18 cells at the true parameter values, with solvers 1, 2 and 3 and tolerances from 1e-3 to 1e-8.
The cause is upstream. The likelihood is not log-concave (its negative Hessian is indefinite even at the mode in 12 of 18 cells). Solvers 1 and 2 need a positive-definite matrix and fail from the default start, so Stan falls through to solver 3. Solver 3 reaches the mode, but its compute_log_determinant takes log of the signed LU diagonal. That is NaN whenever partial pivoting leaves a negative pivot, although det(B) > 0 in every cell.
Started at the exact conditional mode, all three solvers return the correct Laplace value.
With #3438 applied to a local copy of Stan Math:
Values are finite, but one gradient costs about 440 times the joint model's.
The marginal is not smooth at small scales: directional finite differences agree with the gradient at step 1e-2 and diverge below 1e-4.
NUTS (4 chains) did not finish warm-up in 30 minutes. The joint model sampled 4 × 1,000 draws in about a minute.
Resume condition
Revisit when a BridgeStan release ships a Stan Math with #3438, and its marginal is smooth on this shape. Re-measure on this model before adding a lowering. Any such lowering must be opt-in. A per-unit Laplace for the RK backend (RKBRMI) is being developed separately.
Activity