State Space Model vs Attention Complexity
State Space Models (SSMs) like Mamba offer an alternative to Transformers with linear complexity in sequence length.
Self-Attention complexity: - quadratic in sequence length
SSM (Mamba) complexity: - linear in sequence length
- : Sequence length
- : Hidden dimension
- : State dimension (typically 16-64)
Task: Return the asymptotic complexity for both architectures as a tuple of strings.
This linear scaling enables Mamba to process much longer sequences (e.g., 1M tokens) that would be computationally infeasible for Transformers.
Example
N=1000, D=512, S=16
("O(N*D*S)", "O(N^2*D)")SSM processes each token once with state updates: O(N×D×S). Attention computes all pairwise interactions: O(N²×D). For N=1000, SSM is ~60× more efficient.
Constraints
- (Sequence Length):
- (Hidden Dimension):
- (State Dimension):