Introduction
Large language models (LLMs) based on the Transformer architecture (Vaswani et al., [40 ] ) have achieved remarkable performance across a wide range of natural language processing tasks, including language understanding, reasoning, question answering, and code generation. Since GPT-2 (Radford et al., [33 ] ), the prevailing paradigm has converged on decoder-only architectures and has remained largely unchanged: LLMs are built from stacks of Transformer blocks or its variants that combine causal scaled dot-product attention (SDPA) with feed-forward network (FFN), and are pretrained through next-token prediction on large-scale corpora followed by instruction tuning (Christiano et al., [4 ] ; Ouyang et al., [27 ] ; Rafailov et al., 2023). Despite its success, SDPA incurs quadratic computational complexity O ( T 2 ) O(T^2) O ( T 2 ) with respect to the sequence length T T T .
A growing body of work therefore explores linear-time architectures with computational complexity O ( T ) O(T) O ( T ) . Selective state-space models (SSMs), such as Mamba (Gu & Dao, [10 ] ) and its variants, replace the attention mixing module with selective state-space recurrences, while recurrent linear-attention models, such as Receptance Weighted Key Value (RWKV) (Peng et al., [29 ] ), employ recurrent weighted key–value mechanisms. Other approaches preserve attention-like algebra while replacing the softmax operator: the Linear Transformer ([21 ] ) factorizes kernelized attention through feature maps and associativity, Retentive Network (RetNet) ([38 ] ) introduces a multi-scale retention mechanism with parallel, recurrent, and chunkwise-recurrent formulations, and Gated Linear Attention (GLA) ([42 ] ) incorporates data-dependent decay gates with efficient chunkwise computation. DeltaNet ([34 , 43 ] ) introduces delta-rule updates to recurrent fast-weight states, while Gated DeltaNet ([44 ] ) further augments the delta-rule recurrence with data-dependent gating. HGRN2 ([32 ] ) develops hierarchical gated recurrent dynamics for linear-time sequence modeling, whereas Hyena ([31 ] ) replaces recurrent state updates with implicitly parameterized long convolutions for efficient long-range sequence mixing.
In the theory of digital signal processing (DSP) ([26 ] ), representations of language sequences are discrete temporal signals. A system that maps an input sequence to an output sequence is a transfer operator. Its input–output response can be characterized by its transfer function. Let x 1 : n = ( x 1 , ⋯ , x n ) x_{1:n}=(x_1,\cdots,x_n) x 1 : n = ( x 1 , ⋯ , x n ) be a finite temporal sequence of length n n n . Let Z { ⋅ } \mathcal{Z}\{\cdot\} Z { ⋅ } be z z z -transform operator, and Z − 1 { ⋅ } \mathcal{Z}^{-1}\{\cdot\} Z − 1 { ⋅ } be inverse z z z -transform operator, defined as
X n ( z ) = Z { x 1 : n } : = ∑ j = 1 n x j z − j , x j = Z − 1 { X n ( z ) } = 1 2 π i ∮ Γ X n ( z ) z j − 1 d z , X_n(z)=\mathcal{Z}\{x_{1:n}\}:=\sum_{j=1}^{n}x_jz^{-j},\qquad x_j=\mathcal{Z}^{-1}\{X_n(z)\}=\frac{1}{2\pi i}\oint_{\Gamma}X_n(z)z^{j-1}\,\mathrm{d}z, X n ( z ) = Z { x 1 : n } := j = 1 ∑ n x j z − j , x j = Z − 1 { X n ( z )} = 2 π i 1 ∮ Γ X n ( z ) z j − 1 d z ,
respectively, where the counter-clockwise closed integral contour Γ \Gamma Γ on complex plane encloses all poles of the polynomial X n ( z ) X_n(z) X n ( z ) for ensuring causal condition and z ∈ C z\in\mathbb{C} z ∈ C is complex variable ([26 ] ). Let x 1 : t x_{1:t} x 1 : t and y 1 : t y_{1:t} y 1 : t be input and output sequences of t t t tokens. Let X t ( z ) : = Z { x 1 : t } X_t(z):=\mathcal{Z}\{x_{1:t}\} X t ( z ) := Z { x 1 : t } and Y t ( z ) : = Z { y 1 : t } Y_t(z):=\mathcal{Z}\{y_{1:t}\} Y t ( z ) := Z { y 1 : t } denote the z z z -transforms of the input sequence x 1 : t x_{1:t} x 1 : t and output sequence y 1 : t y_{1:t} y 1 : t , respectively. The ratio of the output to the input in the z z z -domain H ( z ; x t ) : = Y t ( z ) X t ( z ) H(z;x_t):=\frac{Y_t(z)}{X_t(z)} H ( z ; x t ) := X t ( z ) Y t ( z ) is referred to as the transfer function ([26 ] ). We show that recurrent dynamical systems — such as SDPA, SSM, RWKV, RetNet, HGRN2, Hyena, and DeltaNet — admit following input-conditioned transfer operator,
H ( z ; x t ) = A ( z ; x t ) B ( z ; x t ) = a 0 ( x t ) + ∑ i = 1 m a i ( x t ) z − i 1 + ∑ j = 1 n b j ( x t ) z − j , a 0 , a i , b j ∈ R , (1) H(z;x_t)=\frac{A(z;x_t)}{B(z;x_t)}=\frac{a_0(x_t)+\sum_{i=1}^{m}a_i(x_t)z^{-i}}{1+\sum_{j=1}^{n}b_j(x_t)z^{-j}},\qquad a_0,a_i,b_j\in\mathbb{R}, \tag*{(1)} H ( z ; x t ) = B ( z ; x t ) A ( z ; x t ) = 1 + ∑ j = 1 n b j ( x t ) z − j a 0 ( x t ) + ∑ i = 1 m a i ( x t ) z − i , a 0 , a i , b j ∈ R , (1)
where A ( z ; x t ) A(z;x_t) A ( z ; x t ) defines an order-m m m finite-impulse-response (FIR) system, and B ( z ; x t ) B(z;x_t) B ( z ; x t ) defines an order-n n n infinite-impulse-response (IIR) system. This transfer function H ( z ; x t ) H(z;x_t) H ( z ; x t ) is uniquely characterized by the roots of its numerator and denominator polynomials, where the roots of the numerator polynomial A ( z ; x t ) A(z;x_t) A ( z ; x t ) are referred to as zeros , and the roots of the denominator polynomial B ( z ; x t ) B(z;x_t) B ( z ; x t ) are referred to as poles . The zero–pole geometry of H ( z ; x t ) H(z;x_t) H ( z ; x t ) governs how temporal modes are retrieved from input sequences: zeros attenuate or cancel specific modes, whereas poles determine persistent or resonant temporal modes. Table 1 summarizes the transfer-function and zero–pole characterizations of SDPA, the selective SSM of Mamba-1, RWKV v4–v6, RetNet, HGRN2, Hyena, DeltaNet, and Gated DeltaNet. The proofs are provided in Appendix § 8 .9. To trade parallelism, the algebraic structures of the parameterizations of these methods, such as a diagonal-matrix parameterization in SSM that preserves channel-wise parallelism, often constrain their poles to lie on the real axis.
Table 1. Transfer-Function Characterization. A ( z ) A(z) A ( z ) and B ( z ) B(z) B ( z ) denote the numerator (FIR) and denominator (IIR) polynomials of the transfer function H ( z ) = A ( z ) / B ( z ) H(z)=A(z)/B(z) H ( z ) = A ( z ) / B ( z ) . The transfer functions are input-dependent. The roots of A ( z ) = 0 A(z)=0 A ( z ) = 0 are the zeros and the roots of B ( z ) = 0 B(z)=0 B ( z ) = 0 are the poles. We also verify the derived transfer functions numerically, comparing the sequence each predicts against the measured output of its recurrence, with a maximum discrepancy of 3.6 × 10 − 12 3.6 \times10^{-12} 3.6 × 1 0 − 12 ; the pole ranges are verified formally, in Lean 4 ([25 ] ) and Z3 ([8 ] ).
This pole geometry constrained on real axis therefore induces an architectural bias in recurrent dynamics and delimits the modes that they can represent. To demonstrate this bias, we construct an experiment as shown in Figure 1 , using a synthesized token sequence x 1 : 200 x_{1:200} x 1 : 200 and target sequence y 1 : 200 y_{1:200} y 1 : 200 with a dimension four, where the true transfer function Z { y 1 : 200 } / Z { x 1 : 200 } \mathcal{Z}\{y_{1:200}\}/\mathcal{Z}\{x_{1:200}\} Z { y 1 : 200 } / Z { x 1 : 200 } has poles not constrained on real axis. We train single-layer MIRA, SDPA, Mamba-S6, and RWKV-7 models to perform next-token prediction for predicting the target token sequence using MSE (mean squared error) loss. The experiment demonstrates the provable failure of causal mode retrieval: models with poles constrained to the real axis fail to retrieve modes associated with complex-conjugate poles.
Figure 1. Provable Failure of Causal Mode Retrieval. We synthesize 4-dimensional continuous input tokens x 1 : 200 x_{1:200} x 1 : 200 and target tokens y 1 : 200 y_{1:200} y 1 : 200 of a length 200. The ground-truth transfer function contains poles that are not on the real axis. We use parameter-matched single-layer models trained to predict next-token y t + 1 y_{t+1} y t + 1 from input sequence x 1 : t x_{1:t} x 1 : t by using MSE (mean squared error) loss. Each model is optimized for 1000 steps using AdamW [23 ] with a learning rate of 10 − 2 10^{-2} 1 0 − 2 . Left: synthetic temporal signals of length 200. Middle: pole geometries of MIRA, Mamba-S6, RWKV-7, and SDPA. Right: next-token prediction error with logarithmic scale. The results show that MIRA admits complex poles and more accurately retrieves the temporal modes associated with complex poles. The provable failure signal synthesis is provided in Appendix § 8 .6.
To unify the recurrent architectures and eliminate the pole geometric bias, inspired by general adaptive IIR filters in the form of equation (1) , we present MIRA (Modal IIR Recurrent Architecture), pronounced “mee-ruh ”, a unified architectural family with linear time complexity for building LLMs with a highly parallel algebraic structure (see Figure 5 ). As illustrated in Figure 2 , for each block, MIRA realizes a higher-order IIR system through a lattice–ladder structure (Oppenheim & Schafer, [26 ] ), followed by a FFN. This structure enables the model to provably represent the feature modes associated with both real and complex-conjugate poles. Its recurrent dynamics inherently encode temporal order, eliminating the need for explicit positional encoding. The contributions are summarized as follows:
Figure 2. MIRA Block & Reference LLM. The diagram illustrates lattice circuit at stage k k k (top left), an order-K K K lattice module (bottom left), a MIRA block (top right), and a reference implementation of the MIRA LLM composed entirely of MIRA blocks (bottom right). In the order-K K K lattice module, a rank-one signal mixer forms the input representations through channel-wise signal mixing, the dynamical-modulation signal modulates the lattice–ladder dynamics, the lattice module implements the order-K K K lattice dynamics, and the ladder readout produces the output representations.
Figure 5. Performance of Dedicated CUDA Kernel. We compare MIRA module with parameter-matched baseline modules on an NVIDIA RTX A6000 GPU. Execution time: at a context length of 32K, MIRA completes a forward pass in 11.37 ms, yielding speedups of 4.13×, 1.32×, 2.15×, and 2.85× over MHA (Multi-Head Attention) with FlashAttention, Mamba (S6), RWKV-6, and RWKV-7, respectively (left). Throughput: At the same context length, MIRA reaches 8.36 million tokens per second, exceeding the throughput of the respective baselines by factors of 6.41×, 2.20×, 1.02×, and 1.28× (right).
A Unified Architectural Family. We introduce MIRA (Modal IIR Recurrent Architecture), a unified, positional-encoding-free, linear-time architectural family that realizes higher-order IIR dynamics through an adaptive lattice–ladder topology, enabling the representation of temporal modes associated with both real and complex-conjugate poles.
Dedicated CUDA Kernel. We show that the algebraic structure of the MIRA realization admits computational associativity despite its higher-order recurrent form. We exploit this associativity to parallelize state propagation in our dedicated CUDA kernel, admitting a minimal critical path of O ( T ) O(\sqrt{T}) O ( T ) where T T T is sequence length.
Experimental Validation. Controlled experiments on language corpora show that enabling complex poles improves language-modeling performance, while inference measurements with dedicated CUDA kernel show that the MIRA block achieves higher throughput than strong baselines. We further build and pretrain MIRA-S, a small-scale 0.14B-parameter LLM composed entirely of MIRA blocks, which achieves the highest next-token prediction accuracy and the lowest perplexity among strong baselines.
A Unified Parameterized Lattice–Ladder Realization
We treat token sequences in language modeling as the propagation of high-dimensional temporal signals. Since recurrent models admit a unified representation as IIR systems, we seek a unified IIR parameterization whose algebraic structure facilitates GPU parallelism without imposing a pole geometry bias. As illustrated in Figure 2 (left), the lattice–ladder structure [2 , 9 ] is a canonical realization form of general IIR systems, arising naturally from coupled wave propagation in modern physical systems such as photonic crystals and metawaveguides [41 ] . Intuitively, a lattice-ladder realization represents the propagation of mode-coupled input and readout signals in an IIR system: (i) forward signals (i.e., input signals) that represent input tokens and (ii) backward signals (i.e., readout signals) that carry both the temporal memories and token representations. The mode coupling between the input and readout signals enables a parameterized IIR-based recurrent system to represent modes without pole geometric bias. The algebraic structure of this realization enables associative composition along the temporal axis, thereby facilitating GPU parallelism.
Stable Recurrent Lattice Dynamics. Let x 1 : T x_{1:T} x 1 : T denote an input token representation sequence, where each token has dimension d d d . As illustrated in Figure 2 , we first normalize x 1 : T x_{1:T} x 1 : T using RMS-Norm (Root Mean Square Layer Normalization) [46 ] and project the representations into an expanded dimension d e > d d_e > d d e > d , allowing the lattice dynamics to operate in a higher-dimensional space
z t = RMSNorm ( x t ) , x ~ t = W i n z t , x t ∈ R d , W i n ∈ R d e × d , z_t = \operatorname{RMSNorm}(x_t), \qquad\widetilde{x}_t = W_{\mathrm{in}}z_t, \qquad x_t \in\mathbb{R}^{d}, \qquad W_{\mathrm{in}} \in\mathbb{R}^{d_e \times d}, z t = RMSNorm ( x t ) , x t = W in z t , x t ∈ R d , W in ∈ R d e × d ,
where W i n W_{\mathrm{in}} W in denotes the input projection matrix and d e / d d_e/d d e / d is referred to as expansion factor . Let U t ( k ) ∈ R d e × d m U_t^{(k)} \in\mathbb{R}^{d_e \times d_m} U t ( k ) ∈ R d e × d m denote the forward token signal and V t ( k ) ∈ R d e × d m V_t^{(k)} \in\mathbb{R}^{d_e \times d_m} V t ( k ) ∈ R d e × d m denote the backward state signal at lattice stage k k k , where t ∈ { 1 , … , T } t \in\{1,\ldots,T\} t ∈ { 1 , … , T } represents the token position and k ∈ { K , … , 0 } k \in\{K,\ldots,0\} k ∈ { K , … , 0 } indexes the lattice stage and d m d_m d m is referred to as per-channel memory size . We construct a generalized, stable, parameterized, matrix-valued dual-port lattice scattering dynamics as follows
( U t ( k − 1 ) V t ( k ) ) = A t ( k ) ( U t ( k ) V t − 1 ( k − 1 ) ) , A t ( k ) = r t ( k ) ⊙ R t ( k ) , r t ( k ) ∈ R d e , R t ( k ) = ( diag ( cos ( θ t ( k ) ) ) − diag ( sin ( θ t ( k ) ) ) diag ( sin ( θ t ( k ) ) ) diag ( cos ( θ t ( k ) ) ) ) , R t ( k ) ∈ R 2 d e × 2 d e , (2) \begin{aligned}
\begin{pmatrix} U_t^{(k-1)} \\ V_t^{(k)} \end{pmatrix}
&= A_t^{(k)} \begin{pmatrix} U_t^{(k)} \\ V_{t-1}^{(k-1)} \end{pmatrix}, \qquad A_t^{(k)} = r_t^{(k)} \odot R_t^{(k)}, \qquad r_t^{(k)} \in\mathbb{R}^{d_e},\\
R_t^{(k)}
&= \begin{pmatrix}
\operatorname{diag}\left(\cos\left(\theta_t^{(k)}\right)\right) & -\operatorname{diag}\left(\sin\left(\theta_t^{(k)}\right)\right)\\
\operatorname{diag}\left(\sin\left(\theta_t^{(k)}\right)\right) & \operatorname{diag}\left(\cos\left(\theta_t^{(k)}\right)\right)
\end{pmatrix}, \qquad R_t^{(k)} \in\mathbb{R}^{2d_e \times2d_e}, \tag*{(2)}
\end{aligned} ( U t ( k − 1 ) V t ( k ) ) R t ( k ) = A t ( k ) ( U t ( k ) V t − 1 ( k − 1 ) ) , A t ( k ) = r t ( k ) ⊙ R t ( k ) , r t ( k ) ∈ R d e , = diag ( cos ( θ t ( k ) ) ) diag ( sin ( θ t ( k ) ) ) − diag ( sin ( θ t ( k ) ) ) diag ( cos ( θ t ( k ) ) ) , R t ( k ) ∈ R 2 d e × 2 d e , (2)
under k = { K , … , 1 } k = \{K,\ldots,1\} k = { K , … , 1 } and with initial conditions
s t = SiLU ( W s z t + b s ) , U t ( K ) = x ~ t s t T , W s ∈ R d m × d , s_t = \operatorname{SiLU}(W_s z_t + b_s), \qquad U_t^{(K)} = \widetilde{x}_t s_t^{\mathsf{T}}, \qquad W_s \in\mathbb{R}^{d_m \times d}, s t = SiLU ( W s z t + b s ) , U t ( K ) = x t s t T , W s ∈ R d m × d ,
(rank-one signal mixer),
V t ( 0 ) = U t ( 0 ) , V 0 ( k ) = 0 , V_t^{(0)} = U_t^{(0)}, \qquad V_0^{(k)} = 0, V t ( 0 ) = U t ( 0 ) , V 0 ( k ) = 0 ,
(boundary conditions),
where operator ⊙ \odot ⊙ denotes the generalized element-wise product with broadcasting defined by r t ( k ) ⊙ R t ( k ) = ( I 2 ⊗ diag ( r t ( k ) ) ) R t ( k ) r_t^{(k)} \odot R_t^{(k)} = (I_2 \otimes\operatorname{diag}(r_t^{(k)}))R_t^{(k)} r t ( k ) ⊙ R t ( k ) = ( I 2 ⊗ diag ( r t ( k ) )) R t ( k ) , U t ( k ) U_t^{(k)} U t ( k ) is referred to as the forward state which encodes the representation of token t t t at lattice stage k k k , V t ( k ) V_t^{(k)} V t ( k ) is referred to as the backward state which summarizes the recurrent memory up to token t t t at lattice stage k k k , and A t ( k ) A_t^{(k)} A t ( k ) is referred to as the reflection coefficient matrix , which governs the forward-backward state transition. This IIR system is parameterized through
c t = SiLU ( W c z t + b c ) , W c ∈ R d r × d , b c ∈ R d r , c_t = \operatorname{SiLU}(W_c z_t + b_c), \qquad W_c \in\mathbb{R}^{d_r \times d}, \qquad b_c \in\mathbb{R}^{d_r}, c t = SiLU ( W c z t + b c ) , W c ∈ R d r × d , b c ∈ R d r ,
sin ( θ t ) = sech ( α t ) , cos ( θ t ) = tanh ( α t ) , α t = W α c t + b α , W α ∈ R K d e × d r , \sin(\theta_t) = \operatorname{sech}(\alpha_t), \qquad\cos(\theta_t) = \tanh(\alpha_t), \qquad\alpha_t = W_\alpha c_t + b_\alpha, \qquad W_\alpha\in\mathbb{R}^{K d_e \times d_r}, sin ( θ t ) = sech ( α t ) , cos ( θ t ) = tanh ( α t ) , α t = W α c t + b α , W α ∈ R K d e × d r ,
r t = 1 1 + β t 2 , β t = W β c t + b β , W β ∈ R K d e × d r , r_t = \frac{1}{1+\beta_t^2}, \qquad\beta_t = W_\beta c_t + b_\beta, \qquad W_\beta\in\mathbb{R}^{K d_e \times d_r}, r t = 1 + β t 2 1 , β t = W β c t + b β , W β ∈ R K d e × d r ,
where d r ≪ d d_r \ll d d r ≪ d introduces a low-rank state-write bottleneck that enables state writes on a low-dimensional manifold. We construct the rotation matrix R t ( k ) R_t^{(k)} R t ( k ) as a Cayley map ([3 ] ) parameterized by hyperbolic map (see Appendix § 8 .7). The states V 0 ( k ) V_0^{(k)} V 0 ( k ) are reset for every independent input sequence indicated by a special token ⟨ ∣ end-of-session ∣ ⟩ \langle| \text{end-of-session}|\rangle ⟨ ∣ end-of-session ∣ ⟩ . We refer to K K K , d r d_r d r , and d m d_m d m as the lattice order , state-write bottleneck size , and memory size , respectively. We further refer to H t = − 1 / log r t H_t = -1/\log r_t H t = − 1/ log r t as the characteristic horizon , which governs the decay timescale of the backward state mode V t V_t V t with discrete-time factor r t e i θ t r_t e^{i\theta_t} r t e i θ t , since the continuous-time ordinary differential equation (ODE) of the backward state evolution satisfies d V t d t = ( log r t + i θ t ) V t = ( − 1 H t + i θ t ) V t \frac{\mathrm{d}V_t}{\mathrm{d}t} = (\log r_t + i\theta_t)V_t = \left(-\frac{1}{H_t} + i\theta_t\right)V_t d t d V t = ( log r t + i θ t ) V t = ( − H t 1 + i θ t ) V t .
Representation Readout. Since the backward state V t ( k ) V_t^{(k)} V t ( k ) carries both the current representation of token t t t and the recurrent memory of preceding tokens, therefore the ladder readout aggregates backward states across the lattice stages using the input-conditioned ladder readout coefficient ρ t ( k ) ∈ R d e \rho_t^{(k)} \in\mathbb{R}^{d_e} ρ t ( k ) ∈ R d e , the learned state-read direction ν t ( k ) ∈ R d m \nu_t^{(k)} \in\mathbb{R}^{d_m} ν t ( k ) ∈ R d m , and the selective gate γ t ∈ R d e \gamma_t \in\mathbb{R}^{d_e} γ t ∈ R d e
y t = W o u t ( ( ∑ k = 0 K ρ t ( k ) ⊙ ( V t ( k ) ν t ( k ) ) ) ⊙ γ t ) , W o u t ∈ R d × d e , y_t = W_{\mathrm{out}}\left(\left(\sum_{k=0}^{K}\rho_t^{(k)} \odot\left(V_t^{(k)} \nu_t^{(k)}\right)\right)\odot\gamma_t\right), \qquad W_{\mathrm{out}} \in\mathbb{R}^{d\times d_e}, y t = W out ( ( k = 0 ∑ K ρ t ( k ) ⊙ ( V t ( k ) ν t ( k ) ) ) ⊙ γ t ) , W out ∈ R d × d e ,
where W o u t W_{\mathrm{out}} W out denotes the readout projection matrix. The readout coefficient ρ t \rho_t ρ t , state-read direction ν t \nu_t ν t , and readout gate γ t \gamma_t γ t are parameterized as
ρ t = W ρ c t + b ρ , W ρ ∈ R ( K + 1 ) d e × d r , b ρ ∈ R ( K + 1 ) d e , \rho_t = W_\rho c_t + b_\rho,\qquad W_\rho\in\mathbb{R}^{(K+1)d_e\times d_r},\qquad b_\rho\in\mathbb{R}^{(K+1)d_e}, ρ t = W ρ c t + b ρ , W ρ ∈ R ( K + 1 ) d e × d r , b ρ ∈ R ( K + 1 ) d e ,
ν t = W ν c t + b ν , W ν ∈ R ( K + 1 ) d m × d r , b ν ∈ R ( K + 1 ) d m , \nu_t = W_\nu c_t + b_\nu,\qquad W_\nu\in\mathbb{R}^{(K+1)d_m\times d_r},\qquad b_\nu\in\mathbb{R}^{(K+1)d_m}, ν t = W ν c t + b ν , W ν ∈ R ( K + 1 ) d m × d r , b ν ∈ R ( K + 1 ) d m ,
γ t = SiLU ( W γ z t + b γ ) , W γ ∈ R d e × d , b γ ∈ R d e . \gamma_t = \operatorname{SiLU}(W_\gamma z_t + b_\gamma),\qquad W_\gamma\in\mathbb{R}^{d_e\times d},\qquad b_\gamma\in\mathbb{R}^{d_e}. γ t = SiLU ( W γ z t + b γ ) , W γ ∈ R d e × d , b γ ∈ R d e .
Stability Condition. Remaining Schur stability of the recurrent dynamics requires all the eigenvalues of diag ( r t ( k ) ⊙ sin ( θ t ( k ) ) ) \operatorname{diag}(r_t^{(k)} \odot\sin(\theta_t^{(k)})) diag ( r t ( k ) ⊙ sin ( θ t ( k ) )) to have magnitude strictly smaller than 1 [35 , 6 , 26 ] . Our parameterization satisfies this condition almost surely under an absolutely continuous joint distribution of α t ( k ) \alpha_t^{(k)} α t ( k ) and β t ( k ) \beta_t^{(k)} β t ( k ) , since their corresponding entries vanish simultaneously only on a measure-zero set. The proof is provided in Appendix § 8 .10.
Jeffreys Initializer. The initialization of α t \alpha_t α t and β t \beta_t β t must ensure a non-nilpotent state transition
( U t ( k ) , V t ( k − 1 ) ) ↦ ( U t − 1 ( k − 1 ) , V t ( k ) ) \left(U_t^{(k)}, V_t^{(k-1)}\right) \mapsto\left(U_{t-1}^{(k-1)}, V_t^{(k)}\right) ( U t ( k ) , V t ( k − 1 ) ) ↦ ( U t − 1 ( k − 1 ) , V t ( k ) )
and meaningful characteristic horizons. Trivial initializations, such as small zero-centered uniform and normal initializers, degenerate the recurrent dynamics because the cross-stage magnitude of state transition decreases exponentially with K K K . When stage coupling vanishes or exact pole–zero cancellations occur, the McMillan degree [18 ] falls below K K K , degenerating the IIR dynamics into an FIR system. We therefore design the Jeffreys initializer described in Appendix § 8 .8, which sets the biases of α t \alpha_t α t and β t \beta_t β t to coupled pole pairs whose horizons are the quantiles of the Jeffreys prior [15 ] .
Algebraic Structure and Parallelism
Let
( k , t ) : ( U t ( k ) , V t − 1 ( k − 1 ) ) ⟼ ( U t − 1 ( k − 1 ) , V t ( k ) ) , k ∈ { K , … , 1 } , t ∈ { 1 , … , T } (k,t): \left(U_t^{(k)}, V_{t-1}^{(k-1)}\right) \longmapsto\left(U_{t-1}^{(k-1)}, V_t^{(k)}\right), \qquad k \in\{K,\ldots,1\}, \qquad t \in\{1,\ldots,T\} ( k , t ) : ( U t ( k ) , V t − 1 ( k − 1 ) ) ⟼ ( U t − 1 ( k − 1 ) , V t ( k ) ) , k ∈ { K , … , 1 } , t ∈ { 1 , … , T }
be the state transition given by equation (2) , as illustrated in Figure 3 . Directly using equation (2) for computing the dynamics up to token position t t t requires all previous states. To parallelize the computation on GPUs, we need to further explore its algebraic structure that allows parallelism.
Figure 3. Algebraic Structure of the Lattice Realization. Each node ( k , t ) (k,t) ( k , t ) represents the recursive state transition ( U t ( k ) , V t − 1 ( k − 1 ) ) ↦ ( U t ( k − 1 ) , V t ( k ) ) (U_t^{(k)}, V_{t-1}^{(k-1)}) \mapsto(U_t^{(k-1)}, V_t^{(k)}) ( U t ( k ) , V t − 1 ( k − 1 ) ) ↦ ( U t ( k − 1 ) , V t ( k ) ) at lattice stage k ∈ { K , … , 1 } k \in\{K,\ldots,1\} k ∈ { K , … , 1 } and token position t ∈ { 1 , … , T } t \in\{1,\ldots,T\} t ∈ { 1 , … , T } , with edges encoding dependencies on ( k + 1 , t ) (k+1,t) ( k + 1 , t ) and ( k − 1 , t − 1 ) (k-1,t-1) ( k − 1 , t − 1 ) .
Algebraic Associativity & State Interposition. Since U t ( k ) U_t^{(k)} U t ( k ) propagates only across lattice stages, while V t ( k ) V_t^{(k)} V t ( k ) carries the temporal memory up to token position t t t , we define the carried state as
V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m , V 0 = 0. \mathbf{V}_t = \left(V_t^{(0)}, \ldots, V_t^{(K-1)}\right)^{\mathrm{T}} \in\mathbb{R}^{K d_e \times d_m}, \qquad\mathbf{V}_0 = 0. V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m , V 0 = 0.
Because x ~ t \tilde{x}_t x ~ t and s t s_t s t depend only on x t x_t x t , we show that the complete cascade { ( k , t ) } k = K 1 \{(k,t)\}_{k=K}^{1} {( k , t ) } k = K 1 admits an affine operator
T t = ( Φ t ( α t ) , S t ( α t , x ~ t , s t ) ) , T t ( V ) = Φ t ( α t ) V + S t ( α t , x ~ t , s t ) , V t = T t ( V t − 1 ) , (3) \mathcal{T}_t = \left(\Phi_t(\alpha_t), S_t(\alpha_t,\tilde{x}_t,s_t)\right), \qquad\mathcal{T}_t(\mathbf{V}) = \Phi_t(\alpha_t)\mathbf{V} + S_t(\alpha_t,\tilde{x}_t,s_t), \qquad\mathbf{V}_t = \mathcal{T}_t(\mathbf{V}_{t-1}), \tag*{(3)} T t = ( Φ t ( α t ) , S t ( α t , x ~ t , s t ) ) , T t ( V ) = Φ t ( α t ) V + S t ( α t , x ~ t , s t ) , V t = T t ( V t − 1 ) , (3)
where Φ t ( α t ) ∈ R K d e × K d e \Phi_t(\alpha_t) \in\mathbb{R}^{K d_e \times K d_e} Φ t ( α t ) ∈ R K d e × K d e denotes the transition matrix and S t ( α t , x ~ t , s t ) ∈ R K d e × d m S_t(\alpha_t,\tilde{x}_t,s_t) \in\mathbb{R}^{K d_e \times d_m} S t ( α t , x ~ t , s t ) ∈ R K d e × d m denotes the input contribution independent of any V t ( k ) V_t^{(k)} V t ( k ) . For any t 1 < t 2 < t 3 t_1 < t_2 < t_3 t 1 < t 2 < t 3 , temporal composition of two affine operators is associative
( T t 3 ∘ T t 2 ) ∘ T t 1 = ( Φ t 3 Φ t 2 Φ t 1 , Φ t 3 Φ t 2 S t 1 + Φ t 3 S t 2 + S t 3 ) = T t 3 ∘ ( T t 2 ∘ T t 1 ) . (4) \left(\mathcal{T}_{t_3} \circ\mathcal{T}_{t_2}\right) \circ\mathcal{T}_{t_1} = \left(\Phi_{t_3}\Phi_{t_2}\Phi_{t_1}, \Phi_{t_3}\Phi_{t_2}S_{t_1} + \Phi_{t_3}S_{t_2} + S_{t_3}\right) = \mathcal{T}_{t_3} \circ\left(\mathcal{T}_{t_2} \circ\mathcal{T}_{t_1}\right). \tag*{(4)} ( T t 3 ∘ T t 2 ) ∘ T t 1 = ( Φ t 3 Φ t 2 Φ t 1 , Φ t 3 Φ t 2 S t 1 + Φ t 3 S t 2 + S t 3 ) = T t 3 ∘ ( T t 2 ∘ T t 1 ) . (4)
Therefore, for any $1 \le s < t \le T$, this algebraic structure interposes the preceding memory and the segment dynamics within the carried state
V t = Φ s → t V s ⏟ preceding memory up to token s + S s → t ⏟ segment dynamics from V s = 0 , (5) \mathbf{V}_t =
\underbrace{\Phi_{s\to t}\mathbf{V}_s}_{\text{preceding memory up to token }s}
+
\underbrace{S_{s\to t}}_{\text{segment dynamics from }\mathbf{V}_s=0}, \tag*{(5)} V t = preceding memory up to token s Φ s → t V s + segment dynamics from V s = 0 S s → t , (5)
where ( Φ s → t , S s → t ) (\Phi_{s\to t}, S_{s\to t}) ( Φ s → t , S s → t ) composes T s + 1 , … , T t \mathcal{T}_{s+1}, \ldots, \mathcal{T}_t T s + 1 , … , T t : the transition Φ s → t \Phi_{s\to t} Φ s → t transports the preceding memory V s \mathbf{V}_s V s accumulated over tokens 1 , … , s 1,\ldots,s 1 , … , s , whereas the input contribution S s → t S_{s\to t} S s → t is accumulated over the segment alone from the zero entry state V s = 0 \mathbf{V}_s = 0 V s = 0 , and is therefore independent of all tokens preceding s s s . The proof and further details are provided in Appendix § 8 .11.
Critical Parallel Path. Theoretically, this algebraic structure enables chunkwise parallel state propagation along with token axis 1 → T 1 \to T 1 → T and admits a critical path 2 L + T / L 2L + T/L 2 L + T / L , where L L L is chunk size of token sequence. A minimal critical path of O ( T ) O(\sqrt{T}) O ( T ) is obtained by choosing the chunk size as L ≈ T / 2 L \approx\sqrt{T}/2 L ≈ T /2 .
Dedicated CUDA Kernel. We realize this algebraic structure as a dedicated CUDA kernel, such that the computation within the MIRA module remains on-chip. Exploiting associativity in equation (4) and state interposition in equation (5), the token axis is partitioned into N C = ⌈ T / L ⌉ N_C = \lceil T/L\rceil N C = ⌈ T / L ⌉ chunks of length L L L , and three phases are mapped onto thread blocks, each processing one chunk across adjacent channels with the carried state held in registers: (i) chunk summarization evaluates every chunk concurrently from the zero carried state, yielding its pair ( Φ s → t , S s → t ) (\Phi_{s\to t}, S_{s\to t}) ( Φ s → t , S s → t ) ; (ii) associative composition applies equation (5) at the chunk boundaries alone, recovering every chunk-entry state; and (iii) chunk replay restores the interior states concurrently and produces the gated ladder readout. The details are provided in Appendix § 8 .12.
Experiments
We build a small-scale model MIRA-S for benchmarking against strong baselines of comparable size, comprising 12 layers with model width d = 768 d = 768 d = 768 , expansion width d e = 1536 d_e = 1536 d e = 1536 , memory dimension d m = 16 d_m = 16 d m = 16 , state-write bottleneck dimension d r = d / 16 d_r = d/16 d r = d /16 , lattice order K = 2 K = 2 K = 2 , and FFN width 3072. The model has 0.14B parameters and a state-to-parameter ratio of 4.076 ‰. We also build an extra-small-scale model MIRA-XS for architectural ablation experiments, comprising 10 layers with model width d = 512 d = 512 d = 512 , expansion width d e = 1024 d_e = 1024 d e = 1024 , memory dimension d m = 16 d_m = 16 d m = 16 , write bottleneck dimension d r = d / 16 d_r = d/16 d r = d /16 , lattice order K = 2 K = 2 K = 2 , and FFN width 2048. The model has 65M parameters and a state-to-parameter ratio of 9.760 ‰. For both MIRA-S and MIRA-XS, we initialize the characteristic horizon of the Jeffreys initializer to range from 10 to 2000 tokens across all layers and from 1 to 128 tokens in the first layer.
Training Protocol. We use the FineWeb-Edu dataset (text corpus) ([28 ] ) to train a Byte-Pair Encoding (BPE) ([36 ] ) tokenizer and yield a tokenizer with a vocabulary of 50,259 tokens. The tokenizer reserves three special tokens: <|end-of-session|>, <|unknown|> and <|pad|>. We pretrain each model with a weight-update budget corresponding to nine billion tokens, following the Chinchilla scaling rule ([13 ] ), with a fixed context length of 512 tokens. For the next-token prediction objective, we weight each sequence-level cross-entropy loss by its number of valid target tokens, thereby averaging the loss uniformly over all predicted tokens ([20 ] ). To reduce the GPU memory footprint, we use chunked loss ([22 ] ) with a chunk size of 8,192 and mixed-precision training, where the model weights and optimizer states are stored in 32-bit floating point (FP32), while activations are stored in brain floating point (BF16) ((Kalamekar et al., 2019)). We optimize the model using AdamW ([23 ] ) with β 1 = 0.9 \beta_1 = 0.9 β 1 = 0.9 , β 2 = 0.999 \beta_2 = 0.999 β 2 = 0.999 , weight decay 10 − 5 10^{-5} 1 0 − 5 , and a numerical stability constant of ϵ = 10 − 8 \epsilon= 10^{-8} ϵ = 1 0 − 8 . We use a peak learning rate of 2 × 10 − 4 2 \times10^{-4} 2 × 1 0 − 4 , and apply a cosine learning-rate scheduler with a final learning rate of 2 × 10 − 5 2 \times10^{-5} 2 × 1 0 − 5 and a linear learning-rate warmup of 500 steps. Before each weight update, we apply gradient clipping with a maximum norm of 1.0.
Architectural Ablation. For MIRA-XS, we independently vary the lattice order K ∈ { 1 , 2 , 4 , 8 } K \in\{1, 2, 4, 8\} K ∈ { 1 , 2 , 4 , 8 } while fixing d r = d / 16 d_r = d/16 d r = d /16 and d m = 16 d_m = 16 d m = 16 ; vary the write bottleneck size d r ∈ { d / 64 , d / 32 , d / 16 , d / 8 } d_r \in\{d/64, d/32, d/16, d/8\} d r ∈ { d /64 , d /32 , d /16 , d /8 } while fixing K = 2 K = 2 K = 2 and d m = 16 d_m = 16 d m = 16 ; and vary the memory size d m ∈ { 8 , 16 , 32 , 64 } d_m \in\{8, 16, 32, 64\} d m ∈ { 8 , 16 , 32 , 64 } while fixing K = 2 K = 2 K = 2 and d r = d / 16 d_r = d/16 d r = d /16 . We match model sizes by varying only the model width d d d and pretrain each model for 10,000 steps on FineWeb-Edu . Figure 4 shows that models admitting complex-conjugate poles (K > 1 K > 1 K > 1 ) achieve lower perplexity than the model with real poles (K = 1 K = 1 K = 1 ), while d r = d / 8 d_r = d/8 d r = d /8 yields the lowest perplexity among the evaluated state-write bottleneck sizes. Perplexity generally decreases as d m d_m d m increases, reaching its lowest value at d m = 64 d_m = 64 d m = 64 . Since the MIRA module has parameter size O ( K ( d e + d m ) d r + d e + d m + d r ) \mathcal{O}(K(d_e + d_m)d_r + d_e + d_m + d_r) O ( K ( d e + d m ) d r + d e + d m + d r ) , higher-order lattice orders, wider state-write bottlenecks, and larger memory sizes incur greater computational costs and memory footprints, we choose K = 2 K = 2 K = 2 , d r = d / 16 d_r = d/16 d r = d /16 , and d m = 16 d_m = 16 d m = 16 as the default configuration scheme of MIRA, balancing performance and computational efficiency. Full experiments are presented in Appendix A.1.
Figure 4. Effects of Lattice Order K K K , State-Write Bottleneck Size d r d_r d r , and Memory Size d m d_m d m . Using MIRA-XS (65M), we independently vary the lattice order K ∈ { 1 , 2 , 4 , 8 } K \in\{1, 2, 4, 8\} K ∈ { 1 , 2 , 4 , 8 } , state-write bottleneck size d r ∈ { d / 64 , d / 32 , d / 16 , d / 8 } d_r \in\{d/64, d/32, d/16, d/8\} d r ∈ { d /64 , d /32 , d /16 , d /8 } , and memory size d m ∈ { 8 , 16 , 32 , 64 } d_m \in\{8, 16, 32, 64\} d m ∈ { 8 , 16 , 32 , 64 } . We match model sizes by varying only the model width d d d and pretrain each model for 10,000 steps on FineWeb-Edu using AdamW . The results show that models admitting complex-conjugate poles (K > 1 K > 1 K > 1 ) achieve lower perplexity than the model with real poles (K = 1 K = 1 K = 1 ). Among the evaluated state-write bottleneck sizes, d r = d / 8 d_r = d/8 d r = d /8 yields the lowest perplexity. Perplexity generally decreases as d m d_m d m increases, reaching its lowest value at d m = 64 d_m = 64 d m = 64 .
CUDA Kernel Performance. We benchmark the dedicated MIRA CUDA kernel against strong GPU-optimized baselines whose CUDA kernels are available, including MHA with FlashAttention ([7 ] ), Mamba (S6), RWKV-6, and RWKV-7, using parameter-matched models on an NVIDIA RTX A6000 GPU. As shown in Figure 5 , MIRA consistently achieves lower execution time and higher throughput across the evaluated context lengths. At a context length of 32,768, MIRA completes a forward pass in 11.37 ms, corresponding to speedups of 4.13 × 4.13 \times 4.13 × , 1.32 × 1.32 \times 1.32 × , 2.15 × 2.15 \times 2.15 × , and 2.85 × 2.85 \times 2.85 × over MHA with FlashAttention, Mamba (S6), RWKV-6, and RWKV-7, respectively. At the same context length, MIRA achieves a throughput of 8.36 million tokens per second, exceeding the respective baselines by 6.41 × 6.41 \times 6.41 × , 2.20 × 2.20 \times 2.20 × , 1.02 × 1.02 \times 1.02 × , and 1.28 × 1.28 \times 1.28 × . Compared with the baselines, MIRA exposes parallelism along with token chunks, expanded channels, and memory components, while its fixed number of lattice stages is unrolled at compile time.
Pretraining Benchmark. We pretrain MIRA-S on FineWeb-Edu and compare MIRA-S with strong recurrent language model baselines, including Mamba-v1 (S6), Mamba-v2 (SSD), RWKV-6, and RWKV-7, with MHA as a reference baseline. The Transformer-based MHA baseline uses RoPE (Rotary Position Embedding) ([37 ] ) for positional encoding. For a fair comparison, we adjust the model width of each architecture to maintain the approximately identical parameter size. On the training dataset, MIRA-S consistently achieves lower perplexity and higher next-token prediction accuracy than the strong baselines throughout pretraining. Table 2 presents the validation results, with detailed results reported in Appendix § 8 .§ 1 . Additional experiments, including evaluation on the MMLU (Massive Multitask Language Understanding) test set across all 57 subjects ([12 a] ), evaluation on the AI2 Reasoning Challenge (ARC) ([5 ] ), and memory-state projection, are presented in Appendix § 8 .§ 1 .
Table 2. Benchmark Performance. Validation loss, perplexity (PPL) and next-token accuracy at context lengths of 512 and 32,768 tokens. The training context window is 512 tokens. FineWeb-Edu is scored on the held-out last 5% of the corpus; WikiText-103 and HellaSwag on their test splits. State denotes the ratio of the total recurrent state size across all layers to the model parameter count, expressed in parts per thousand.
Context Window Generalization. We evaluate context-length generalization for MIRA, Mamba-1 (S6), Mamba-2 (SSD), RWKV-6, and RWKV-7, with MHA as a reference, on three corpora: a held-out set of FineWeb-Edu (230 documents, 263,837 tokens), WikiText-103 ([24 ] ), and HellaSwag ([45 ] ). Besides MHA without positional-encoding extrapolation (legend “MHA”), we also apply YaRN ([30 ] ) to MHA beyond the training context length, with legend “MHA (YaRN)”. Figure 6 reports perplexity for context lengths from 256 to 32,768 tokens, with a fixed training context of 512 tokens. Throughout the evaluation, MIRA attains the lowest perplexity among the strong recurrent baselines and matches or improves on MHA. Full experiments are presented in Appendix § 8 .§ 1 .
Figure 6. Context-Window Generalization. We evaluate the context-window generalization for the pretrained MIRA on a holdout set of FineWeb-Edu , WikiText-103 , and HellaSwag , respectively. The dotted vertical line marks the training context length. MIRA attains the lowest perplexity among the recurrent baselines and matches or improves on the MHA reference.
Conclusions
We present MIRA, a recurrent, linear-time architectural family that eliminates the pole-geometry bias. MIRA unifies recurrent architectures and removes the pole-geometry bias through lattice–ladder realizations of higher-order IIR systems. The lattice–ladder parameterization admits chunk-wise associativity, enabling efficient GPU parallelism. We implement a dedicated CUDA kernel by leveraging this algebraic structure. Language modeling experiments demonstrate that MIRA outperforms strong recurrent language model baselines and generalizes beyond the training context without explicit positional encoding. These results establish MIRA as a promising direction for efficient LLMs.
AI Use Statement
In this work, we used generative AI tools for: polishing writing drafted by the human authors; checking for typographical and grammatical errors; refining wording choices; partially assisting with the development of experimental code; assisting human mathematicians in verifying and normalizing proofs (e.g., standardizing notations); and retrieving related literature. We have not used generative AI tools for drafting the manuscript, fully deriving proofs without the supervision of the human mathematician (the first author), or developing the theoretical model, retrieving bibliography, and the rest of the required disclosure tasks are not applicable to this work. We have reviewed all AI-assisted work. For example, we carefully reviewed LLM-polished sentences; verified LLM-normalized proofs through numerical experiments, symbolic algebra, and independent examination by human mathematicians; and manually verified LLM-aided literature retrieval by consulting the ACM Digital Library or the literature’s original publication venues, such as OpenReview , and having human experts read the retrieved works. We take responsibility for the final content of this work, including text, claims or artifacts produced with the aid of generative AI.
Acknowledgments
This research was financially supported in part by Taighde Éireann – Research Ireland under Grant No. 18/CRT/6223, and by the J.E. Cairnes School of Business & Economics, University of Galway, Ireland. It was also supported in part by computational resources and services provided by Calcul Québec (calculquebec.ca ) and the Digital Research Alliance of Canada (alliancecan.ca ). Partial computational support was also provided by Taighde Éireann – Research Ireland under Grant No. SFI/12/RC/2289_P2 and the Insight Research Ireland Centre for Data Analytics. The authors gratefully acknowledge Prof. Karyn Morrissey of the J.E. Cairnes School of Business & Economics, University of Galway, Ireland, for the support. For the purpose of open access, the author has applied a CC BY public copyright licence to any Author Accepted Manuscript version arising from this submission.
Appendix
Additional Experimental Results
Pretraining Dynamics (Accuracy, Loss, and Perplexity)
Figure 7. Dynamics of Pretraining Benchmark. We implement a small-scale reference LLM composed entirely of MIRA blocks, denoted as MIRA-S. Pretraining results show that MIRA-S achieves the lowest perplexity among strong recurrent language model baselines and Transformer-based MHA, while attaining higher token-prediction accuracy than the recurrent baselines and comparable token-prediction accuracy to MHA.
Figure 8. Final-Stage Dynamics of the Pretraining Benchmark. Training loss over the final stage of pretraining for MIRA-S and the baseline models.
Zero-Shot & Few-Shot Prompting
Zero-Shot & Few-Shot Prompting. We evaluate the pretrained LLMs on the full MMLU (Massive Multitask Language Understanding) test set across all 57 subjects [12 a] using zero-shot and 5-shot prompting. Zero-shot prompts contain the test question and its answer choices, whereas five-shot prompts additionally include five answered examples from the corresponding subject’s development split. We select the answer choice with the highest predicted probability and report overall test accuracy without updating model parameters. For prompts exceeding the training context window of the baseline Transformer, we apply YaRN [30 ] for extrapolating the positional embeddings.
Figure 9. Zero-Shot & Few-Shot Prompting.
ARC Reasoning
ARC Reasoning. We evaluate the pretrained LLMs on the AI2 Reasoning Challenge (ARC) [5 ] , a benchmark of grade-school science questions with three to five answer choices, divided into an Easy set and a Challenge set, the latter containing the questions that both a retrieval-based and a word co-occurrence baseline answer incorrectly; we use the full test sets of 2,376 Easy and 1,172 Challenge questions, of which 3,530 out of 3,548 have four answer choices. Zero-shot prompts consist of the test question in the form
Question: . . . Answer:
whereas 25-shot prompts additionally precede the test question with 25 answered examples in the same form, taken in order from the training split of the same set. We score each answer choice by the sum of the log-probabilities that the model assigns to the tokens of that choice conditioned on the prompt, divided by the number of characters in the choice so that longer choices are not penalized, select the answer choice with the highest normalized score, and report the resulting length-normalized test accuracy in Figure 10 .
Figure 10. ARC Reasoning with Zero-Shot & Few-Shot Prompting.
Context-window generalization experiments
Context Window Generalization. We evaluate context-length generalization for MIRA, Mamba-1 (S6), Mamba-2 (SSD), RWKV-6, and RWKV-7, with MHA as a reference, on three corpora: a held-out set of FineWeb-Edu (230 documents, 263,837 tokens), WikiText-103 ([24 ] ), and HellaSwag ([45 ] ). Besides MHA without positional-encoding extrapolation (legend “MHA”), we also apply YaRN ([30 ] ) to MHA beyond the training context length, with legend “MHA (YaRN)”. Figure 6 reports perplexity for context lengths from 256 to 32,768 tokens, with a fixed training context of 512 tokens. Throughout the evaluation, MIRA attains the lowest perplexity among the strong recurrent baselines and matches or improves on MHA.
Figure 11. (a) Loss. (b) Perplexity. (c) Token accuracy. Context-window generalization experiments.
Extra context-window generalization experiments. We further evaluate the pretrained MIRA-S on sequences extending beyond their training context windows to assess their ability to generalize to longer contexts, reporting results on held-out FineWeb-Edu [28 ] , WikiText-103 [24 ] , and HellaSwag [45 ] . We use four tasks: needle-in-a-haystack retrieval of a single fact embedded in background text [19 ] , RULER-style multi-key retrieval with distractors [14 ] , multi-query associative recall (MQAR) of multiple key–value associations queried in a different order [1 ] , and copying of an earlier text span [16 ] . We vary the evaluation context length while keeping model parameters fixed and report token accuracy on the retrieved answers or copied continuations.
Figure 12. (a) Needle-in-a-haystack retrieval. (b) RULER-style multi-key retrieval. (c) Multi-query associative recall. (d) Copying. Extra context-window generalization experiments.
Profiling dynamics
Profiling dynamics. We profile MIRA-S throughout training to track the per-layer evolution of the rotation angle θ t ( k c ) \theta_t^{(kc)} θ t ( k c ) of Cayley matrix R t ( k c ) R_t^{(kc)} R t ( k c ) , radius r t ( k c ) r_t^{(kc)} r t ( k c ) , and characteristic horizon H t ( k c ) = − 1 / ln r t ( k c ) H_t^{(kc)} = -1/\ln r_t^{(kc)} H t ( k c ) = − 1/ ln r t ( k c ) , where t t t indexes tokens, k k k indexes lattice stages, and c c c indexes channels. At each profiling step, we compute these quantities from the token-dependent coefficients and report their 10-th, 50-th, and 90-th percentiles within each layer. We additionally compute the poles of the assembled lattice transition matrix for each token and channel, reporting the fraction with nonzero imaginary parts in the rotation-angle panel and the median pole modulus in the radius panel.
Figure 13. Profiling rotation-angle dynamics (θ t \theta_t θ t ).
Figure 14. Profiling pole-radius dynamics (r t r_t r t ).
Figure 15. Characteristic-horizon dynamics (H t H_t H t ).
Initializer Ablation
Initializer Ablation. We ablate the initialization of the coefficient projection, namely the weights W α W_\alpha W α , W β W_\beta W β , W ρ W_\rho W ρ , W ν W_\nu W ν and the biases b α b_\alpha b α , b β b_\beta b β , b ρ b_\rho b ρ , b ν b_\nu b ν , on MIRA-XS with K = 2 K = 2 K = 2 , d r = 32 d_r = 32 d r = 32 , d m = 16 d_m = 16 d m = 16 and d = 528 d = 528 d = 528 , where every other parameter is initialized identically, and train each variant for 10,000 steps on The Stack and on FineWeb-Edu , reporting held-out perplexity and token accuracy, with each bar labelled in the legend by the name of its initializer. Throughout, σ = ( K + 1 ) − 1 / 4 / d r \sigma= (K + 1)^{-1/4}/\sqrt{d_r} σ = ( K + 1 ) − 1/4 / d r .
W W W uniform w/ b jeffreys is our default: the d e d_e d e characteristic horizons H c = 1 / λ c H_c = 1/\lambda_c H c = 1/ λ c of a layer are the quantiles ( c − 1 2 ) / d e (c - \frac{1}{2})/d_e ( c − 2 1 ) / d e of the Jeffreys prior p ( log λ ) ∝ I ( λ ) p(\log\lambda) \propto\sqrt{I(\lambda)} p ( log λ ) ∝ I ( λ ) on [ 1 / H max , 1 / H min ] [1/H_{\max},1/H_{\min}] [ 1/ H m a x , 1/ H m i n ] , with I ( λ ) = ∑ t = 1 256 t e − 2 λ t I(\lambda) = \sum_{t=1}^{256} t e^{-2\lambda t} I ( λ ) = ∑ t = 1 256 t e − 2 λ t the Fisher information of the decay rate λ \lambda λ and [ H min , H max ] = [ 1 , 1000 ] [H_{\min}, H_{\max}] = [1,1000] [ H m i n , H m a x ] = [ 1 , 1000 ] ([ 1 , 128 ] [1,128] [ 1 , 128 ] in the first layer), assigned to channels by a random permutation; channel c c c starts from the pole pair e − 1 / H c e ± i ω c e^{-1/H_c}e^{\pm i\omega_c} e − 1/ H c e ± i ω c with ω c = 2 π / P c \omega_c = 2\pi/P_c ω c = 2 π / P c , P c P_c P c cycling through 5, 7, 11, 17, 23, 31, 43, 61, and ω c = min ( 2 π / P c , 2 / H c ) \omega_c = \min(2\pi/P_c,2/H_c) ω c = min ( 2 π / P c , 2/ H c ) when H c ≥ 100 H_c \ge100 H c ≥ 100 ; the step-down recursion converts its denominator 1 − 2 e − 1 / H c cos ( ω c ) z − 1 + e − 2 / H c z − 2 1 - 2e^{-1/H_c}\cos(\omega_c)z^{-1} + e^{-2/H_c}z^{-2} 1 − 2 e − 1/ H c cos ( ω c ) z − 1 + e − 2/ H c z − 2 into reflection coefficients κ ( k ) \kappa^{(k)} κ ( k ) , realized as r ( k ) = 1 − 2 − 13 ( 1 − ∣ κ ( k ) ∣ ) r^{(k)} = 1 - 2^{-13}(1 - |\kappa^{(k)}|) r ( k ) = 1 − 2 − 13 ( 1 − ∣ κ ( k ) ∣ ) and sin ( θ ( k ) ) / r ( k ) = κ ( k ) / r ( k ) \sin(\theta^{(k)})/r^{(k)} = \kappa^{(k)}/r^{(k)} sin ( θ ( k ) ) / r ( k ) = κ ( k ) / r ( k ) and inverted through the radius and rotation maps into b α b_\alpha b α and b β b_\beta b β ; every weight is drawn from U ( − 0.02 3 , 0.02 3 ) U(-0.02\sqrt{3},0.02\sqrt{3}) U ( − 0.02 3 , 0.02 3 ) , and b ρ b_\rho b ρ , b ν b_\nu b ν take a random sign and a magnitude uniform in [ σ / 4 , σ ] [\sigma/4,\sigma] [ σ /4 , σ ] .
W , b W,b W , b pytorch-uniform resets the coefficient projection to the PyTorch default of a linear layer, W , b ∼ U ( − 1 / d r , 1 / d r ) W,b \sim U(-1/\sqrt{d_r},1/\sqrt{d_r}) W , b ∼ U ( − 1/ d r , 1/ d r ) , which removes any structure from the initial poles.
W , b W,b W , b pytorch-normal draws W , b ∼ N ( 0 , 1 / d r ) W,b \sim\mathcal{N}(0,1/d_r) W , b ∼ N ( 0 , 1/ d r ) , which likewise removes any structure from the initial poles.
W W W jeffreys w/ b uniform is the control for placing the Jeffreys poles in the biases: it draws b α , b β ∼ U ( − 1 / d r , 1 / d r ) b_\alpha,b_\beta\sim U(-1/\sqrt{d_r},1/\sqrt{d_r}) b α , b β ∼ U ( − 1/ d r , 1/ d r ) and sets every entry of row i i i of W α , W β W_\alpha,W_\beta W α , W β to ( b i ∗ − b i ) / ∑ j = 1 d r E [ c t , j ] (b_i^* - b_i)/\sum_{j=1}^{d_r}\mathbb{E}[c_{t,j}] ( b i ∗ − b i ) / ∑ j = 1 d r E [ c t , j ] , where b i ∗ b_i^* b i ∗ is the bias of that row under the default and c t , j c_{t,j} c t , j is the j j j -th entry of the control c t c_t c t , with the normalized input taken as standard normal; the initial poles therefore equal those of the default on average over tokens, but are carried by the weights rather than the biases; W ρ W_\rho W ρ , W ν W_\nu W ν , b ρ b_\rho b ρ , b ν b_\nu b ν are those of the default.
W W W jeffreys w/ b normal is the same control with b α , b β ∼ N ( 0 , 1 / d r ) b_\alpha,b_\beta\sim\mathcal{N}(0,1/d_r) b α , b β ∼ N ( 0 , 1/ d r ) .
W W W normal w/ b jeffreys keeps the biases of the default and draws the weights from N ( 0 , 0.02 2 ) \mathcal{N}(0,0.02^2) N ( 0 , 0.0 2 2 ) , of the same standard deviation.
W uniform w/ b nested jeffreys assigns one Jeffreys horizon per pole pair, pair m m m at the quantile shifted by the van der Corput value ϕ m = 0 , 1 2 , 1 4 , … \phi_m = 0, \frac{1}{2}, \frac{1}{4}, \ldots ϕ m = 0 , 2 1 , 4 1 , … , and scales W ρ W_\rho W ρ , W ν W_\nu W ν by ( 3 / ( K + 1 ) ) 1 / 4 (3/(K+1))^{1/4} ( 3/ ( K + 1 ) ) 1/4 , which makes it identical to the default at K = 2 K = 2 K = 2 .
uniform horizon w/ fixed angles draws H c ∼ U ( H min , H max ) H_c \sim\mathcal{U}(H_{\min}, H_{\max}) H c ∼ U ( H m i n , H m a x ) and the fixed angle ω c = π / 4 \omega_c = \pi/4 ω c = π /4 , obtains b α b_\alpha b α and b β b_\beta b β by the same recursion, draws each entry of a row of W α W_\alpha W α , W β W_\beta W β with a random sign and a magnitude uniform in [ 1 4 , 1 ] ⋅ min ( ∣ b ∣ / ( 4 d r ) , σ ) [\frac{1}{4}, 1] \cdot\min(|b|/(4\sqrt{d_r}), \sigma) [ 4 1 , 1 ] ⋅ min ( ∣ b ∣/ ( 4 d r ) , σ ) for the bias b b b of that row, and draws W ρ W_\rho W ρ , W ν W_\nu W ν , b ρ b_\rho b ρ , b ν b_\nu b ν with a random sign and a magnitude uniform in [ σ / 4 , σ ] [\sigma/4, \sigma] [ σ /4 , σ ] .
uniform horizon w/ fixed angles, right half-plane places every pole in the right half-plane, the real pole of odd orders at + e − 1 / H c +e^{-1/H_c} + e − 1/ H c and the angles taken from a second table, and coincides with uniform horizon w/ fixed angles at K = 2 K = 2 K = 2 .
α , β \alpha, \beta α , β uniform draws W α W_\alpha W α , W β W_\beta W β , b α b_\alpha b α , b β b_\beta b β from U ( − 1 / d r , 1 / d r ) \mathcal{U}(-1/\sqrt{d_r}, 1/\sqrt{d_r}) U ( − 1/ d r , 1/ d r ) , maps the drawn biases to the poles they define under sin ( θ ) = ( 1 − b α 2 ) / ( 1 + b α 2 ) \sin(\theta) = (1 - b_\alpha^2)/(1 + b_\alpha^2) sin ( θ ) = ( 1 − b α 2 ) / ( 1 + b α 2 ) and r = 1 / ( 1 + b β 2 ) r = 1/(1 + b_\beta^2) r = 1/ ( 1 + b β 2 ) , and initializes W ρ W_\rho W ρ , W ν W_\nu W ν , b ρ b_\rho b ρ , b ν b_\nu b ν as uniform horizon w/ fixed angles does.
Figure 16. Initializer ablation experiment. The charts are labelled “The Stack” and “FineWeb-Edu”, with y-axis “Perplexity”. The legend entries are “W, b pytorch-uniform”, “W, b pytorch-normal”, “W jeffreys w/ b uniform”, “W jeffreys w/ b normal”, “W normal w/ b jeffreys”, “W uniform w/ b jeffreys”, “W uniform w/ b nested jeffreys”, “uniform horizon w/ fixed angles”, “uniform horizon w/ fixed angles, right half-plane”, and “α, β uniform”.
Visualizing memory-state projection
Visualizing memory-state projection. To examine what the recurrent state of MIRA-S retains about a document, we treat each of the 14,042 questions of the MMLU test set ([12 a] ), formatted as its zero-shot prompt and terminated by the end-of-document token <|end-of-session|>, as one document and feed it to the pretrained MIRA-S from a zero initial state. The state V T ∈ R K d e × d m V_T \in\mathbb{R}^{K_{de} \times d_m} V T ∈ R K d e × d m of the last layer at <|end-of-session|>, the final token T T T of the document, flattened into a vector of K d e d m K_{de}d_m K d e d m entries, serves as the document embedding, and the subject of the question, one of the 57 MMLU subjects, serves as its label. The embeddings are projected onto their first 50 principal components and mapped to two dimensions with t-SNE (van der Maaten & Hinton, [39 ] ) at perplexity 30. Figure 17 shows the resulting embedding, colored by subject. Figure 18 shows the corresponding projection of GPT-2’s last-layer hidden states for reference. This suggests that MIRA has the potential to extract more discriminative embeddings.
Figure 17. Visualizing memory-state projection.
Figure 18. Visualizing the projection of GPT-2’s last-layer hidden states for reference.
BPE Tokenizer
Python BPE versus C++ BPE. Our byte-level BPE tokenizer has two implementations, one in Python and one in C++17 that depends on nothing beyond the C++ standard library, and the C++ implementation is the default. Figure 19 shows the benchmark on WikiText-103.
Figure 19. BPE Tokenizer benchmark.
Modulus & Argument Maps
Modulus & Argument Maps. Each lattice stage places its pole at modulus r t ∈ ( 0 , 1 ) r_t \in(0,1) r t ∈ ( 0 , 1 ) and argument θ t \theta_t θ t , where t t t indexes the token; r t r_t r t is produced from the control β t ∈ R \beta_t \in\mathbb{R} β t ∈ R by a modulus map and θ t \theta_t θ t from the control α t ∈ R \alpha_t \in\mathbb{R} α t ∈ R by an argument map. We compare the following modulus maps:
Cauchy (default): r t = 1 1 + β t 2 r_t = \frac{1}{1+\beta_t^2} r t = 1 + β t 2 1 ;
Gaussian : r t = e − β t 2 r_t = e^{-\beta_t^2} r t = e − β t 2 ;
exp-exp : r t = e − e β t r_t = e^{-e^{\beta_t}} r t = e − e β t ;
exp-softplus : r t = e − softplus ( β t ) r_t = e^{-\operatorname{softplus}(\beta_t)} r t = e − softplus ( β t ) , where softplus ( β t ) = log ( 1 + e β t ) \operatorname{softplus}(\beta_t) = \log(1+e^{\beta_t}) softplus ( β t ) = log ( 1 + e β t ) ;
and the following argument maps:
hyperbolic (default): sin θ t = sech α t \sin\theta_t = \operatorname{sech}\alpha_t sin θ t = sech α t , cos θ t = tanh α t \cos\theta_t = \tanh\alpha_t cos θ t = tanh α t ;
Möbius : sin θ t = 1 − α t 2 1 + α t 2 \sin\theta_t = \frac{1-\alpha_t^2}{1+\alpha_t^2} sin θ t = 1 + α t 2 1 − α t 2 , cos θ t = 2 α t 1 + α t 2 \cos\theta_t = \frac{2\alpha_t}{1+\alpha_t^2} cos θ t = 1 + α t 2 2 α t ;
identity : θ t = α t \theta_t = \alpha_t θ t = α t .
Figure 20. Modulus map.
Figure 21. Argument map.
Mira Non-CUDA-Accelerated Pseudo Code
The following PyTorch pseudocode implements the MIRA forward pass sequentially using the Cauchy radius and hyperbolic rotation.
Sequential-Lattice Implementation (Conceptual Code)
def forward(self, x, state=None):
B, T, d = x.shape
de, dr, dm, K = self.de, self.dr, self.dm, self.K
z = self.rn1(x)
x_tilde, raw_s = self.W_in_s(z).split([de, dm], dim=-1)
s = F.silu(raw_s)
c = F.silu(self.W_c(z))
alpha, beta, rho, nu = self.W_control(c).split(
[K * de, K * de, (K + 1) * de, (K + 1) * dm],
dim=-1)
alpha = alpha.float().reshape(B, T, de, K)
beta = beta.float().reshape(B, T, de, K)
rho = rho.float().reshape(B, T, de, K + 1)
nu = nu.float().reshape(B, T, K + 1, dm)
gamma = F.silu(self.W_gamma(z).float())
x_tilde, s = x_tilde.float(), s.float()
if state is None:
state = torch.zeros(
B, K, de, dm, device=x.device, dtype=torch.float32)
else:
state = state.to(device=x.device, dtype=torch.float32)
outputs = []
for t in range(T):
U = x_tilde[:, t, :, None] * s[:, t, None, :]
V = [None] * (K + 1)
for k in range(K, 0, -1):
V_prev = state[:, k - 1]
alpha_t = alpha[:, t, :, k - 1, None]
beta_t = beta[:, t, :, k - 1, None]
r = 1 / (1 + beta_t.square())
cos_theta = 1 / torch.cosh(alpha_t)
sin_theta = torch.sinh(alpha_t) / torch.cosh(alpha_t)
V[k] = r * (sin_theta * U + cos_theta * V_prev)
U = r * (cos_theta * U - sin_theta * V_prev)
V[0] = U
V = torch.stack(V, dim=1)
state = V[:, :K]
y = torch.einsum("bkem,bkm->bke", V, nu[:, t])
y = (rho[:, t].transpose(1, 2) * y).sum(dim=1)
outputs.append(gamma[:, t] * y)
y = torch.stack(outputs, dim=1).to(z.dtype)
x = x + self.W_out(y)
x = x + self.ffn(self.rn2(x))
return x, state
Parallel-Lattice Implementation (Product Version)
def forward(self, x, state=None):
B, T, d = x.shape
de, dr, dm, K = self.de, self.dr, self.dm, self.K
z = self.rn1(x)
x_tilde, raw_s = self.W_in_s(z).split([de, dm], dim=-1)
s = F.silu(raw_s)
c = F.silu(self.W_c(z))
alpha, beta, rho, nu = self.W_control(c).split(
[K * de, K * de, (K + 1) * de, (K + 1) * dm],
dim=-1)
alpha = alpha.float().reshape(B, T, de, K)
beta = beta.float().reshape(B, T, de, K)
rho = rho.float().reshape(B, T, de, K + 1)
nu = nu.float().reshape(B, T, K + 1, dm)
gamma = F.silu(self.W_gamma(z).float())
x_tilde, s = x_tilde.float(), s.float()
# D^(k) = r^(k) cos(theta^(k)),
# E^(k) = r^(k) sin(theta^(k)),
# every token and stage at once; stage k at index k - 1
r = 1 / (1 + beta.square())
D = r / torch.cosh(alpha)
E = r * torch.tanh(alpha)
# D0[..., k] = D^(k); E0[..., k] = E^(k), E0[..., 0] = 1
one = torch.ones_like(D[..., :1])
D0 = torch.cat([one, D], dim=-1)
E0 = torch.cat([one, E], dim=-1)
# G[k, i] = D^(k+1) ... D^(i) for i >= k (G[k, k] = 1),
# else 0
upper = torch.ones(K + 1, K + 1, dtype=torch.bool,
device=x.device).triu()
G = torch.where(upper.triu(1), D0[..., None, :], 1.0)
G = G.cumprod(-1) * upper
# the K stages solved in closed form:
# U^(k) = G[k, K] U^(K)
# - sum_{j >= k} G[k, j] E^(j+1) V_{t-1}^(j)
# V^(k) = E^(k) U^(k) + D^(k) V_{t-1}^(k-1)
# V^(0) = U^(0)
# so V_t^(0..K) = Phi_t V_{t-1}^(0..K-1)
# + S_coef_t U_t^(K);
# rows 0..K-1 of Phi_t are Phi_t, row K gives V_t^(K)
# S_coef: (B, T, de, K+1), Phi: (B, T, de, K+1, K)
S_coef = E0 * G[..., K]
Phi = (-E0[..., None] * G[..., :K] * E[..., None, :]
+ torch.diag_embed(D, offset=-1)[..., :K])
# U_t^(K) = x_tilde_t s_t^T
U = x_tilde[..., None] * s[:, :, None, :]
if state is None:
state = torch.zeros(B, K, de, dm, device=x.device,
dtype=torch.float32)
else:
state = state.to(device=x.device,
dtype=torch.float32)
# the affine scan V_t = Phi_t V_{t-1} + S_t over tokens
V = []
# scan tokens
for t in range(T):
S_t = (S_coef[:, t].transpose(1, 2)[..., None]
* U[:, t, None])
V_t = torch.einsum("bekj,bjem->bkem",
Phi[:, t], state) + S_t
state = V_t[:, :K]
V.append(V_t)
# V: (B, T, K+1, de, dm)
V = torch.stack(V, dim=1)
# y_t = (sum_k rho_t^(k) * (V_t^(k) nu_t^(k))) * gamma_t
y = gamma * torch.einsum("btkem,btkm,btek->bte",
V, nu, rho)
y = y.to(z.dtype)
x = x + self.W_out(y)
x = x + self.ffn(self.rn2(x))
return x, state
Mira Parameter and State Sizes
Parameter & State Sizes. Let L L L be the number of layers, d d d be the model width, d e d_e d e be the lattice-channel width, d r d_r d r be the write bottleneck size, d m d_m d m be the memory dimension, K K K be the lattice order, and d f f n d_{\mathrm{ffn}} d ffn be the FFN width. Let P m i x e r P_{\mathrm{mixer}} P mixer and P l a y e r P_{\mathrm{layer}} P layer be the parameter counts of the MIRA mixer and a complete layer, respectively, and let S l a y e r S_{\mathrm{layer}} S layer be the recurrent state size per sequence. Collecting the parameter contributions, with the width-product terms preceding the bias terms, gives
P m i x e r = [ 3 d + ( 3 K + 1 ) d r ] d e + d ( d r + d m ) + ( K + 1 ) d r d m + ( 3 K + 2 ) d e + ( K + 1 ) d m + d r , (6) P_{\mathrm{mixer}} = [3d + (3K + 1)d_r]d_e + d(d_r + d_m) + (K + 1)d_rd_m + (3K + 2)d_e + (K + 1)d_m + d_r, \tag*{(6)} P mixer = [ 3 d + ( 3 K + 1 ) d r ] d e + d ( d r + d m ) + ( K + 1 ) d r d m + ( 3 K + 2 ) d e + ( K + 1 ) d m + d r , (6)
P l a y e r = P m i x e r + ( 2 d + 1 ) d f f n + 3 d , (7) P_{\mathrm{layer}} = P_{\mathrm{mixer}} + (2d + 1)d_{\mathrm{ffn}} + 3d, \tag*{(7)} P layer = P mixer + ( 2 d + 1 ) d ffn + 3 d , (7)
S l a y e r = K d e d m , S l a y e r P l a y e r = K d e d m P l a y e r . (8) S_{\mathrm{layer}} = Kd_ed_m,\qquad\frac{S_{\mathrm{layer}}}{P_{\mathrm{layer}}} = \frac{Kd_ed_m}{P_{\mathrm{layer}}}. \tag*{(8)} S layer = K d e d m , P layer S layer = P layer K d e d m . (8)
Let ∣ V ∣ |V| ∣ V ∣ be the vocabulary size. Including tied embedding and output weights and the final affine RMSNorm, the model parameter count P m o d e l P_{\mathrm{model}} P model , recurrent state size S m o d e l S_{\mathrm{model}} S model , and state-to-parameter ratio are
P m o d e l = L P l a y e r + ( ∣ V ∣ + 2 ) d , S m o d e l = L K d e d m , (9) P_{\mathrm{model}} = LP_{\mathrm{layer}} + (|V| + 2)d,\qquad S_{\mathrm{model}} = LK d_ed_m, \tag*{(9)} P model = L P layer + ( ∣ V ∣ + 2 ) d , S model = L K d e d m , (9)
S m o d e l P m o d e l = L K d e d m L P l a y e r + ( ∣ V ∣ + 2 ) d . (10) \frac{S_{\mathrm{model}}}{P_{\mathrm{model}}} = \frac{LKd_ed_m}{LP_{\mathrm{layer}} + (|V| + 2)d}. \tag*{(10)} P model S model = L P layer + ( ∣ V ∣ + 2 ) d L K d e d m . (10)
Configuration reference table
Table A.3.1.
Initializer Pseudo Code
Constants and Horizons
# ----------------------------------------------------------
# CONSTANTS
# T_J : lag window of the Fisher information
# GRID : points of the log-rate grid
# H_TIE : horizon from which a pair angle is tied
# KAPPA : a tied angle is min(angle, KAPPA / H)
# SIGMA_W : standard deviation of the uniform W rows
# GAP : stage radius r = 1 - GAP (1 - |kappa|)
# PERIODS : phase-bank periods, cycled over channels
# F_BOTH : fixed pair angles / pi, both half-planes
# F_RIGHT : fixed pair angles / pi, right half-plane
# ----------------------------------------------------------
T_J, GRID = 256, 200001
H_TIE, KAPPA, SIGMA_W = 100.0, 2.0, 0.02
GAP = 2.0 ** -13
PERIODS = (5, 7, 11, 17, 23, 31, 43, 61)
F_BOTH = (0.25, 0.5, 0.75, 0.125,
0.375, 0.625, 0.875, 0.0625)
F_RIGHT = (0.25, 0.125, 0.375, 0.0625,
0.1875, 0.3125, 0.4375, 0.03125)
# ----------------------------------------------------------
# RANDOM SIGN, magnitude from U(lo, hi)
# ----------------------------------------------------------
def signed_uniform(shape, lo, hi):
magnitude = torch.empty(shape).uniform_(lo, hi)
sign = torch.empty(shape).bernoulli_(0.5) * 2 - 1
return magnitude * sign
# ----------------------------------------------------------
# JEFFREYS QUANTILES of the horizon H = 1 / lambda
# density per unit log lambda: sqrt(I(lambda)) lambda,
# I(lambda) = sum_{t=1}^{T_J} t q^t, q = exp(-2 lambda),
# on lambda in [1/hi, 1/lo]; levels in (0, 1), counted
# from the fastest decay
# ----------------------------------------------------------
def jeffreys_quantiles(levels, lo, hi):
u = torch.linspace(math.log(1 / hi), math.log(1 / lo),
GRID, dtype=torch.float64)
q = torch.exp(-2 * torch.exp(u))
info = q * (1 - (T_J + 1) * q.pow(T_J)
+ T_J * q.pow(T_J + 1))
info = info / (1 - q).square()
p = info.sqrt() * torch.exp(u)
# cumulative distribution by trapezoids, then inverted
F = torch.cumsum(0.5 * (p[1:] + p[:-1]) * u.diff(), 0)
F = torch.cat((F.new_zeros(1), F)) / F[-1]
i = torch.searchsorted(F, levels).clamp(1, GRID - 1)
w = (levels - F[i - 1]) / (F[i] - F[i - 1])
return torch.exp(-(u[i - 1] + w * (u[i] - u[i - 1])))
# the d_e quantiles (c - 1/2) / d_e, c = 1..d_e
def jeffreys_horizons(d_e, lo, hi):
levels = (torch.arange(d_e, dtype=torch.float64)
+ 0.5) / d_e
return jeffreys_quantiles(levels, lo, hi)
# base-2 van der Corput value: 0, 1/2, 1/4, 3/4, 1/8, ...
def van_der_corput(m):
value, digit = 0.0, 0.5
while m:
value += digit * (m & 1)
m >>= 1
digit *= 0.5
return value
# ----------------------------------------------------------
# NESTED JEFFREYS HORIZONS, one per pole: [d_e, ceil(K/2)]
# column 0: the jeffreys horizon of the permuted channel
# column m: quantile at (l_c + phi_m) mod 1,
# l_c = (perm[c] + 1/2) / d_e,
# phi_m = van_der_corput(m)
# ----------------------------------------------------------
def nested_jeffreys_horizons(perm, K, lo, hi):
d_e = len(perm)
columns = [jeffreys_horizons(d_e, lo, hi)[perm]]
levels = (perm.double() + 0.5) / d_e
for m in range(1, (K + 1) // 2):
shifted = torch.remainder(
levels + van_der_corput(m), 1.0)
columns.append(jeffreys_quantiles(shifted, lo, hi))
return torch.stack(columns, dim=-1)
Poles and Coefficients
# ----------------------------------------------------------
# PRODUCT OF POLYNOMIALS in zˆ-1, one row per channel
# ----------------------------------------------------------
def poly_mul(a, b):
width = a.shape[1] + b.shape[1] - 1
out = a.new_zeros(a.shape[0], width)
for i in range(b.shape[1]):
out[:, i:i + a.shape[1]] += a * b[:, i:i + 1]
return out
# ----------------------------------------------------------
# REFLECTION COEFFICIENTS kappa [d_e, K] (float64)
# H [d_e]: one horizon per channel; pair j has radius
# exp(-(1 + j/J)/H), the real pole (odd K) exp(-1/H)
# H [d_e, ceil(K/2)]: one horizon per pole (nested)
# real pole: -p (right=False) or +p (right=True)
# pair angle: bank=False: pi F[j]
# bank=True: the phase bank, tied to
# min(angle, KAPPA / H_j) when H_j >= H_TIE
# step-down (Schur) recursion of the denominator
# ----------------------------------------------------------
def reflection_coefficients(H, K, right=False, bank=False):
per_pole = H.ndim == 2
rad = torch.exp(-torch.reciprocal(H.double()))
first = rad[:, 0] if per_pole else rad
d_e = first.shape[0]
poly = torch.ones(d_e, 1, dtype=torch.float64)
factors = []
if K % 2:
p = rad[:, K // 2] if per_pole else first
coef = -p if right else p
factors.append(torch.stack(
(torch.ones_like(p), coef), dim=-1))
poly = poly_mul(poly, factors[-1])
F = torch.tensor(F_RIGHT if right else F_BOTH,
dtype=torch.float64)
J = K // 2
for j in range(J):
p = (rad[:, j] if per_pole
else first.pow(1.0 + j / max(1, J)))
if bank:
c = torch.arange(d_e)
P = torch.tensor(PERIODS, dtype=torch.float64)
P = P[c.remainder(len(PERIODS))]
shift = 2 * math.pi / P - math.pi / 4
angle = torch.acos(
torch.cos(math.pi * F[j] + shift))
H_j = -torch.reciprocal(torch.log(p))
tied = torch.minimum(angle, KAPPA / H_j)
angle = torch.where(H_j >= H_TIE, tied, angle)
else:
angle = math.pi * F[j]
factors.append(torch.stack(
(torch.ones_like(first),
-2 * p * torch.cos(angle), p.square()), dim=-1))
poly = poly_mul(poly, factors[-1])
kappa = torch.empty(d_e, K, dtype=torch.float64)
a = poly
for k in range(K, 0, -1):
last = a[:, -1]
kappa[:, k - 1] = last
a = ((a - last.unsqueeze(-1) * a.flip(-1))[:, :-1]
/ (1 - last.square()).unsqueeze(-1))
# a channel whose float64 recursion gives some
# |kappa| >= 1, or a value that is not finite, is
# recomputed by step_down_decimal: the same recursion
# in 100-digit decimal arithmetic
ok = kappa.isfinite().all(-1) & (kappa.abs() < 1).all(-1)
for c in (~ok).nonzero().flatten().tolist():
kappa[c] = kappa.new_tensor(step_down_decimal(
[f[c].tolist() for f in factors], K))
return kappa
# ----------------------------------------------------------
# STAGE COEFFICIENTS, Cauchy radius x hyperbolic rotation
# r = 1 - GAP (1 - |kappa|), sin(theta) = kappa / r
# alpha = artanh(sin(theta)), in float64 because r is
# within GAP of 1
# beta = sign * sqrt(1/r - 1)
# ----------------------------------------------------------
def stage_coefficients(kappa, beta_sign):
r64 = 1 - (1 - kappa.abs()) * GAP
alpha = torch.atanh(kappa / r64).float()
k32 = kappa.float()
r32 = 1 - (1 - k32.abs()) * GAP
beta = beta_sign * torch.sqrt(torch.reciprocal(r32) - 1)
return alpha, beta
Shared Functions
# ----------------------------------------------------------
# THE COEFFICIENT PROJECTION of one layer, m:
# m.W [rows, d_r], m.b [rows]; rows, in order:
# alpha [K d_e], beta [K d_e], rho [(K+1) d_e],
# nu [(K+1) d_m]; stage k of channel c: row c K + k - 1
# m.W_c [d_r, d], m.b_c [d_r]: the control projection
# m.K, m.d_e, m.d_r, m.d_m; (m.lo, m.hi): the horizon
# range of the layer
# ----------------------------------------------------------
def spans(m):
a = m.K * m.d_e
rho = (2 * a, 2 * a + (m.K + 1) * m.d_e)
nu = (rho[1], rho[1] + (m.K + 1) * m.d_m)
return a, rho, nu
# s = (K+1)^(-1/4) / sqrt(d_r)
def readout_scale(m):
return 1 / math.sqrt(m.d_r) * (m.K + 1) ** -0.25
# ----------------------------------------------------------
# START: every W and b entry has a random sign and a
# magnitude from U(s/4, s)
# ----------------------------------------------------------
def start(m):
s = readout_scale(m)
m.W.copy_(signed_uniform(m.W.shape, s / 4, s))
m.b.copy_(signed_uniform(m.b.shape, s / 4, s))
# ----------------------------------------------------------
# PLACE POLES of horizons H into b_alpha, b_beta and scale
# the W_alpha, W_beta rows to them
# W_alpha, W_beta row: random sign, magnitude from
# U(1/4, 1) min(|b_mob| / (4 sqrt(d_r)), s) x ratio,
# b_mob: the cauchy x mobius coefficient of the stage,
# alpha_mob = sign sqrt((1 - sin)/(1 + sin));
# ratio (alpha rows): (d theta_mob / d alpha_mob)
# / (d theta / d alpha)
# = 2 / (1 + alpha_mob^2) x cosh(alpha); beta rows: 1
# returns (alpha, beta) [d_e, K]
# ----------------------------------------------------------
def place_poles(m, H, right=False, bank=False):
a, _, _ = spans(m)
kappa = reflection_coefficients(H, m.K, right, bank)
shape = (m.d_e, m.K)
alpha_sign = torch.empty(shape).bernoulli_(0.5) * 2 - 1
beta_sign = torch.empty(shape).bernoulli_(0.5) * 2 - 1
alpha, beta = stage_coefficients(kappa, beta_sign)
k32 = kappa.float()
sin32 = k32 / (1 - (1 - k32.abs()) * GAP)
alpha_mob = alpha_sign * torch.sqrt(
(1 - sin32) / (1 + sin32))
b_mob = torch.cat((alpha_mob.reshape(-1),
beta.reshape(-1)))
size = (b_mob.abs().clamp_min(1e-6)
/ (4 * math.sqrt(m.d_r)))
size = size.clamp_max(readout_scale(m))
rotation = (2 / (1 + alpha_mob.double().square())
* torch.cosh(alpha.double()))
ratio = torch.cat(
(rotation.reshape(-1),
torch.ones(beta.numel(), dtype=torch.float64)))
size = size * ratio.float()
m.W[:2 * a] = (signed_uniform((2 * a, m.d_r), 0.25, 1.0)
* size.unsqueeze(-1))
m.b[:a] = alpha.reshape(-1)
m.b[a:2 * a] = beta.reshape(-1)
return alpha, beta
# ----------------------------------------------------------
# UNIFORM W ROWS: every W entry from
# U(-sqrt(3) SIGMA_W, sqrt(3) SIGMA_W); b is kept
# nested: W_rho, W_nu then scaled by (3/(K+1))^(1/4)
# ----------------------------------------------------------
def uniform_weight_rows(m, nested=False):
limit = math.sqrt(3) * SIGMA_W
m.W.uniform_(-limit, limit)
if nested:
_, rho, nu = spans(m)
scale = (3 / (m.K + 1)) ** 0.25
m.W[rho[0]:rho[1]] *= scale
m.W[nu[0]:nu[1]] *= scale
# ----------------------------------------------------------
# CONTROL MEAN E[c_j] of c = silu(W_c z + b_c), z ~ N(0, I):
# pre-activation j ~ N(b_c[j], ||W_c[j]||^2), integrated
# on 4801 points of [-12, 12] standard deviations
# ----------------------------------------------------------
def control_mean(m):
mean = m.b_c.double()
spread = m.W_c.double().norm(dim=1)
x = torch.linspace(-12, 12, 4801, dtype=torch.float64)
w = torch.exp(-0.5 * x.square())
w = w / w.sum()
pts = mean.unsqueeze(-1) + spread.unsqueeze(-1) * x
return (F.silu(pts) * w).sum(-1)
Implementations
# ----------------------------------------------------------
# THE TEN INITIALIZERS, each on one layer m
# ----------------------------------------------------------
# W uniform w/ b jeffreys (the default)
def W_uniform_b_jeffreys(m):
start(m)
H = jeffreys_horizons(m.d_e, m.lo, m.hi)
H = H[torch.randperm(m.d_e)].float()
coefficients = place_poles(m, H, bank=True)
uniform_weight_rows(m)
return coefficients
# W uniform w/ b nested jeffreys
def W_uniform_b_nested_jeffreys(m):
start(m)
H = nested_jeffreys_horizons(torch.randperm(m.d_e),
m.K, m.lo, m.hi).float()
place_poles(m, H, bank=True)
uniform_weight_rows(m, nested=True)
# W normal w/ b jeffreys
def W_normal_b_jeffreys(m):
W_uniform_b_jeffreys(m)
m.W.normal_(0, SIGMA_W)
# W,b pytorch-uniform
def W_b_uniform(m):
W_uniform_b_jeffreys(m)
limit = 1 / math.sqrt(m.d_r)
m.W.uniform_(-limit, limit)
m.b.uniform_(-limit, limit)
# W,b pytorch-normal
def W_b_normal(m):
W_uniform_b_jeffreys(m)
scale = 1 / math.sqrt(m.d_r)
m.W.normal_(0, scale)
m.b.normal_(0, scale)
# ----------------------------------------------------------
# W JEFFREYS: the jeffreys stage coefficients carried by
# the W_alpha, W_beta rows, b_alpha, b_beta redrawn:
# every entry of row i = (b*_i - b_i) / sum_j E[c_j],
# b*_i the W_uniform_b_jeffreys coefficient of the row,
# so E[alpha], E[beta] equal those of the default
# ----------------------------------------------------------
def place_in_weight_rows(m, coefficients, draw_bias):
a, _, _ = spans(m)
draw_bias(m.b[:2 * a])
response = control_mean(m).sum()
alpha, beta = coefficients
target = torch.cat((alpha.reshape(-1),
beta.reshape(-1))).double()
rows = (target - m.b[:2 * a].double()) / response
m.W[:2 * a] = rows.unsqueeze(-1).expand(
-1, m.d_r).float()
# W jeffreys w/ b uniform
def W_jeffreys_b_uniform(m):
bound = 1 / math.sqrt(m.d_r)
place_in_weight_rows(m, W_uniform_b_jeffreys(m),
lambda b: b.uniform_(-bound, bound))
# W jeffreys w/ b normal
def W_jeffreys_b_normal(m):
bound = 1 / math.sqrt(m.d_r)
place_in_weight_rows(m, W_uniform_b_jeffreys(m),
lambda b: b.normal_(0, bound))
# uniform horizon w/ fixed angles
def uniform_horizon_fixed_angles(m):
start(m)
H = torch.empty(m.d_e).uniform_(m.lo, m.hi)
place_poles(m, H)
# uniform horizon w/ fixed angles, right half-plane
def uniform_horizon_fixed_angles_right(m):
start(m)
H = torch.empty(m.d_e).uniform_(m.lo, m.hi)
place_poles(m, H, right=True)
# ----------------------------------------------------------
# ALPHA, BETA UNIFORM: W_alpha, W_beta, b_alpha, b_beta
# from U(-1/sqrt(d_r), 1/sqrt(d_r)); b_alpha is read as
# the cauchy x mobius coefficient,
# sin(theta) = (1 - b^2) / (1 + b^2),
# and mapped to the hyperbolic alpha = artanh(sin(theta))
# of the same pole; b_beta is already a cauchy radius
# ----------------------------------------------------------
def alpha_beta_uniform(m):
start(m)
a, _, _ = spans(m)
bound = 1 / math.sqrt(m.d_r)
m.W[:2 * a].uniform_(-bound, bound)
m.b[:2 * a].uniform_(-bound, bound)
draw = m.b[:a].double()
sin = ((1 - draw.square()) / (1 + draw.square())).clamp(
-1 + 1e-12, 1 - 1e-12)
m.b[:a] = torch.atanh(sin).float()
Benchmark configuration
Table 3. Benchmark configurations. All models use 12 layers, a vocabulary of 50,259 tokens, tied input and output embeddings, and a training context window of 512 tokens. Parameter size counts all trainable parameters. State size counts recurrent-state elements per sequence across all layers, excluding convolution buffers; for the Transformer, it counts key–value cache elements at 512 tokens. The state-to-parameter ratio is the state size divided by the parameter size.
Synthesizing Provable Failure Signals for Causal Mode Retrieval
We synthesize four-channel input and target signals related by a true transfer function with nonreal poles. We first construct the input signal X ( z ) X(z) X ( z ) and the true transfer function H ( z ) H(z) H ( z ) , and then generate the target signal as Y ( z ) = H ( z ) X ( z ) Y(z) = H(z)X(z) Y ( z ) = H ( z ) X ( z ) . The transfer function H ( z ) H(z) H ( z ) is withheld from the models and must be learned from the input–target sequences.
Input Signal. We construct an input signal containing both magnitude and phase noise. For a sequence of T T T tokens, with token index t ∈ { 1 , … , T } t \in\{1,\ldots,T\} t ∈ { 1 , … , T } and channel index c ∈ { 1 , … , 4 } c \in\{1,\ldots,4\} c ∈ { 1 , … , 4 } , the latent input is
u t , c = 0.75 ϵ t , c + 0.45 sin ( ω c ( t − 1 ) + ϕ c ) + 0.25 sin ( 1.7 ω c ( t − 1 ) − ϕ c ) , (11) u_{t,c} = 0.75\epsilon_{t,c} + 0.45\sin\left(\omega_c(t-1)+\phi_c\right) + 0.25\sin\left(1.7\omega_c(t-1)-\phi_c\right), \tag*{(11)} u t , c = 0.75 ϵ t , c + 0.45 sin ( ω c ( t − 1 ) + ϕ c ) + 0.25 sin ( 1.7 ω c ( t − 1 ) − ϕ c ) , (11)
where ϵ t , c ∼ N ( 0 , 1 ) \epsilon_{t,c} \sim\mathcal{N}(0,1) ϵ t , c ∼ N ( 0 , 1 ) denotes Gaussian noise, ϕ c ∼ U ( − π , π ) \phi_c \sim\mathcal{U}(-\pi,\pi) ϕ c ∼ U ( − π , π ) denotes a random phase, and
( ω 1 , ω 2 , ω 3 , ω 4 ) = π ( 0.07 , 0.11 , 0.17 , 0.23 ) . (12) (\omega_1,\omega_2,\omega_3,\omega_4) = \pi(0.07,0.11,0.17,0.23). \tag*{(12)} ( ω 1 , ω 2 , ω 3 , ω 4 ) = π ( 0.07 , 0.11 , 0.17 , 0.23 ) . (12)
The unnormalized input is
x ~ t , c = sin ( s c u t , c ) + λ c sgn ( u t , c ) log ( 1 + ∣ u t , c ∣ ) + q c ( e − ∣ u t , c ∣ − 1 T ∑ τ = 1 T e − ∣ u τ , c ∣ ) + 0.12 ξ t , c , (13) \begin{aligned}
\widetilde{x}_{t,c} ={}& \sin(s_cu_{t,c}) + \lambda_c\operatorname{sgn}(u_{t,c})\log(1+\lvert u_{t,c}\rvert) \\
&+ q_c\left(e^{-\lvert u_{t,c}\rvert} - \frac{1}{T}\sum_{\tau=1}^{T}e^{-\lvert u_{\tau,c}\rvert}\right) + 0.12\xi_{t,c}, \tag*{(13)}
\end{aligned} x t , c = sin ( s c u t , c ) + λ c sgn ( u t , c ) log ( 1 + ∣ u t , c ∣) + q c ( e − ∣ u t , c ∣ − T 1 τ = 1 ∑ T e − ∣ u τ , c ∣ ) + 0.12 ξ t , c , (13)
where ξ t , c ∼ N ( 0 , 1 ) \xi_{t,c} \sim\mathcal{N}(0,1) ξ t , c ∼ N ( 0 , 1 ) denotes independent Gaussian noise and
( s 1 , s 2 , s 3 , s 4 ) = ( 0.85 , 1.05 , 1.20 , 1.40 ) , (14) (s_1,s_2,s_3,s_4) = (0.85,1.05,1.20,1.40), \tag*{(14)} ( s 1 , s 2 , s 3 , s 4 ) = ( 0.85 , 1.05 , 1.20 , 1.40 ) , (14)
( λ 1 , λ 2 , λ 3 , λ 4 ) = ( 0.35 , 0.25 , 0.30 , 0.20 ) , (15) (\lambda_1,\lambda_2,\lambda_3,\lambda_4) = (0.35,0.25,0.30,0.20), \tag*{(15)} ( λ 1 , λ 2 , λ 3 , λ 4 ) = ( 0.35 , 0.25 , 0.30 , 0.20 ) , (15)
( q 1 , q 2 , q 3 , q 4 ) = ( 0.20 , 0.30 , 0.25 , 0.35 ) . (16) (q_1,q_2,q_3,q_4) = (0.20,0.30,0.25,0.35). \tag*{(16)} ( q 1 , q 2 , q 3 , q 4 ) = ( 0.20 , 0.30 , 0.25 , 0.35 ) . (16)
Using the channel mean
μ c = 1 T ∑ t = 1 T x ~ t , c (17) \mu_c = \frac{1}{T}\sum_{t=1}^{T}\widetilde{x}_{t,c} \tag*{(17)} μ c = T 1 t = 1 ∑ T x t , c (17)
and channel standard deviation
σ c = [ 1 T ∑ t = 1 T ( x ~ t , c − μ c ) 2 ] 1 / 2 , (18) \sigma_c = \left[\frac{1}{T}\sum_{t=1}^{T}(\widetilde{x}_{t,c}-\mu_c)^2\right]^{1/2}, \tag*{(18)} σ c = [ T 1 t = 1 ∑ T ( x t , c − μ c ) 2 ] 1/2 , (18)
the normalized input is
x t , c = x ~ t , c − μ c σ c . (19) x_{t,c} = \frac{\widetilde{x}_{t,c}-\mu_c}{\sigma_c}. \tag*{(19)} x t , c = σ c x t , c − μ c . (19)
True Transfer Function. For each channel c ∈ { 1 , … , 4 } c \in\{1,\ldots,4\} c ∈ { 1 , … , 4 } , we construct the true transfer function as
H c ( z ) = Y c ( z ) X c ( z ) = z − 1 ∑ j = 0 4 b c , j z − j 1 − ∑ j = 1 4 a c , j z − j , (20) H_c(z) = \frac{Y_c(z)}{X_c(z)} = \frac{z^{-1}\sum_{j=0}^{4}b_{c,j}z^{-j}}{1-\sum_{j=1}^{4}a_{c,j}z^{-j}}, \tag*{(20)} H c ( z ) = X c ( z ) Y c ( z ) = 1 − ∑ j = 1 4 a c , j z − j z − 1 ∑ j = 0 4 b c , j z − j , (20)
where the coefficient a c , j a_{c,j} a c , j is entry ( c , j ) (c,j) ( c , j ) of
A = ( 1.952735784 − 1.974230161 1.930926548 − 0.974392257 − 1.400051941 − 1.315949473 − 1.333286522 − 0.427346553 − 1.030066375 − 0.458960346 0.497746636 0.527108251 − 1.086474355 − 0.263198919 0.686737838 0.743993180 ) (21) \mathbf{A} =
\begin{pmatrix}
1.952735784 & -1.974230161 & 1.930926548 & -0.974392257 \\
-1.400051941 & -1.315949473 & -1.333286522 & -0.427346553 \\
-1.030066375 & -0.458960346 & 0.497746636 & 0.527108251 \\
-1.086474355 & -0.263198919 & 0.686737838 & 0.743993180
\end{pmatrix} \tag*{(21)} A = 1.952735784 − 1.400051941 − 1.030066375 − 1.086474355 − 1.974230161 − 1.315949473 − 0.458960346 − 0.263198919 1.930926548 − 1.333286522 0.497746636 0.686737838 − 0.974392257 − 0.427346553 0.527108251 0.743993180 (21)
and the numerator coefficient b c , j b_{c,j} b c , j is entry ( c , j + 1 ) (c,j+1) ( c , j + 1 ) of
B = ( − 0.055171491 0.136620626 − 0.188283824 0.201492045 − 0.097161900 − 0.146266818 − 0.064363154 0.155433501 0.021868375 − 0.057037339 0.144469820 0.163038836 0.134055985 − 0.021828775 − 0.044674776 − 0.226198180 − 0.514066284 − 0.387318389 − 0.199410167 − 0.092755378 ) . (22) \mathbf{B} =
\begin{pmatrix}
-0.055171491 & 0.136620626 & -0.188283824 & 0.201492045 & -0.097161900 \\
-0.146266818 & -0.064363154 & 0.155433501 & 0.021868375 & -0.057037339 \\
0.144469820 & 0.163038836 & 0.134055985 & -0.021828775 & -0.044674776 \\
-0.226198180 & -0.514066284 & -0.387318389 & -0.199410167 & -0.092755378
\end{pmatrix}. \tag*{(22)} B = − 0.055171491 − 0.146266818 0.144469820 − 0.226198180 0.136620626 − 0.064363154 0.163038836 − 0.514066284 − 0.188283824 0.155433501 0.134055985 − 0.387318389 0.201492045 0.021868375 − 0.021828775 − 0.199410167 − 0.097161900 − 0.057037339 − 0.044674776 − 0.092755378 . (22)
Multiplying the numerator and denominator by z 5 z^5 z 5 gives
H c ( z ) = b c , 0 z 4 + b c , 1 z 3 + b c , 2 z 2 + b c , 3 z + b c , 4 z ( z 4 − a c , 1 z 3 − a c , 2 z 2 − a c , 3 z − a c , 4 ) (23) H_c(z)=\frac{b_{c,0}z^4+b_{c,1}z^3+b_{c,2}z^2+b_{c,3}z+b_{c,4}}{z\left(z^4-a_{c,1}z^3-a_{c,2}z^2-a_{c,3}z-a_{c,4}\right)} \tag*{(23)} H c ( z ) = z ( z 4 − a c , 1 z 3 − a c , 2 z 2 − a c , 3 z − a c , 4 ) b c , 0 z 4 + b c , 1 z 3 + b c , 2 z 2 + b c , 3 z + b c , 4 (23)
in which the factor z z z in the denominator is the one-token delay of (20) and contributes a further pole at the origin. The zeros for channel c c c are the roots of the numerator polynomial:
Z c = { z ∈ C : b c , 0 z 4 + b c , 1 z 3 + b c , 2 z 2 + b c , 3 z + b c , 4 = 0 } , (24) \mathcal{Z}_c=\left\{z\in\mathbb{C}:b_{c,0}z^4+b_{c,1}z^3+b_{c,2}z^2+b_{c,3}z+b_{c,4}=0\right\}, \tag*{(24)} Z c = { z ∈ C : b c , 0 z 4 + b c , 1 z 3 + b c , 2 z 2 + b c , 3 z + b c , 4 = 0 } , (24)
and the poles are the roots of the denominator polynomial:
P c = { z ∈ C : z ( z 4 − a c , 1 z 3 − a c , 2 z 2 − a c , 3 z − a c , 4 ) = 0 } . (25) \mathcal{P}_c=\left\{z\in\mathbb{C}:z\left(z^4-a_{c,1}z^3-a_{c,2}z^2-a_{c,3}z-a_{c,4}\right)=0\right\}. \tag*{(25)} P c = { z ∈ C : z ( z 4 − a c , 1 z 3 − a c , 2 z 2 − a c , 3 z − a c , 4 ) = 0 } . (25)
For the specified values of a c , j a_{c,j} a c , j and b c , j b_{c,j} b c , j , the resulting zero and pole sets are listed below, rounded to six decimal places. The zero sets are
Z 1 = { 0.171722 ± 1.223544 i , 1.066424 ± 0.127992 i } , (26) \mathcal{Z}_1=\{0.171722\pm1.223544i,\ 1.066424\pm0.127992i\}, \tag*{(26)} Z 1 = { 0.171722 ± 1.223544 i , 1.066424 ± 0.127992 i } , (26)
Z 2 = { − 0.908806 , − 0.857417 , 0.663092 ± 0.246471 i } , (27) \mathcal{Z}_2=\{-0.908806,\ -0.857417,\ 0.663092\pm0.246471i\}, \tag*{(27)} Z 2 = { − 0.908806 , − 0.857417 , 0.663092 ± 0.246471 i } , (27)
Z 3 = { − 0.598555 , 0.474890 , − 0.502433 ± 0.914034 i } , (28) \mathcal{Z}_3=\{-0.598555,\ 0.474890,\ -0.502433\pm0.914034i\}, \tag*{(28)} Z 3 = { − 0.598555 , 0.474890 , − 0.502433 ± 0.914034 i } , (28)
Z 4 = { − 1.272319 , − 0.907339 , − 0.046490 ± 0.594179 i } , (29) \mathcal{Z}_4=\{-1.272319,\ -0.907339,\ -0.046490\pm0.594179i\}, \tag*{(29)} Z 4 = { − 1.272319 , − 0.907339 , − 0.046490 ± 0.594179 i } , (29)
and the resulting pole sets are
P 1 = { 0 , ± 0.994400 i , 0.976368 ± 0.179176 i } , (30) \mathcal{P}_1=\{0,\ \pm0.994400i,\ 0.976368\pm0.179176i\}, \tag*{(30)} P 1 = { 0 , ± 0.994400 i , 0.976368 ± 0.179176 i } , (30)
P 2 = { 0 , − 0.990691 , − 0.461592 , 0.026116 ± 0.966347 i } , (31) \mathcal{P}_2=\{0,\ -0.990691,\ -0.461592,\ 0.026116\pm0.966347i\}, \tag*{(31)} P 2 = { 0 , − 0.990691 , − 0.461592 , 0.026116 ± 0.966347 i } , (31)
P 3 = { 0 , − 0.761948 , 0.718261 , − 0.493190 ± 0.848475 i } , (32) \mathcal{P}_3=\{0,\ -0.761948,\ 0.718261,\ -0.493190\pm0.848475i\}, \tag*{(32)} P 3 = { 0 , − 0.761948 , 0.718261 , − 0.493190 ± 0.848475 i } , (32)
P 4 = { 0 , − 0.932245 , 0.838485 , − 0.496357 ± 0.839896 i } . (33) \mathcal{P}_4=\{0,\ -0.932245,\ 0.838485,\ -0.496357\pm0.839896i\}. \tag*{(33)} P 4 = { 0 , − 0.932245 , 0.838485 , − 0.496357 ± 0.839896 i } . (33)
Each channel therefore contains a complex-conjugate pole pair, ensuring that the constructed true transfer function contains poles not constrained to the real axis, and every pole lies strictly inside the unit circle, with max z ∈ P c ∣ z ∣ \max_{z\in\mathcal{P}_c}|z| max z ∈ P c ∣ z ∣ approximately equal to 0.994400, 0.990691, 0.981400 and 0.975600 for the four channels.
Target Signal. We generate the target signal by applying the true transfer function to the input signal, such that Y c ( z ) = H c ( z ) X c ( z ) Y_c(z)=H_c(z)X_c(z) Y c ( z ) = H c ( z ) X c ( z ) . Here, the input is zero outside 1 ≤ t ≤ T 1\le t\le T 1 ≤ t ≤ T , and Y c ( z ) Y_c(z) Y c ( z ) transforms the full causal zero-state response, whose first T T T samples form the target sequence. Equivalently,
Y c ( z ) = z − 1 ( ∑ j = 0 4 b c , j z − j ) X c ( z ) + ( ∑ j = 1 4 a c , j z − j ) Y c ( z ) . (34) Y_c(z)=z^{-1}\left(\sum_{j=0}^{4}b_{c,j}z^{-j}\right)X_c(z)+\left(\sum_{j=1}^{4}a_{c,j}z^{-j}\right)Y_c(z). \tag*{(34)} Y c ( z ) = z − 1 ( j = 0 ∑ 4 b c , j z − j ) X c ( z ) + ( j = 1 ∑ 4 a c , j z − j ) Y c ( z ) . (34)
The corresponding direct causal recurrence is
y t , c = ∑ j = 0 4 b c , j x t − 1 − j , c + ∑ j = 1 4 a c , j y t − j , c , y t , c = x t , c = 0 for t ≤ 0. (35) y_{t,c}=\sum_{j=0}^{4}b_{c,j}x_{t-1-j,c}+\sum_{j=1}^{4}a_{c,j}y_{t-j,c},\qquad y_{t,c}=x_{t,c}=0\quad\text{for }t\le0. \tag*{(35)} y t , c = j = 0 ∑ 4 b c , j x t − 1 − j , c + j = 1 ∑ 4 a c , j y t − j , c , y t , c = x t , c = 0 for t ≤ 0. (35)
Constructing Cayley Map
For any skew-symmetric S S S , the matrix I − S I-S I − S is invertible and the Cayley map [3 ]
R = ( I + S ) ( I − S ) − 1 (36) R=(I+S)(I-S)^{-1} \tag*{(36)} R = ( I + S ) ( I − S ) − 1 (36)
is a rotation. Orthogonality follows from S T = − S S^{\mathsf{T}}=-S S T = − S together with the commutation of I + S I+S I + S and I − S I-S I − S ,
R T R = ( I − S ) − T ( I + S ) T ( I + S ) ( I − S ) − 1 = ( I + S ) − 1 ( I − S ) ( I + S ) ( I − S ) − 1 = I , R^{\mathsf{T}}R=(I-S)^{-\mathsf{T}}(I+S)^{\mathsf{T}}(I+S)(I-S)^{-1}=(I+S)^{-1}(I-S)(I+S)(I-S)^{-1}=I, R T R = ( I − S ) − T ( I + S ) T ( I + S ) ( I − S ) − 1 = ( I + S ) − 1 ( I − S ) ( I + S ) ( I − S ) − 1 = I ,
and det R = 1 \det R=1 det R = 1 by continuity from S = 0 S=0 S = 0 . The map therefore parameterizes rotations without trigonometric evaluation, and its image is the set of rotations that do not have − 1 -1 − 1 as an eigenvalue.
In two dimensions every skew-symmetric matrix carries a single free parameter,
S = τ J , J = ( 0 − 1 1 0 ) , S = ( 0 − τ τ 0 ) , S=\tau J,\qquad J=\begin{pmatrix}0&-1\\1&0\end{pmatrix},\qquad S=\begin{pmatrix}0&-\tau\\\tau&0\end{pmatrix}, S = τ J , J = ( 0 1 − 1 0 ) , S = ( 0 τ − τ 0 ) ,
so that a planar rotation is determined by τ \tau τ alone. Evaluating equation (36) with det ( I − S ) = 1 + τ 2 \det(I-S)=1+\tau^2 det ( I − S ) = 1 + τ 2 gives
R = 1 1 + τ 2 ( 1 − τ τ 1 ) ( 1 − τ τ 1 ) = 1 1 + τ 2 ( 1 − τ 2 − 2 τ 2 τ 1 − τ 2 ) , R=\frac{1}{1+\tau^2}\begin{pmatrix}1&-\tau\\\tau&1\end{pmatrix}\begin{pmatrix}1&-\tau\\\tau&1\end{pmatrix}=\frac{1}{1+\tau^2}\begin{pmatrix}1-\tau^2&-2\tau\\2\tau&1-\tau^2\end{pmatrix}, R = 1 + τ 2 1 ( 1 τ − τ 1 ) ( 1 τ − τ 1 ) = 1 + τ 2 1 ( 1 − τ 2 2 τ − 2 τ 1 − τ 2 ) ,
and therefore
cos θ = 1 − τ 2 1 + τ 2 , sin θ = 2 τ 1 + τ 2 , τ = tan θ 2 , (37) \cos\theta=\frac{1-\tau^2}{1+\tau^2},\qquad\sin\theta=\frac{2\tau}{1+\tau^2},\qquad\tau=\tan\frac{\theta}{2}, \tag*{(37)} cos θ = 1 + τ 2 1 − τ 2 , sin θ = 1 + τ 2 2 τ , τ = tan 2 θ , (37)
which is the general Cayley parameterization of a planar rotation.
Hyperbolic map. Choosing τ = tanh ( α / 2 ) \tau=\tanh(\alpha/2) τ = tanh ( α /2 ) gives the hyperbolic parameterization
cos θ = 1 − tanh 2 ( α / 2 ) 1 + tanh 2 ( α / 2 ) = sech α , sin θ = 2 tanh ( α / 2 ) 1 + tanh 2 ( α / 2 ) = tanh α , (38) \cos\theta=\frac{1-\tanh^2(\alpha/2)}{1+\tanh^2(\alpha/2)}=\operatorname{sech}\alpha,\qquad\sin\theta=\frac{2\tanh(\alpha/2)}{1+\tanh^2(\alpha/2)}=\tanh\alpha, \tag*{(38)} cos θ = 1 + tanh 2 ( α /2 ) 1 − tanh 2 ( α /2 ) = sech α , sin θ = 1 + tanh 2 ( α /2 ) 2 tanh ( α /2 ) = tanh α , (38)
with θ = arctan ( sinh α ) ∈ ( − π / 2 , π / 2 ) \theta=\arctan(\sinh\alpha)\in(-\pi/2,\pi/2) θ = arctan ( sinh α ) ∈ ( − π /2 , π /2 ) . The identity sech 2 α + tanh 2 α = 1 \operatorname{sech}^2\alpha+\tanh^2\alpha=1 sech 2 α + tanh 2 α = 1 preserves orthogonality.
Weight Initialization
Characteristic Horizon. Consider a stable continuous-time oscillatory mode
d V ( τ ) d τ = ( − 1 H + i ω ) V ( τ ) . (39) \frac{\mathrm{d}V(\tau)}{\mathrm{d}\tau}=\left(-\frac{1}{H}+\mathrm{i}\omega\right)V(\tau). \tag*{(39)} d τ d V ( τ ) = ( − H 1 + i ω ) V ( τ ) . (39)
Its evolution over one token interval is
V ( τ + 1 ) = exp ( − 1 H ) exp ( i ω ) V ( τ ) . (40) V(\tau+1)=\exp\left(-\frac{1}{H}\right)\exp(\mathrm{i}\omega)V(\tau). \tag*{(40)} V ( τ + 1 ) = exp ( − H 1 ) exp ( i ω ) V ( τ ) . (40)
Therefore, the corresponding discrete-time pole is λ = q exp ( i ω ) \lambda=q\exp(\mathrm{i}\omega) λ = q exp ( i ω ) , where its radius and horizon satisfy
q = exp ( − 1 H ) , H = − 1 log q . (41) q=\exp\left(-\frac{1}{H}\right),\qquad H=-\frac{1}{\log q}. \tag*{(41)} q = exp ( − H 1 ) , H = − log q 1 . (41)
Here q q q denotes the radius of an assembled recurrent pole rather than the local contraction coefficient r c ( k ) r_c^{(k)} r c ( k ) .
Jeffreys Prior. The Jeffreys prior of a parameter η \eta η is p ( η ) ∝ I ( η ) p(\eta) \propto\sqrt{\mathcal{I}(\eta)} p ( η ) ∝ I ( η ) , where I ( η ) \mathcal{I}(\eta) I ( η ) denotes the Fisher information of η \eta η ; it is invariant under reparameterization, so that equal prior mass corresponds to equal statistical distinguishability [15 ] . We apply it to the decay rate η = 1 / H \eta= 1/H η = 1/ H of a channel c ∈ { 1 , … , d e } c \in\{1,\ldots,d_e\} c ∈ { 1 , … , d e } whose readout depends on the preceding T T T writes through the energy-normalized memory kernel
k H ( τ ) = q τ ∑ s = 1 T q 2 s , τ ∈ { 1 , … , T } , (42) k_H(\tau) = \frac{q^\tau}{\sqrt{\sum_{s=1}^{T}q^{2s}}}, \qquad\tau\in\{1,\ldots,T\}, \tag*{(42)} k H ( τ ) = ∑ s = 1 T q 2 s q τ , τ ∈ { 1 , … , T } , (42)
which is the response C q τ cos ( ω τ + ϕ ) Cq^\tau\cos(\omega\tau+\phi) C q τ cos ( ω τ + ϕ ) of the pole pair q exp ( ± i ω ) q\exp(\pm i\omega) q exp ( ± iω ) averaged over the readout phase ϕ \phi ϕ and normalized to unit energy. For a readout y t = g ∑ τ = 1 T k H ( τ ) u t − τ + n t y_t = g\sum_{\tau=1}^{T} k_H(\tau)u_{t-\tau}+n_t y t = g ∑ τ = 1 T k H ( τ ) u t − τ + n t with gain g > 0 g>0 g > 0 , uncorrelated unit-variance writes u t u_t u t and noise n t ∼ N ( 0 , σ n 2 ) n_t\sim\mathcal{N}(0,\sigma_n^2) n t ∼ N ( 0 , σ n 2 ) , the Fisher information of η \eta η is I ( η ) = ( g 2 / σ n 2 ) Var w η ( τ ) \mathcal{I}(\eta)=(g^2/\sigma_n^2)\operatorname{Var}_{w_\eta}(\tau) I ( η ) = ( g 2 / σ n 2 ) Var w η ( τ ) , the variance of the lag τ \tau τ under the weights w η ( τ ) = k H ( τ ) 2 w_\eta(\tau)=k_H(\tau)^2 w η ( τ ) = k H ( τ ) 2 . The Jeffreys prior per unit log H \log H log H is therefore
p ( log H ) ∝ η Var w η ( τ ) , (43) p(\log H) \propto\eta\sqrt{\operatorname{Var}_{w_\eta}(\tau)}, \tag*{(43)} p ( log H ) ∝ η Var w η ( τ ) , (43)
which is constant for H ≪ T H\ll T H ≪ T and decays as 1 / H 1/H 1/ H for H ≫ T H\gg T H ≫ T . We evaluate it through the closed form
p ~ ( log H ) ∝ η I ~ ( η ) , I ~ ( η ) = ∑ τ = 1 T τ ϱ τ = ϱ ( 1 − ( T + 1 ) ϱ T + T ϱ T + 1 ) ( 1 − ϱ ) 2 , ϱ = e − 2 η , (44) \widetilde{p}(\log H) \propto\eta\sqrt{\widetilde{\mathcal{I}}(\eta)}, \qquad\widetilde{\mathcal{I}}(\eta)=\sum_{\tau=1}^{T}\tau\varrho^\tau=\frac{\varrho\left(1-(T+1)\varrho^T+T\varrho^{T+1}\right)}{(1-\varrho)^2}, \qquad\varrho=e^{-2\eta}, \tag*{(44)} p ( log H ) ∝ η I ( η ) , I ( η ) = τ = 1 ∑ T τ ϱ τ = ( 1 − ϱ ) 2 ϱ ( 1 − ( T + 1 ) ϱ T + T ϱ T + 1 ) , ϱ = e − 2 η , (44)
which has the same two regimes.
Initialization. On the horizon range [ H min , H max ] [H_{\min},H_{\max}] [ H m i n , H m a x ] , let F F F denote the cumulative distribution of the density (44) . The d e d_e d e horizons are its quantiles H c ⋆ = F − 1 ( ( c − 1 2 ) / d e ) H_c^\star=F^{-1}((c-\frac{1}{2})/d_e) H c ⋆ = F − 1 (( c − 2 1 ) / d e ) , and channel c c c receives H c = H π ( c ) ⋆ H_c=H_{\pi(c)}^\star H c = H π ( c ) ⋆ , where π \pi π is a uniformly random permutation of { 1 , … , d e } \{1,\ldots,d_e\} { 1 , … , d e } . For K = 2 K=2 K = 2 , channel c c c takes the target pole pair q c exp ( ± i ω c ) q_c\exp(\pm i\omega_c) q c exp ( ± i ω c ) with q c = exp ( − 1 / H c ) q_c=\exp(-1/H_c) q c = exp ( − 1/ H c ) and
ω c = { min { 2 π N c , a ω H c } , H c ≥ H ω , 2 π N c , H c < H ω , (45) \omega_c =
\begin{cases}
\min\left\{\dfrac{2\pi}{N_c},\dfrac{a_\omega}{H_c}\right\}, & H_c\ge H_\omega,\\
\dfrac{2\pi}{N_c}, & H_c<H_\omega,
\end{cases} \tag*{(45)} ω c = ⎩ ⎨ ⎧ min { N c 2 π , H c a ω } , N c 2 π , H c ≥ H ω , H c < H ω , (45)
where N c = N ( ( c − 1 ) m o d P ) + 1 N_c=N_{((c-1)\bmod P)+1} N c = N (( c − 1 ) mod P ) + 1 cycles through the integers N 1 , … , N P > 4 N_1,\ldots,N_P>4 N 1 , … , N P > 4 , and H ω > 0 H_\omega>0 H ω > 0 and a ω > 0 a_\omega>0 a ω > 0 denote the horizon threshold and the constant of the horizon-tied angle. Matching the characteristic polynomial z 2 + κ ( 1 ) ( 1 + κ ( 2 ) ) z + r 2 2 κ ( 2 ) z^2+\kappa^{(1)}(1+\kappa^{(2)})z+r_2^2\kappa^{(2)} z 2 + κ ( 1 ) ( 1 + κ ( 2 ) ) z + r 2 2 κ ( 2 ) of the two-stage transition of equation (2) , where κ ( k ) = r k sin θ k \kappa^{(k)}=r_k\sin\theta_k κ ( k ) = r k sin θ k , to z 2 − 2 q c cos ( ω c ) z + q c 2 z^2-2q_c\cos(\omega_c)z+q_c^2 z 2 − 2 q c cos ( ω c ) z + q c 2 at r 1 = 1 r_1=1 r 1 = 1 gives the stage coefficients, from which each stage takes its radius and sine with a margin ϵ ∈ ( 0 , 1 ) \epsilon\in(0,1) ϵ ∈ ( 0 , 1 ) ,
κ c ( 1 ) = − 2 q c cos ( ω c ) 1 + q c 2 , κ c ( 2 ) = q c 2 , r c ( k ) = 1 − ϵ ( 1 − ∣ κ c ( k ) ∣ ) , sin ( θ c ( k ) ) = κ c ( k ) r c ( k ) . (46) \kappa_c^{(1)}=-\frac{2q_c\cos(\omega_c)}{1+q_c^2}, \qquad\kappa_c^{(2)}=q_c^2, \qquad r_c^{(k)}=1-\epsilon\left(1-\left|\kappa_c^{(k)}\right|\right), \qquad\sin\left(\theta_c^{(k)}\right)=\frac{\kappa_c^{(k)}}{r_c^{(k)}}. \tag*{(46)} κ c ( 1 ) = − 1 + q c 2 2 q c cos ( ω c ) , κ c ( 2 ) = q c 2 , r c ( k ) = 1 − ϵ ( 1 − κ c ( k ) ) , sin ( θ c ( k ) ) = r c ( k ) κ c ( k ) . (46)
The realized pole pair has modulus r c ( 1 ) q c r_c^{(1)}q_c r c ( 1 ) q c . Inverting sin ( θ ) = ( 1 − α 2 ) / ( 1 + α 2 ) \sin(\theta)=(1-\alpha^2)/(1+\alpha^2) sin ( θ ) = ( 1 − α 2 ) / ( 1 + α 2 ) and r = 1 / ( 1 + β 2 ) r=1/(1+\beta^2) r = 1/ ( 1 + β 2 ) gives the biases
b α , c ( k ) = ξ α , c ( k ) 1 − sin ( θ c ( k ) ) 1 + sin ( θ c ( k ) ) , b β , c ( k ) = ξ β , c ( k ) 1 r c ( k ) − 1 , k ∈ { 1 , 2 } , (47) b_{\alpha,c}^{(k)}=\xi_{\alpha,c}^{(k)}\sqrt{\frac{1-\sin\left(\theta_c^{(k)}\right)}{1+\sin\left(\theta_c^{(k)}\right)}}, \qquad b_{\beta,c}^{(k)}=\xi_{\beta,c}^{(k)}\sqrt{\frac{1}{r_c^{(k)}}-1}, \qquad k\in\{1,2\}, \tag*{(47)} b α , c ( k ) = ξ α , c ( k ) 1 + sin ( θ c ( k ) ) 1 − sin ( θ c ( k ) ) , b β , c ( k ) = ξ β , c ( k ) r c ( k ) 1 − 1 , k ∈ { 1 , 2 } , (47)
where ξ α , c ( k ) , ξ β , c ( k ) ∈ { − 1 , + 1 } \xi_{\alpha,c}^{(k)},\xi_{\beta,c}^{(k)}\in\{-1,+1\} ξ α , c ( k ) , ξ β , c ( k ) ∈ { − 1 , + 1 } are independent uniformly random signs that leave the poles unchanged. Every entry of W α W_\alpha W α , W β W_\beta W β , W ρ W_\rho W ρ , and W ν W_\nu W ν is drawn independently from U ( − 3 σ 0 , 3 σ 0 ) \mathcal{U}(-\sqrt{3}\sigma_0,\sqrt{3}\sigma_0) U ( − 3 σ 0 , 3 σ 0 ) , where σ 0 > 0 \sigma_0>0 σ 0 > 0 denotes the standard deviation of the weight entries, and each entry of b ρ b_\rho b ρ and b ν b_\nu b ν has a uniformly random sign and a magnitude drawn from U ( ( K + 1 ) − 1 / 4 / ( 4 d r ) , ( K + 1 ) − 1 / 4 / d r ) \mathcal{U}((K+1)^{-1/4}/(4\sqrt{d_r}),(K+1)^{-1/4}/\sqrt{d_r}) U (( K + 1 ) − 1/4 / ( 4 d r ) , ( K + 1 ) − 1/4 / d r ) .
Poles of Recurrent Systems
We characterize the poles induced by the recurrent dynamics of each sequence mixer. For methods with input-dependent coefficients, we fix the coefficients at token position t t t and analyze the resulting frozen system. The denominators below are unreduced; actual transfer poles may be removed by cancellation.
Theorem 1 (Poles of First-Order Systems). Let x t ∈ R d x x_t \in\mathbb{R}^{d_x} x t ∈ R d x , h t ∈ R n h_t \in\mathbb{R}^n h t ∈ R n , and y t ∈ R d y y_t \in\mathbb{R}^{d_y} y t ∈ R d y denote the input, recurrent state, and output at token position t t t , respectively. Consider the first-order system
h t = A h t − 1 + B x t , y t = C h t + D x t , (48) h_t = A h_{t-1} + Bx_t, \qquad y_t = C h_t + D x_t, \tag*{(48)} h t = A h t − 1 + B x t , y t = C h t + D x t , (48) where A ∈ R n × n A \in\mathbb{R}^{n \times n} A ∈ R n × n is the recurrent transition matrix and B B B , C C C , and D D D are the input, readout, and feedthrough matrices of compatible dimensions. With h 0 = 0 h_0 = 0 h 0 = 0 , the corresponding transfer function is
H ( z ) = A ( z ) B ( z ) , (49) H(z) = \frac{A(z)}{B(z)}, \tag*{(49)} H ( z ) = B ( z ) A ( z ) , (49) where
A ( z ) = C adj ( I − A z − 1 ) B + D det ( I − A z − 1 ) , (50) A(z) = C \operatorname{adj}(I - A z^{-1}) B + D \det(I - A z^{-1}), \tag*{(50)} A ( z ) = C adj ( I − A z − 1 ) B + D det ( I − A z − 1 ) , (50) B ( z ) = det ( I − A z − 1 ) = ∏ j = 1 n ( 1 − λ j z − 1 ) . (51) B(z) = \det(I - A z^{-1}) = \prod_{j=1}^{n} (1 - \lambda_j z^{-1}). \tag*{(51)} B ( z ) = det ( I − A z − 1 ) = j = 1 ∏ n ( 1 − λ j z − 1 ) . (51) Here, z ∈ C z \in\mathbb{C} z ∈ C is the z z z -transform variable, I ∈ R n × n I \in\mathbb{R}^{n \times n} I ∈ R n × n is the identity matrix, adj ( ⋅ ) \operatorname{adj}(\cdot) adj ( ⋅ ) and det ( ⋅ ) \det(\cdot) det ( ⋅ ) denote the adjugate and determinant, respectively, and λ 1 , … , λ n ∈ spec ( A ) \lambda_1, \ldots, \lambda_n \in\operatorname{spec}(A) λ 1 , … , λ n ∈ spec ( A ) are the eigenvalues of A A A . The finite poles of the transfer function form a subset of spec ( A ) \operatorname{spec}(A) spec ( A ) , after clearing negative powers of z z z and cancelling common factors.
Proof. Let X ( z ) X(z) X ( z ) and H z ( z ) H_z(z) H z ( z ) denote the z z z -transforms of the input sequence and recurrent-state sequence, respectively. Taking the z z z -transform of the state equation gives
H z ( z ) = A z − 1 H z ( z ) + B X ( z ) , (52) H_z(z) = A z^{-1} H_z(z) + B X(z), \tag*{(52)} H z ( z ) = A z − 1 H z ( z ) + B X ( z ) , (52)
and therefore
H z ( z ) = ( I − A z − 1 ) − 1 B X ( z ) . (53) H_z(z) = (I - A z^{-1})^{-1} B X(z). \tag*{(53)} H z ( z ) = ( I − A z − 1 ) − 1 B X ( z ) . (53)
Substitution into the output equation yields
H ( z ) = C ( I − A z − 1 ) − 1 B + D = z C ( z I − A ) − 1 B + D . (54) H(z) = C(I - A z^{-1})^{-1} B + D = z C(zI - A)^{-1}B + D. \tag*{(54)} H ( z ) = C ( I − A z − 1 ) − 1 B + D = z C ( z I − A ) − 1 B + D . (54)
Using
( I − A z − 1 ) − 1 = adj ( I − A z − 1 ) det ( I − A z − 1 ) (55) (I - A z^{-1})^{-1} = \frac{\operatorname{adj}(I - A z^{-1})}{\det(I - A z^{-1})} \tag*{(55)} ( I − A z − 1 ) − 1 = det ( I − A z − 1 ) adj ( I − A z − 1 ) (55)
gives the stated numerator and denominator. Moreover,
det ( I − A z − 1 ) = z − n det ( z I − A ) = ∏ j = 1 n ( 1 − λ j z − 1 ) , (56) \det(I - A z^{-1}) = z^{-n} \det(zI - A) = \prod_{j=1}^{n}(1 - \lambda_j z^{-1}), \tag*{(56)} det ( I − A z − 1 ) = z − n det ( z I − A ) = j = 1 ∏ n ( 1 − λ j z − 1 ) , (56)
Thus, H ( z ) = [ z C adj ( z I − A ) B + D det ( z I − A ) ] / det ( z I − A ) H(z) = [zC\operatorname{adj}(zI - A)B + D\det(zI - A)]/\det(zI - A) H ( z ) = [ z C adj ( z I − A ) B + D det ( z I − A )] / det ( z I − A ) , so every finite transfer pole, including any pole at the origin, is an eigenvalue of A A A ; numerator cancellation can remove such poles. □ \square □
For token-dependent coefficients evaluated along the input sequence, h t = A t h t − 1 + B t x t h_t = A_t h_{t-1} + B_t x_t h t = A t h t − 1 + B t x t , y t = C t h t + D t x t y_t = C_t h_t + D_t x_t y t = C t h t + D t x t , and h 0 = 0 h_0 = 0 h 0 = 0 , repeated substitution gives
y t = D t x t + ∑ τ = 1 t C t ( A t ⋯ A τ + 1 ) B τ x τ , (57) y_t = D_t x_t + \sum_{\tau=1}^{t} C_t(A_t \cdots A_{\tau+1})B_\tau x_\tau, \tag*{(57)} y t = D t x t + τ = 1 ∑ t C t ( A t ⋯ A τ + 1 ) B τ x τ , (57)
where τ \tau τ indexes the input position and the product is I I I for τ = t \tau= t τ = t . This exact response retains the coefficient history. When the coefficients are held constant, the product becomes A t − τ A^{t-\tau} A t − τ and the rational transfer function above applies.
Corollary 1 (Symmetric Transitions Imply Real Poles). If A A A is symmetric, or if there exists a positive-definite diagonal matrix D s D_s D s such that D s A D_sA D s A is symmetric, then every pole of the corresponding recurrent system is real.
Proof. If A A A is symmetric, the spectral theorem gives
spec ( A ) ⊂ R . (58) \operatorname{spec}(A) \subset\mathbb{R}. \tag*{(58)} spec ( A ) ⊂ R . (58) If D s ≻ 0 D_s \succ0 D s ≻ 0 and D s A D_sA D s A is symmetric, then
D s 1 / 2 A D s − 1 / 2 = D s − 1 / 2 ( D s A ) D s − 1 / 2 (59) D_s^{1/2} A D_s^{-1/2} = D_s^{-1/2}(D_sA)D_s^{-1/2} \tag*{(59)} D s 1/2 A D s − 1/2 = D s − 1/2 ( D s A ) D s − 1/2 (59) is symmetric. Since similar matrices have the same eigenvalues, A A A also has a real spectrum. The result then follows from Theorem 1.
Scaled Dot-Product Attention
Let q t , k t ∈ R d q_t, k_t \in\mathbb{R}^{d} q t , k t ∈ R d and v t ∈ R d v v_t \in\mathbb{R}^{d_v} v t ∈ R d v denote the query, key, and value at token position t t t , where d d d is the query–key dimension and d v d_v d v is the value dimension. Causal SDPA computes
y t = ∑ s = 1 t exp ( q t T k s / d ) ∑ s ′ = 1 t exp ( q t T k s ′ / d ) v s , (60) y_t = \sum_{s=1}^{t} \frac{\exp(q_t^{\mathsf{T}} k_s/\sqrt{d})}{\sum_{s'=1}^{t} \exp(q_t^{\mathsf{T}} k_{s'}/\sqrt{d})} v_s, \tag*{(60)} y t = s = 1 ∑ t ∑ s ′ = 1 t exp ( q t T k s ′ / d ) exp ( q t T k s / d ) v s , (60)
where s s s and s ′ s' s ′ index preceding token positions. An exact recurrent representation retains the preceding keys and values,
h t = ( k 1 , v 1 , … , k t , v t ) , (61) h_t = (k_1, v_1, \ldots, k_t, v_t), \tag*{(61)} h t = ( k 1 , v 1 , … , k t , v t ) , (61)
whose dimension grows with t t t . In particular, the softmax kernel does not admit an exact finite-dimensional factorization because
exp ( q T k / d ) = ∑ p = 0 ∞ ( q T k ) p p ! d p / 2 , (62) \exp(q^{\mathsf{T}}k/\sqrt{d}) = \sum_{p=0}^{\infty} \frac{(q^{\mathsf{T}}k)^p}{p!d^{p/2}}, \tag*{(62)} exp ( q T k / d ) = p = 0 ∑ ∞ p ! d p /2 ( q T k ) p , (62)
where p p p indexes the polynomial degree. The kernel has infinite feature rank: even for scalar queries and keys, the functions q ↦ e q k j q \mapsto e^{qk_j} q ↦ e q k j for arbitrarily many distinct keys k j k_j k j are linearly independent. Thus, unrestricted SDPA has no exact fixed finite-dimensional linear feature-state representation and no corresponding fixed finite-order rational LTI transfer function. At a fixed finite context with attention weights frozen, its output is instead a finite weighted sum of delayed values.
Linear Attention
Let ϕ : R d → R d ϕ \phi: \mathbb{R}^{d} \to\mathbb{R}^{d_\phi} ϕ : R d → R d ϕ denote a finite-dimensional feature map, where d ϕ d_\phi d ϕ is the feature dimension. Linear attention maintains the matrix state S t ∈ R d ϕ × d v S_t \in\mathbb{R}^{d_\phi\times d_v} S t ∈ R d ϕ × d v and normalization state z t ∈ R d ϕ z_t \in\mathbb{R}^{d_\phi} z t ∈ R d ϕ :
S t = S t − 1 + ϕ ( k t ) v t T , (63) S_t = S_{t-1} + \phi(k_t)v_t^{\mathsf{T}}, \tag*{(63)} S t = S t − 1 + ϕ ( k t ) v t T , (63)
z t = z t − 1 + ϕ ( k t ) , (64) z_t = z_{t-1} + \phi(k_t), \tag*{(64)} z t = z t − 1 + ϕ ( k t ) , (64)
y t = ϕ ( q t ) T S t ϕ ( q t ) T z t . (65) y_t = \frac{\phi(q_t)^{\mathsf{T}}S_t}{\phi(q_t)^{\mathsf{T}}z_t}. \tag*{(65)} y t = ϕ ( q t ) T z t ϕ ( q t ) T S t . (65)
Using vec ( ⋅ ) \operatorname{vec}(\cdot) vec ( ⋅ ) to denote column-wise matrix vectorization and ⊗ \otimes ⊗ to denote the Kronecker product, the stacked state
h t = ( vec ( S t ) z t ) ∈ R d ϕ d v + d ϕ (66) h_t =
\begin{pmatrix}
\operatorname{vec}(S_t) \\
z_t
\end{pmatrix}
\in\mathbb{R}^{d_\phi d_v+d_\phi} \tag*{(66)} h t = ( vec ( S t ) z t ) ∈ R d ϕ d v + d ϕ (66)
satisfies
h t = ( I d ϕ d v 0 0 I d ϕ ) h t − 1 + ( v t ⊗ ϕ ( k t ) ϕ ( k t ) ) , (67) h_t =
\begin{pmatrix}
I_{d_\phi d_v} & 0 \\
0 & I_{d_\phi}
\end{pmatrix}
h_{t-1}
+
\begin{pmatrix}
v_t \otimes\phi(k_t) \\
\phi(k_t)
\end{pmatrix}, \tag*{(67)} h t = ( I d ϕ d v 0 0 I d ϕ ) h t − 1 + ( v t ⊗ ϕ ( k t ) ϕ ( k t ) ) , (67)
where I m I_m I m denotes the m × m m \times m m × m identity matrix. The state transition is therefore the identity matrix, with denominator
B ( z ) = ( 1 − z − 1 ) d ϕ d v + d ϕ . (68) B(z) = (1-z^{-1})^{d_\phi d_v+d_\phi}. \tag*{(68)} B ( z ) = ( 1 − z − 1 ) d ϕ d v + d ϕ . (68)
Thus, all poles of the recurrent state lie at z = 1 z = 1 z = 1 . The normalized output remains a ratio of two linear functionals of the state; without the normalizer and with query and key coefficients frozen, the map from values to outputs is a first-order linear system.
Selective State Space Models
Let u t , d ∈ R u_{t,d} \in\mathbb{R} u t , d ∈ R and y t , d ∈ R y_{t,d} \in\mathbb{R} y t , d ∈ R denote the input and output at token position t t t and channel d d d . Let h t ∈ R N h_t \in\mathbb{R}^{N} h t ∈ R N denote the corresponding recurrent state, where N N N is the state dimension. A selective SSM has the frozen recurrent dynamics
h t = diag ( e Δ t , d A d , 1 , … , e Δ t , d A d , N ) h t − 1 + Δ t , d B t u t , d , (69) h_t = \operatorname{diag}\left(e^{\Delta_{t,d}A_{d,1}}, \ldots, e^{\Delta_{t,d}A_{d,N}}\right)h_{t-1} + \Delta_{t,d}B_tu_{t,d}, \tag*{(69)} h t = diag ( e Δ t , d A d , 1 , … , e Δ t , d A d , N ) h t − 1 + Δ t , d B t u t , d , (69)
where Δ t , d > 0 \Delta_{t,d} > 0 Δ t , d > 0 is the input-dependent step size, A d , n < 0 A_{d,n} < 0 A d , n < 0 is the continuous-time transition coefficient of state n n n , and B t ∈ R N B_t \in\mathbb{R}^{N} B t ∈ R N is the input coefficient. Let C t ∈ R N C_t \in\mathbb{R}^{N} C t ∈ R N and D d ∈ R D_d \in\mathbb{R} D d ∈ R denote the readout and feedthrough coefficients, respectively. The corresponding transfer function is
H ( z ) = ∑ n = 1 N Δ B n C n 1 − a ˉ n z − 1 + D , a ˉ n = e Δ a n , (70) H(z) = \sum_{n=1}^{N} \frac{\Delta B_n C_n}{1-\bar{a}_n z^{-1}} + D,\qquad\bar{a}_n = e^{\Delta a_n}, \tag*{(70)} H ( z ) = n = 1 ∑ N 1 − a ˉ n z − 1 Δ B n C n + D , a ˉ n = e Δ a n , (70)
with denominator
B ( z ) = ∏ n = 1 N ( 1 − a ˉ n z − 1 ) . (71) B(z) = \prod_{n=1}^{N}(1-\bar{a}_n z^{-1}). \tag*{(71)} B ( z ) = n = 1 ∏ N ( 1 − a ˉ n z − 1 ) . (71)
The frozen transition matrix is diagonal and therefore symmetric. By Corollary 1 , all poles are real. Since Δ > 0 \Delta> 0 Δ > 0 and a n < 0 a_n < 0 a n < 0 ,
a ˉ n = e Δ a n ∈ ( 0 , 1 ) , (72) \bar{a}_n = e^{\Delta a_n} \in(0,1), \tag*{(72)} a ˉ n = e Δ a n ∈ ( 0 , 1 ) , (72)
so every pole lies on the positive real axis inside the unit circle.
RWKV-6
For each head, let S t ∈ R S × S S_t \in\mathbb{R}^{S \times S} S t ∈ R S × S denote the recurrent state and let r t , k t , v t , w t ∈ R S r_t, k_t, v_t, w_t \in\mathbb{R}^{S} r t , k t , v t , w t ∈ R S denote the receptance, key, value, and decay vectors, respectively, where S S S is the head dimension and w t ∈ ( 0 , 1 ) S w_t \in(0,1)^{S} w t ∈ ( 0 , 1 ) S . RWKV-6 updates
S t = diag ( w t ) S t − 1 + k t v t T . (73) S_t = \operatorname{diag}(w_t)S_{t-1} + k_t v_t^{\mathsf{T}}. \tag*{(73)} S t = diag ( w t ) S t − 1 + k t v t T . (73)
Its readout is
y t = r t T ( diag ( u ) k t v t T + S t − 1 ) , (74) y_t = r_t^{\mathsf{T}}\left(\operatorname{diag}(u)k_t v_t^{\mathsf{T}} + S_{t-1}\right), \tag*{(74)} y t = r t T ( diag ( u ) k t v t T + S t − 1 ) , (74)
where u ∈ R S u \in\mathbb{R}^{S} u ∈ R S denotes the time-mixing bonus coefficient. Since diag ( w t ) \operatorname{diag}(w_t) diag ( w t ) is invertible,
S t − 1 = diag ( w t ) − 1 ( S t − k t v t T ) , (75) S_{t-1} = \operatorname{diag}(w_t)^{-1}\left(S_t-k_t v_t^{\mathsf{T}}\right), \tag*{(75)} S t − 1 = diag ( w t ) − 1 ( S t − k t v t T ) , (75)
and therefore
y t = r t T diag ( 1 / w t ) S t + [ r t T ( ( u − 1 / w t ) ⊙ k t ) ] v t T , (76) y_t = r_t^{\mathsf{T}}\operatorname{diag}(1/w_t)S_t + \left[r_t^{\mathsf{T}}\left((u-1/w_t)\odot k_t\right)\right]v_t^{\mathsf{T}}, \tag*{(76)} y t = r t T diag ( 1/ w t ) S t + [ r t T ( ( u − 1/ w t ) ⊙ k t ) ] v t T , (76)
where ⊙ \odot ⊙ denotes element-wise multiplication. For each state column, the transition matrix is
A t = diag ( w t ) . (77) A_t = \operatorname{diag}(w_t). \tag*{(77)} A t = diag ( w t ) . (77)
Its denominator polynomial is
B ( z ) = ∏ j = 1 S ( 1 − w t , j z − 1 ) . (78) B(z) = \prod_{j=1}^{S}(1-w_{t,j}z^{-1}). \tag*{(78)} B ( z ) = j = 1 ∏ S ( 1 − w t , j z − 1 ) . (78)
Because A t A_t A t is diagonal, all poles are real and satisfy
w t , j ∈ ( 0 , 1 ) . (79) w_{t,j} \in(0,1). \tag*{(79)} w t , j ∈ ( 0 , 1 ) . (79)
RWKV-7
Let S t ∈ R N × N S_t \in\mathbb{R}^{N \times N} S t ∈ R N × N denote the recurrent state, where N N N is the head dimension. Let v t , k t , r t ∈ R N v_t, k_t, r_t \in\mathbb{R}^{N} v t , k t , r t ∈ R N denote the value, key, and receptance vectors; let w t ∈ ( 0 , 1 ) N w_t \in(0,1)^{N} w t ∈ ( 0 , 1 ) N denote the decay vector; let a t ∈ ( 0 , 1 ) N a_t \in(0,1)^{N} a t ∈ ( 0 , 1 ) N denote the learning-rate vector; and let κ t ∈ R N \kappa_t \in\mathbb{R}^{N} κ t ∈ R N denote a normalized key direction satisfying ∥ κ t ∥ 2 = 1 \lVert\kappa_t\rVert_2 = 1 ∥ κ t ∥ 2 = 1 . RWKV-7 updates
S t = S t − 1 diag ( w t ) − S t − 1 κ t ( a t ⊙ κ t ) T + v t k t T . (80) S_t = S_{t-1}\operatorname{diag}(w_t)-S_{t-1}\kappa_t(a_t\odot\kappa_t)^{\mathsf{T}}+v_tk_t^{\mathsf{T}}. \tag*{(80)} S t = S t − 1 diag ( w t ) − S t − 1 κ t ( a t ⊙ κ t ) T + v t k t T . (80)
Factoring the state terms gives
S t = S t − 1 [ diag ( w t ) − κ t κ t T diag ( a t ) ] + v t k t T . (81) S_t = S_{t-1}\left[\operatorname{diag}(w_t)-\kappa_t\kappa_t^{\mathsf{T}}\operatorname{diag}(a_t)\right]+v_tk_t^{\mathsf{T}}. \tag*{(81)} S t = S t − 1 [ diag ( w t ) − κ t κ t T diag ( a t ) ] + v t k t T . (81)
After transposition, the left-acting transition matrix is
A t = diag ( w t ) − diag ( a t ) κ t κ t T . (82) A_t = \operatorname{diag}(w_t) - \operatorname{diag}(a_t)\kappa_t\kappa_t^{\mathsf{T}}. \tag*{(82)} A t = diag ( w t ) − diag ( a t ) κ t κ t T . (82)
The matrix determinant lemma gives
B ( z ) = ∏ j = 1 N ( 1 − w t , j z − 1 ) [ 1 + z − 1 ∑ j = 1 N a t , j κ t , j 2 1 − w t , j z − 1 ] . (83) B(z) = \prod_{j=1}^{N}(1-w_{t,j}z^{-1})\left[1+z^{-1}\sum_{j=1}^{N}\frac{a_{t,j}\kappa_{t,j}^{2}}{1-w_{t,j}z^{-1}}\right]. \tag*{(83)} B ( z ) = j = 1 ∏ N ( 1 − w t , j z − 1 ) [ 1 + z − 1 j = 1 ∑ N 1 − w t , j z − 1 a t , j κ t , j 2 ] . (83)
Although A t A_t A t is not generally symmetric, define the positive-definite diagonal matrix
D s = diag ( a t − 1 ) . (84) D_s = \operatorname{diag}(a_t^{-1}). \tag*{(84)} D s = diag ( a t − 1 ) . (84)
Then
D s A t = diag ( w t / a t ) − κ t κ t T (85) D_sA_t = \operatorname{diag}(w_t/a_t)-\kappa_t\kappa_t^{\mathsf{T}} \tag*{(85)} D s A t = diag ( w t / a t ) − κ t κ t T (85)
is symmetric. Equivalently,
D s 1 / 2 A t D s − 1 / 2 = diag ( w t ) − ( a t 1 / 2 ⊙ κ t ) ( a t 1 / 2 ⊙ κ t ) T (86) D_s^{1/2}A_tD_s^{-1/2}=\operatorname{diag}(w_t)-\left(a_t^{1/2}\mathbin{\odot}\kappa_t\right)\left(a_t^{1/2}\mathbin{\odot}\kappa_t\right)^{\mathsf{T}} \tag*{(86)} D s 1/2 A t D s − 1/2 = diag ( w t ) − ( a t 1/2 ⊙ κ t ) ( a t 1/2 ⊙ κ t ) T (86)
is symmetric. Corollary 1 therefore guarantees that all poles of RWKV-7 are real.
RetNet
For each head, let S t ∈ C d k × d v S_t \in\mathbb{C}^{d_k \times d_v} S t ∈ C d k × d v denote the recurrent state, where d k d_k d k and d v d_v d v are the key and value dimensions, respectively. Let q t , k t ∈ C d k q_t,k_t \in\mathbb{C}^{d_k} q t , k t ∈ C d k and v t ∈ R d v v_t \in\mathbb{R}^{d_v} v t ∈ R d v denote the query, key, and value at token position t t t . In the original RetNet formulation, the positional rotations are incorporated into the query and key:
q t = ( x t W Q ) ⊙ Θ t , k t = ( x t W K ) ⊙ Θ ‾ t , (87) q_t=(x_tW_Q)\mathbin{\odot}\Theta_t,\qquad k_t=(x_tW_K)\mathbin{\odot}\overline{\Theta}_t, \tag*{(87)} q t = ( x t W Q ) ⊙ Θ t , k t = ( x t W K ) ⊙ Θ t , (87)
where Θ t \Theta_t Θ t denotes the complex positional rotation at token position t t t and Θ ‾ t \overline{\Theta}_t Θ t denotes its complex conjugate. The recurrent representation is
S t = γ S t − 1 + k t v t T , y t = q t T S t , (88) S_t=\gamma S_{t-1}+k_tv_t^{\mathsf{T}},\qquad y_t=q_t^{\mathsf{T}}S_t, \tag*{(88)} S t = γ S t − 1 + k t v t T , y t = q t T S t , (88)
where γ ∈ ( 0 , 1 ) \gamma\in(0,1) γ ∈ ( 0 , 1 ) is the head-specific decay coefficient.
The recurrent transition matrix is γ I \gamma I γ I , where I I I denotes the identity matrix. Freezing the complete query and key coefficients, including their positional rotations, the corresponding transfer function has the denominator
B ( z ) = 1 − γ z − 1 . (89) B(z)=1-\gamma z^{-1}. \tag*{(89)} B ( z ) = 1 − γ z − 1 . (89)
Therefore, the only possible pole of each frozen RetNet head is
z = γ ∈ ( 0 , 1 ) . (90) z=\gamma\in(0,1). \tag*{(90)} z = γ ∈ ( 0 , 1 ) . (90)
For multi-scale retention with head-specific decay coefficients γ h \gamma_h γ h , the candidate pole set is
P = { γ h } h = 1 H , (91) \mathcal{P}=\{\gamma_h\}_{h=1}^{H}, \tag*{(91)} P = { γ h } h = 1 H , (91)
where H H H is the number of heads. Thus, all poles of this frozen representation are real and lie strictly inside the unit circle. This conclusion does not apply when the positional rotations retain their temporal progression, which can produce complex lag factors.
HGRN2
Let S t ∈ R d × d v S_t \in\mathbb{R}^{d \times d_v} S t ∈ R d × d v denote the recurrent state, where d d d is the feature dimension and d v d_v d v is the value dimension. Let f t ∈ ( 0 , 1 ) d f_t \in(0,1)^d f t ∈ ( 0 , 1 ) d denote the forget gate, i t ∈ R d v i_t \in\mathbb{R}^{d_v} i t ∈ R d v the input value, and o t ∈ R d o_t \in\mathbb{R}^d o t ∈ R d the output vector. HGRN2 updates
S t = diag ( f t ) S t − 1 + ( 1 − f t ) i t T , (92) S_t=\operatorname{diag}(f_t)S_{t-1}+(1-f_t)i_t^{\mathsf{T}}, \tag*{(92)} S t = diag ( f t ) S t − 1 + ( 1 − f t ) i t T , (92)
with readout
y t = o t T S t . (93) y_t=o_t^{\mathsf{T}}S_t. \tag*{(93)} y t = o t T S t . (93)
For each state column, the transition matrix is
A t = diag ( f t ) . (94) A_t=\operatorname{diag}(f_t). \tag*{(94)} A t = diag ( f t ) . (94)
The corresponding denominator is
B ( z ) = ∏ j = 1 d ( 1 − f t , j z − 1 ) . (95) B(z) = \prod_{j=1}^{d} \left(1-f_{t,j}z^{-1}\right). \tag*{(95)} B ( z ) = j = 1 ∏ d ( 1 − f t , j z − 1 ) . (95)
The transition matrix is diagonal, and its eigenvalues are
z = f t , j ∈ ( 0 , 1 ) . (96) z=f_{t,j}\in(0,1). \tag*{(96)} z = f t , j ∈ ( 0 , 1 ) . (96)
Thus, all poles of HGRN2 are real and lie strictly inside the unit circle.
Hyena
Let u t u_t u t and y t y_t y t denote the input and output of a Hyena convolutional stage. The stage applies a finite causal convolution
y t = ∑ n = 0 L − 1 κ n u t − n + D u t , (97) y_t=\sum_{n=0}^{L-1}\kappa_n u_{t-n}+Du_t, \tag*{(97)} y t = n = 0 ∑ L − 1 κ n u t − n + D u t , (97)
where L L L is the filter length, κ n \kappa_n κ n is the filter coefficient at lag n n n , and D D D is the feedthrough coefficient. The filter coefficients are generated from position according to
κ n = MLP s i n ( z ( n ) ) ⊙ e − n ∣ δ ∣ , (98) \kappa_n=\operatorname{MLP}_{\mathrm{sin}}(z(n))\odot e^{-n|\delta|}, \tag*{(98)} κ n = MLP sin ( z ( n )) ⊙ e − n ∣ δ ∣ , (98)
where z ( n ) z(n) z ( n ) is the positional embedding at lag n n n , MLP s i n \operatorname{MLP}_{\mathrm{sin}} MLP sin is the sinusoidal filter-generating network, and δ \delta δ controls exponential decay. Introducing the shift-register state
h t = ( u t , u t − 1 , … , u t − L + 1 ) T ∈ R L (99) h_t=(u_t,u_{t-1},\ldots,u_{t-L+1})^{\mathsf{T}}\in\mathbb{R}^{L} \tag*{(99)} h t = ( u t , u t − 1 , … , u t − L + 1 ) T ∈ R L (99)
gives
h t = S ↓ h t − 1 + e 1 u t , (100) h_t=S_{\downarrow}h_{t-1}+e_1u_t, \tag*{(100)} h t = S ↓ h t − 1 + e 1 u t , (100)
where S ↓ ∈ R L × L S_{\downarrow}\in\mathbb{R}^{L\times L} S ↓ ∈ R L × L is the down-shift matrix and e 1 ∈ R L e_1\in\mathbb{R}^{L} e 1 ∈ R L is the first standard basis vector. The transfer function is
H ( z ) = D + ∑ n = 0 L − 1 κ n z − n , (101) H(z)=D+\sum_{n=0}^{L-1}\kappa_n z^{-n}, \tag*{(101)} H ( z ) = D + n = 0 ∑ L − 1 κ n z − n , (101)
whose denominator is
B ( z ) = 1. (102) B(z)=1. \tag*{(102)} B ( z ) = 1. (102)
Therefore, a Hyena convolutional stage is an FIR system and has no nonzero finite poles.
DeltaNet and Gated DeltaNet
Let S t ∈ R d k × d v S_t\in\mathbb{R}^{d_k\times d_v} S t ∈ R d k × d v denote the recurrent state, where d k d_k d k and d v d_v d v are the key and value dimensions. Let k t ∈ R d k k_t\in\mathbb{R}^{d_k} k t ∈ R d k and v t ∈ R d v v_t\in\mathbb{R}^{d_v} v t ∈ R d v denote the normalized key and value, with ∥ k t ∥ 2 = 1 \lVert k_t\rVert_2=1 ∥ k t ∥ 2 = 1 . Let β t ∈ ( 0 , 1 ) \beta_t\in(0,1) β t ∈ ( 0 , 1 ) denote the update rate and α t ∈ ( 0 , 1 ) \alpha_t\in(0,1) α t ∈ ( 0 , 1 ) denote the decay coefficient for Gated DeltaNet; for DeltaNet, α t = 1 \alpha_t=1 α t = 1 . The dynamics are
S t ′ = α t S t − 1 , (103) S'_t=\alpha_t S_{t-1}, \tag*{(103)} S t ′ = α t S t − 1 , (103)
v ~ t = β t ( v t − S t ′ k t ) , (104) \tilde{v}_t=\beta_t\left(v_t-S'_t k_t\right), \tag*{(104)} v ~ t = β t ( v t − S t ′ k t ) , (104)
S t = S t ′ + k t v ~ t T , (105) S_t=S'_t+k_t\tilde{v}_t^{\mathsf{T}}, \tag*{(105)} S t = S t ′ + k t v ~ t T , (105)
where S t ′ S'_t S t ′ is the decayed state and v ~ t ∈ R d v \tilde{v}_t\in\mathbb{R}^{d_v} v ~ t ∈ R d v is the delta-rule update. Substitution gives
S t = α t S t − 1 + β t k t v t T − α t β t k t k t T S t − 1 = α t ( I d k − β t k t k t T ) S t − 1 + β t k t v t T . (106) \begin{aligned}
S_t&=\alpha_t S_{t-1}+\beta_t k_t v_t^{\mathsf{T}}-\alpha_t\beta_t k_t k_t^{\mathsf{T}}S_{t-1}\\
&=\alpha_t\left(I_{d_k}-\beta_t k_t k_t^{\mathsf{T}}\right)S_{t-1}+\beta_t k_t v_t^{\mathsf{T}}. \tag*{(106)}
\end{aligned} S t = α t S t − 1 + β t k t v t T − α t β t k t k t T S t − 1 = α t ( I d k − β t k t k t T ) S t − 1 + β t k t v t T . (106)
The transition matrix is therefore
A t = α t ( I d k − β t k t k t T ) , (107) A_t=\alpha_t\left(I_{d_k}-\beta_t k_t k_t^{\mathsf{T}}\right), \tag*{(107)} A t = α t ( I d k − β t k t k t T ) , (107)
with denominator
B ( z ) = ( 1 − α t z − 1 ) d k − 1 ( 1 − α t ( 1 − β t ) z − 1 ) . (108) B(z)=\left(1-\alpha_t z^{-1}\right)^{d_k-1}\left(1-\alpha_t(1-\beta_t)z^{-1}\right). \tag*{(108)} B ( z ) = ( 1 − α t z − 1 ) d k − 1 ( 1 − α t ( 1 − β t ) z − 1 ) . (108)
Since
A t k t = α t ( 1 − β t ) k t (109) A_t k_t = \alpha_t(1-\beta_t)k_t \tag*{(109)} A t k t = α t ( 1 − β t ) k t (109)
A t z = α t z , z ⊥ k t , (110) A_t z = \alpha_t z,\qquad z \perp k_t, \tag*{(110)} A t z = α t z , z ⊥ k t , (110)
where z ∈ R d k z \in\mathbb{R}^{d_k} z ∈ R d k denotes any vector orthogonal to k t k_t k t , the spectrum is
spec ( A t ) = { α t ( 1 − β t ) } ∪ { α t } d k − 1 . (111) \operatorname{spec}(A_t) = \{\alpha_t(1-\beta_t)\} \cup\{\alpha_t\}^{d_k-1}. \tag*{(111)} spec ( A t ) = { α t ( 1 − β t )} ∪ { α t } d k − 1 . (111)
The transition matrix is symmetric, so Corollary 1 guarantees that all poles are real.
Transfer Function of Lattice–Ladder Network
This section derives the transfer function of the parameterized lattice–ladder network. We consider a single expanded feature channel ℓ ∈ { 1 , … , d e } \ell\in\{1,\ldots,d_e\} ℓ ∈ { 1 , … , d e } and omit the channel index for clarity. For the frozen-system analysis at token position t t t , we treat the input-conditioned reflection angles θ t , ℓ ( k ) \theta_{t,\ell}^{(k)} θ t , ℓ ( k ) , radius coefficients r t , ℓ ( k ) r_{t,\ell}^{(k)} r t , ℓ ( k ) , readout coefficients ρ t , ℓ ( k ) \rho_{t,\ell}^{(k)} ρ t , ℓ ( k ) , memory write projection s t s_t s t , and memory readout projections ν t ( k ) \nu_t^{(k)} ν t ( k ) as constants, denoted by θ ( k ) \theta^{(k)} θ ( k ) , r ( k ) r^{(k)} r ( k ) , ρ ( k ) \rho^{(k)} ρ ( k ) , s s s , and ν ( k ) \nu^{(k)} ν ( k ) , respectively. Since the lattice recursion acts independently across expanded feature channels, the derivation applies to every channel.
Let K K K denote the lattice order and k ∈ { 1 , … , K } k \in\{1,\ldots,K\} k ∈ { 1 , … , K } denote the lattice stage. For token positions t ∈ { 1 , … , T } t \in\{1,\ldots,T\} t ∈ { 1 , … , T } , the lattice recursion is
U t ( k − 1 ) = r ( k ) [ cos ( θ ( k ) ) U t ( k ) − sin ( θ ( k ) ) V t − 1 ( k − 1 ) ] , (112) U_t^{(k-1)} = r^{(k)}\left[\cos\left(\theta^{(k)}\right)U_t^{(k)}-\sin\left(\theta^{(k)}\right)V_{t-1}^{(k-1)}\right], \tag*{(112)} U t ( k − 1 ) = r ( k ) [ cos ( θ ( k ) ) U t ( k ) − sin ( θ ( k ) ) V t − 1 ( k − 1 ) ] , (112)
V t ( k ) = r ( k ) [ sin ( θ ( k ) ) U t ( k ) + cos ( θ ( k ) ) V t − 1 ( k − 1 ) ] , (113) V_t^{(k)} = r^{(k)}\left[\sin\left(\theta^{(k)}\right)U_t^{(k)}+\cos\left(\theta^{(k)}\right)V_{t-1}^{(k-1)}\right], \tag*{(113)} V t ( k ) = r ( k ) [ sin ( θ ( k ) ) U t ( k ) + cos ( θ ( k ) ) V t − 1 ( k − 1 ) ] , (113)
with the boundary conditions
U t ( K ) = x t s T , V t ( 0 ) = U t ( 0 ) , V 0 ( k ) = 0 , k ∈ { 0 , … , K − 1 } . (114) U_t^{(K)}=x_t s^{\mathsf T},\qquad V_t^{(0)}=U_t^{(0)},\qquad V_0^{(k)}=0,\quad k\in\{0,\ldots,K-1\}. \tag*{(114)} U t ( K ) = x t s T , V t ( 0 ) = U t ( 0 ) , V 0 ( k ) = 0 , k ∈ { 0 , … , K − 1 } . (114)
Here, x t x_t x t denotes the input signal, U t ( k ) U_t^{(k)} U t ( k ) denotes the forward signal at stage k k k , and V t ( k ) V_t^{(k)} V t ( k ) denotes the recurrent state at stage k k k . The ladder readout is
y t = ∑ k = 0 K ρ ( k ) V t ( k ) ν ( k ) , (115) y_t=\sum_{k=0}^{K}\rho^{(k)}V_t^{(k)}\nu^{(k)}, \tag*{(115)} y t = k = 0 ∑ K ρ ( k ) V t ( k ) ν ( k ) , (115)
where y t y_t y t denotes the output signal.
Polynomial Recursion of the Lattice Stages
Let X ( z ) X(z) X ( z ) , U ( k ) ( z ) U^{(k)}(z) U ( k ) ( z ) , and V ( k ) ( z ) V^{(k)}(z) V ( k ) ( z ) denote the z z z -transforms of x t x_t x t , U t ( k ) U_t^{(k)} U t ( k ) , and V t ( k ) V_t^{(k)} V t ( k ) , respectively, with the input zero outside 1 ≤ t ≤ T 1\leq t\leq T 1 ≤ t ≤ T and the frozen recursion continued causally beyond T T T . Ratios of the row-vector signals below denote scalar response factors, not vector division. Under the zero-state condition, taking the z z z -transform of the lattice recursion gives
U ( k − 1 ) ( z ) = r ( k ) [ cos ( θ ( k ) ) U ( k ) ( z ) − sin ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) ] , (116) U^{(k-1)}(z)=r^{(k)}\left[\cos\left(\theta^{(k)}\right)U^{(k)}(z)-\sin\left(\theta^{(k)}\right)z^{-1}V^{(k-1)}(z)\right], \tag*{(116)} U ( k − 1 ) ( z ) = r ( k ) [ cos ( θ ( k ) ) U ( k ) ( z ) − sin ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) ] , (116)
V ( k ) ( z ) = r ( k ) [ sin ( θ ( k ) ) U ( k ) ( z ) + cos ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) ] . (117) V^{(k)}(z)=r^{(k)}\left[\sin\left(\theta^{(k)}\right)U^{(k)}(z)+\cos\left(\theta^{(k)}\right)z^{-1}V^{(k-1)}(z)\right]. \tag*{(117)} V ( k ) ( z ) = r ( k ) [ sin ( θ ( k ) ) U ( k ) ( z ) + cos ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) ] . (117)
Assuming cos ( θ ( k ) ) ≠ 0 \cos\left(\theta^{(k)}\right)\ne0 cos ( θ ( k ) ) = 0 at every stage for the intermediate divisions, rearranging the first equation and substituting it into the second equation gives
U ( k ) ( z ) = 1 r ( k ) cos ( θ ( k ) ) U ( k − 1 ) ( z ) + tan ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) , U^{(k)}(z)=\frac{1}{r^{(k)}\cos\left(\theta^{(k)}\right)}U^{(k-1)}(z)+\tan\left(\theta^{(k)}\right)z^{-1}V^{(k-1)}(z), U ( k ) ( z ) = r ( k ) cos ( θ ( k ) ) 1 U ( k − 1 ) ( z ) + tan ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) ,
V ( k ) ( z ) = tan ( θ ( k ) ) U ( k − 1 ) ( z ) + r ( k ) cos ( θ ( k ) ) z − 1 V ( k − 1 ) ( z ) . (118) V^{(k)}(z)=\tan\left(\theta^{(k)}\right)U^{(k-1)}(z)+\frac{r^{(k)}}{\cos\left(\theta^{(k)}\right)}z^{-1}V^{(k-1)}(z). \tag*{(118)} V ( k ) ( z ) = tan ( θ ( k ) ) U ( k − 1 ) ( z ) + cos ( θ ( k ) ) r ( k ) z − 1 V ( k − 1 ) ( z ) . (118)
Define the normalized stage polynomial P k ( z ) P_k(z) P k ( z ) and ladder-basis polynomial Q k ( z ) Q_k(z) Q k ( z ) by
P 0 ( z ) = 1 , Q 0 ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) , P_0(z)=1,\qquad Q_0(z)=\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right), P 0 ( z ) = 1 , Q 0 ( z ) = i = 1 ∏ K r ( i ) cos ( θ ( i ) ) ,
P k ( z ) = P k − 1 ( z ) + r ( k ) sin ( θ ( k ) ) ∏ i = k K r ( i ) cos ( θ ( i ) ) z − 1 Q k − 1 ( z ) , P_k(z)=P_{k-1}(z)+\frac{r^{(k)}\sin\left(\theta^{(k)}\right)}{\prod_{i=k}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}z^{-1}Q_{k-1}(z), P k ( z ) = P k − 1 ( z ) + ∏ i = k K r ( i ) cos ( θ ( i ) ) r ( k ) sin ( θ ( k ) ) z − 1 Q k − 1 ( z ) ,
Q k ( z ) = r ( k ) sin ( θ ( k ) ) ∏ i = k + 1 K r ( i ) cos ( θ ( i ) ) P k − 1 ( z ) + r ( k ) cos ( θ ( k ) ) z − 1 Q k − 1 ( z ) . (119) Q_k(z)=r^{(k)}\sin\left(\theta^{(k)}\right)\prod_{i=k+1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)P_{k-1}(z)+\frac{r^{(k)}}{\cos\left(\theta^{(k)}\right)}z^{-1}Q_{k-1}(z). \tag*{(119)} Q k ( z ) = r ( k ) sin ( θ ( k ) ) i = k + 1 ∏ K r ( i ) cos ( θ ( i ) ) P k − 1 ( z ) + cos ( θ ( k ) ) r ( k ) z − 1 Q k − 1 ( z ) . (119)
Inductively, Q k − 1 ( z ) Q_{k-1}(z) Q k − 1 ( z ) contains the factor ∏ i = k K r ( i ) cos ( θ ( i ) ) \prod_{i=k}^{K} r^{(i)} \cos\left(\theta^{(i)}\right) ∏ i = k K r ( i ) cos ( θ ( i ) ) . Cancelling this factor in the recursion for P k P_k P k and its k k k -th factor in the recursion for Q k Q_k Q k makes every coefficient polynomial in r ( i ) sin ( θ ( i ) ) r^{(i)}\sin\left(\theta^{(i)}\right) r ( i ) sin ( θ ( i ) ) , ( r ( i ) ) 2 \left(r^{(i)}\right)^2 ( r ( i ) ) 2 , and r ( i ) cos ( θ ( i ) ) r^{(i)}\cos\left(\theta^{(i)}\right) r ( i ) cos ( θ ( i ) ) . The final polynomial transfer formula therefore extends continuously to parameters with cos ( θ ( k ) ) = 0 \cos\left(\theta^{(k)}\right)=0 cos ( θ ( k ) ) = 0 . We first establish the stage-response identities
U ( k ) ( z ) U ( 0 ) ( z ) = P k ( z ) ∏ i = 1 k r ( i ) cos ( θ ( i ) ) , V ( k ) ( z ) U ( 0 ) ( z ) = Q k ( z ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) . (120) \frac{U^{(k)}(z)}{U^{(0)}(z)}=\frac{P_k(z)}{\prod_{i=1}^{k}r^{(i)}\cos\left(\theta^{(i)}\right)},
\qquad
\frac{V^{(k)}(z)}{U^{(0)}(z)}=\frac{Q_k(z)}{\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}. \tag*{(120)} U ( 0 ) ( z ) U ( k ) ( z ) = ∏ i = 1 k r ( i ) cos ( θ ( i ) ) P k ( z ) , U ( 0 ) ( z ) V ( k ) ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) Q k ( z ) . (120)
For k = 0 k=0 k = 0 , the identity follows immediately from V ( 0 ) ( z ) = U ( 0 ) ( z ) V^{(0)}(z)=U^{(0)}(z) V ( 0 ) ( z ) = U ( 0 ) ( z ) , P 0 ( z ) = 1 P_0(z)=1 P 0 ( z ) = 1 , and Q 0 ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) Q_0(z)=\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right) Q 0 ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) . Suppose that it holds at stage k − 1 k-1 k − 1 . Substituting equation (120) into the first equation of equation (118) gives
U ( k ) ( z ) U ( 0 ) ( z ) = P k − 1 ( z ) ∏ i = 1 k r ( i ) cos ( θ ( i ) ) + tan ( θ ( k ) ) z − 1 Q k − 1 ( z ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) = P k ( z ) ∏ i = 1 k r ( i ) cos ( θ ( i ) ) . (121) \frac{U^{(k)}(z)}{U^{(0)}(z)}
=
\frac{P_{k-1}(z)}{\prod_{i=1}^{k}r^{(i)}\cos\left(\theta^{(i)}\right)}
+
\frac{\tan\left(\theta^{(k)}\right)z^{-1}Q_{k-1}(z)}{\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}
=
\frac{P_k(z)}{\prod_{i=1}^{k}r^{(i)}\cos\left(\theta^{(i)}\right)}. \tag*{(121)} U ( 0 ) ( z ) U ( k ) ( z ) = ∏ i = 1 k r ( i ) cos ( θ ( i ) ) P k − 1 ( z ) + ∏ i = 1 K r ( i ) cos ( θ ( i ) ) tan ( θ ( k ) ) z − 1 Q k − 1 ( z ) = ∏ i = 1 k r ( i ) cos ( θ ( i ) ) P k ( z ) . (121)
Similarly, the second equation of equation (118) gives
V ( k ) ( z ) U ( 0 ) ( z ) = tan ( θ ( k ) ) P k − 1 ( z ) ∏ i = 1 k − 1 r ( i ) cos ( θ ( i ) ) + r ( k ) z − 1 Q k − 1 ( z ) cos ( θ ( k ) ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) = Q k ( z ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) , (122) \frac{V^{(k)}(z)}{U^{(0)}(z)}
=
\frac{\tan\left(\theta^{(k)}\right)P_{k-1}(z)}{\prod_{i=1}^{k-1}r^{(i)}\cos\left(\theta^{(i)}\right)}
+
\frac{r^{(k)}z^{-1}Q_{k-1}(z)}{\cos\left(\theta^{(k)}\right)\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}
=
\frac{Q_k(z)}{\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}, \tag*{(122)} U ( 0 ) ( z ) V ( k ) ( z ) = ∏ i = 1 k − 1 r ( i ) cos ( θ ( i ) ) tan ( θ ( k ) ) P k − 1 ( z ) + cos ( θ ( k ) ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) r ( k ) z − 1 Q k − 1 ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) Q k ( z ) , (122)
which proves equation (120) for every k ∈ { 1 , … , K } k \in\{1,\ldots,K\} k ∈ { 1 , … , K } .
Write the order-k k k stage polynomials as
P k ( z ) = ∑ j = 0 k p k , j z − j , Q k ( z ) = ∑ j = 0 k q k , j z − j , (123) P_k(z)=\sum_{j=0}^{k}p_{k,j}z^{-j},\qquad Q_k(z)=\sum_{j=0}^{k}q_{k,j}z^{-j}, \tag*{(123)} P k ( z ) = j = 0 ∑ k p k , j z − j , Q k ( z ) = j = 0 ∑ k q k , j z − j , (123)
where p k , j p_{k,j} p k , j and q k , j q_{k,j} q k , j denote the coefficients of z − j z^{-j} z − j . The initial coefficients are
p 0 , 0 = 1 , q 0 , 0 = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) . (124) p_{0,0}=1,\qquad q_{0,0}=\prod_{i=1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right). \tag*{(124)} p 0 , 0 = 1 , q 0 , 0 = i = 1 ∏ K r ( i ) cos ( θ ( i ) ) . (124)
Matching coefficients in equation (119) gives
p k , j = { 1 , j = 0 , p k − 1 , j + r ( k ) sin ( θ ( k ) ) ∏ i = k K r ( i ) cos ( θ ( i ) ) q k − 1 , j − 1 , 1 ≤ j ≤ k , p_{k,j}=
\begin{cases}
1, & j=0,\\
p_{k-1,j}+\dfrac{r^{(k)}\sin\left(\theta^{(k)}\right)}{\prod_{i=k}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)}q_{k-1,j-1}, & 1\leq j\leq k,
\end{cases} p k , j = ⎩ ⎨ ⎧ 1 , p k − 1 , j + ∏ i = k K r ( i ) cos ( θ ( i ) ) r ( k ) sin ( θ ( k ) ) q k − 1 , j − 1 , j = 0 , 1 ≤ j ≤ k ,
q k , j = { r ( k ) sin ( θ ( k ) ) ∏ i = k + 1 K r ( i ) cos ( θ ( i ) ) p k − 1 , 0 , j = 0 , r ( k ) sin ( θ ( k ) ) ∏ i = k + 1 K r ( i ) cos ( θ ( i ) ) p k − 1 , j + r ( k ) cos ( θ ( k ) ) q k − 1 , j − 1 , 1 ≤ j ≤ k . (125) q_{k,j}=
\begin{cases}
r^{(k)}\sin\left(\theta^{(k)}\right)\prod_{i=k+1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)p_{k-1,0}, & j=0,\\
r^{(k)}\sin\left(\theta^{(k)}\right)\prod_{i=k+1}^{K}r^{(i)}\cos\left(\theta^{(i)}\right)p_{k-1,j}+\dfrac{r^{(k)}}{\cos\left(\theta^{(k)}\right)}q_{k-1,j-1}, & 1\leq j\leq k.
\end{cases} \tag*{(125)} q k , j = ⎩ ⎨ ⎧ r ( k ) sin ( θ ( k ) ) ∏ i = k + 1 K r ( i ) cos ( θ ( i ) ) p k − 1 , 0 , r ( k ) sin ( θ ( k ) ) ∏ i = k + 1 K r ( i ) cos ( θ ( i ) ) p k − 1 , j + cos ( θ ( k ) ) r ( k ) q k − 1 , j − 1 , j = 0 , 1 ≤ j ≤ k . (125)
where coefficients whose second index exceeds the polynomial degree are zero. After K K K lattice stages,
P K ( z ) = 1 + ∑ j = 1 K p K , j z − j . (126) P_K(z) = 1 + \sum_{j=1}^{K} p_{K,j} z^{-j}. \tag*{(126)} P K ( z ) = 1 + j = 1 ∑ K p K , j z − j . (126)
Since equation (120) gives
U ( K ) ( z ) U ( 0 ) ( z ) = P K ( z ) ∏ i = 1 K r ( i ) cos ( θ ( i ) ) , (127) \frac{U^{(K)}(z)}{U^{(0)}(z)} = \frac{P_K(z)}{\prod_{i=1}^{K} r^{(i)} \cos\left(\theta^{(i)}\right)}, \tag*{(127)} U ( 0 ) ( z ) U ( K ) ( z ) = ∏ i = 1 K r ( i ) cos ( θ ( i ) ) P K ( z ) , (127)
every ladder-stage response relative to U ( K ) ( z ) U^{(K)}(z) U ( K ) ( z ) has the common denominator P K ( z ) P_K(z) P K ( z ) . Therefore, the denominator polynomial induced by the lattice recursion is
B ( z ) = P K ( z ) = 1 + ∑ j = 1 K b j z − j , (128) B(z) = P_K(z) = 1 + \sum_{j=1}^{K} b_j z^{-j}, \tag*{(128)} B ( z ) = P K ( z ) = 1 + j = 1 ∑ K b j z − j , (128)
where
b j = p K , j . (129) b_j = p_{K,j}. \tag*{(129)} b j = p K , j . (129)
Ladder Readout and Numerator Polynomial
From the stage-response identity in equation (120) , the intermediate lattice states satisfy
V ( k ) ( z ) = Q k ( z ) P K ( z ) X ( z ) s T , 1 ≤ k ≤ K , (130) V^{(k)}(z) = \frac{Q_k(z)}{P_K(z)} X(z) \mathbf{s}^{\mathrm{T}}, \qquad1 \leq k \leq K, \tag*{(130)} V ( k ) ( z ) = P K ( z ) Q k ( z ) X ( z ) s T , 1 ≤ k ≤ K , (130)
with
V ( 0 ) ( z ) = Q 0 ( z ) P K ( z ) X ( z ) s T . (131) V^{(0)}(z) = \frac{Q_0(z)}{P_K(z)} X(z) \mathbf{s}^{\mathrm{T}}. \tag*{(131)} V ( 0 ) ( z ) = P K ( z ) Q 0 ( z ) X ( z ) s T . (131)
Let Y ( z ) Y(z) Y ( z ) denote the z z z -transform of the output sequence y t y_t y t . The ladder readout becomes
Y ( z ) = ∑ k = 0 K ρ ( k ) V ( k ) ( z ) ν ( k ) = ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) P K ( z ) X ( z ) . (132) \begin{aligned}
Y(z) &= \sum_{k=0}^{K} \rho^{(k)} V^{(k)}(z) \nu^{(k)} \\
&= \frac{\sum_{k=0}^{K} \rho^{(k)} \left(\mathbf{s}^{\mathrm{T}}\nu^{(k)}\right) Q_k(z)}{P_K(z)} X(z). \tag*{(132)}
\end{aligned} Y ( z ) = k = 0 ∑ K ρ ( k ) V ( k ) ( z ) ν ( k ) = P K ( z ) ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) X ( z ) . (132)
The ladder-basis polynomial satisfies
Q k ( z ) = P K ( z ) V ( k ) ( z ) U ( K ) ( z ) , 0 ≤ k ≤ K . (133) Q_k(z) = P_K(z) \frac{V^{(k)}(z)}{U^{(K)}(z)}, \qquad0 \leq k \leq K. \tag*{(133)} Q k ( z ) = P K ( z ) U ( K ) ( z ) V ( k ) ( z ) , 0 ≤ k ≤ K . (133)
Substituting
V ( k ) ( z ) U ( K ) ( z ) = Q k ( z ) P K ( z ) (134) \frac{V^{(k)}(z)}{U^{(K)}(z)} = \frac{Q_k(z)}{P_K(z)} \tag*{(134)} U ( K ) ( z ) V ( k ) ( z ) = P K ( z ) Q k ( z ) (134)
gives
Y ( z ) = ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) P K ( z ) X ( z ) . (135) Y(z) = \frac{\sum_{k=0}^{K} \rho^{(k)} \left(\mathbf{s}^{\mathrm{T}}\nu^{(k)}\right) Q_k(z)}{P_K(z)} X(z). \tag*{(135)} Y ( z ) = P K ( z ) ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) X ( z ) . (135)
Therefore, the transfer function is
H ( z ) = Y ( z ) X ( z ) = A ( z ) B ( z ) . (136) H(z) = \frac{Y(z)}{X(z)} = \frac{A(z)}{B(z)}. \tag*{(136)} H ( z ) = X ( z ) Y ( z ) = B ( z ) A ( z ) . (136)
where the numerator and denominator polynomials are
A ( z ) = ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) , (137) A(z) = \sum_{k=0}^{K} \rho^{(k)}\left(s^{\mathsf{T}}\nu^{(k)}\right)Q_k(z), \tag*{(137)} A ( z ) = k = 0 ∑ K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) , (137)
B ( z ) = P K ( z ) . (138) B(z) = P_K(z). \tag*{(138)} B ( z ) = P K ( z ) . (138)
Expanding the numerator as
A ( z ) = ∑ m = 0 K a m z − m , (139) A(z) = \sum_{m=0}^{K} a_m z^{-m}, \tag*{(139)} A ( z ) = m = 0 ∑ K a m z − m , (139)
where a m a_m a m denotes the coefficient of z − m z^{-m} z − m , gives
∑ m = 0 K a m z − m = ∑ k = 0 K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) . (140) \sum_{m=0}^{K} a_m z^{-m} = \sum_{k=0}^{K} \rho^{(k)}\left(s^{\mathsf{T}}\nu^{(k)}\right)Q_k(z). \tag*{(140)} m = 0 ∑ K a m z − m = k = 0 ∑ K ρ ( k ) ( s T ν ( k ) ) Q k ( z ) . (140)
Hence, the order-K K K lattice–ladder network realizes the transfer function
H ( z ) = ∑ m = 0 K a m z − m 1 + ∑ j = 1 K b j z − j , (141) H(z) = \frac{\sum_{m=0}^{K}a_m z^{-m}}{1+\sum_{j=1}^{K}b_j z^{-j}}, \tag*{(141)} H ( z ) = 1 + ∑ j = 1 K b j z − j ∑ m = 0 K a m z − m , (141)
where the numerator coefficients a m a_m a m and denominator coefficients b j b_j b j are induced by the reflection angles θ ( 1 : K ) \theta^{(1:K)} θ ( 1 : K ) , radius coefficients r ( 1 : K ) r^{(1:K)} r ( 1 : K ) , readout coefficients ρ ( 0 : K ) \rho^{(0:K)} ρ ( 0 : K ) , memory write projection s s s , and memory readout projections ν ( 0 : K ) \nu^{(0:K)} ν ( 0 : K ) through the lattice recursion.
Complex-Conjugate Poles. For K = 2 K=2 K = 2 , take r ( 1 ) = r ( 2 ) = 1 / 2 r^{(1)}=r^{(2)}=1/2 r ( 1 ) = r ( 2 ) = 1/2 , θ ( 1 ) = 0 \theta^{(1)}=0 θ ( 1 ) = 0 , and θ ( 2 ) = π / 6 \theta^{(2)}=\pi/6 θ ( 2 ) = π /6 . The polynomial recursion gives P 2 ( z ) = 1 + z − 2 / 16 P_2(z)=1+z^{-2}/16 P 2 ( z ) = 1 + z − 2 /16 and Q 0 ( z ) = 3 / 8 Q_0(z)=\sqrt{3}/8 Q 0 ( z ) = 3 /8 . Choosing ρ ( 0 ) ( s T ν ( 0 ) ) = 1 \rho^{(0)}(s^{\mathsf{T}}\nu^{(0)})=1 ρ ( 0 ) ( s T ν ( 0 ) ) = 1 and the remaining ladder contributions zero yields H ( z ) = ( 3 / 8 ) / ( 1 + z − 2 / 16 ) H(z)=(\sqrt{3}/8)/(1+z^{-2}/16) H ( z ) = ( 3 /8 ) / ( 1 + z − 2 /16 ) , with uncancelled complex-conjugate poles z = ± i / 4 z=\pm i/4 z = ± i /4 .
Stability of the Carried State. For homogeneous propagation, set U t ( K ) = 0 U_t^{(K)}=0 U t ( K ) = 0 and let q = max 1 ≤ k ≤ K r ( k ) ≤ 1 q=\max_{1\leq k\leq K}r^{(k)}\leq1 q = max 1 ≤ k ≤ K r ( k ) ≤ 1 . Orthogonality of each stage rotation gives ∥ U t ( k ) ∥ F 2 + ∥ V t ( k ) ∥ F 2 ≤ q 2 ( ∥ U t ( k − 1 ) ∥ F 2 + ∥ V t − 1 ( k − 1 ) ∥ F 2 ) \lVert U_t^{(k)}\rVert_F^2+\lVert V_t^{(k)}\rVert_F^2\leq q^2(\lVert U_t^{(k-1)}\rVert_F^2+\lVert V_{t-1}^{(k-1)}\rVert_F^2) ∥ U t ( k ) ∥ F 2 + ∥ V t ( k ) ∥ F 2 ≤ q 2 (∥ U t ( k − 1 ) ∥ F 2 + ∥ V t − 1 ( k − 1 ) ∥ F 2 ) . Summing over stages and using V t ( 0 ) = U t ( 0 ) V_t^{(0)}=U_t^{(0)} V t ( 0 ) = U t ( 0 ) yields
∑ k = 0 K − 1 ∥ V t ( k ) ∥ F 2 + ∥ V t ( K ) ∥ F 2 + ( 1 − q 2 ) ∑ k = 0 K − 1 ∥ U t ( k ) ∥ F 2 ≤ q 2 ∑ k = 0 K − 1 ∥ V t − 1 ( k ) ∥ F 2 . (142) \sum_{k=0}^{K-1}\lVert V_t^{(k)}\rVert_F^2+\lVert V_t^{(K)}\rVert_F^2+(1-q^2)\sum_{k=0}^{K-1}\lVert U_t^{(k)}\rVert_F^2\leq q^2\sum_{k=0}^{K-1}\lVert V_{t-1}^{(k)}\rVert_F^2. \tag*{(142)} k = 0 ∑ K − 1 ∥ V t ( k ) ∥ F 2 + ∥ V t ( K ) ∥ F 2 + ( 1 − q 2 ) k = 0 ∑ K − 1 ∥ U t ( k ) ∥ F 2 ≤ q 2 k = 0 ∑ K − 1 ∥ V t − 1 ( k ) ∥ F 2 . (142)
Thus, the complete carried-state transition is nonexpansive for q ≤ 1 q\leq1 q ≤ 1 and Schur stable for q < 1 q<1 q < 1 , so all poles of the frozen transfer function lie strictly inside the unit circle under the latter sufficient condition. For time-varying coefficients, the same bound holds at each token with q t q_t q t ; a uniform bound sup t q t < 1 \sup_t q_t<1 sup t q t < 1 guarantees uniform exponential decay.
Algebraic Structure for Parallelism
We define the transition ( k , t ) (k,t) ( k , t ) as
( k , t ) : ( U t ( k ) , V t − 1 ( k − 1 ) ) ⟼ ( U t ( k − 1 ) , V t ( k ) ) , k ∈ { K , … , 1 } , t ∈ { 1 , … , T } . (k,t):(U_t^{(k)},V_{t-1}^{(k-1)})\longmapsto(U_t^{(k-1)},V_t^{(k)}),\qquad k\in\{K,\ldots,1\},\quad t\in\{1,\ldots,T\}. ( k , t ) : ( U t ( k ) , V t − 1 ( k − 1 ) ) ⟼ ( U t ( k − 1 ) , V t ( k ) ) , k ∈ { K , … , 1 } , t ∈ { 1 , … , T } .
Its component-wise update is given by equation (2) , as illustrated in Figure 3 . The transitions within token t t t form a dependent cascade from k = K k=K k = K to k = 1 k=1 k = 1 . Since the recurrence acts independently across channels, we define the carried state as
V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m . \mathbf{V}_t=\left(V_t^{(0)},\ldots,V_t^{(K-1)}\right)^{\mathsf{T}}\in\mathbb{R}^{K d_e\times d_m}. V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m .
For compactness, we define
D t ( k ) = diag ( r t ( k ) ⊙ cos ( θ t ( k ) ) ) , E t ( k ) = diag ( r t ( k ) ⊙ sin ( θ t ( k ) ) ) . D_t^{(k)}=\operatorname{diag}\left(r_t^{(k)}\odot\cos\left(\theta_t^{(k)}\right)\right),\qquad E_t^{(k)}=\operatorname{diag}\left(r_t^{(k)}\odot\sin\left(\theta_t^{(k)}\right)\right). D t ( k ) = diag ( r t ( k ) ⊙ cos ( θ t ( k ) ) ) , E t ( k ) = diag ( r t ( k ) ⊙ sin ( θ t ( k ) ) ) .
Let T t ( V t − 1 ) \mathcal{T}_t(\mathbf{V}_{t-1}) T t ( V t − 1 ) denote the state transition, where T t \mathcal{T}_t T t is the corresponding transition operator. We now derive its explicit form using the closure V t ( 0 ) = U t ( 0 ) V_t^{(0)}=U_t^{(0)} V t ( 0 ) = U t ( 0 ) . By equation (2) , recursively expanding the forward signal gives
U t ( k ) = ( ∏ i = k + 1 K D t ( i ) ) x ~ t s t T − ∑ j = k + 1 K ( ∏ i = k + 1 j − 1 D t ( i ) ) E t ( j ) V t − 1 ( j − 1 ) . U_t^{(k)}=\left(\prod_{i=k+1}^{K}D_t^{(i)}\right)\widetilde{x}_t s_t^{\mathsf{T}}-\sum_{j=k+1}^{K}\left(\prod_{i=k+1}^{j-1}D_t^{(i)}\right)E_t^{(j)}V_{t-1}^{(j-1)}. U t ( k ) = ( i = k + 1 ∏ K D t ( i ) ) x t s t T − j = k + 1 ∑ K ( i = k + 1 ∏ j − 1 D t ( i ) ) E t ( j ) V t − 1 ( j − 1 ) .
and substituting U t ( k ) U_t^{(k)} U t ( k ) into the update of V t ( k ) V_t^{(k)} V t ( k ) yields
V t ( k ) = E t ( k ) ( ∏ i = k + 1 K D t ( i ) ) x ~ t s t T + D t ( k ) V t − 1 ( k − 1 ) − E t ( k ) ∑ j = k + 1 K ( ∏ i = k + 1 j − 1 D t ( i ) ) E t ( j ) V t − 1 ( j − 1 ) . V_t^{(k)}=E_t^{(k)}\left(\prod_{i=k+1}^{K}D_t^{(i)}\right)\widetilde{x}_t s_t^{\mathsf{T}}+D_t^{(k)}V_{t-1}^{(k-1)}-E_t^{(k)}\sum_{j=k+1}^{K}\left(\prod_{i=k+1}^{j-1}D_t^{(i)}\right)E_t^{(j)}V_{t-1}^{(j-1)}. V t ( k ) = E t ( k ) ( i = k + 1 ∏ K D t ( i ) ) x t s t T + D t ( k ) V t − 1 ( k − 1 ) − E t ( k ) j = k + 1 ∑ K ( i = k + 1 ∏ j − 1 D t ( i ) ) E t ( j ) V t − 1 ( j − 1 ) .
Because D t ( k ) D_t^{(k)} D t ( k ) , E t ( k ) E_t^{(k)} E t ( k ) , x ~ t \widetilde{x}_t x t , and s t s_t s t depend only on x t x_t x t , the complete cascade { ( k , t ) } k = K 1 \{(k,t)\}_{k=K}^{1} {( k , t ) } k = K 1 defines the affine operator
T t = ( Φ t , S t ) , T t ( V ) = Φ t V + S t , V t = T t ( V t − 1 ) , (143) \mathcal{T}_t=(\Phi_t,S_t),\qquad\mathcal{T}_t(\mathbf{V})=\Phi_t\mathbf{V}+S_t,\qquad\mathbf{V}_t=\mathcal{T}_t(\mathbf{V}_{t-1}), \tag*{(143)} T t = ( Φ t , S t ) , T t ( V ) = Φ t V + S t , V t = T t ( V t − 1 ) , (143)
where the transition matrix Φ t ∈ R K d e × K d e \Phi_t\in\mathbb{R}^{K d_e\times K d_e} Φ t ∈ R K d e × K d e and input contribution S t ∈ R K d e × d m S_t\in\mathbb{R}^{K d_e\times d_m} S t ∈ R K d e × d m are
Φ t = ( − E t ( 1 ) ⋯ − ( ∏ i = 1 k − 1 D t ( i ) ) E t ( k ) ⋯ − ( ∏ i = 1 K − 1 D t ( i ) ) E t ( K ) D t ( 1 ) ⋯ − E t ( 1 ) ( ∏ i = 2 k − 1 D t ( i ) ) E t ( k ) ⋯ − E t ( 1 ) ( ∏ i = 2 K − 1 D t ( i ) ) E t ( K ) ⋮ ⋱ ⋮ ⋮ 0 d e ⋯ D t ( k ) ⋯ − E t ( k ) ( ∏ i = k + 1 K − 1 D t ( i ) ) E t ( K ) ⋮ ⋮ ⋱ ⋮ 0 d e ⋯ 0 d e D t ( K − 1 ) − E t ( K − 1 ) E t ( K ) ) , \Phi_t=
\begin{pmatrix}
-E_t^{(1)} & \cdots& -\left(\prod_{i=1}^{k-1}D_t^{(i)}\right)E_t^{(k)} & \cdots& -\left(\prod_{i=1}^{K-1}D_t^{(i)}\right)E_t^{(K)}\\
D_t^{(1)} & \cdots& -E_t^{(1)}\left(\prod_{i=2}^{k-1}D_t^{(i)}\right)E_t^{(k)} & \cdots& -E_t^{(1)}\left(\prod_{i=2}^{K-1}D_t^{(i)}\right)E_t^{(K)}\\
\vdots& \ddots& \vdots& & \vdots\\
0_{d_e} & \cdots& D_t^{(k)} & \cdots& -E_t^{(k)}\left(\prod_{i=k+1}^{K-1}D_t^{(i)}\right)E_t^{(K)}\\
\vdots& & \vdots& \ddots& \vdots\\
0_{d_e} & \cdots& 0_{d_e} & D_t^{(K-1)} & -E_t^{(K-1)}E_t^{(K)}
\end{pmatrix}, Φ t = − E t ( 1 ) D t ( 1 ) ⋮ 0 d e ⋮ 0 d e ⋯ ⋯ ⋱ ⋯ ⋯ − ( ∏ i = 1 k − 1 D t ( i ) ) E t ( k ) − E t ( 1 ) ( ∏ i = 2 k − 1 D t ( i ) ) E t ( k ) ⋮ D t ( k ) ⋮ 0 d e ⋯ ⋯ ⋯ ⋱ D t ( K − 1 ) − ( ∏ i = 1 K − 1 D t ( i ) ) E t ( K ) − E t ( 1 ) ( ∏ i = 2 K − 1 D t ( i ) ) E t ( K ) ⋮ − E t ( k ) ( ∏ i = k + 1 K − 1 D t ( i ) ) E t ( K ) ⋮ − E t ( K − 1 ) E t ( K ) ,
S t = ( ∏ i = 1 K D t ( i ) E t ( 1 ) ∏ i = 2 K D t ( i ) ⋮ E t ( k ) ∏ i = k + 1 K D t ( i ) ⋮ E t ( K − 1 ) D t ( K ) ) x ~ t s t T . S_t=
\begin{pmatrix}
\prod_{i=1}^{K}D_t^{(i)}\\
E_t^{(1)}\prod_{i=2}^{K}D_t^{(i)}\\
\vdots\\
E_t^{(k)}\prod_{i=k+1}^{K}D_t^{(i)}\\
\vdots\\
E_t^{(K-1)}D_t^{(K)}
\end{pmatrix}
\widetilde{x}_t s_t^{\mathsf{T}}. S t = ∏ i = 1 K D t ( i ) E t ( 1 ) ∏ i = 2 K D t ( i ) ⋮ E t ( k ) ∏ i = k + 1 K D t ( i ) ⋮ E t ( K − 1 ) D t ( K ) x t s t T .
respectively. Therefore, for any t 1 < t 2 < t 3 t_1 < t_2 < t_3 t 1 < t 2 < t 3 , temporal composition of the affine operators is associative
( T t 3 ⊙ T t 2 ) ⊙ T t 1 = ( Φ t 3 Φ t 2 Φ t 1 , Φ t 3 Φ t 2 S t 1 + Φ t 3 S t 2 + S t 3 ) = T t 3 ⊙ ( T t 2 ⊙ T t 1 ) . (144) (\mathcal{T}_{t_3} \odot\mathcal{T}_{t_2}) \odot\mathcal{T}_{t_1} = (\Phi_{t_3}\Phi_{t_2}\Phi_{t_1}, \Phi_{t_3}\Phi_{t_2}S_{t_1} + \Phi_{t_3}S_{t_2} + S_{t_3})
= \mathcal{T}_{t_3} \odot(\mathcal{T}_{t_2} \odot\mathcal{T}_{t_1}). \tag*{(144)} ( T t 3 ⊙ T t 2 ) ⊙ T t 1 = ( Φ t 3 Φ t 2 Φ t 1 , Φ t 3 Φ t 2 S t 1 + Φ t 3 S t 2 + S t 3 ) = T t 3 ⊙ ( T t 2 ⊙ T t 1 ) . (144)
In general, they are non-commutative:
T t 2 ⊙ T t 1 ≠ T t 1 ⊙ T t 2 . \mathcal{T}_{t_2} \odot\mathcal{T}_{t_1} \ne\mathcal{T}_{t_1} \odot\mathcal{T}_{t_2}. T t 2 ⊙ T t 1 = T t 1 ⊙ T t 2 .
Iterating equation (144) , the composition of T s , … , T q \mathcal{T}_s,\ldots,\mathcal{T}_q T s , … , T q for any $1 \le s \le q \le T$ remains affine,
T q ⊙ ⋯ ⊙ T s = ( Φ s → q , S s → q ) , Φ s → q = Φ q Φ q − 1 ⋯ Φ s , S s → q = ∑ j = s q Φ j + 1 → q S j , \mathcal{T}_q \odot\cdots\odot\mathcal{T}_s = (\Phi_{s\to q}, S_{s\to q}), \qquad\Phi_{s\to q} = \Phi_q\Phi_{q-1}\cdots\Phi_s, \qquad S_{s\to q} = \sum_{j=s}^{q}\Phi_{j+1\to q}S_j, T q ⊙ ⋯ ⊙ T s = ( Φ s → q , S s → q ) , Φ s → q = Φ q Φ q − 1 ⋯ Φ s , S s → q = j = s ∑ q Φ j + 1 → q S j ,
with the empty product Φ q + 1 → q = I K d e \Phi_{q+1\to q} = I_{K_{\mathrm{de}}} Φ q + 1 → q = I K de . This follows by induction on q − s q-s q − s . At q = s q=s q = s the composition is T s \mathcal{T}_s T s itself, for which Φ s → s = Φ s \Phi_{s\to s} = \Phi_s Φ s → s = Φ s and S s → s = S s S_{s\to s} = S_s S s → s = S s . Composing T q \mathcal{T}_q T q with the hypothesis at q − 1 q-1 q − 1 gives Φ q Φ s → q − 1 = Φ s → q \Phi_q\Phi_{s\to q-1} = \Phi_{s\to q} Φ q Φ s → q − 1 = Φ s → q together with
Φ q S s → q − 1 + S q = ∑ j = s q − 1 Φ q Φ j + 1 → q − 1 S j + S q = ∑ j = s q Φ j + 1 → q S j . \Phi_q S_{s\to q-1} + S_q = \sum_{j=s}^{q-1}\Phi_q\Phi_{j+1\to q-1}S_j + S_q = \sum_{j=s}^{q}\Phi_{j+1\to q}S_j. Φ q S s → q − 1 + S q = j = s ∑ q − 1 Φ q Φ j + 1 → q − 1 S j + S q = j = s ∑ q Φ j + 1 → q S j .
Applying this operator to V s − 1 V_{s-1} V s − 1 gives equation (5) , in which Φ s → q \Phi_{s\to q} Φ s → q transports the preceding memory V s − 1 V_{s-1} V s − 1 across the segment, whereas setting V s − 1 = 0 V_{s-1}=0 V s − 1 = 0 identifies S s → q S_{s\to q} S s → q as the segment dynamics generated from a zero entry state, independent of all tokens preceding s s s .
CUDA Implementation
Chunk Partition. The token axis is partitioned into C C C contiguous chunks, chunk c c c spanning t c , t c + 1 , … , t c + L c − 1 t_c, t_c+1, \ldots, t_c+L_c-1 t c , t c + 1 , … , t c + L c − 1 with t 1 = 1 t_1=1 t 1 = 1 , t c + 1 = t c + L c t_{c+1}=t_c+L_c t c + 1 = t c + L c and ∑ c = 1 C L c = T \sum_{c=1}^{C}L_c=T ∑ c = 1 C L c = T . Every chunk but the last has the same length L L L , so t c = ( c − 1 ) L + 1 t_c=(c-1)L+1 t c = ( c − 1 ) L + 1 and C = ⌈ T / L ⌉ C=\lceil T/L\rceil C = ⌈ T / L ⌉ , where L L L is computed in closed form from T T T , the batch size B B B , d e d_e d e and the number of thread blocks the GPU holds at once: C ≤ ⌊ T ⌋ C\leq\lfloor\sqrt{T}\rfloor C ≤ ⌊ T ⌋ is chosen so that the thread blocks of phase (iii) come close to a whole multiple of that number, and C = 1 C=1 C = 1 unless the split is predicted to be more than 1.125 times faster, in which case phases (i) and (ii) are not executed and phase (iii) starts from V 0 = 0 V_0=0 V 0 = 0 . Writing the carried state in stacked form
V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m , \mathbf{V}_t=\left(V_t^{(0)},\ldots,V_t^{(K-1)}\right)^{\mathsf{T}}\in\mathbb{R}^{K d_e\times d_m}, V t = ( V t ( 0 ) , … , V t ( K − 1 ) ) T ∈ R K d e × d m ,
each chunk is delimited by an entry state V t c − 1 \mathbf{V}_{t_c-1} V t c − 1 and an exit state V t c + L c − 1 \mathbf{V}_{t_c+L_c-1} V t c + L c − 1 , related across chunks by V t c − 1 = V t c − 1 + L c − 1 − 1 \mathbf{V}_{t_c-1}=\mathbf{V}_{t_{c-1}+L_{c-1}-1} V t c − 1 = V t c − 1 + L c − 1 − 1 . This relation orders the chunks strictly, and the following three phases remove it by exploiting the affine structure of equation (3) and its associativity in equation (4) .
Phase (i): Chunk Summarization. All C C C chunks are summarized concurrently, each from a zero entry state; in inference the last chunk is skipped, since phase (ii) never reads its summary. With
D t ( k ) = diag ( r t ( k ) ⊙ cos ( θ t ( k ) ) ) , E t ( k ) = diag ( r t ( k ) ⊙ sin ( θ t ( k ) ) ) , D_t^{(k)}=\operatorname{diag}\left(r_t^{(k)}\odot\cos\left(\theta_t^{(k)}\right)\right),\qquad E_t^{(k)}=\operatorname{diag}\left(r_t^{(k)}\odot\sin\left(\theta_t^{(k)}\right)\right), D t ( k ) = diag ( r t ( k ) ⊙ cos ( θ t ( k ) ) ) , E t ( k ) = diag ( r t ( k ) ⊙ sin ( θ t ( k ) ) ) ,
the token transition of equation (2) is
U t ( K ) = x ~ t s t T , U_t^{(K)}=\widetilde{x}_t s_t^{\mathsf{T}}, U t ( K ) = x t s t T ,
U t ( k − 1 ) = D t ( k ) U t ( k ) − E t ( k ) V t − 1 ( k − 1 ) , k = K , … , 1 , U_t^{(k-1)}=D_t^{(k)}U_t^{(k)}-E_t^{(k)}V_{t-1}^{(k-1)},\qquad k=K,\ldots,1, U t ( k − 1 ) = D t ( k ) U t ( k ) − E t ( k ) V t − 1 ( k − 1 ) , k = K , … , 1 ,
V t ( k ) = E t ( k ) U t ( k ) + D t ( k ) V t − 1 ( k − 1 ) , k = K , … , 1 , V_t^{(k)}=E_t^{(k)}U_t^{(k)}+D_t^{(k)}V_{t-1}^{(k-1)},\qquad k=K,\ldots,1, V t ( k ) = E t ( k ) U t ( k ) + D t ( k ) V t − 1 ( k − 1 ) , k = K , … , 1 ,
V t ( 0 ) = U t ( 0 ) , V_t^{(0)}=U_t^{(0)}, V t ( 0 ) = U t ( 0 ) ,
where Φ t ∈ R K d e × K d e \Phi_t\in\mathbb{R}^{K d_e\times K d_e} Φ t ∈ R K d e × K d e of equation (3) is determined by D t ( 1 ) , … , D t ( K ) D_t^{(1)},\ldots,D_t^{(K)} D t ( 1 ) , … , D t ( K ) and E t ( 1 ) , … , E t ( K ) E_t^{(1)},\ldots,E_t^{(K)} E t ( 1 ) , … , E t ( K ) . Chunk c c c retains the pair of equation (5) at s = t c s=t_c s = t c and q = t c + L c − 1 q=t_c+L_c-1 q = t c + L c − 1 ,
Φ t c → t c + L c − 1 = Φ t c + L c − 1 Φ t c + L c − 2 ⋯ Φ t c , \Phi_{t_c\to t_c+L_c-1}=\Phi_{t_c+L_c-1}\Phi_{t_c+L_c-2}\cdots\Phi_{t_c}, Φ t c → t c + L c − 1 = Φ t c + L c − 1 Φ t c + L c − 2 ⋯ Φ t c ,
S t c → t c + L c − 1 = ∑ j = t c t c + L c − 1 Φ j + 1 → t c + L c − 1 S j = V t c + L c − 1 ∣ V t c − 1 = 0 , S_{t_c\to t_c+L_c-1}=\sum_{j=t_c}^{t_c+L_c-1}\Phi_{j+1\to t_c+L_c-1}S_j=V_{t_c+L_c-1}\big|_{V_{t_c-1}=0}, S t c → t c + L c − 1 = j = t c ∑ t c + L c − 1 Φ j + 1 → t c + L c − 1 S j = V t c + L c − 1 V t c − 1 = 0 ,
the transition being obtained by homogeneous propagation of the K K K standard basis states and shared across memory components. Since the token transition is affine in V \mathbf{V} V , this pair characterizes the chunk for an arbitrary entry state,
V t c + L c − 1 = Φ t c → t c + L c − 1 V t c − 1 + S t c → t c + L c − 1 , (145) \mathbf{V}_{t_c+L_c-1}=\Phi_{t_c\to t_c+L_c-1}\mathbf{V}_{t_c-1}+S_{t_c\to t_c+L_c-1}, \tag*{(145)} V t c + L c − 1 = Φ t c → t c + L c − 1 V t c − 1 + S t c → t c + L c − 1 , (145)
so that no chunk requires the output of another. The states traversed under the zero entry are therefore auxiliary for c ≥ 2 c\geq2 c ≥ 2 and are not retained.
Phase (ii): Boundary Composition. Applying equation (145) for c = 1 , … , C c=1,\ldots,C c = 1 , … , C in token order from the sequence reset V 0 = 0 V_0=0 V 0 = 0 recovers the entry state of every chunk, and by the associativity of equation (4) the C C C applications are evaluated as one parallel scan. Since Φ t \Phi_t Φ t couples only the K K K stages of one channel and is shared across memory components, every sequence, channel and group of min ( d m , 8 / K ) \min(d_m,8/K) min ( d m , 8/ K ) memory components forms an independent stream, and each stream is assigned P P P threads, where P P P is the smallest power of two at which all streams together occupy the threads the GPU holds at once, limited to 256 and to C C C rounded up to a power of two. Each thread composes the pairs of its ⌈ C / P ⌉ \lceil C/P\rceil ⌈ C / P ⌉ consecutive chunks into one pair, the P P P composed pairs are combined by a Kogge–Stone scan with warp shuffles within a warp and shared memory across warps, and each thread applies the composition of the pairs preceding its own to V 0 = 0 V_0=0 V 0 = 0 and replays equation (145) over its chunks, writing their entry states. The depth is 2 ⌈ C / P ⌉ + log 2 P + max ( 0 , P / 32 − 1 ) 2\lceil C/P\rceil+\log_2P+\max(0,P/32-1) 2 ⌈ C / P ⌉ + log 2 P + max ( 0 , P /32 − 1 ) compositions instead of C C C , and P = 1 P=1 P = 1 is the sequential composition in C C C steps. This is the only exchange of information between chunks. It resolves the chunk boundaries alone: no interior state is evaluated, and its cost is independent of L c L_c L c .
Phase (iii): Chunk Replay. The ladder readout is defined at every token position, so the boundary states of phase (ii) are not sufficient and the interior states must be restored. All C C C chunks are replayed concurrently, chunk c c c repeating the token transition from the entry state V t c − 1 V_{t_c-1} V t c − 1 obtained in phase (ii). This recovers V t ( k ) V_t^{(k)} V t ( k ) at every token t t t and every stage k = 0 , … , K k = 0, \ldots, K k = 0 , … , K and yields
y t = W o u t ( ( ∑ k = 0 K ρ t ( k ) ⊙ ( V t ( k ) ν t ( k ) ) ) ⊙ γ t ) , t = t c , … , t c + L c − 1. y_t = W_{\mathrm{out}}\left(\left(\sum_{k=0}^{K} \rho_t^{(k)} \odot\left(V_t^{(k)} \nu_t^{(k)}\right)\right) \odot\gamma_t\right), \qquad t = t_c, \ldots, t_c + L_c - 1. y t = W out ( ( k = 0 ∑ K ρ t ( k ) ⊙ ( V t ( k ) ν t ( k ) ) ) ⊙ γ t ) , t = t c , … , t c + L c − 1.
Parallel Token Scan
Figure 22. Chunk summarization (i), boundary composition (ii) and chunk replay (iii) for one stream, read from the bottom up: T T T tokens in chunks of L = 2 L = 2 L = 2 tokens, and P ≤ 32 P \le32 P ≤ 32 threads of two chunks each (threads 4 to P − 1 P - 1 P − 1 not drawn). A box holds the pair ( Φ s → t , S s → t ) (\Phi_{s\to t}, S_{s\to t}) ( Φ s → t , S s → t ) of equation (5) ; two adjacent pairs compose by equation (4) . In the successive scan steps, a thread composes its pair with that of the thread 1, 2, . . . , P / 2 P/2 P /2 positions to its left (dashed). For P > 32 P > 32 P > 32 , the steps run within each warp of 32 threads, and each thread also composes the pair of every earlier warp.
Chunk partition on host
# ----------------------------------------------------------
# PARTITION, closed form from the shape and the queried GPU
# R_* : resident blocks of a kernel (SMs x blocks/SM)
# N_* : blocks of a kernel grid at one chunk
# e_b : bytes per element
# kernel constants, read from the compiled kernels:
# S : b3 segment length (tokens)
# A_tile : token tile staged by p1 and p3
# C_tile : channels of one b3 block
# KV_max : registers of state a tree-scan thread holds
# TREE_T : threads per tree-scan block
# W_max : most workers per tree-scan unit
# ----------------------------------------------------------
def partition(B, T, de, dm, K, training):
# BACKWARD FINE CHUNK f (training)
# f_smem: longest multiple of S whose b3 shared
# block fits the per-block budget sigma
# f_par : keeps at least one wave of b3 blocks
f_smem = S * floor((sigma - smem_b3(0))
/ (S * smem_b3_per_token))
f_par = S * floor(B * T * ceil(de / C_tile)
/ (S * R_b3))
f_min = min(f_smem, max(f_par, S))
f = min(T, max(S, 2 ** floor(log2(f_min))))
# FORWARD COARSE CHUNK c, a multiple of a
a = f if training else A_tile
c0 = A_tile + 4 * (3*K**2 + 5*K*dm) / (e_b * (5*K + 5))
q = max((2*K + 1) / (3*K + 4), ops_p1 / ops_p3)
x = N_p3 / R_p3
W = max(ceil(x), floor(x * sqrt(T / c0)))
n = min(floor(W * R_p3 / N_p3), floor(sqrt(T)),
ceil(T / a))
c = min(T, a * ceil(T / (n * a)))
n = ceil(T / c)
t1 = ceil(x) * T
if training:
t1 += q * ceil(N_p1 / R_p1) * T
tn = (ceil(n * N_p3 / R_p3) * (c + c0)
+ q * ceil(n * N_p1 / R_p1) * c)
# split only when predicted more than 1.125x faster
if not (n > 1 and t1 > 1.125 * tn):
c, n = T, 1
# TREE SCAN over the n coarse chunks
workers, r = tree_plan(B, de, dm, K, n)
return f, c, n, workers, r
# ----------------------------------------------------------
# TREE PLAN for n chunks
# unit = (sequence, channel, V memory columns)
# ----------------------------------------------------------
def tree_plan(B, de, dm, K, n):
V = max(1, min(dm, KV_max // K))
units = B * de * (dm // V)
workers = pow2ceil(R_tree * TREE_T / units)
workers = clamp(workers, 1, min(pow2ceil(n), W_max))
r = ceil(n / workers)
return workers, r
Reference CUDA Kernel Pseudo Code
Shared Device Functions
// ---------------------------------------------------------
// STAGE COEFFICIENTS of one (b, t, e, k)
// D = r cos(theta), E = r sin(theta)
// dtheta/dalpha, (dr/dbeta)/r: cached for the backward
// ---------------------------------------------------------
struct Stage { float D, E, dth_dal, dlr_dbe; };
__device__ Stage stage(float alpha, float beta) {
float r = 1.f / (1.f + beta * beta);
return {r / coshf(alpha), r * tanhf(alpha),
1.f / coshf(alpha), -2.f * beta * r};
}
// ---------------------------------------------------------
// TOKEN STEP, one channel e, one memory column m
// in: V[0..K-1] = V_{t-1}^(0..K-1), U = U_t^(K)
// out: V[0..K-1] = V_t^(0..K-1)
// lev[0..K] = V_t^(0..K)
// stg[k] holds stage k, k = 1..K
// ---------------------------------------------------------
template <int K>
__device__ void step(const Stage *stg, float *V, float U,
float *lev) {
for (int k = K; k >= 1; --k) {
lev[k] = stg[k].E * U + stg[k].D * V[k-1];
U = stg[k].D * U - stg[k].E * V[k-1];
}
lev[0] = U;
for (int k = 0; k < K; ++k) V[k] = lev[k];
}
// ---------------------------------------------------------
// LEVELS of one token, for the backward
// in: Vp[0..K-1] = V_{t-1}^(0..K-1), u = U_t^(K)
// out: U[0..K] = U_t^(0..K), Vt[0..K] = V_t^(0..K)
// ---------------------------------------------------------
template <int K>
__device__ void levels(const Stage *stg, const float *Vp,
float u, float *U, float *Vt) {
U[K] = u;
for (int k = K; k >= 1; --k) {
Vt[k] = stg[k].E * U[k] + stg[k].D * Vp[k-1];
U[k-1] = stg[k].D * U[k] - stg[k].E * Vp[k-1];
}
Vt[0] = U[0];
}
// ---------------------------------------------------------
// ADJOINT STEP, one channel e, one memory column m
// in: dV[0..K-1] = dL/dV_t^(0..K-1) from token t+1
// g[0..K] = local dL/dV_t^(0..K)
// out: dV[0..K-1] = dL/dV_{t-1}^(0..K-1)
// returns dL/dU_t^(K)
// ---------------------------------------------------------
template <int K>
__device__ float adjoint_step(const Stage *stg, float *dV,
const float *g) {
float gU = g[0] + dV[0];
for (int k = 1; k <= K; ++k) {
float gV = g[k] + (k < K ? dV[k] : 0.f);
dV[k-1] = stg[k].D * gV - stg[k].E * gU;
gU = stg[k].D * gU + stg[k].E * gV;
}
return gU;
}
// ---------------------------------------------------------
// AFFINE MAP x -> A x + c of one unit (b, e, V columns)
// A: K x K, c: K x V
// compose(m2, m) applies m first:
// (A2, c2) o (A, c) = (A2 A, A2 c + c2)
// ---------------------------------------------------------
struct Map { Mat A; Vec c; };
__device__ Map compose(const Map &m2, const Map &m) {
return {m2.A * m.A, m2.A * m.c + m2.c};
}
// ---------------------------------------------------------
// TREE SCAN, run by p2 and b2
// unit u = (b, e, V columns), W worker threads per unit
// worker w owns chunks [w r, (w+1) r)
// out[u][j] = state ENTERING chunk j:
// x_{j+1} = A_j x_j + c_j, x_0 = x0[u]
// depth: 2 r + log2(W) + W/32 - 1 compositions
// ---------------------------------------------------------
__device__ void tree_scan(const Map *chunk, const Vec *x0,
Vec *out, int n, int W, int r) {
int u = (blockIdx.x * blockDim.x + threadIdx.x) / W;
int w = threadIdx.x % W;
int lo = w * r, hi = min(n, lo + r);
// 1. fold: compose the chunks of this worker
Map own = identity();
for (int j = lo; j < hi; ++j)
own = compose(chunk[u][j], own);
// 2. exclusive Kogge-Stone scan over the W workers:
// __shfl_up_sync in a warp, shared memory across
Map inc = own;
for (int d = 1; d < W; d *= 2) {
Map prev = shfl_up(inc, d);
if (w >= d) inc = compose(inc, prev);
}
Map pre = w > 0 ? shfl_up(inc, 1) : identity();
// 3. replay: write the entry state of each chunk
Vec x = pre.A * x0[u] + pre.c;
for (int j = lo; j < hi; ++j) {
out[u][j] = x;
x = chunk[u][j].A * x + chunk[u][j].c;
}
}
Forward on Device
// ---------------------------------------------------------
// FORWARD KERNELS
// block (b, chunk j, channel group of G channels),
// thread (e, m): channel e, memory column m
// (a lane holds d_m / L columns)
// the kernel reads W_gamma z_t and forms
// gamma_t = silu(W_gamma z_t) itself
// ---------------------------------------------------------
// p1: CHUNK SUMMARY from a zero entry state
// S_j = V at the chunk end, V_{t_j - 1} = 0
// Phi_j = Phi_{t_j + c - 1} ... Phi_{t_j}: lane m < K
// carries basis state m with zero input, the
// column m of Phi_j
template <int K>
__global__ void p1_chunk_summary(Args a) {
auto [b, j, e, m] = coordinates();
// P: column m of the current fine transition
// Pc: column m of the coarse transition Phi_j
float V[K] = {}, P[K] = {}, Pc[K] = {}, lev[K + 1];
if (m < K) P[m] = Pc[m] = 1.f;
for (int t = first(j); t < last(j); ++t) {
Stage stg[K + 1];
for (int k = 1; k <= K; ++k)
stg[k] = stage(a.alpha[b][t][e][k],
a.beta[b][t][e][k]);
float U = a.x_tilde[b][t][e] * a.s[b][t][m];
step<K>(stg, V, U, lev);
if (m < K) step<K>(stg, P, 0.f, lev);
// training: close fine chunk i every f tokens
if (a.training && closes_fine_chunk(t)) {
int i = fine_index(t);
if (m < K) {
a.Phi_fine[b][i][e].col(m) = P;
// Phi_j <- P Phi_j, the rows of P
// gathered by __shfl_sync
Pc = mul_lanes(P, Pc);
reset(P, m);
}
}
}
a.S[b][j][e].col(m) = V;
if (m < K)
a.Phi[b][j][e].col(m) = a.training ? Pc : P;
}
// p2: BOUNDARY COMPOSITION, the state entering every
// coarse chunk, by the tree scan over n chunks
__global__ void p2_boundary_composition(Args a, int n,
int W, int r) {
tree_scan(a.chunk_maps(), a.V_0, a.V_in, n, W, r);
}
// p3: CHUNK REPLAY from its entry state
template <int K>
__global__ void p3_chunk_replay(Args a) {
auto [b, j, e, m] = coordinates();
float V[K], lev[K + 1];
load(V, a.V_in[b][j][e].col(m));
for (int t = first(j); t < last(j); ++t) {
// training: checkpoint the state entering
// every fine chunk i
if (a.training && opens_fine_chunk(t))
a.V_ck[b][fine_index(t)][e].col(m) = V;
Stage stg[K + 1];
load_stage(stg, a, b, t, e);
float U = a.x_tilde[b][t][e] * a.s[b][t][m];
step<K>(stg, V, U, lev);
// y_t = gamma_t sum_k rho_t^(k) (V_t^(k) nu_t^(k))
// V_t^(k) nu_t^(k): sum over the d_m lanes
float acc = 0.f;
for (int k = 0; k <= K; ++k)
acc += a.rho[b][t][e][k]
* warp_sum(lev[k] * a.nu[b][t][k][m]);
if (m == 0)
a.y[b][t][e] = silu(a.W_gamma_z[b][t][e]) * acc;
}
if (last(j) == T) a.V_T[b][e].col(m) = V;
}
// ---------------------------------------------------------
// FORWARD, host: p1 -> p2 -> p3
// n = 1 in inference: p3 alone, from V_0
// T = 1 in inference: one fused step kernel
// ---------------------------------------------------------
void forward(Args a) {
Plan pl = partition(B, T, de, dm, K, a.training);
int blocks = B * pl.n * ceil_div(de, G);
if (pl.n > 1 || a.training) {
p1_chunk_summary<K><<<blocks, G * L>>>(a);
int tb = tree_blocks(pl.n, pl.workers);
p2_boundary_composition<<<tb, TREE_T>>>(
a, pl.n, pl.workers, pl.r);
}
p3_chunk_replay<K><<<blocks, G * L>>>(a);
}
Backward on Device
// ---------------------------------------------------------
// BACKWARD KERNELS, over fine chunks i
// gamma_t = silu(W_gamma z_t)
// dsilu(a) = sigmoid(a) (1 + a (1 - sigmoid(a)))
// local level gradient:
// g_t^(k) = dy_t gamma_t rho_t^(k) nu_t^(k)
// ---------------------------------------------------------
// b1: ADJOINT SUMMARY from a zero future
// block (b, fine chunk i, channel group), thread (e, m)
template <int K>
__global__ void b1_adjoint_summary(Args a) {
auto [b, i, e, m] = coordinates();
float dV[K] = {}, g[K + 1];
for (int t = last(i) - 1; t >= first(i); --t) {
Stage stg[K + 1];
load_stage(stg, a, b, t, e);
local_gradient(g, a, b, t, e, m);
adjoint_step<K>(stg, dV, g);
}
a.L[b][i][e].col(m) = dV;
}
// b2: BOUNDARY COMPOSITION in reverse, the adjoint at
// the end of every fine chunk, by the tree scan over
// nf chunks: maps (Phi_fine[i+1]^T, L[i+1]), read
// last to first
__global__ void b2_boundary_composition(Args a, int nf,
int W, int r) {
tree_scan(a.reverse_maps(), zeros, a.dV_out, nf, W, r);
}
// b3: CHUNK GRADIENTS
// block (b, fine chunk i, tile of C_tile channels),
// S: segment length (tokens)
template <int K, int S>
__global__ void b3_chunk_gradients(Args a) {
auto [b, i, e, m] = coordinates();
// pass 1: replay from V_ck[i], keep the state at
// every S-token segment start (shared)
__shared__ float seg_ck[SEGMENTS][G][K][dm];
replay_segments(seg_ck, a.V_ck[b][i][e], m);
float dV[K];
load(dV, a.dV_out[b][i][e].col(m));
for (int sg = segments(i) - 1; sg >= 0; --sg) {
// pass 2: replay the segment: V_{t-1} in registers,
// q_t^(k) = V_t^(k) nu_t^(k) in shared
float Vp[S][K], q[S][K + 1];
replay_segment(Vp, q, seg_ck[sg], a, m);
// pass 3: reverse over the segment
for (int u = S - 1; u >= 0; --u) {
int t = first(i) + sg * S + u;
if (t >= last(i)) continue;
float gm = a.dy[b][t][e]
* silu(a.W_gamma_z[b][t][e]);
float total = 0.f, g[K + 1];
local_gradient(g, a, b, t, e, m);
for (int k = 0; k <= K; ++k) {
a.drho[b][t][e][k] = gm * q[u][k];
total += a.rho[b][t][e][k] * q[u][k];
}
// dL/d(W_gamma z_t)
a.dW_gamma_z[b][t][e] = a.dy[b][t][e] * total
* dsilu(a.W_gamma_z[b][t][e]);
Stage stg[K + 1];
load_stage(stg, a, b, t, e);
// recompute U_t^(0..K), V_t^(0..K) from V_{t-1}
float xt = a.x_tilde[b][t][e];
float U[K + 1], Vt[K + 1];
levels<K>(stg, Vp[u], xt * a.s[b][t][m], U, Vt);
float gU = g[0] + dV[0];
for (int k = 1; k <= K; ++k) {
float gV = g[k] + (k < K ? dV[k] : 0.f);
// dL/dtheta^(k), r dL/dr^(k),
// summed over the d_m lanes
float dth = warp_sum(gV * U[k-1]
- gU * Vt[k]);
float dlr = warp_sum(gV * Vt[k]
+ gU * U[k-1]);
a.dalpha[b][t][e][k] = dth * stg[k].dth_dal;
a.dbeta[b][t][e][k] = dlr * stg[k].dlr_dbe;
dV[k-1] = stg[k].D * gV - stg[k].E * gU;
gU = stg[k].D * gU + stg[k].E * gV;
}
// gU = dL/dU_t^(K), U_t^(K) = x_tilde_t s_t^T
a.dx_tilde[b][t][e] =
warp_sum(gU * a.s[b][t][m]);
// partial sums over the channels of this tile
a.ds_part[tile][b][t][m] = tile_sum(gU * xt);
for (int k = 0; k <= K; ++k)
a.dnu_part[tile][b][t][k][m] = tile_sum(
gm * a.rho[b][t][e][k] * Vt[k]);
}
// b4: TILE REDUCTION, sum the channel-tile partials
__global__ void b4_tile_reduction(Args a) {
a.ds = sum_over_tiles(a.ds_part);
a.dnu = sum_over_tiles(a.dnu_part);
}
// ---------------------------------------------------------
// BACKWARD, host: b1 -> b2 -> b3 -> b4
// dV_out[i] = dL/dV at the end of fine chunk i
// dV_out[i] = Phi_fine[i+1]^T dV_out[i+1] + L[i+1]
// dV_out[last] = 0
// ---------------------------------------------------------
void backward(Args a) {
Plan pl = partition(B, T, de, dm, K, true);
int nf = ceil_div(T, pl.f);
// the reverse tree scan joins the nf fine chunks, so
// it takes a tree plan of its own over nf
auto [wb, rb] = tree_plan(B, de, dm, K, nf);
int groups = ceil_div(de, G);
int tiles = ceil_div(de, C_tile);
int values = B * T * (K + 2) * dm;
b1_adjoint_summary<K><<<B * nf * groups, G * L>>>(a);
int tb = tree_blocks(nf, wb);
b2_boundary_composition<<<tb, TREE_T>>>(a, nf, wb, rb);
b3_chunk_gradients<K, S><<<B * nf * tiles,
threads_b3>>>(a);
b4_tile_reduction<<<ceil_div(values, RED_T),
RED_T>>>(a);
}