cs.LGSep 11, 2026

Attention Is All You Need (to Avoid Spurious Oscillations)

Authors: Jinyoung Jeong, Joseph B. Choi, Xinlun Cheng, H. S. Udaykumar, Sanghun Choi, Stephen S. Baek

Organizations: School of Mechanical Engineering & IEDT, Kyungpook National University, Daegu, South Korea · School of Data Science, University of Virginia, Charlottesville, VA 22903, USA · Department of Mechanical Engineering, University of Iowa, Iowa City, Iowa 52242, USA · Department of Mechanical and Aerospace Engineering, University of Virginia, Charlottesville, VA 22903, USA

Abstract

Can attention move a shock across several cells in one update without breaking it? We develop a conservative, fixed grid finite-volume scheme in which a CFL-conditioned attention flux selects upstream information according to the transport required by the current time step. One-dimensional inviscid Burgers transport is used as the central mechanism test: the same learned flux remains reliable in the conventional small-step regime and, with a time step four times larger, preserves sharp shocks while using one stage per update. A standard fifth-order WENO scheme with third-order strong-stability-preserving Runge-Kutta time integration (WENO-5+SSP-RK3) is included alongside controlled Forward Euler comparisons to separate flux selection from time integration. The learned attention shifts upstream with the local transport reach and becomes more selective near shocks; inference-time interventions and retrained ablations show that transport-scale information and state-dependent selection contribute directly to performance. Directional two-dimensional scalar Burgers transport and the one-dimensional shallow-water system then test whether the conservation-scale-selection principle transfers beyond the original scalar setting. The results support attention as a learnable information stencil for conservative large-step shock transport, while identifying finite candidate reach and problem-dependent robustness as the present limits.

Explore similar work

Dec 14, 2025cs.LG

Exact Flow Linear Attention: Exact Solution from Continuous-Time Dynamics

In this paper, we introduce Exact Flow Linear Attention~(EFLA), an exact-flow formulation of delta-rule linear attention. We show that the delta-rule update can be interpreted as an explicit Euler discretization of an underlying continuous-time system. EFLA replaces this first-order update with the exact closed-form flow. By exploiting the rank-1 structure of the dynamics matrix, both the matrix exponential and the input integral collapse to a simple update that preserves delta-rule linear attention's algebraic structure, parameter count, linear-time complexity, and chunkwise parallelism. This attention mechanism removes the Euler discretization error of the delta-rule dynamics without introducing additional parameters. Experiments on robustness tests, language modeling benchmarks, and the MAD synthetic benchmark show that EFLA improves stability under corrupted and high-energy inputs, reduces perplexity, and achieves stronger downstream performance compared to SSM and Euler-style baselines. These results establish exact-flow integration as a principled and scalable update mechanism for delta-rule linear attention.
Jul 22, 2026physics.flu-dyn

Guarantees by Construction for Learned Finite Volume Schemes on Steady Supersonic Flow

A second order finite volume scheme rests on two local quantities: a gradient reconstructed in each cell, and a limiter which scales it down where the reconstruction would overshoot. Both are set by fixed formulas, and on coarse unstructured meshes a small network can supply better values. But a network is free to output anything, and the usual safeguard is a penalty in the training loss, which discourages inadmissible states without preventing them. We replace the penalty by a hard constraint. The network still sets both quantities, and every value it can produce lies inside safe bounds: its stencil weights cannot cancel a neighbour, and its limiter is capped by the local flow. The flux, the wall treatment and the time step are not learned and carry their own guarantees. Admissibility therefore holds for every value of the weights rather than as an outcome of training, and no negative density or pressure occurred in any computation reported here. Because the scheme is safe whatever the network does, we could ask what the network contributes. We test it on supersonic channel flow over an obstacle, including the forward facing step of Woodward and Colella. Learning lowers the error by 38% on an unseen geometry and 29% on an unseen obstacle topology, measured against the same scheme with the network switched off. The method aims at the accuracy of a fine mesh for the cost of a coarse one, and refining once improves the error fourfold while multiplying the run time by eight. Learning secures half of this improvement for a sixth of this time. All of this comes from one of the two quantities the network sets. The gradient reconstruction reproduces the full effect on its own, and the limiter accounts for about a tenth as much. This also explains why the gain fades beyond the Mach numbers the weights were trained on.
Jun 2, 2026cs.AR

P-Cast Precision in FP8 Attention: Sink-Induced Collapse and the Optimality of S=2^8

FP8 (E4M3) acceleration for attention computation offers significant throughput gains, but the 3-bit mantissa introduces precision challenges when the softmax probability matrix~PP is cast to FP8 before the P⋅VP \cdot V matrix multiplication. We analyze two implementation choices that affect output precision under the \emph{Attention Sink} phenomenon: (1)~the KV block iteration order, and (2) the static scaling factor applied to PP before casting. We show that forward KV iteration causes \emph{P-collapse} -- to leading order a fraction Φ(Δ+δk−6.93−ln⁡S)Φ(Δ+ δ_k - 6.93 - \ln S) of non-sink PP values underflow to zero, where the small shift δk≈1δ_k \approx 1 (for ksink=4k_{\text{sink}}{=}4) is the expected within-sink-block score maximum -- and that reverse iteration removes it, with a zero-underflow guarantee when reverse is combined with S=256S{=}256. We further give a constructive characterization of S=256=28S = 256 = 2^8 as the static scale that simultaneously satisfies (i)~bit-exact IEEE 754 scaling, (ii) the lower envelope of a sawtooth function dp(S)dp(S) over the E4M3 number line (dp=2−4dp = 2^{-4}, the minimum worst-case quantization step), and (iii)~the maximum normal-range coverage \emph{among bit-exact (2k2^k) scales} (a non-bit-exact scale such as 448448 attains slightly higher coverage; sec.5}). Both optimizations are already deployed in FlashAttention-3/4 on engineering grounds; our contribution is a quantitative account of \emph{why} these choices are good and a closed-form threshold Δc=6.93+ln⁡S−δkΔ_c = 6.93 + \ln S - δ_k for predicting kernel-level precision loss. Kernel-faithful experiments (Q,K,VQ, K, V in FP32 to isolate the P-cast effect) show 33-10×10\times MSE improvement at moderate sink strengths, and paired tests confirm both fixes saturate to the same precision floor when combined -- which motivated updating the hpc-ops kernel from S=1S{=}1 to S=256S{=}256.