arXiv:2610.39854cs.LGOct 2026

Manuscript Offprint

arXiv:2610.39854

Attention, Dynamic Wave and Hybrid Sequence Mixers in Language Models

Dmytro Babarytskyi, Oleksandr Babarytskyi

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Dmytro Babarytskyi

Kharkiv National University of Radio Electronics

Kharkiv, Ukraine

dmytro.babarytskyi@nure.ua

babaritskiydmytro@gmail.com

ORCID: 0009-0009-3614-9601

Oleksandr Babarytskyi

Military Law Institute

Yaroslav Mudryi National Law University

Kharkiv, Ukraine

aleksandr.babaritskiy@ukr.net

ORCID: 0000-0002-1690-1837

Abstract—Large Language Models (LLMs) rely on Multi-Head Attention (MHA) for sequence modeling, but scaling to long contexts is constrained by the quadratic cost of attention, motivating sub-quadratic recurrent alternatives. This paper formalizes a Dynamic Wave recurrent layer, based on input-dependent exponential damping and cosine phase modulation, and evaluates three 10.94M-parameter configurations—Pure Transformer, Pure Wave, and Hybrid Wave-Attention—on TinyS-tories under perplexity, latency, throughput and peak VRAM profiling up to 4096 tokens. The Hybrid configuration reaches the best perplexity, 5.95 on the full held-out split against 6.93 for the Transformer and 7.26 for Pure Wave. The efficiency picture, however, is governed by implementation rather than by architecture. Against an unfused attention baseline, Pure Wave uses 78.7% less peak VRAM at a 4096-token context (1404.3 MB vs. 6601.6 MB); against a fused scaled-dot-product attention kernel the same comparison yields no advantage at all (1404.3 MB vs. 1403.6 MB), and in training mode Pure Wave is 8.3% more expensive than the Transformer. Likewise, hoisting elementwise terms out of the recurrence loop speeds the layer up 2.53-fold with no custom kernel, reducing its latency gap to attention from 2.48-fold to 1.12-fold. A hybrid stack is found to inherit the cost of its more expensive mixer rather than the advantage of its cheaper one, its peak VRAM matching the Pure Transformer to within 0.1%. A closed-form memory model reproduces these measurements and predicts the context length beyond which attention overtakes the vocabulary projection. The findings indicate that reported efficiency gains for recurrent attention replacements must be stated relative to a named attention backend and a named implementation, and that hybridization is best justified on quality grounds.

Index Terms—Large Language Models, Sequence Modeling, Multi-Head Attention, Dynamic Wave Layer, Hybrid Architectures, Memory Efficiency, Context Scaling, Perplexity.

I. INTRODUCTION

Large Language Models (LLMs) have fundamentally transformed the paradigms of natural language processing, computer vision, and software engineering by enabling sophisticated text generation, contextual reasoning, and zero-shot problem-solving [1], [2]. At the core of modern LLM architectures lies the Transformer model, which relies heavily on the Multi-Head Attention (MHA) mechanism to perform sequence modeling [3]. This mechanism enables the model to dynamically capture long-range global dependencies across a sequence, establishing MHA as the standard for autoregressive language generation and deep context understanding.

Despite its unparalleled success, scaling traditional MHA to exceptionally long contexts remains constrained by its inherent quadratic computational complexity O(N2)O(N^{2}), where N denotes the sequence length. As the context window expands, the memory footprint required to store the Key-Value (KV) cache grows linearly with context length while the cost of the attention computation itself grows quadratically, together precipitating a critical “memory wall” that exhausts available Video RAM (VRAM) [4]. This memory problem not only drives up computational infrastructure costs but also leads to long-context degradation, where the model’s token-processing efficiency drops significantly, and its retrieval capabilities suffer from structural information loss deep within lengthy prompts [5].

To alleviate this quadratic complexity, alternative subquadratic sequence mixing paradigms have been proposed, including State-Space Models (SSMs), linear-time recurrent layers, and specialized linear attention approximations [6], [7]. Architectures such as Mamba and RWKV compress the sequence history into a fixed-size latent state, effectively reducing spatial complexity to O(N)O(N) during inference. However, these pure recurrent implementations frequently suffer from sequential processing latency on parallel hardware during training and can exhibit degraded semantic understanding. Specifically, they lack the strong global associative recall capabilities of standard MHA, leading to suboptimal performance on tasks that require tight, non-local token dependencies.

To address the trade-off between the expressive power of attention and the computational efficiency of recurrent networks, recent architectural trends have shifted toward hybrid sequence modeling paradigms [8], [9]. Models like Griffin and Jamba interleave MHA layers with gated linear recurrences or SSMs to achieve sub-quadratic memory scaling while preserving long-range contextual fidelity. Building on this paradigm, this paper investigates substituting standard attention with a Dynamic Wave recurrent layer that leverages exponential damping and phase modulation to maintain a stable, long-term memory state.

Existing literature extensively covers linear attention variants [10], [11] and pure state-space layer scaling [6], [12].

However, the specific behavior of a dynamic wave mechanism utilizing phase modulation in hybrid configurations remains insufficiently studied. More importantly, efficiency claims in this literature are frequently reported without stating which attention backend they are measured against, even though—as this paper shows—that choice can change the sign of the result.

This paper bridges these gaps by evaluating a Dynamic Wave layer and its integration into hybrid language models. Three distinct 10.94M-parameter model configurations—Pure Transformer, Pure Wave, and Hybrid Wave-Attention—are formalized and trained on the TinyStories corpus [13]. They are evaluated under a measurement protocol that isolates each configuration on a clean allocator, separates the cost of the sequence mixer from that of the shared language-model head, and reports every memory figure against both a fused and an unfused attention backend.

The main contributions of this paper are as follows:

  • The mathematical apparatus of the Dynamic Wave recurrent layer, based on input-dependent exponential damping and cosine phase modulation, is formalized for sequence processing, and its relationship to complex-valued diagonal state spaces is made explicit.

  • The recurrence is shown to be an associative scan, so that it admits the same O(log⁡T)O(\log T)-depth parallelization as the state-space layers it is compared against.

  • Three comparable 10.94M-parameter architectures (Pure Transformer, Pure Wave, and Hybrid Wave-Attention) are proposed, implemented, and compared at a matched parameter budget.

  • A measurement protocol is introduced that separates mixer memory from output-layer memory and controls for the attention backend, the compilation setting, and allocator state; it is shown that omitting these controls produces qualitatively wrong conclusions.

  • An implementation-level ablation quantifies how much of the recurrent layer’s latency penalty is architectural and how much is an artifact of an unoptimized loop.

  • A closed-form model of peak activation memory is derived and validated against measurement; it reproduces the observed figures and predicts the context length beyond which attention, rather than the vocabulary projection, dominates memory.

  • A hardware-aware strategy selection model is developed to guide architectural choices under explicit operational constraints.

References (44)