HISA: Indexação Hierárquica Eficiente para Atenção Esparsa de Granularidade Fina
HISA: Efficient Hierarchical Indexing for Fine-Grained Sparse Attention
March 30, 2026
Autores: Yufei Xu, Fanxu Meng, Fan Jiang, Yuxuan Wang, Ruijie Zhou, Jiexi Wu, Zhixin Pan, Zhaohui Wang, Xiaojuan Tang, Wenjie Pei, Tongxuan Liu, Di yin, Xing Sun, Muhan Zhang
cs.AI
Resumo
Os mecanismos de atenção esparsa a nível de token, exemplificados pela DeepSeek Sparse Attention (DSA), alcançam uma seleção granular de chaves ao atribuir uma pontuação a cada token histórico para cada consulta usando um indexador leve, e subsequentemente calcular a atenção apenas sobre o subconjunto selecionado. Embora a atenção esparsa subsequente seja computacionalmente eficiente, o indexador ainda precisa varrer todo o prefixo para cada consulta, introduzindo um gargalo de O(L²) por camada que se torna proibitivo à medida que o contexto aumenta. Propomos o HISA (Hierarchical Indexed Sparse Attention), um substituto direto para o indexador que transforma o processo de busca de uma varredura plana de tokens em um procedimento hierárquico de dois estágios. Primeiro, um filtro grosseiro a nível de bloco pontua representantes agregados dos blocos para podar regiões irrelevantes. Em seguida, um refinamento a nível de token aplica o indexador original apenas dentro dos blocos candidatos restantes. O HISA preserva exatamente o padrão de esparsidade top-k a nível de token exigido pelo operador Sparse MLA subsequente e não requer treinamento adicional. Em benchmarks a nível de kernel, o HISA alcança uma aceleração de 2x para um contexto de 32K tokens e de 4x para 128K. No Needle-in-a-Haystack e no LongBench, substituímos diretamente o indexador no DeepSeek-V3.2 pelo HISA, sem qualquer ajuste fino. O HISA equipara-se estreitamente à DSA original em qualidade, enquanto supera significativamente as linhas de base baseadas em atenção esparsa por blocos. Além disso, os conjuntos de seleção de tokens produzidos pelo HISA e pela DSA original exibem um IoU médio superior a 99%, indicando que os ganhos de eficiência são obtidos praticamente sem impacto na fidelidade da seleção.
English
Token-level sparse attention mechanisms, exemplified by DeepSeek Sparse Attention (DSA), achieve fine-grained key selection by scoring every historical token for each query using a lightweight indexer, and then computing attention only over the selected subset. While the downstream sparse attention scales efficiently, the indexer still scans the entire prefix for every query, introducing an O(L^2) per-layer bottleneck that becomes prohibitive as context length grows. We propose HISA (Hierarchical Indexed Sparse Attention), a drop-in replacement for the indexer that transforms the search process from a flat token scan into a two-stage hierarchical procedure. First, a block-level coarse filter scores pooled block representatives to prune irrelevant regions. Then, a token-level refinement applies the original indexer only within the remaining candidate blocks. HISA preserves the exact token-level top-k sparsity pattern required by the downstream Sparse MLA operator and requires no additional training. On kernel-level benchmarks, HISA achieves a 2times speedup at 32K context length and 4times at 128K. On Needle-in-a-Haystack and LongBench, we directly replace the indexer in DeepSeek-V3.2 with HISA, without any fine-tuning. HISA closely matches the original DSA in quality while significantly outperforming block-sparse baselines. Moreover, the token selection sets produced by HISA and the original DSA exhibit a mean IoU greater than 99%, indicating that the efficiency gains come with virtually no impact on selection fidelity.