Gram-Preconditioned Langevin Sampling Inside Empirical-Bayes Matrix Factorization

Many low-rank models fit a matrix as a product of two thin factors, $LR^T$. The hyperparameters of these models are usually chosen by grid search over a held-out split. Examples include the noise level and how strongly each latent dimension is shrunk toward zero. A more principled route is empirical Bayes: maximize the marginal likelihood, meaning the probability of the data with the factors integrated out. Stochastic approximation does this by alternating two steps. It draws approximate posterior samples of the factors with a cheap sampler, then nudges the hyperparameters along the resulting gradient estimate. The sampler of choice is the unadjusted Langevin algorithm (ULA), which takes gradient steps plus Gaussian noise and skips the Metropolis accept-reject test. It is fast and rejection-free, but it has one weakness. When the true matrix has singular values spread over orders of magnitude, the posterior over the factors is badly stretched, and the sampler crawls along the weak directions. Those weak directions are exactly the ones the hyperparameter update needs to see in order to decide whether a latent dimension is real.

This proposal borrows the fix that optimization already has. Scaled gradient descent (ScaledGD) multiplies each factor's gradient by the inverse Gram matrix of the other factor, $(R^TR)^{-1}$, and this makes convergence independent of the condition number. Applied blockwise inside the Langevin sampler, the same matrix is more than a speed trick: for a Gaussian likelihood it is, up to a known noise scale, the exact conditional posterior covariance of $L$ given $R$. Applying it therefore turns each block's target into a nearly round Gaussian. The prior's per-dimension shrinkage weights then serve as the damping term that overparameterized ScaledGD needs, and the outer loop learns them instead of hand-tuning them. Because $R$ is held fixed while $L$ moves, each block step is a valid preconditioned Langevin step with no correction term for position-dependent geometry.

Core Claim

Take a factor model with likelihood $p(Y \mid LR^T, \theta)$ and column-wise Gaussian priors on the factors with precisions $\alpha = (\alpha_1,\dots,\alpha_r)$. Here $\theta$ collects the noise and likelihood parameters, $r$ is a deliberately generous search rank, and the precisions together with $\theta$ are the hyperparameters to be learned. The inner sampler alternates two block updates:

$$L_{k+1} = L_k - \gamma\, \nabla_L U(L_k, R_k)\, P(R_k) + \sqrt{2\gamma}\; \xi_{k+1}\, P(R_k)^{1/2}, \qquad P(R) = \big(\sigma^{-2} R^T R + \mathrm{diag}(\alpha)\big)^{-1}.$$

In this update, $U$ is the negative log joint density, $\gamma$ is the step size, $\xi_{k+1}$ is a matrix of standard Gaussians, and $\sigma^2$ is a curvature scale (the noise variance in the Gaussian case). The $R$ update is symmetric, with $P(L_{k+1})$ in place of $P(R_k)$. The outer loop then updates $(\theta, \alpha)$ with the warm-started stochastic approximation scheme of SOUL, introduced in Efficient stochastic optimisation by unadjusted Langevin Monte Carlo.

The claim has three parts. The first is an exact statement: for a fully observed Gaussian likelihood, each preconditioned block conditional is isotropic. The second is a proposition to prove: for any likelihood whose per-entry curvature lies between $m$ and $M$, such as the censored Gaussian (Tobit) likelihood, the condition number of each preconditioned block conditional is at most $M/m$, independent of the condition number $\kappa$ of the true matrix. The third is a hypothesis to test: the outer estimates of the weakest true components' precisions converge in a number of iterations that does not grow with $\kappa$. Vanilla ULA, by contrast, should slow down roughly linearly in $\kappa$.

Relation to Prior Work

Two papers supply the outer method and motivate the gap. SOUL embeds warm-started ULA in stochastic approximation and bounds the bias it induces. Stochastic Approximation with Biased MCMC for Expectation Maximization shows that the error of expectation-maximization driven by a biased sampler is governed by the sampler bias. It also shows that adding the Metropolis test, as in the Metropolis-adjusted Langevin algorithm (MALA), backfires in high dimensions because acceptance collapses. Both papers use an isotropic Langevin kernel, and neither examines low-rank latent structure.

Four papers supply the preconditioner. Accelerating Ill-Conditioned Low-Rank Matrix Estimation via Scaled Gradient Descent introduces the Gram-inverse scaling and its condition-free rate. Preconditioned Gradient Descent for Over-Parameterized Nonconvex Matrix Factorization and The Power of Preconditioning in Overparameterized Low-Rank Matrix Sensing show that when the search rank exceeds the true rank, a damping term is needed. They set the damping either by an error-tracking schedule or by a fixed constant. Our damping instead comes from the learned prior precisions, which also grow on unused dimensions and prune them. Accelerating SGD for Highly Ill-Conditioned Huge-Scale Online Matrix Completion maintains the Gram inverse with rank-one updates costing $O(r^2)$, which we reuse. Scaled stochastic gradient descent for low-rank matrix completion blends a global Gram matrix with row-specific ones, which addresses partially observed rows. All four are point estimators: none injects noise, samples a posterior, or learns hyperparameters by marginal likelihood.

Three papers constrain the design. A Non-asymptotic Analysis for Learning and Applying a Preconditioner in MCMC learns a static full covariance preconditioner once and then samples a fixed target. Our target moves with the hyperparameters, and our preconditioner is a cheap $r\times r$ function of the current state. Preconditioned Stochastic Gradient Langevin Dynamics for Deep Neural Networks uses a diagonal preconditioner, which cannot undo the rotational coupling between columns of the factors. Learning High-dimensional Gaussians from Censored Data motivates the censored-likelihood setting but has no low-rank structure.

Research Program

The theory has three steps, in order of difficulty. First, prove the per-block conditioning bound for fully observed data with bounded-curvature, log-concave likelihoods. For partially observed rows the relevant Gram matrix is row-specific. We will bound the extra conditioning cost of using a shared global Gram matrix, which costs $O(r^2)$, instead of exact per-row Gram matrices, which cost $O(r^3)$ per row. Under uniform sampling the row Grams concentrate around a multiple of the global one, which is why we expect the gap to be modest.

Second, combine the block contraction with the biased-sampler error decomposition of the biased-MCMC expectation-maximization paper, measuring distance in the factor-scaled metric of ScaledGD rather than the Euclidean one. Steps one and two should yield an outer error bound in which only the per-entry curvature ratio $M/m$, and not $\kappa$, enters.

Third, the hard part, which is open. The blocked chain's joint mixing still depends on how strongly $L$ and $R$ are coupled, for example through rotations of the factors. We will measure this empirically and attempt a proof only near a balanced posterior mode.

The implementation is minibatch stochastic-gradient Langevin over observed entries. It maintains the Gram inverses with Sherman-Morrison updates. A step-size schedule decays $\gamma$ slowly, following SOUL, so that bias shrinks without stalling.

Baselines

The naive reference is SOUL with isotropic ULA on the same model, using the same step-size schedule, warm starts, and number of gradient evaluations. On synthetic data its stall as $\kappa$ grows is the effect we claim to remove. Beating it means reaching the same hyperparameter error with $\kappa$-independent cost, where SOUL's cost grows with $\kappa$.

The strongest point-estimation competitor is ScaledSGD trained to a MAP estimate (the posterior mode), with hyperparameters chosen by validation grid search under a matched total compute budget. On MovieLens25M, the online ScaledSGD paper reports that ScaledSGD "reached target accuracy 4 times faster than standard SGD." At $\kappa = 10^4$ it reports that SGD "stagnated and failed to converge within 200 epochs," while ScaledSGD reached machine precision. Scaled-SGD reports MSE "$10^{-8}$ in approximately 20 iterations" at $\kappa=100$. For Jester NMAE there is no reported number on Lacuna (the paper reports only that Scaled-SGD beat its baselines), so we will rerun it. Beating this baseline does not mean beating its root-mean-square error, since it may match us there. It means a higher test log-predictive density, better calibrated predictive intervals, and correct rank recovery without a grid search.

The diagonal-preconditioned Langevin baseline follows Preconditioned Stochastic Gradient Langevin Dynamics for Deep Neural Networks. The static two-stage preconditioner baseline follows A Non-asymptotic Analysis for Learning and Applying a Preconditioner in MCMC, with its warm-up cost charged to its budget. MALA-SAEM gets an equal tuning budget over step sizes.

Two ablations isolate the key ingredient. One replaces the learned prior-precision damping with fixed damping $\lambda$, mirroring ScaledGD($\lambda$). The other replaces it with the undamped Gram inverse, which should become unstable when the search rank exceeds the true rank. On Wisconsin breast cancer logistic regression, SOUL reports results "within approximately 3% of the true MLE." This serves only as a sanity check that our reimplementation of SOUL is faithful.

Why not just…?

Why not just fit MAP with ScaledSGD and tune hyperparameters on a validation split? This is the real threat for point prediction, and we expect it to match us on held-out error when data are plentiful. Our advantage should appear where grid search is weak. One such place is per-dimension shrinkage over many latent dimensions, a grid that grows exponentially with $r$. Others are sparse rows, censored entries, and anywhere calibrated uncertainty matters. If the MAP baseline matches us on log-predictive density and rank recovery at matched compute, the proposal reduces to a rank-selection heuristic, and we will report it that way.

Why not just use Gibbs sampling, which is exact for Bayesian matrix factorization? Gibbs needs conjugate conditionals, which the Tobit, Poisson, and logistic likelihoods targeted here lack. It also needs a full $r^3$ solve per row on every sweep with all of that row's entries. In the Gaussian case our sampler should behave like a stochastic-gradient approximation to Gibbs, and Gibbs will be included as the reference there to confirm that the two agree.

Why not just use an Adam-style diagonal preconditioner? The stretching comes from correlations between factor columns that change with the factor's rotation. A diagonal rescaling cannot remove these correlations, as the ScaledGD analysis argues. We test this directly by measuring effective sample size per gradient evaluation against $\kappa$ when the true factors are rotated away from the coordinate axes.

Why not just learn a covariance preconditioner once? The target posterior moves as the hyperparameters change, and the useful scaling depends on the current $R$. The static baseline under a matched budget will show whether its preconditioner goes stale, which should appear as degradation late in the outer loop.

Proposed Experiments

The synthetic study fixes a true rank of 5 and sweeps $\kappa$ from 1 to $10^4$, matching the range of the online ScaledSGD experiments. It uses search ranks of 5, 10, and 20, Gaussian and Tobit-censored observations (values clipped at fixed bounds), and 5% to 30% observed entries. The decisive check has two curves. The first is effective sample size per gradient evaluation of the inner chain in the weakest singular direction, as a function of $\kappa$; we predict it is flat for our method and falls about as $1/\kappa$ for isotropic ULA. The second is the number of outer iterations until the precision $\alpha_j$ of the weakest true component stabilizes while the spurious components' precisions diverge. We also report the bias of the outer estimate against a long, small-step reference chain, to confirm that preconditioning does not trade speed for unacceptable discretization bias.

The real-data study uses two datasets. On Jester the ratings are bounded, so we model the bounds as censoring. On MovieLens25M we use a Poisson or ordinal likelihood. Metrics are held-out root-mean-square error and NMAE, test log-predictive density, coverage of 90% predictive intervals, recovered rank, and wall-clock time at matched gradient evaluations.

The proposal is falsified if either of two things happens. The inner effective sample size of the Gram-preconditioned sampler degrades with $\kappa$ as fast as vanilla ULA's, which would mean the coupling between $L$ and $R$ dominates. Or tuned MAP with ScaledSGD matches it on log-predictive density and rank recovery at equal compute.