Motivated by the problem of fast processing of attention matrices, we study fast algorithms for computing matrix-vector products for asymmetric Gaussian Kernel matrices K R^n n. K's columns are indexed by a set of n keys k₁, k₂, kₙ Rᵈ, rows by a set of n queries q₁, q₂, , qₙ Rᵈ, and its i, j entry is K₈₉ = e^-\|qᵢ-kⱼ\|₂²/2σ² for some bandwidth parameter σ>0. Given a vector x Rⁿ and error parameter ε>0, our task is to output a y Rⁿ such that \|Kx-y\|₂ ε\|x\|₂ in time subquadratic in n and linear in d. Our algorithms rely on the following modelling assumption about the matrices K: the sum of the entries of K scales linearly in n, as opposed to worst case quadratic growth. We validate this assumption experimentally, for Gaussian kernel matrices encountered in various settings such as fast attention computation in LLMs. We obtain the first subquadratic-time algorithm that works under this assumption, for unrestricted vectors.
Indyk et al. (Thu,) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: