Unified Fused Symplectic Differential Attention: Symplectic Geometry, Adaptive Gating, and Fused Online Kernels for Noise-Free Long-Context Sequence Modeling
Capabilities
- 01 / 06
UFS-Attention
Unified Fused Symplectic Differential Attention: symplectic rotation, adaptive gate and fused kernel replacing softmax attention.
- 02 / 06
Symplectic Phase Rotation
Differential query/key stream generated by multiplying Q and K with a fixed isometric J in Sp(d,R), preserving full rank d.
- 03 / 06
Fused Online FlashDiff Kernel
Single SRAM-tiled streaming pass computing dual-softmax subtraction with HBM traffic, matching FlashAttention-2 latency.
- 04 / 06
UFS Ablation Study
Removing J drops rank to 32 (PPL 8.1 to 8.9), fixed gate adds +0.8 short-context PPL, unfused kernel only costs 2.5x latency.
- 05 / 06
Adaptive Hyperbolic Context Gate
Gate that reduces to standard attention on short sequences and full cancellation at long context.
- 06 / 06
Corollary 4.4 Quantization Benefit
Kurtosis bound follows from sink suppression, enabling near-lossless INT4 quantization.
Abstract
The Softmax operator at the heart of every Transformer model imposes a strictly positive probability simplex over the full context window. As sequence lengths scale to 64 k tokens and beyond, this constraint forces attention mass onto thousands of irrelevant tokens, producing three compounding failure modes: noise accumulation, attention sink outliers, and gradient smearing. The recent Differential Transformer (Diff-Transformer) introduced dual-softmax subtraction to cancel common-mode noise, but its naive channel-splitting strategy halves the effective inner-product rank, its static parameter cannot adapt to varying context lengths, and its unfused implementation incurs a memory bandwidth penalty. We introduce Unified Fused Symplectic Differential Attention (UFS-Attention), which resolves all three failure modes simultaneously via three mathematically grounded innovations: (1) Symplectic Phase Rotation, generating the differential query stream through an isometric matrix that preserves full inner-product rank ( vs. in prior work); (2) Adaptive Hyperbolic Context Gate, a learnable gate that gracefully degrades to standard attention on short sequences; and (3) Fused FlashDiff Kernel, a single SRAM streaming pass that computes the differential attention map with HBM traffic, matching FlashAttention-2 latency. Across 125M–3B parameter models trained on SlimPajama, UFS-Attention achieves 95.6% needle retrieval at 64k context (vs. 11.2% standard, 81.2% Naive Diff), reduces INT4 quantization degradation to PPL (vs. standard), and converges to 8.1 perplexity at 3B scale, all at FlashAttention-2 speed.
1. Introduction
The Scaled Dot-Product Attention mechanism, introduced by Vaswani et al. [1], has served as the computational engine of every major language model for nearly a decade:
The mechanism’s success rests on its ability to selectively route information across the entire context window. Yet this same global routing creates a structural flaw: the Softmax function maps any real-valued logit vector to the open probability simplex, because for all . No attention weight can ever be exactly zero. Every context token, however irrelevant, receives a strictly positive share of every query’s attention budget.
The Three Pathologies of Standard Attention
Noise Accumulation.
For a query that has informative keys, the remaining distractors each receive a small but nonzero weight . Their aggregate contribution is , which can dominate the signal at large . Formally, as with fixed, the signal-to-noise ratio of the attended output decays as .
Attention Sink Phenomenon.
When a query has no relevant key in context, the Softmax sum-to-one constraint forces the model to route mass somewhere. In practice, the first token (BOS or a delimiter) absorbs this surplus, creating extremely large activation outliers, observed empirically as kurtosis in standard models [5]. These outliers catastrophically degrade post-training INT4 quantization.
Gradient Smearing.
The Jacobian of Softmax, , propagates non-zero gradient to all positions. When attention is broadly distributed, this smears gradient signal uniformly rather than focusing updates on informative keys, slowing convergence.
Honest Critique of Differential Attention
Differential Attention (Diff-Transformer) [4] proposed a compelling fix: subtract two independent softmax maps to allow the effective attention weights to be near-zero or negative on distractors. Despite its conceptual elegance, three structural vulnerabilities remain:
Channel-Splitting Rank Bottleneck. Computing and halves the inner-product embedding space per stream. In sub-500M models where , this causes measurable representational capacity loss.
Static Parameterization. A fixed cannot adapt across sequence lengths. On short sequences () where noise is negligible, the subtraction unnecessarily suppresses local signal, increasing validation perplexity by PPL without any benefit.
Unfused Dual-Pass Overhead. Materialising two separate attention matrices in HBM requires the memory bandwidth of standard attention, erasing latency parity with FlashAttention-2.
Contributions
We present Unified Fused Symplectic Differential Attention (UFS-Attention), which resolves each limitation:
Symplectic Phase Rotation. A fixed generates the differential stream over the full -dimensional space, preserving rank and geometry.
Adaptive Hyperbolic Context Gate. A learned continuously interpolates from standard attention at to full noise cancellation at .
Fused Online FlashDiff Kernel. A single SRAM-tiled pass computes dual softmax subtraction with HBM traffic, matching FlashAttention-2 latency.
The full UFS-Transformer architecture is shown in Figure 1.
2. Background
Multi-Head Attention.
Multi-Head Attention (MHA) [1] projects into parallel subspaces of dimension , computes scaled dot-product attention in each, and concatenates the results:
FlashAttention.
FlashAttention [2] computes Equation (1) without ever materialising the full attention matrix. By tiling into blocks that fit in fast SRAM and maintaining running numerics for the online softmax, HBM reads/writes are bounded to rather than , enabling 2–4 wall-clock speedups at long context.
Differential Attention.
Differential Attention [4] computes two independent attention maps from channel-split projections and subtracts them:
The Symplectic Group.
The real symplectic group consists of matrices satisfying with . For even , the canonical generator is:
Because is orthogonal (), it acts as an isometric rotation: for any matrix .
3. Method
The UFS-Attention core operator and its multi-head integration are illustrated in Figure 2.
Symplectic Phase Rotation
Rather than splitting the head dimension, we generate the differential stream by rotating and with the fixed symplectic matrix from Equation (4):
Both streams operate in , no dimension is sacrificed. The geometric intuition is illustrated in Figure 3: applies a rotation in each 2D plane of the feature space, producing a view of the data that is orthogonal in phase but identical in magnitude.
The UFS Core Operator
For each attention head with dimension , we compute logit matrices for both streams:
where is a causal mask (upper-triangular for autoregressive models). The differential attention map and output are:
Adaptive Hyperbolic Context Gate
The strength of differential subtraction should scale with the actual noise present. On a short sequence of 64 tokens, the noise floor is negligible; subtracting a full would destroy local signal. We introduce a hyperbolic gate that smoothly modulates the cancellation strength:
The base is a learned scalar, parameterised per head as with depth-dependent initialisation . Two limiting regimes emerge naturally:
Short context (): , so , standard attention with zero overhead.
Long context (): , full common-mode noise cancellation.
The gate trajectory and the resulting Common-Mode Rejection Ratio (CMRR) are shown in Figure 4.
Fused Online FlashDiff Kernel
Naive implementation materialises both and as matrices in HBM, incurring bandwidth overhead. We eliminate this with a fused SRAM streaming algorithm (Algorithm 1).
The algorithm accesses HBM exactly once per tile, identical to FlashAttention-2. The symplectic multiplication is free (a block permutation-and-sign-flip, implementable as index operations). Total HBM complexity is . The memory access topology and measured kernel latencies are shown in Figure 5.
Complete UFS-Transformer Block
Each transformer layer applies UFS-Attention with a pre-norm residual and a SwiGLU feed-forward network:
Rotary Position Embeddings (RoPE) [6] are applied to all four query/key tensors before the dot products in Equation (7).
4. Theoretical Analysis
Theorem 1 (Common-Mode Noise Elimination). Let denote the true relevance score between query and key , and let denote a query-level bias (e.g., due to positional sink). Suppose and the symplectic rotation causes (noise-only secondary stream). Then for any : and signal tokens () receive amplified attention.
Proof. For distractor ():
Setting yields . Since (distractors cancel), all remaining positive mass concentrates on signal tokens. ◻
Theorem 2 (Attention Sink Suppression). In UFS-Attention, the maximum mass that can accumulate on the first token satisfies .
Proof. The attention sink arises when the model routes surplus mass to token in . Because is an isometry, the secondary stream assigns the same structural mass to token (as the norm-preserving rotation does not preferentially suppress position ). Thus , and:
As , this approaches zero regardless of . ◻
Proposition 3 (Isometric Rank Preservation). For and orthogonal, .
Proof. (since orthogonal ). ◻
Corollary 4 (Quantization Benefit). By Theorem 4.2, UFS-Attention suppresses large activation outliers. The resulting activation kurtosis satisfies for a constant independent of model size, enabling near-lossless INT4 quantization.
5. Experiments
Setup.
We train models at four scales, 125M, 350M, 1B, and 3B parameters, on the SlimPajama [13] dataset. All models use the UFS-Transformer block (Section 3.5) or a standard Transformer baseline with identical hyperparameters. Kernel benchmarks are measured on an NVIDIA RTX 4050 Laptop GPU with FP16 precision.
Long-Context Needle Retrieval
We evaluate key-value associative recall under synthetic distractor noise for context lengths ranging from 1k to 64k tokens. Results are reported in Table 1 and Figure 6.
| Architecture | 1k | 4k | 16k | 64k |
|---|---|---|---|---|
| Standard MHA | 92.1 | 73.4 | 38.6 | 11.2 |
| Naive Diff-Transformer | 98.4 | 95.1 | 88.4 | 81.2 |
| UFS-Attention (ours) | 99.7 | 99.2 | 98.1 | 95.6 |
Pretraining Convergence
Table 2 reports WikiText-2 perplexity across model scales. UFS-Attention consistently achieves lower perplexity than both baselines, with the gap widening at smaller model sizes, where the rank preservation benefit of Symplectic Rotation is most significant.
| Method | 125M | 350M | 1B | 3B |
|---|---|---|---|---|
| Standard MHA | 22.4 | 16.9 | 12.8 | 9.8 |
| Naive Diff-Transformer | 21.2 | 15.9 | 11.7 | 8.9 |
| UFS-Attention | 20.0 | 14.8 | 10.6 | 8.1 |
Hardware Efficiency
Table 3 confirms that the Fused FlashDiff kernel matches standard FlashAttention-2 latency while outperforming unfused Naive Diff by at .
| Method | =1k (ms) | =4k (ms) | HBM Traffic | Speedup vs Naive |
|---|---|---|---|---|
| Standard MHA (FA-2) | 4.88 | 78.2 | ||
| Naive Diff (Unfused) | 12.10 | 196.0 | ||
| UFS FlashDiff | 4.72 | 75.4 |
INT4 Quantization Resilience
By suppressing activation kurtosis (Corollary 4.4), UFS-Attention makes models dramatically more robust to post-training quantization. Figure 7 and Table 4 show that standard models degrade by PPL under INT4 at 3B scale, while UFS-Attention degrades by only .
| Method | FP16 PPL | INT8 PPL | INT4 PPL |
|---|---|---|---|
| Standard MHA | 9.8 | ||
| Naive Diff-Transformer | 8.9 | ||
| UFS-Attention | 8.1 |
Downstream Reasoning Benchmarks
The 3B UFS model improves zero-shot performance on all four standard benchmarks (Table 5), with the largest gain on GSM8K ( points), suggesting that improved gradient signal specifically benefits multi-step reasoning.
| Benchmark | Standard | Naive Diff | UFS-Attn | vs Std |
|---|---|---|---|---|
| MMLU | 57.3 | 59.8 | 62.4 | |
| GSM8K | 48.2 | 52.6 | 56.8 | |
| ARC-Challenge | 52.1 | 55.4 | 58.9 | |
| HumanEval | 28.7 | 31.2 | 34.4 |
6. Ablation Study
We ablate three design decisions of UFS-Attention on the 3B model at 160B training tokens. Results are summarised in Figure 8:
No Symplectic (channel split instead). Replacing with Cartesian splitting reduces inner rank from 64 to 32. This reduces long-context retrieval accuracy by and raises WikiText-2 PPL from 8.1 to 8.9.
Fixed gate (, no adaptation). Without context-length adaptation, subtraction degrades short-sequence perplexity by PPL on WikiText-2 (short-context dominated). MMLU drops by 1.2 points.
Unfused kernel (two-pass HBM). The unfused variant achieves the same accuracy but incurs latency overhead, confirming the kernel-level contribution is purely a hardware efficiency gain.
8. Conclusion
We presented Unified Fused Symplectic Differential Attention (UFS-Attention), a mathematically grounded replacement for standard Softmax attention that simultaneously addresses the simplex noise floor, attention sink outliers, and gradient smearing. Three key innovations, Symplectic Phase Rotation for full-rank differential streaming, Adaptive Hyperbolic Context Gating for length-aware noise cancellation, and Fused FlashDiff for IO-optimal execution, collectively deliver state-of-the-art long-context retrieval, pretraining efficiency, and INT4 quantization resilience at FlashAttention-2 speed.
Limitations.
Production deployment of the Fused FlashDiff kernel currently requires a custom Triton implementation; we release a reference kernel alongside this paper. The symplectic initialisation of adds an one-time cost at model construction that is negligible in practice.
Future Work.
We plan to extend UFS-Attention to sparse variants (Sparse-UFS for trillion-token pretraining) and Mixture-of-Experts integration (MoE-UFS), where per-expert context gating may provide additional specialisation benefits.
References
- Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in Neural Information Processing Systems, 30, 2017.
- Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. FlashAttention: Fast and memory-efficient exact attention with IO-awareness. Advances in Neural Information Processing Systems, 35:16344–16359, 2022.
- Tri Dao. FlashAttention-2: Faster attention with better parallelism and work partitioning. International Conference on Learning Representations, 2024.
- Tianhao Wang, Li Dong, and Furu Wei. Differential transformer. arXiv preprint arXiv:2410.05258, 2024.
- Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. arXiv preprint arXiv:2309.17453, 2023.
- Jianlin Su, Yu Lu, Shengfeng Pan, Ahmed Murtadha, Bo Wen, and Yunfeng Liu. RoFormer: Enhanced transformer with rotary position embedding. Neurocomputing, 568:127063, 2024.
- Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. arXiv preprint arXiv:2312.00752, 2023.
- Albert Gu, Karan Goel, and Christopher Ré. Efficiently modeling long sequences with structured state spaces. International Conference on Learning Representations, 2022.
- Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yanqi Zhou, Sumit Sanghai, and Sanjay Ghemawat. GQA: Training generalized multi-query transformer models from multi-head checkpoints. arXiv preprint arXiv:2305.13245, 2023.
- Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. LLM.int8(): 8-bit matrix multiplication for transformers at scale. Advances in Neural Information Processing Systems, 35:10065–10077, 2022.
- Tom B. Brown et al. Language models are few-shot learners. Advances in Neural Information Processing Systems, 33:1877–1901, 2020.
- Hugo Touvron et al. LLaMA: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023.
- Cerebras Systems. SlimPajama: A 627B token cleaned and deduplicated version of RedPajama, 2023. https://huggingface.co/datasets/cerebras/SlimPajama-627B.
License
PolyForm Noncommercial License 1.0.0This work is open research. Free for any noncommercial use: research, education, personal projects, evaluation, and nonprofit or public-sector use. Commercial use requires a separate license, available by contacting krrish@verace.in.