Efficient Context Scaling with LongCat ZigZag Attention
Chen Zhang, Yang Bai, Jiahuan Li, Anchun Gui, Keheng Wang, Feifan Liu, Guanyu Wu, Yuwei Jiang, Defei Bu, Li Wei, Haihang Jing, Hongyin Tang, Xin Chen, Xiangzhou Huang, Fengcun Li, Rongxiang Weng, Yulei Qian, Yifan Lu, Yerui Sun, Jingang Wang, Yuchen Xie, Xunliang Cai
TL;DR
This work tackles the quadratic context-cost of full-attention by introducing LongCat ZigZag Attention (LoZA), a sparsification pipeline that calibrates and sparsifiesMLAs during mid-training and then retrains to recover performance. By employing layer-level sparsity and a calibrated mix of full- and sparse-attention paths, LoZA enables long-context processing, demonstrated on LongCat-Flash with LongCat-Flash-Exp extending to up to 1M tokens via YaRN extrapolation. Evaluations show that LoZA preserves effectiveness across a wide range of benchmarks while delivering significant efficiency gains in prefill and decode phases, making context-native reasoning and long-horizon agentic tasks more viable. The approach offers a general pathway to retrofit existing full-attention models into sparse architectures without prohibitive compute, with potential broad impact on sparse-attention research and open-source multimodal models.
Abstract
We introduce LongCat ZigZag Attention (LoZA), which is a sparse attention scheme designed to transform any existing full-attention models into sparse versions with rather limited compute budget. In long-context scenarios, LoZA can achieve significant speed-ups both for prefill-intensive (e.g., retrieval-augmented generation) and decode-intensive (e.g., tool-integrated reasoning) cases. Specifically, by applying LoZA to LongCat-Flash during mid-training, we serve LongCat-Flash-Exp as a long-context foundation model that can swiftly process up to 1 million tokens, enabling efficient long-term reasoning and long-horizon agentic capabilities.
