potentialpaper

Fast and Stable Gradient Approximation for Quadratic Forms of Hermitian Matrix Functions

Navjot Singh, Kipton Barros, Sherry Li

NeurIPS 2026

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Objectives involving quadratic forms u∗f(A(θ))uu^*f(A(\theta))u for Hermitian AA arise widely in scientific computing and machine learning. Lanczos efficiently approximates these quantities, but differentiating through its recurrence can introduce numerical instability and costly reorthogonalization. Building on existing low-rank Krylov approximations of Fr'echet derivatives, we develop a matrix-free gradient implementation that reuses the forward Lanczos quantities without differentiating through the recurrence. We analyze its discrepancy from the exact gradient of the finite Lanczos approximation, deriving an exact residual-coupled error identity and a bound involving the best degree-(m−1)(m-1) uniform polynomial approximation error of f′f', multiplied by a basis-sensitivity factor. The discrepancy vanishes when the Krylov subspace is invariant. Experiments demonstrate accurate gradients and runtime improvements over differentiated-Lanczos and modified-Arnoldi baselines. It remains numerically stable without reorthogonalization in all tested settings, including cases where adjoint-based Lanczos differentiation becomes unstable.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

edit · history

DateVersionSubmitted toPDFEvidence
5 May 2026NeurIPS 2026submittedNeurIPS 2026Accept (poster)reviews ↓[1]—[1]
Missing a version?

NeurIPS 2026

Accept (poster) · 3 reviews · OpenReview

Updated 25 Nov 2026, 03:42 UTC.

Program Chairs · DecisionOpenReview ↗
Decision
Accept (poster)
Read decision
Meta-review

The paper introduces a forward-only method for approximating gradients of bilinear or quadratic forms u⊤f(A(θ))vu^\top f(A(\theta))v, reusing a Lanczos decomposition rather than differentiating through the recurrence (this is technical, and looks narrow, but I believe this is relevant). It proves that the omitted basis-variation error is tied to the Lanczos residual and reports improved runtime and empirical stability on log-determinant, graph-sensitivity, and Hamiltonian-learning tasks.

On the positive side, this is a common primitive in machine learning. Moreover, the method is conceptually simple, matrix-free, and computationally efficient, with minimal overhead beyond the forward Lanczos pass. Its residual-based error decomposition is theoretically useful, and the experiments show substantial accuracy, stability, and speed advantages over existing approaches.

On the negative side, the paper does not clearly delimit the machine-learning problems or regimes where the approximation is preferable.

I am leaning towards acceptance, but I think that a positive response to the questions raised by the reviewers would finally convince all of them to accept and lead to a final paper with more impact (in particular related to relevance to ML, or "in which regimes is the proposed method preferable to differentiating through Lanczos or using Fréchet/adjoint-based methods in terms of accuracy, stability, memory, and runtime?").

Final justification

I recommend acceptance. The paper proposes a simple and practically relevant matrix-free gradient approximation that reuses the forward Lanczos computation and avoids differentiating through a long recurrence, a contribution reviewers viewed as useful for large-scale problems. The rebuttal strengthens the theory with an exact residual-boundary error identity, polynomial-approximation bounds, and an explicit factorially decaying bound for the matrix exponential; reviewers who raised these concerns remained positive after the response. The added experiments (that should make it to the final version) also clearly identify the favorable regime: at moderate Lanczos depth the method matches reference gradient accuracy while full-reorthogonalized AD is slower, and at larger depth full reorthogonalization runs out of memory while the proposed method remains accurate. Finally, the authors clarified the target applications and operating regime, addressing the main positioning concern raised during review.

-- All papers were submitted to a hallucinated reference checker, which highlighted at least two severe violations (see verbatim below). Inventing authors is a serious concern that reflects poorly on the scholarship of authors, but given the paper's contributions and positive opinions of the reviewers, I am still recommending acceptance. Please correct these mistakes.

List of Problematic References with Reasoning @article{Davies2021Computing, author = {Davies, Alexander and Higham, Nicholas J.}, title = {Computing f(a)b for matrix functions f}, journal = {SIAM Journal on Matrix Analysis and Applications}, volume = {42}, number = {2}, pages = {1084--1105}, year = {2021}, doi = {10.1137/20M1363868} } The paper titled 'Computing f(A)b for matrix functions f' was authored by Philip I. Davies (not Alexander Davies) and Nicholas J. Higham. It was published in 2005 in the edited volume 'QCD and Numerical Analysis III' (Lecture Notes in Computational Science and Engineering, Vol. 47, Springer, pp. 15–24), not in the 'SIAM Journal on Matrix Analysis and Applications' in 2021.

@article{haah2024practical, author = {Jeongwan Haah et al.}, title = {Practical hamiltonian learning with unitary dynamics and gibbs states}, journal = {Nature Communications}, year = {2024} } The paper 'Practical Hamiltonian learning with unitary dynamics and Gibbs states' was published in Nature Communications in 2024, but its actual authors are Andi Gu, Lukasz Cincio, and Patrick J. Coles, not Jeongwan Haah.

@article{huang2023robust, author = {Hsin-Yuan Huang et al.}, title = {Robust and efficient hamiltonian learning}, journal = {Quantum}, volume = {7}, pages = {1045}, year = {2023} } The paper titled 'Robust and Efficient Hamiltonian Learning' published in Quantum (Volume 7, page 1045, 2023) was authored by Wenjun Yu, Jinzhao Sun, Zeyao Han, and Xiao Yuan, not Hsin-Yuan Huang.

Area Chair rNkM · Meta-reviewOpenReview ↗
Read meta-review
Meta-review

The paper introduces a forward-only method for approximating gradients of bilinear or quadratic forms u⊤f(A(θ))vu^\top f(A(\theta))v, reusing a Lanczos decomposition rather than differentiating through the recurrence (this is technical, and looks narrow, but I believe this is relevant). It proves that the omitted basis-variation error is tied to the Lanczos residual and reports improved runtime and empirical stability on log-determinant, graph-sensitivity, and Hamiltonian-learning tasks.

On the positive side, this is a common primitive in machine learning. Moreover, the method is conceptually simple, matrix-free, and computationally efficient, with minimal overhead beyond the forward Lanczos pass. Its residual-based error decomposition is theoretically useful, and the experiments show substantial accuracy, stability, and speed advantages over existing approaches.

On the negative side, the paper does not clearly delimit the machine-learning problems or regimes where the approximation is preferable.

I am leaning towards acceptance, but I think that a positive response to the questions raised by the reviewers would finally convince all of them to accept and lead to a final paper with more impact (in particular related to relevance to ML, or "in which regimes is the proposed method preferable to differentiating through Lanczos or using Fréchet/adjoint-based methods in terms of accuracy, stability, memory, and runtime?").

Final justification

I recommend acceptance. The paper proposes a simple and practically relevant matrix-free gradient approximation that reuses the forward Lanczos computation and avoids differentiating through a long recurrence, a contribution reviewers viewed as useful for large-scale problems. The rebuttal strengthens the theory with an exact residual-boundary error identity, polynomial-approximation bounds, and an explicit factorially decaying bound for the matrix exponential; reviewers who raised these concerns remained positive after the response. The added experiments (that should make it to the final version) also clearly identify the favorable regime: at moderate Lanczos depth the method matches reference gradient accuracy while full-reorthogonalized AD is slower, and at larger depth full reorthogonalization runs out of memory while the proposed method remains accurate. Finally, the authors clarified the target applications and operating regime, addressing the main positioning concern raised during review.

-- All papers were submitted to a hallucinated reference checker, which highlighted at least two severe violations (see verbatim below). Inventing authors is a serious concern that reflects poorly on the scholarship of authors, but given the paper's contributions and positive opinions of the reviewers, I am still recommending acceptance. Please correct these mistakes.

List of Problematic References with Reasoning @article{Davies2021Computing, author = {Davies, Alexander and Higham, Nicholas J.}, title = {Computing f(a)b for matrix functions f}, journal = {SIAM Journal on Matrix Analysis and Applications}, volume = {42}, number = {2}, pages = {1084--1105}, year = {2021}, doi = {10.1137/20M1363868} } The paper titled 'Computing f(A)b for matrix functions f' was authored by Philip I. Davies (not Alexander Davies) and Nicholas J. Higham. It was published in 2005 in the edited volume 'QCD and Numerical Analysis III' (Lecture Notes in Computational Science and Engineering, Vol. 47, Springer, pp. 15–24), not in the 'SIAM Journal on Matrix Analysis and Applications' in 2021.

@article{haah2024practical, author = {Jeongwan Haah et al.}, title = {Practical hamiltonian learning with unitary dynamics and gibbs states}, journal = {Nature Communications}, year = {2024} } The paper 'Practical Hamiltonian learning with unitary dynamics and Gibbs states' was published in Nature Communications in 2024, but its actual authors are Andi Gu, Lukasz Cincio, and Patrick J. Coles, not Jeongwan Haah.

@article{huang2023robust, author = {Hsin-Yuan Huang et al.}, title = {Robust and efficient hamiltonian learning}, journal = {Quantum}, volume = {7}, pages = {1045}, year = {2023} } The paper titled 'Robust and Efficient Hamiltonian Learning' published in Quantum (Volume 7, page 1045, 2023) was authored by Wenjun Yu, Jinzhao Sun, Zeyao Han, and Xiao Yuan, not Hsin-Yuan Huang.

1 comment
Authors · CommentOpenReview ↗

We thank the area chair for their positive review and constructive comments. We have addressed the reviewers concerns and added a new theorem to clarify the error term above^.

We also found via ChatGPT that a similar approximation is used in Computing low-rank approximations of the Fréchet derivative of a matrix function using Krylov subspace methods by Kandolf et. al., for other applications, and have a proof of convergence for this approximation converging to exact derivatives (not to Lanczos derivatives) for certain cases. However, their proof is much more involved as they need convergence to exact derivative of the objective and the applications used are more specific.

We also provide a case study for an end-to-end Matern kernel hyperparmater case study in reply to Reviewer yqqx where we incorporate a GPU implementation of our algorithm leveraging PyTorch and compare with AD. Naive AD fails miserably, and so for a fair baseline, we inject the frechet derivatives of the tridiagonal matrix (like done in Kramer et. al.) into the AD. This case study shows how reorthgonalization can be expensive and lead to memory bottlenecks and slow speed on modern hardware (run on our local Mac leveraging Metal for GPU). It also shows that Chebyshev needs much more polynomial depth to achieve similar accuracy as Lanczos (established in previous literature), and our approximation remains stable through the optimization procedure non reorth AD loses stability.

During the waiting process, we also developed a high performance library leveraging PETSc and SLEPc in C++ to get rapid fast derivatives through Lanczos when closed form expressions of derivatives are given (we currently do not support AD in the C++ interface) and have a Python wrapper around it. We plan to develop this library for future work and this is where we show margin of speedups against PyTorch (unfair comparison as we use the formulas and AD needs a gradient tape which has overhead)

The extreme large scale operators on GPUs or closed form derivatives available for efficient VTdAVV^T dAV computations are the regime where our approximation beats the available algorithms by big margins. More research is needed for incorporating selective orthogonalization for stabilizing forward Lanczos on GPUs which could benefit our algorithm even more, as differentiating through these procedures is slow and unstable.

We will also address some of the minor concerns about title and confusion of bilinear and quadratic forms and clarify exactly where the approximation will be beneficial

Reviewer JZQdOpenReview ↗
Rating
4/6
Confidence
3/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
theory
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper proposes a simple and practical method for approximating the gradient of quadratic form of Hermitian matrix functions via Lanczos. We assume that the parametrized matrix A(θ)A(\theta) could be accessed via matrix-vector product, making Lanczos an attractive method, by Lanczos, we know that AV=VT+βmvmem+1⊤AV=VT+\beta_m v_m e_{m+1}^\top where VV is an orthonormal basis for the Krylov subspace of A,uA, u, ignoring the last term, we could approximate u⊤f(A)uu^\top f(A) u via ∥u∥22e1⊤f(T)e1\|u\|_2^2 e_1^\top f(T) e_1 for tridiagonal TT. Set ϕ(T)=∥u∥22e1⊤f(T)e1\phi(T)=\|u\|_2^2 e_1^\top f(T) e_1, then dϕ=tr(G⊤dT)d\phi={\rm tr}(G^\top dT) where GG is a matrix that depends on the first row of QQ and the divided-difference matrix common in matrix differentiation. Since T=V⊤AVT=V^\top AV, dT=V⊤dAV+dV⊤AV+V⊤AdVdT=V^\top dA V+dV^\top AV+V^\top AdV, the paper proposes to drop the non-dAdA terms, this gives a way to approximate dϕd\phi through dAdA terms only, and yields an efficient, practical algorithm that first runs mm iterations of Lanczos to generate V,TV, T, then form the GG matrix, and let W=VGW=VG, the derivative of ϕ\phi wrt θ\theta can be written as a bilinear form of wj,vjw_j, v_j wrt the derivative of A(θ)A(\theta) of θ\theta. Experiments for several functions, including u⊤log⁡(K(θ))uu^\top \log(K(\theta))u, network sensitivity and quantum Hamiltonian show the improvements over existing results.

Strengths and weaknesses

Strengths:

  • The proposed method is simple and practical, through extensive experiments, the efficiency improvements are quite significant. This is important when one wants to deploy this algorithm at scale.

  • The studied problem is important, approximating the gradient of bilinear or quadratic form of Hermitian matrix functions is a quite common use case, especially when one tries to use first-order methods to optimize this class of functions.

Weaknesses:

  • One major weakness is the numerical stability is verified only through experiments, there are no formal statements proving the numerical stability of the proposed algorithm. This also holds for most of the results in this paper, the only theoretical piece Theorem 2, as Theorem 1 follows from a straightforward calculation. Though Theorem 2 spells out the error term explicitly, it deserves more discussions on the magnitude of the error for various functions.
Questions

Typos:

  • Line 262: "We use their We run these..." should be "We run these...".

Questions:

  • Can authors give some estimates on the error term of Theorem 2 for specific pairs of (A,u)(A, u)?
Limitations

Yes.

Final justification

Authors' response gives a concrete example that clarifies my question, I'll keep my initial positive rating.

Formatting concerns

N/A.

2 comments
Authors · CommentOpenReview ↗

We thank the reviewer for their positive review and catching the typo. We have addressed it. For some intuition on scalar function, hermitian matrix, and uu

Consider the pair

f(x)=exp⁡(τx),σ(A)⊆I=[a,b],f(x)=\exp(\tau x), \qquad \sigma(A)\subseteq\mathcal I=[a,b],

and define the spectral midpoint and half-width

c=a+b2,d=b−a2,M=max⁡s∈Iτs.c=\frac{a+b}{2}, \qquad d=\frac{b-a}{2}, \qquad M=\max_{s\in\mathcal I}\tau s .

Since Em−1(f′;I)\mathcal E_{m-1}(f';\mathcal I) is a best-approximation error, any degree-(m−1)(m-1) polynomial bounds it from above. Taking the Taylor polynomial of

f′(x)=τexp⁡(τx)f'(x)=\tau\exp(\tau x)

about cc, and using (f′)(m)(x)=τm+1exp⁡(τx)(f')^{(m)}(x)=\tau^{m+1}\exp(\tau x) together with ∣x−c∣≤d|x-c|\leq d on I\mathcal I, gives

Em−1(f′;I)≤∣τ∣ eM (∣τ∣d)mm!.\mathcal E_{m-1}(f';\mathcal I) \leq |\tau|\, e^{M}\, \frac{(|\tau|d)^m}{m!}.

Substituting this into Theorem 2 yields the explicit estimate

∣gexact−gapprox∣≤2∥u∥22 ∥ξm∥2 ∣τ∣ eM (∣τ∣d)mm!,\left|g_{\mathrm{exact}}-g_{\mathrm{approx}}\right| \leq 2\|u\|_2^2\, \|\xi_m\|_2\, |\tau|\, e^{M}\, \frac{(|\tau|d)^m}{m!},

where

ξm=(∂Vm∂θ)⊤rm.\xi_m= \left( \frac{\partial V_m}{\partial\theta} \right)^\top r_m .

Thus, for the matrix exponential, the function-dependent factor decreases factorially with the Lanczos depth. The effective difficulty is governed by the product ∣τ∣d|\tau|d, i.e. the evolution scale multiplied by the spectral half-width. Indeed, the ratio between the bounds at two successive depths is

∣τ∣dm+1,\frac{|\tau|d}{m+1},

so the bound decreases rapidly once m+1>∣τ∣dm+1>|\tau|d. Note that only the half-width enters the polynomial factor: the location of the spectrum enters solely through the scalar prefactor eMe^{M}, which equals 11 in the common case τ<0\tau<0, A⪰0A\succeq 0.

For example, take f(x)=exf(x)=e^x, a unit-norm vector uu, and a matrix whose spectrum has been scaled to

σ(A)⊆[−1,1],\sigma(A)\subseteq[-1,1],

so that d=1d=1 and eM=ee^{M}=e. If the residual-coupled sensitivity is bounded by ∥ξm∥2≤C\|\xi_m\|_2\leq C uniformly over the depths considered, then

∣gexact−gapprox∣≤2eCm!.\left|g_{\mathrm{exact}}-g_{\mathrm{approx}}\right| \leq \frac{2eC}{m!} .

The corresponding upper bounds are approximately

1.5×10−6Cat m=10,1.5\times10^{-6}C \quad\text{at }m=10,

and

2.6×10−13Cat m=16.2.6\times10^{-13}C \quad\text{at }m=16 .

These numerical values isolate the function- and spectrum-dependent part of the estimate; the constant CC represents the residual-coupled Lanczos sensitivity discussed in our response to the previous question. In the regular finite-step regime, where the Lanczos recurrence remains separated from an intermediate near-breakdown, this sensitivity is bounded. If the Krylov subspace becomes invariant, then rm=0r_m=0, so ξm=0\xi_m=0 and the discrepancy vanishes exactly.

This example also indicates when convergence may be slower: a wider spectral interval or larger ∣τ∣|\tau| increases ∣τ∣d|\tau|d, and therefore requires a larger Krylov depth before the factorial decay dominates (which is the regime we would prefer for our approximation as Lanczos loses orthogonality and AD becomes unstable).

The complete derivation is included in the revised appendix. For other functions, matrices, similar results can be derived.

Reviewer JZQd · CommentOpenReview ↗

I thank the authors for providing the example, and I don't have more questions. Since my initial rating is positive, I'll keep it as is.

Reviewer yqqxOpenReview ↗
Rating
3/6
Confidence
3/5
Quality
3/4
Clarity
2/4
Significance
2/4
Originality
3/4
Contribution type
theory
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper proposes a forward-only method for approximating gradients of scalar bilinear forms involving functions of large Hermitian matrices. The method uses Lanczos to project the large matrix problem onto a small tridiagonal matrix, differentiates the projected objective, and then lifts the sensitivity back to the original parameters using vector-Jacobian products. The authors provide an error analysis related to the Lanczos residual and evaluate the approach on matrix-logarithm derivatives, network sensitivity benchmarks, and quantum Hamiltonian learning.

Strengths and weaknesses

Strengths

The paper addresses a relevant computational problem: differentiating scalar objectives involving functions of large Hermitian matrices. The proposed method is conceptually clean, using Lanczos to reduce the large problem to a small tridiagonal projected problem and then computing gradients through vector-Jacobian products. This avoids backpropagating through the Lanczos recurrence, which can be costly and numerically delicate. The work also provides an error decomposition related to the Lanczos residual. The experiments on matrix-logarithm derivatives, network sensitivity benchmarks, and quantum Hamiltonian learning suggest that the method can be efficient and stable in several settings.

Weaknesses

The paper’s positioning could be clearer to a machine learning audience. While the theoretical and algorithmic contribution is interesting, the paper does not fully articulate which classes of learning problems are the primary targets of the proposed approximation. The error analysis is also informative but somewhat limited, since the residual-related term does not provide a complete a priori bound.

Questions
  1. Could the authors clarify which learning problems are the main targets of the method?

  2. Could the authors provide more intuition or conditions under which the residual-related error term in Theorem 2 is small?

  3. In which regimes is the proposed method preferable to differentiating through Lanczos or using Fréchet/adjoint-based methods in terms of accuracy, stability, memory, and runtime?

Limitations

Yes

Final justification

The authors have addressed most of my concerns. However, incorporating all of these changes represents substantial additional work that we as reviewers won't have the opportunity to re-review before camera-ready. I will defer to the AC to judge whether a paper in this situation is appropriate to accept as is, or whether the authors should be asked to incorporate everything and resubmit to a future venue.

Formatting concerns

No concerns

2 comments
Authors · CommentOpenReview ↗

Clarification of which learning problems are the main targets of the method The main target is a more specific class of learning and inverse problems: objectives that contain one or more scalar, vector-specific matrix-function terms of the form

u⊤f(A(θ))u,u^\top f(A(\theta))u,

where A(θ)A(\theta) is a large Hermitian operator available only through differentiable matrix-vector products, and Lanczos is already needed to evaluate the forward objective. During training, one then needs gradients of this Lanczos-computed scalar with respect to the parameters of A(θ)A(\theta). For a general matrix function ff, this derivative involves a Fréchet derivative and usually cannot be reduced to one ordinary linear solve.

The principal target problems are therefore:

  1. PDE Hermitian Operator learning. PDE based operator are usual symmetric and the time stepping involves a fitting objective which boils down to the following

    u∗exp⁡(−itH(θ))v,u^* \exp(-itH(\theta))v,

    where HH is Hermitian, the exponential action is naturally evaluated by Lanczos, and parameter learning requires differentiating this quantity repeatedly. Our Hamiltonian-learning experiment directly instantiates this setting.

  2. Graph and diffusion-operator learning. Learning edge weights or other graph parameters from node-specific diffusion, heat-kernel, communicability, or centrality objectives leads to terms such as

    u⊤exp⁡(−tL(θ))voru⊤exp⁡(A(θ))v.u^\top \exp(-tL(\theta))v \quad\text{or}\quad u^\top \exp(A(\theta))v.

    These are vector-specific rather than trace objectives. Our network-sensitivity experiments instantiate this class.

  3. Fractional covariance, precision operators. For example, a fractional Matérn model may use

    Kθ=Aθ−α.K_\theta=A_\theta^{-\alpha}.

    Its data-fit term contains y⊤Aθαyy^\top A_\theta^\alpha y. When the trainable exponent α\alpha is noninteger, the forward term is a genuine fractional matrix function and cannot be evaluated by a single conjugate-gradient solve. Lanczos is therefore required in the forward pass, and its parameter gradient is required during hyperparameter learning. The new end-to-end Matérn experiment is intended to isolate precisely this regime.

These examples share the important property that the matrix function acts on particular vectors or states. This is where the Fréchet derivative cannot generally be replaced by simply applying f′f' to the matrix.

Pure trace objectives, including ordinary log-determinants, are a related but less distinctive use case. Our method applies to them after stochastic trace estimation reduces the trace to quadratic forms. However, for a pure trace, specialized stochastic estimators may avoid differentiating the finite Lanczos approximation altogether. We therefore view the log-determinant experiment primarily as a standard large-scale stability benchmark, rather than the setting in which our method is uniquely necessary.

We will revise the introduction and limitations section to state this scope explicitly.

more intuition or conditions under which the residual-related error term in Theorem 2 is small As mentioned in the above comment (about new theorem), we have added more mathematical details on how to bound the residual term. To give additional intuition, the bound is small in the regular regime where two conditions hold. First, Lanczos has been run for enough steps that f′f' is accurately approximated by a degree-(m−1)(m-1) polynomial over the relevant spectral interval. This makes the function-dependent factor in the bound small. Second, the Lanczos recurrence remains away from an intermediate near-breakdown, so the finite-step basis varies smoothly with the parameters and its sensitivity remains bounded. Under this condition, a small final Lanczos residual directly suppresses the remaining residual-coupled term.

In practice, convergence of the forward Lanczos approximation is a useful indicator that the Krylov depth is sufficient, although the theorem specifically depends on approximability of f′f', which can be more demanding than approximability of ff. The guarantee can become weak in two distinct regimes. Poor spectral conditioning, for example when the spectrum approaches a singularity of f′f', can make the polynomial approximation converge slowly. Separately, an intermediate near-breakdown can amplify the sensitivity of the normalized Lanczos basis.

The latter difficulty is not unique to our approximation: automatic differentiation and adjoint differentiation pass through the same Lanczos normalizations and can also become numerically unstable. In finite precision, loss of orthogonality is an additional issue and can be mitigated using full, partial, or selective reorthogonalization. Note that our method is much more amenable to selective orthogonalization as we do not need to differentiate through sophisticated procedures.

We will address this in the paper as well.

Authors · CommentOpenReview ↗

Regimes where proposed method preferable to differentiating through Lanczos or using Fréchet/adjoint-based methods in terms of accuracy, stability, memory, and runtime

We agree that this is the main clarification needed in the paper and therefore we spent the majority of time addressing this in the past week (sorry for the delay) with the following experiment. (Please see the comment above for spectral denoising case, but we compare only with Chebyshev in our framework as closed form derivatives are available, and PyTorch AD can be much slower)

Target Regime and Setup

We target large-scale matrix-function learning where the operator is available only through matvecs, and where storing or differentiating through a long Lanczos run is memory-prohibitive or communication-bound (e.g. CPU↔GPU transfers).

The testbed is Graph/SPDE Matérn Gaussian-process models,

Kθ=Aθ−αAθ=massI+scaleB,K_\theta = A_\theta^{-\alpha} \qquad A_\theta = \mathrm{mass} I + \mathrm{scale} B ,

for which learning requires gradients of

12∑iyi⊤Aθαyi−12αlog⁡det⁡(Aθ).\tfrac12 \sum_i y_i^\top A_\theta^{\alpha} y_i - \tfrac12 \alpha \log\det (A_\theta).

Controls. All methods share the same data, initialization, optimizer, and matrix-free GPU matvecs. The size of matrix n=32768n=32768. The log⁡det⁡\log\det term and its gradient are computed exactly for every method, so the comparison isolates the difficult matrix-function quadratic term.

Removing the eigensolver as a confound. For the AD baselines we differentiate a Fréchet derivative of the small tridiagonal TmT_m rather than backpropagating through the PyTorch eigensolver. Raw eigensolver AD produces NaNs much earlier; by removing it we ensure the failures reported below come from differentiating the finite-precision Lanczos recurrence itself, not from an eigendecomposition artifact.


1. Small Depth — All Methods Stable

method mean sec/iter max rel grad err max data rel err final scale final alpha
full reorth AD 1.42 2.72e-6 4.06e-6 5.52883 1.34008
no-reorth AD 0.852 5.10e-6 5.21e-6 5.52884 1.34008
projected no-reorth (ours) 0.474 3.75e-6 5.73e-6 5.52884 1.34008
Chebyshev, deg. 128 0.349 8.53e-4 1.99e-3 5.52841 1.34007

No-reorthogonalization AD is entirely reliable here. This is explicitly not the regime our method is meant to dominate; we report it to establish that the projected rule loses nothing when AD is stable.


2. Moderate Depth (m=384m=384) — AD Begins to Drift

method sec rel grad err rel data err
full reorth AD 9.07 4.29e-8 2.90e-7
no-reorth AD 2.12 1.84e-4 2.86e-7
projected no-reorth (ours) 1.15 5.80e-8 2.86e-7
Chebyshev, deg. 384 0.899 2.26e-5 1.79e-4

Full reorthogonalization remains accurate but is now ~8× slower than the projected rule. The key signature appears: the no-reorth forward value is still accurate (2.86e-7) while its gradient has degraded by four orders of magnitude. The projected gradient stays at reference accuracy.


3. Large Depth (m=768m=768) — Full Reorthogonalization OOMs

Full-reorthogonalized AD fails on MPS before completing a single evaluation with one sample:

RuntimeError: MPS backend out of memory
MPS allocated: 30.13 GiB
max allowed:   30.19 GiB
method sec rel grad err rel data err
full reorth AD OOM OOM OOM
no-reorth AD 4.63 2.88e-2 2.89e-7
projected no-reorth (ours) 2.42 5.08e-8 2.89e-7
Chebyshev, deg. 768 1.79 1.47e-5 1.88e-4

This is the intended operating regime, where full reorth becomes OOM and our method does not become unstable due to loss of orthogonality


4. End-to-End Fit at m=1536m=1536

method mean sec/iter max rel grad err final scale final alpha
no-reorth AD 9.15 2.72e+5 4.63522 1.34011
projected no-reorth (ours) 5.20 1.82e-7 5.52880 1.34008
Chebyshev, deg. 4096 9.89 7.86e-5 5.52881 1.34007

*Full reorthogonalization is infeasible at this depth. No-reorth AD becoms unstable and drives the optimizer down a qualitatively wrong parameter path (final scale 4.635 vs. the 5.5288 recovered by every accurate method)


When the Proposed Method Is Preferable

The method is the right choice when all of the following hold:

  1. mm must be large for forward accuracy.
  2. Full reorthogonalization is too memory-intensive on GPU (see the m=768m=768 OOM).
  3. No-reorthogonalized forward values remain useful, but AD through the recurrence is numerically unreliable due to loss in orthogonality (usuallly happens when mm is large).
  4. GPU↔CPU transfer or storing the full differentiated Lanczos program would dominate runtime/memory.

We will add this experiment in the paper. Please suggest if in the main text or appendix and address all of the above explicitly.

Reviewer LhHuOpenReview ↗
Rating
5/6
Confidence
3/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
theory
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper studies gradient computation for objectives involving bilinear or quadratic forms of Hermitian matrix functions, such as u⊤f(A(θ))vu^\top f(A(\theta))v.

Main contributions:

  • Proposes a forward-only gradient approximation that reuses the Lanczos pass instead of backpropagating through the Lanczos recurrence.
  • Derives the gradient by differentiating the small projected tridiagonal problem and lifting the sensitivity back through matrix-vector-product VJPs.
  • Proves that the error from ignoring Lanczos basis-variation terms is controlled by the final Lanczos residual coefficient βm\beta_m.
  • Shows empirically that the method is more stable than adjoint/backpropagation-based Lanczos gradients without requiring full reorthogonalization.
  • Demonstrates speed and accuracy gains on log-determinant, graph-sensitivity, and Hamiltonian-learning experiments.
Strengths and weaknesses

Strengths.

  • The paper addresses an important matrix-free gradient computation problem for objectives such as u⊤f(A(θ))uu^\top f(A(\theta))u.

  • The proposed method is simple and efficient: it avoids backpropagating through Lanczos and only differentiates the small projected tridiagonal problem.

  • The residual-based analysis is useful, showing that the ignored basis-variation term is controlled by βm\beta_m.

Weaknesses.

  • The paper is framed around bilinear forms u⊤f(A(θ))vu^\top f(A(\theta))v, but the main derivation is for quadratic forms, with bilinear forms handled indirectly.

  • The paper provides a useful residual-based approximation-error result, but the stronger numerical-stability claim is mainly empirical. A more formal finite-precision stability analysis, or a clearer characterization of failure cases, would strengthen the paper.

Questions
  • The error from ignoring basis variation is proportional to βm\beta_m, but it also involves unobserved basis-variation terms. Can the authors provide a practical a posteriori gradient-error estimate, or clarify when a small Lanczos residual reliably implies an accurate gradient?

  • How should practitioners decide between the proposed forward-only gradient, adjoint/backprop-through-Lanczos, and block-Arnoldi Fréchet-derivative methods? Are there regimes of ff, spectra of AA, or accuracy requirements where the proposed approximation is expected to be less reliable than these alternatives?

Limitations

Yes

Final justification

N/A

Formatting concerns

No

1 comment
Authors · CommentOpenReview ↗

We thank the reviewer for their positive feedback and suggestions/insight to make the paper stronger. We agree with the reviewer and will change the title from bilinear to quadratic form and make the relevant changes in the main text to reflect that our algorithm tackles quadratic forms and turns bilinear and other scalar objectives into quadratic forms so that our theory is valid.

We have addressed the other concerns as below:

"The error from ignoring basis variation is proportional to , but it also involves unobserved basis-variation terms. Can the authors provide a practical a posteriori gradient-error estimate, or clarify when a small Lanczos residual reliably implies an accurate gradient?"

We agree that the previous bound was a bit ambiguous, and we have updated the theorem with new stricter bounds. It basically suggests that as long as the residual and variation of basis is bounded, our gradient estimate converges as the best polynomial approximation of the derivative of the scalar function over the ritz value spectrum. if needed we can provide more plots in the appendix to test the bound out

"How should practitioners decide between the proposed forward-only gradient, adjoint/backprop-through-Lanczos, and block-Arnoldi Fréchet-derivative methods? Are there regimes of , spectra of , or accuracy requirements where the proposed approximation is expected to be less reliable than these alternatives?"

This is a practical question and the case study mentioned below and in the official comment above answers this in detail. When a closed form or efficient way to compute VT∂A∂θVV^T \frac {\partial A}{\partial \theta} V is present (for example, Kernel methods in GPs, graph laplacians and sensitivity with respect to certain nodes), then these estimates outperform AD and chebyshev methods by big margins.

For a general case, in practice, we target the regime when the forward Lanczos depth required to reach atleast 5 digits of accuracy is more than 100, as this is when we observe loss of orthogonality and AD becomes unstable. Since reorthogonalization is much more expensive and needs explicit storage of the basis, our algorithm can just replay the Lanczos iteration block-by-block instead of storing to compute the approximation hence becomes very attractive in practice especially for GPU implementation (please see the matern GP case study below).

The case when estimates are slower to converge or less reliable is when ritz values are near the singularity of f', that is, more polynomial degree is needed to fit the oscillations. Similar argument holds for non smooth f', and directly follows from our new theorem 2.

The estimates become unreliable when the forward Lanczos becomes unreliable for which selective reorthogonalization procedures have been proposed and our algorithm can again shine as differentiation through these complicated procedures can get tricky and inefficient.

If a medium scale problem is targetted where storing Lanczos basis is not a problem or the depth of the Lanczos required for good accuracy is not much (no reorthogonalization needed), then the exact methods would be favourable.

Non-Hermitian cases and objective functions that are not scalar are not handled by our approximation and is a target for the future work.

We will clarify all of this in the updated manuscript.

Comments on the paper

2 comments
Authors · CommentOpenReview ↗

Initial response to reviewers

We would like to thank the reviewers and area chair for their well thought-out reviews. We agree with the overall comments of the reviewers and will add the following:

  • $\textbf{A theoretical proof and clarification of the error term in our gradient approximation (to be precise, βmemTGη\beta_m e_m^T G \eta in Theorem 2)}:$ We agree with the reviewers and will be adding a theorem to show that the gradient error is bounded by the best polynomial approximation of smooth scalar functions of eigenvalues of the hermitian matrix (so this nails down the convergence rate of our approximation). For a case study, we show exponential convergence for the derivatives with respect to matrix exponential in theory and practice. It is out of scope of this work to show theoretical bounds for how accurate our approximation is in finite precision (there are multiple math journal papers about accuracy of Lanczos), but this additional part provides an insight via polynomials and can be used as a stepping stone to bound the error.

  • Comparison to the existing methods and when our method should be used\textbf{Comparison to the existing methods and when our method should be used}: Our claim is that the approximation works without reorthogonalization which enables the method to be used in practice for large-scale problem where backprop and the adjoint method would fail. Reorthogonalization not only introduces overhead (can be 10-20x slowdown in time for medium scale (matrix dimension ~ 50k) problems, and would become a memory-bottleneck for large problems, leaving the existing methods intractable. To show this, we have implemented a version of our method that can use multiple passes (when required) of the Lanczos iteration and does not require storage of Lanczos basis making our method viable for large-scale applications. The current limitation is that the theoretical results are only valid for scalar objectives and the extension is left for future work. We will add experiments in the appendix where we show the reorthogonalization overhead in PyTorch.

  • Application areas in ML\textbf{Application areas in ML}: The major application areas in ML where gradients of quadratic/bilinear/fitting objectives involving matrix functions are learning with graphs and Gaussian processes (majorly sparse kernels) as mentioned in the 2024 NeurIPS paper (Gradients of Functions of Large Matrices by Krämer et al.). GraphML and SPDE kernels in GPs and other applications in Physics use Chebyshev polynomials as the baseline method for scalability purposes (for reasons mentioned above). We implement the Chebyshev polynomial method in our infrastructure that is built upon the PETSc and show that our method (which uses multiple passes for large scale problems) can be at least 2×2 \times faster for a benchmark problem in image denoising using spectral graph filters while being same or better in accuracy. The Chebyshev method beats Lanczos method when the underlying matrix is well-conditioned but can struggle when the spectrum needs adaptive quadrature for resolution or is ill-conditioned (this is well-known in the applied math and physics literature) and we confirm this in our experiments.

We believe that the above additions make the paper much stronger and thank the reviewers and area chair again for highlighting these key points in the current manuscript. We will start adding the results and reply individually to reviewers in the forthcoming days.

Authors · CommentOpenReview ↗

New Theorem and Proof for clarifying the error term in gradient approximation

We have strengthened the theoretical result and completed a full proof for inclusion in the revised manuscript.

The revised theorem compares our forward-only gradient with the exact derivative of the finite mm-step Lanczos approximation. In exact arithmetic, their discrepancy is exactly the residual-boundary term

gexact−gapprox=2em⊤G(∂Vm∂θ)⊤rm,g_{\text{exact}} - g_{\text{approx}} = 2 e_m^\top G \left( \frac{\partial V_m}{\partial \theta} \right)^\top r_m,

where rmr_m is the final Lanczos residual and GG is the sensitivity of the projected scalar objective with respect to TmT_m. We further prove

∣gexact−gapprox∣≤2∥u∥22∥(∂Vm/∂θ)⊤rm∥2Em−1(f′;I),|g_{\text{exact}} - g_{\text{approx}}| \le 2 \lVert u \rVert_2^2 \lVert (\partial V_m / \partial \theta)^\top r_m \rVert_2 \mathcal{E}_{m-1}(f'; \mathcal{I}),

where Em−1(f′;I)\mathcal{E}_{m-1}(f'; \mathcal{I}) is the best degree-(m−1)(m-1) uniform polynomial approximation error for f′f' on an interval I=[a,b]\mathcal{I} = [a,b] containing the spectrum of AA. Thus the general sufficient condition for convergence is

∥(∂Vm/∂θ)⊤rm∥2Em−1(f′;I)→0.\lVert (\partial V_m / \partial \theta)^\top r_m \rVert_2 \mathcal{E}_{m-1}(f'; \mathcal{I}) \to 0.

In particular, uniformly bounded residual-coupled basis sensitivity is sufficient.

We also add a short lemma explaining when this sensitivity is bounded. By submultiplicativity,

∥(∂Vm/∂θ)⊤rm∥2≤∥∂Vm/∂θ∥2∥rm∥2.\lVert (\partial V_m / \partial \theta)^\top r_m \rVert_2 \le \lVert \partial V_m / \partial \theta \rVert_2 \lVert r_m \rVert_2.

Because σ(A)⊆[a,b]\sigma(A) \subseteq [a,b], the final residual satisfies ∥rm∥2≤(b−a)/2\lVert r_m \rVert_2 \le (b-a)/2, and hence

∥(∂Vm/∂θ)⊤rm∥2≤b−a2∥∂Vm/∂θ∥2.\lVert (\partial V_m / \partial \theta)^\top r_m \rVert_2 \le \frac{b-a}{2} \lVert \partial V_m / \partial \theta \rVert_2.

For any prescribed finite Lanczos horizon MM, if A(θ)A(\theta) is continuously differentiable on a compact parameter set and the intermediate Lanczos coefficients remain uniformly separated from an early breakdown,

inf⁡θmin⁡1≤j<Mβj(θ)≥γ>0,\inf_{\theta} \min_{1 \le j < M} \beta_j(\theta) \ge \gamma > 0,

then the finite-step Lanczos map is continuously differentiable and

sup⁡θmax⁡1≤m≤M∥∂Vm/∂θ∥2<∞.\sup_{\theta} \max_{1 \le m \le M} \lVert \partial V_m / \partial \theta \rVert_2 < \infty.

The proof is short: the only potentially singular operation in the finite Lanczos recurrence is the normalization wj↦wj/∥wj∥2w_j \mapsto w_j / \lVert w_j \rVert_2, whose derivative has norm at most 1/βj1/\beta_j. The lower bound βj≥γ\beta_j \ge \gamma therefore keeps every required normalization uniformly away from its singularity. A breakdown at the final step is benign, since then rm=0r_m = 0 and the discrepancy vanishes exactly. Likewise, whenever the Krylov subspace is AA-invariant, rm=0r_m = 0, and the proposed gradient is exactly the derivative of the finite Lanczos approximation.

We have also derived an explicit example for f(x)=exp⁡(τx)f(x) = \exp(\tau x). In this case the function-dependent factor Em−1(f′;I)\mathcal{E}_{m-1}(f'; \mathcal{I}) admits a factorially decaying bound in mm. Finally, we clarify that the theorem is an exact-arithmetic result; finite-precision stability is studied empirically.

The complete derivation exceeds the OpenReview response-length limit, so we cannot reproduce it verbatim here. We have prepared it for inclusion in the revised appendix by reallocating space. The appendix proof contains the exact residual-boundary identity, the polynomial-annihilation argument leading to the f′f'-approximation bound, the finite-step sensitivity lemma above, and the explicit matrix-exponential example.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Missing a submission?

Loading the discussion…