TCNCA: Temporal Convolution Network with Chunked Attention for Scalable Sequence Processing

Aleksandar Terzic, Michael Hersche, Geethan Karunaratne, Luca Benini, Abu Sebastian, Abbas RahimiarXiv 2023 · DOI

Introduction

Processing long sequences efficiently remains a fundamental challenge in deep learning. While Transformers have set benchmarks across various domains, their self-attention mechanism suffers from a quadratic computational complexity, $O(L^2)$, relative to sequence length $L$. This makes them prohibitively expensive for processing very long documents or high-resolution data.

Recent innovations like the MEGA architecture attempted to mitigate this by combining chunked attention with linear recurrence operators like Exponential Moving Average (EMA). However, even EMA relies on Fast Fourier Transforms (FFTs) for parallelization, resulting in $O(L \log L)$ complexity. TCNCA (Temporal Convolution Network with Chunked Attention) addresses these limitations by replacing the EMA bottleneck with dilated convolutions. This architectural shift achieves a strictly linear $O(L)$ complexity, delivering up to 7x speedups on long sequences while matching or beating performance on language modeling and long-range reasoning benchmarks.

The TCNCA Architecture

The core innovation of TCNCA is the integration of a specialized Temporal Convolutional Network (TCN) within a hybrid framework that also utilizes chunked attention.

TCNCA architecture overview (a) and the internal TCN block (b).

Dilated Convolutions for Long-Range Context

Instead of recurrent dependencies that hinder parallelization, TCNCA employs dilated convolutions. By exponentially increasing the dilation factor across layers, the network can achieve a massive receptive field with a relatively shallow depth. The authors optimized this further by using a single dilated convolution per residual block ($B=1$), maximizing the receptive field while minimizing parameter count and increasing processing speed.

Hybrid Attention Mechanism

TCNCA retains the "Chunked Attention" mechanism from the MEGA architecture. This allows the model to focus on precise local dependencies within small windows (chunks), while the TCN layers capture the broader global context across the entire sequence. This combination ensures that the model does not sacrifice fine-grained local information for global scalability. Notably, the authors found that a hybrid approach is essential; a "TCN-only" model performed significantly worse on language modeling tasks.

Experimental Evaluation

The authors evaluated TCNCA across several benchmarks to test its efficiency and reasoning capabilities, including EnWik8 for language modeling and the Long-Range Arena (LRA) for long-distance dependencies.

Language Modeling and Reasoning

On the EnWik8 character-level language modeling task, TCNCA achieved a Bit-Per-Character (BPC) score of 1.01, surpassing both MEGA (1.02) and Transformer-XL (1.06). In the Long-Range Arena (LRA), TCNCA achieved an average accuracy of 85.5%, essentially matching MEGA (85.6%) while offering significantly faster inference.

Hardware Efficiency and Scalability

A key insight of the paper is that hardware efficiency often outweighs theoretical complexity. While $O(L \log L)$ and $O(L)$ appear similar, dilated convolutions are natively optimized for GPU kernels, avoiding the complex overhead associated with FFT pipelines.

Comparison of processing time between FFT-based EMA and dilated convolutions across varying sequence lengths.

As shown in the performance analysis, the dilated convolution operator scales much more gracefully than FFT-based EMA. For sequences reaching 128k tokens, TCNCA's core operator is over 7x faster than its predecessor in MEGA. During training on EnWik8, this translated to a 1.37x faster forward pass and a 1.24x faster backward pass.

Conclusion and Future Work

TCNCA demonstrates that strictly linear sequence processing is achievable without compromising performance. By leveraging the GPU-native efficiency of dilated convolutions, it provides a scalable alternative for processing massive datasets.

Future work will focus on optimizing inference through intermediate layer caching, a common feature in recurrent models that has yet to be fully implemented for this convolutional approach. Additionally, the authors aim to simplify the architecture's complex interaction layers to further enhance its accessibility and performance.

Summary updated

BibTeX
@misc{terzic2023tcnca,
  author = {Aleksandar Terzic and Michael Hersche and Geethan Karunaratne and Luca Benini and Abu Sebastian and Abbas Rahimi},
  title = {{TCNCA: Temporal Convolution Network with Chunked Attention for Scalable Sequence Processing}},
  year = {2023},
  eprint = {2312.05605},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2312.05605},
}
Figure