Manuscript Offprint

arXiv:2608.23463

ProxyFormer: A Dual-Stream Proxy Architecture for Ultra-Long Context and High-Resolution Generation

Zhongpan Tang

Abstract

The quadratic growth of attention computation and key-value (KV) cache with respect to sequence length is a central bottleneck for ultra-long-context language models and high-resolution generative models. We propose ProxyFormer, a general dual-stream architecture built upon proxy tokens. In each layer, fine-grained local features are compressed bottom-up into a small set of proxy states; expensive global interactions are performed only in the compressed proxy space; the globally contextualized proxies are then decompressed and injected top-down back into the local stream. Because the local stream persists across layers, fine-grained information that is not captured by one compression step remains accessible for later refinement, alleviating the irreversible information loss of conventional one-shot compression. We further introduce factorized multi-level compression/decompression, layer-wise dynamic compression ratios, asymmetric dual embeddings, and a proxy-only KV-cache inference scheme. On a 16 GB GPU with batch size 1, a standard decoder-only model can train sequences of only about 20K tokens, whereas ProxyFormer with a compression ratio of 64 extends the trainable sequence length to about 0.7M. A model trained with a 64K window retains 92%–95% retrieval accuracy on a multi-needle retrieval task with 1,048,576 tokens, and a model trained with an 8K window exceeds 94% accuracy when extrapolated to 256K tokens. Preliminary image-generation experiments demonstrate the feasibility of ProxyFormer for both pixel-space and latent-space flow matching.

Keywords: long-sequence modeling; efficient attention; proxy token; KV-cache compression; length extrapolation; flow matching

1 Introduction

The attention mechanism [1] has established the Transformer as the foundational architecture for language modeling, long-context reasoning, and visual generation. For a sequence of length L and feature dimension d, the computational complexity of standard self-attention is O(L2d)O(L^{2}d); in autoregressive decoding, the key and value of each historical token must also be persistently cached, resulting in a single-layer KV cache size of O(Ld)O(Ld). As context lengths reach the hundreds of thousands or millions, attention computation and KV caching often far exceed the model weights themselves, becoming the primary factors limiting inference throughput and training sequence length [2, 3].

To address this problem, existing work has largely followed three routes: first, designing linear, sparse, or fixed-pattern attention approximations [4, 5, 6]; second, replacing attention with state space models or recurrent forms [7, 8]; third, pruning, quantizing, or evicting the KV cache [9, 10, 11]. While effective in their respective scenarios, these methods generally face a structural contradiction: if fine-grained information is discarded during compression or approximation, the capability for precise long-range retrieval degrades; if all fine-grained information is retained, the computational and memory advantages are limited. Single-shot, irreversible sequence compression is particularly prone to the "lost in the middle" phenomenon and degradation in Needle-In-A-Haystack (NIAH) performance.

This paper introduces ProxyFormer, driven by the motivation to decouple information fidelity and global interaction cost. ProxyFormer does not require all tokens to participate directly in global attention, but instead organizes the input into two parallel feature streams:

  1. Fine/local stream: maintains fine-grained features that correspond one-to-one with input elements, responsible for preserving local details;

  2. Proxy stream: a small number of proxy vectors obtained by compressing local blocks, responsible for completing global interactions at an extremely low cost.

Each layer executes a closed loop of "bottom-up compression → proxy space interaction → top-down decompression and injection". Because the local stream maintains residual connections across layers, details not absorbed by a compression step in one layer can still be passed to deeper layers and re-utilized in subsequent compressions; meanwhile, the global information carried by the proxy stream is reversely injected into the local stream through decompression and mechanisms such as gating, modulation, or cross-attention. This mechanism allows the model, at a compression ratio of P, to reduce the sequence length for proxy space attention to L/P while preserving the information integrity of the local stream.

The main contributions of this paper are as follows:

  • We propose the general ProxyFormer architecture, uniformly supporting 1D sequences, 2D images, 3D point clouds/voxels/videos, and higher-dimensional tensors, covering tasks such as autoregressive language modeling, flow matching image generation, and diffusion conditional generation;

  • We provide an implementation-friendly architectural instance: compression and decompression are composed of standard operators such as reshape, linear projection, and convolution; proxy interactions can directly reuse existing attention or SSM modules without the need for sparse indexers, block-sparse attention kernels, or custom CUDA operators;

  • We introduce a bidirectional communication mechanism between the local and proxy streams, as well as factorized multi-level compression/decompression and layer-wise dynamic compression ratios, which control the parameter size of the compression modules while maintaining high compression ratios;

  • We propose a proxy-level KV cache and a streaming block-triggered update strategy, allowing autoregressive inference to only maintain historical proxy states of length L/P, while original historical local features can be released or offloaded;

  • We systematically validate the architecture through preliminary experiments on language model perplexity, multi-needle NIAH, memory/speed benchmarks, and image generation tasks, providing quantitative comparisons with standard decoder-only baselines.

References (26)