# Flux Attention: Context-Aware Hybrid Attention for Efficient LLMs Inference

*Quantong Qiu, Zhiyi Hong, Yi Yang, Haitian Wang, Kebin Liu, Qingqing Dang, Juntao Li, Min zhang*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/154703) · [OpenReview](https://openreview.net/forum?id=BfLKfkqbAC) · [alphaXiv](https://www.alphaxiv.org/abs/2604.07394) · [Open on the map](../papers.html#p154703)

Category: [Efficient LLM Inference & Training](../pcat/14.md) › [Sparse Long-Context Attention](../pgroup/226.md) · Type: new method · Keywords: context-aware attention, layer routing, LLM inference acceleration, full attention, sparse attention

Areas: [LLM Reasoning](../areas/reasoning.md) › Efficient Reasoning › Sparse Attention; [Memory](../areas/memory.md) › Model Memory Optimization › Efficient Attention for LLMs; [Long Context](../areas/longcontext.md) › Long-context mechanisms › Attention optimizations; [Model Architectures & Sequence Modeling](../areas/architectures.md) › Language Model Architectures › Sparse Attention

## Summary
Flux Attention introduces a context-aware layer-wise routing framework that dynamically selects Full or Sparse Attention per layer to accelerate LLM inference while preserving performance.

## Explained to a 5-year-old
Big computer programs called language models need a lot of time to think when they read long texts. The authors made a smart helper that decides for each part of the program whether to use a simple way to look at words or a more thorough way, depending on how much there is to read. This helps the program work faster, like speeding up a car. It only needs a little extra training, so it's easy to use. Because of this, the program can answer questions quickly even with long conversations.

## Explained to a 5-year-old, longer
Language models are computer programs that can talk and write, but they get slow when they have to read a lot of text at once. When they read many words, they have to look at every word together, which takes a lot of computer power. This slowness makes it hard to use these programs in real life, like helping people with long conversations. Some researchers tried to make the program skip some words to be faster, but they always used the same skipping rule for everything. The problem with that is that sometimes you need to remember everything, and sometimes you only need a little, but the old method couldn't change. The new idea is like having a smart assistant that looks at each piece of the program and decides whether to use the full way of looking at words or the quick way. The assistant watches how much information is needed for each part of the reading and picks the best method. If the part needs a lot of details, it uses the full method; if it only needs a little, it uses the quick method. This way the program stays accurate when it matters and runs fast when it doesn't. The assistant itself is very small and easy to add to existing programs without changing much. It only needs a short training period, so even a small team can set it up. Because of this, the program can answer questions quickly even when the conversation is long, making it more useful for everyday tasks.

## For a technical reader
Flux Attention introduces a context-aware routing mechanism that decides, per transformer layer, whether to apply full attention or a sparse variant based on the input length. By inserting a lightweight Layer Router into frozen LLMs, the framework maintains high-fidelity retrieval while ensuring contiguous memory access, which translates into practical speedups. The method requires only 12 hours of training on eight high-end GPUs, making it a parameter-efficient drop-in replacement for existing attention modules. Evaluations on long-context and mathematical reasoning benchmarks show up to 2.8× faster prefill and 2.0× faster decode compared to baseline attention schemes. Overall, it offers a simple, scalable solution for accelerating LLM inference without sacrificing model performance.

## Problem
Standard attention mechanisms have quadratic computational complexity, causing a scalability bottleneck for LLMs in long contexts. Existing hybrid attention methods use static allocation ratios and suffer from load imbalance, limiting hardware acceleration during decoding.

## Method
The approach integrates a lightweight Layer Router into frozen pretrained LLMs, which dynamically routes each layer to either Full Attention or Sparse Attention based on input context. This layer-wise routing ensures contiguous memory access and reduces computational load, yielding practical speedups.

## Results
The approach achieves speed improvements of up to 2.8× in prefill and 2.0× in decode stages on the evaluated benchmarks, while maintaining performance comparable to baseline models.

## Contributions
It proposes a context-aware dynamic layer routing mechanism for hybrid attention, a parameter-efficient training recipe requiring only 12 hours on 8 GPUs, and demonstrates superior speed-performance trade-offs on long-context and reasoning tasks.

## Practical relevance
The framework enables faster LLM inference on existing hardware, making long-context processing more feasible for production systems.

## Research questions this paper is counted under

- [How can we reduce the quadratic attention cost and memory usage of large language models for long contexts while preserving performance?](../q/4.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/154703)
