Rank Pooling as a Linear Attention Head: Writing Time into the Values

A video model that averages its frame features cannot tell "sitting down" from "standing up": the two clips contain the same poses in opposite order. Linear attention, the family of attention layers whose cost grows linearly with sequence length because it compresses the past into a fixed-size memory matrix, has a quiet version of the same problem. In its plain form that memory is a sum of key–value outer products. A sum does not change when the frames are shuffled, so the final memory of a clip is a bag of frames. Order enters only indirectly, through positional features or through decay gates that make older frames count less. Decay records how recent something is. It does not record which way time runs.

This note proposes a direct fix, based on an equivalence we want to make precise and exploit. Rank pooling is a classic video descriptor: it fits a linear function that predicts each frame's timestamp from its features and uses the fitted weights as the clip representation. Error-correcting linear attention layers such as DeltaNet and Gated KalmaNet already perform online least-squares regression from keys to values inside their memory matrix. If the values are timestamps, or a small learned basis of time functions, the memory matrix becomes a rank-pooling machine. It is updated in linear time, parallelized with existing chunkwise kernels, and needs no inner optimization solver. Reversing the clip provably maps this memory through a fixed linear transformation (a sign flip, for a centered linear time code). The layer therefore separates time-reversed action pairs by construction, and it can be used at every depth of a network rather than only as a final pooling step.

Core Claim

We claim that the order sensitivity a video model needs can come from what the memory regresses onto, and does not have to come from how the memory forgets. We write $\phi(k_t)\in\mathbb{R}^{m}$ for the feature-mapped key of frame $t$. We write $\tau(t)\in\mathbb{R}^{r}$ for a time code: a vector of $r$ fixed functions of normalized time, such as a centered ramp plus a few sinusoids. The chronological memory after $T$ frames is then

$$S_T=\arg\min_{S\in\mathbb{R}^{m\times r}}\ \sum_{t=1}^{T}\gamma^{T-t}\,\big\|S^\top\phi(k_t)-\tau(t)\big\|^2+\lambda\|S\|_F^2,$$

where $\gamma\in(0,1]$ is an optional forgetting factor and $\lambda>0$ is a ridge penalty. With $r=1$ and $\tau(t)=t$, this is the least-squares form of rank pooling. With $\gamma<1$ and an exact covariance-tracking update, it is precisely the test-time weighted ridge regression that Gated KalmaNet computes. The only change is that the values are time codes rather than content projections. A single delta-rule step, as in DeltaNet, gives a cheaper approximate solution.

Two consequences make this more than a relabeling. First, for time codes whose reversal $\tau(T+1-t)$ equals $R\,\tau(t)$ for a fixed matrix $R$, the memory of the reversed clip is exactly $S_T R^\top$ (taking $\gamma=1$). For the ramp, $R=-1$. A downstream classifier therefore sees forward and reversed versions of an action as distinct points related by a known map, whereas the plain summed memory makes them identical. Second, the per-prefix memories $S_t$ are available at every step at linear cost. The layer can then be a causal token mixer inside a backbone, emitting read-outs $y_t=S_t^\top\phi(q_t)$ that tell each frame where its content sits in the clip's temporal progression so far. Rank pooling was only ever a terminal descriptor.

Research Program

The work has three parts.

The first part is analytic. We will state and prove the permutation-invariance of undecayed summed memories. We will then characterize which time codes admit a fixed reversal map $R$, and show how the separation between forward and reversed memories depends on $\lambda$ and on the conditioning of the key covariance. The conditioning question is where the adaptive regularization and Chebyshev iteration of Gated KalmaNet become necessary rather than optional.

The second part is the layer. It is a multi-head block in which some heads carry ordinary content values and some carry time-code values. The time codes use normalized time $t/T$ for pooling, which makes the descriptor invariant to uniform tempo changes. The causal mode uses a small multi-scale absolute-time basis. We will reuse the chunkwise parallel machinery of DeltaNet and the Triton kernels of Gated KalmaNet unchanged, since only the value stream differs.

The third part is placement. We will compare using the layer as a terminal pooling head on a frame backbone with interleaving it as a temporal mixer in a factorized space-then-time video model.

The prior work plays three distinct roles here. Learning End-to-end Video Classification with Rank-Pooling fits a support-vector ranking machine inside the forward pass and differentiates through its argmin. It supplies the objective and motivates the work: its training throughput (50 frames per second with a diagonal Hessian approximation, 5 with exact inversion) is the bottleneck we remove. It also shows that end-to-end order-aware pooling pays off, with 87% on UCF-sports versus 66% without end-to-end training. DeltaNet and Gated KalmaNet supply the method. They were built and evaluated for language, and we move their regression target from content to time. VideoMambaPro constrains the design. It shows that linear-time state-space video models suffer historical decay and fixes this with a masked backward scan. A backward scan, however, is exactly the operation that makes forward and reversed clips harder to tell apart, so our approach keeps a single causal direction and recovers early frames through the ridge solution rather than through reverse recurrence. Dynamic Linear Attention keeps chronologically ordered multiple states for text. It is complementary but orthogonal: it decides when to open a new memory, while we change what each memory encodes. Higher-order Linear Attention tracks key second moments $\sum k_tk_t^\top$, which is the covariance our ridge solution needs, but it has no time target and no empirical evaluation. Finally, OTAM enforces order across two videos by differentiable time warping over a full query-by-support frame distance matrix. We do not attempt cross-video elastic alignment. We test whether a within-video order-aware memory compared by cosine similarity can stand in for it.

Baselines

The naive reference is temporal mean pooling of the same frame features, followed by the same classifier. It is order-blind by construction, and it anchors how much of each benchmark is solvable from appearance alone.

The most dangerous baseline is closed-form ridge rank pooling. It computes $(V^\top V+\lambda I)^{-1}V^\top\tau$ directly on frame features as a pooling head. Because ridge regression is differentiable in closed form, it avoids the bilevel solver without any recurrence. It also costs linear time in $T$, plus a cubic cost in the feature dimension. It will receive the same time codes, the same backbone, and the same $\lambda$ search as our layer. Our pooling head is mathematically close to it when $\gamma=1$. As a terminal descriptor, we must therefore beat it only through the learned feature map $\phi$, multi-head time codes, and forgetting. The clean win we are looking for comes from the interleaved placement, which closed-form pooling cannot provide.

End-to-end support-vector rank pooling from Fernando et al. is the historical method. It reports 87% on UCF-sports and 40.6 mAP on Hollywood2, and we will reproduce it on those two datasets to check the implementation. For backbones, the strongest linear-time video competitor in the file is VideoMambaPro, which reports 84.0% top-1 on Kinetics-400 for VMP-Middle. The file gives no absolute Something-Something-V2 number for it, only gains over VideoMamba. Alongside it we run a gated decayed linear attention and a plain DeltaNet with content values, both at matched width and depth. ATA, which reports 81.9% on Kinetics-400, is the reference for factorized models with quadratic temporal attention. In the few-shot setting the baseline is OTAM, which reports 42.8% one-shot and 52.3% five-shot accuracy on Something-Something-V2, and 73.0% and 85.8% on Kinetics-400.

Every method will share the backbone, frame sampling, augmentation, training schedule, and hyperparameter search budget. We will report equal-epoch and equal-wall-clock results. Beating a baseline means a gain on Something-Something-V2 larger than the seed-to-seed spread over three seeds, with no loss on Kinetics-400 beyond that spread.

Two ablations isolate the key ingredient. The first keeps the architecture but randomly permutes the time codes across frames during training and test; this should collapse the layer back toward a bag-of-frames model. The second replaces the time codes with content values, which recovers standard DeltaNet or Gated KalmaNet.

Why not just…?

Why not just add positional embeddings to the keys and keep ordinary linear attention? A summed memory over position-augmented keys can encode order in principle, so this is a real alternative. It is our ablation with content values plus positional embeddings, run at matched parameters. Our expectation is that it encodes order only as far as position is entangled with content through the feature map, and has no guaranteed reversal structure. The frame-reversal probe below measures this directly. If this alternative matches us on reversal accuracy and on Something-Something-V2, the time-as-value idea offers nothing and we will say so.

Why not just use closed-form ridge rank pooling as a head? This is the strongest threat to the pooling variant, and we treat it as the primary baseline. If it ties our terminal head, the contribution narrows to the interleaved causal layer. The placement experiment then decides whether that narrower claim holds, because closed-form pooling produces one vector per clip and cannot be stacked as a token mixer.

Why not just rely on decay gates, as Mamba-style models and VideoMambaPro do? Decay weights recent frames more heavily. A clip and its reverse therefore get different memories only insofar as their endings differ, not because their direction differs. VideoMambaPro's own diagnosis of historical decay, and its turn to a backward scan, suggests that decay alone is uncomfortable for video. The reversal probe and the long-clip experiment test this.

Why not just use softmax temporal attention with positional encodings? At 8–16 frames it is affordable and probably competitive. Our claim is limited to longer clips and streaming, where its quadratic cost and growing cache matter. We report the frame count at which the two cross over in accuracy per unit compute rather than claiming a win at short lengths.

Proposed Experiments

The decisive diagnostic is a reversal probe. On Something-Something-V2, whose classes include many direction-defined pairs, and on Kinetics-400 as an appearance-heavy control, we test each method in two ways. We train a linear classifier on frozen clip representations to label a clip as forward or reversed. We also measure the drop in class accuracy when test clips are reversed while labels are kept. Our prediction is that mean pooling and undecayed content-value linear attention sit at chance on the forward/reversed task, that decayed models sit above chance but well below our layer, and that the time-permutation ablation returns our layer to chance.

The main supervised result is Something-Something-V2 top-1 accuracy with the terminal-head and interleaved variants on a shared factorized backbone, with Kinetics-400 reported to check that appearance recognition is not lost. We compare against VideoMambaPro-style decay models and ATA under matched compute.

The few-shot test follows the OTAM protocol on Something-Something-V2 and Kinetics-400. It compares cosine similarity between chronological memories, which costs one inner product per support clip, against OTAM's time-warping score, with OTAM's reported 42.8% and 52.3% as the reference. If we fall well short of OTAM, the result is still informative: it would mean elastic cross-video alignment carries information that a within-video order summary does not.

The historical checks reproduce end-to-end rank pooling on UCF-sports and Hollywood2, against the reported 87% and 40.6 mAP, and measure training throughput against its 50 frames per second.

The scaling test samples 16 to 512 frames per clip. It plots accuracy and wall-clock time for our layer, softmax temporal attention, and decayed linear attention, and measures whether early-frame information survives by probing the memory for the content of the first quarter of the clip. For longer streams, the 50-hour teleoperation recordings in DECO-50 offer a place to test whether the causal read-out tracks task progress in manipulation, though no reported result was found on Lacuna for this dataset.