AI Model Wiki

    Skip to main content
    Back to Glossary

    Ring Attention

    Ring Attention is a distributed Self-Attention algorithm that partitions an extremely long sequence across multiple devices arranged in a logical ring, allowing each device to compute attention over its local chunk while streaming key-value blocks from neighbouring devices in a pipelined fashion. Proposed by Liu et al. in 2023, it enables Transformer models to process sequences far longer than any single GPU's memory would otherwise permit.

    Think of it like a relay race where each runner holds a piece of a puzzle. As they pass the baton, they also share their puzzle piece with the next runner, so that by the time everyone has run, each runner has seen every piece-but no single runner ever had to carry the whole puzzle at once.

    Without ring attention, a 1-million-token sequence would require storing an attention matrix quadratic in sequence length-impossible on a single accelerator. Ring attention solves this by having, say, 8 GPUs each hold 125,000 tokens. GPU 0 computes its local attention while simultaneously sending its key-value pairs to GPU 1, which does the same while forwarding to GPU 2, and so on around the ring. Each device accumulates partial attention scores until it has processed every other device's keys and values, yielding the correct global attention output with linear memory per device.

    Ring Attention extends Self-Attention and Transformer architecture to regimes where Context Window sizes reach millions of tokens; it is closely related to Flash Attention (which optimises single-device memory) and connects to research on long-context LLMs and Multimodal models that ingest lengthy video or document streams.

    You will encounter ring attention in academic papers and engineering blogs discussing 1M+ token context windows, long-video understanding, and the distributed training infrastructure behind frontier AI models.

    AI Terminology
    Glossary