Signed spectral attention
Source paper: Signed random Fourier features for fast density estimation with indefinite kernels arXiv:2608.29265 ⓘ · analyzed Sep 1, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Replace a quadratic pairwise attention or graph aggregation kernel with a compact, translation-invariant indefinite kernel approximated by signed random Fourier features. The feature map preserves the kernel's negative spectral mass through a diagonal sign matrix, so the resulting linear-time aggregation can represent similarities that ordinary positive-definite random features cannot.
Formulas
Mathematical statement
The paper starts from the Monte Carlo identity $\int f(\boldsymbol{x})g(\boldsymbol{x})d\boldsymbol{x}=\mathbb{E}[g(\boldsymbol{X})]$ and estimator $M^{-1}\sum_{m=1}^{M}g(\boldsymbol{X}_m)$, then applies it to a signed Fourier density. Let $K:\mathbb{R}^{d}\to\mathbb{R}$ be an even translation-invariant kernel, let $\widehat K(\boldsymbol{\omega})$ be its Fourier transform under the convention $K(\boldsymbol{u})=\int_{\mathbb{R}^{d}}e^{i\boldsymbol{\omega}^{\top}\boldsymbol{u}}\widehat K(\boldsymbol{\omega})d\boldsymbol{\omega}$, and assume $\int|\widehat K(\boldsymbol{\omega})|d\boldsymbol{\omega}=C<\infty$. Define $q(\boldsymbol{\omega})=|\widehat K(\boldsymbol{\omega})|/C$ and $s(\boldsymbol{\omega})=\operatorname{sign}(\widehat K(\boldsymbol{\omega}))\in\{-1,+1\}$. If $\boldsymbol{\Omega}_m\sim q$ independently, then $K(\boldsymbol{u})=C\mathbb{E}[s(\boldsymbol{\Omega})\cos(\boldsymbol{\Omega}^{\top}\boldsymbol{u})]$ for real even kernels. Using $\cos(a-b)=\cos a\cos b+\sin a\sin b$, define $z(\boldsymbol{x})=[\cos(\boldsymbol{\Omega}_1^{\top}\boldsymbol{x}),\sin(\boldsymbol{\Omega}_1^{\top}\boldsymbol{x}),\ldots,\cos(\boldsymbol{\Omega}_M^{\top}\boldsymbol{x}),\sin(\boldsymbol{\Omega}_M^{\top}\boldsymbol{x})]$. Then $K(\boldsymbol{x}-\boldsymbol{y})\approx (C/M)z(\boldsymbol{x})D z(\boldsymbol{y})^{\top}$, where $D$ is diagonal and repeats $s(\boldsymbol{\Omega}_m)$ twice. For values $V\in\mathbb{R}^{N\times r}$, all-pairs aggregation $AV$ with $A_{ij}=K(x_i-x_j)$ becomes $(C/M)Z D(Z^{\top}V)$ instead of an $N\times N$ product.
Implementation notes
(1) Integration point: implement a linear attention or graph-message-passing layer. Project each token or node to $x_i=W_xh_i$ and $y_j=W_yh_j$, optionally divide both by a learned bandwidth $\ell$; use the signed radial interaction $K(x_i-y_j)$ instead of forming softmax logits. The value tensor is $V=W_vH$. Keep a separate positive normalization, such as $n_i=\sum_j|\widehat K_M(x_i-y_j)|+\epsilon$, rather than dividing by a signed sum. (2) Pseudocode: sample $M$ frequencies $\Omega_m\sim q(\omega)=|\widehat K(\omega)|/C$ and set $s_m=\operatorname{sign}(\widehat K(\Omega_m))$; construct $Z_x=[\cos(X\Omega),\sin(X\Omega)]$ and $Z_y=[\cos(Y\Omega),\sin(Y\Omega)]$; compute $U=(C/M)Z_y^\top V$, replace it by $DU$ with $D=\operatorname{diag}(s_1,s_1,\ldots,s_M,s_M)$, and return $Z_x(DU)$. For cross-attention, use distinct query and key matrices but the same sampled frequencies. (3) What comes from the mathematics: the signed measure, the $C/M$ Monte Carlo scaling, the duplicated cosine/sine factorization, and the sign insertion are fixed by the formulas. Estimate $C$ and sample $q$ numerically for the chosen kernel; for Kuttner-Golubov kernels $K(u)=(1-\|u\|^\alpha)^\beta\mathbf{1}_{\{\|u\|\le1\}}$, obtain $\widehat K$ by numerical radial Fourier integration or a precomputed lookup table, then use rejection sampling with proposal $p_0$ and envelope $B$ accepting $\omega$ with probability $|\widehat K(\omega)|/(Bp_0(\omega))$. (4) First experiment: train a 6-layer, 8-head transformer on CIFAR-10 treated as 196 image patches, and compare standard softmax attention, ordinary positive RFF attention, and signed attention at equal feature width and measured FLOPs. Start with $M\in\{32,64,128\}$ and the parabolic kernel. Measure validation accuracy, wall-clock time, memory, and approximation error against exact pairwise aggregation on a small batch. Success is lower memory and superlinear sequence-length scaling with no more than 1 percentage point accuracy loss; a stronger result is faster loss descent or improved accuracy from the compact negative lobes at equal FLOPs.
Verification
This idea has not been verified yet.
Verification happens in two stages: Stage 1 — a mechanism check on a toy system confirms the claimed mathematical phenomenon reproduces; Stage 2 — a benchmark implements the idea on a real (small) neural network task and compares it against a tuned baseline over 8 paired seeds with a permutation test.
Artifacts
Artifacts unavailable.