Why does Qwen4 stay fast at long context?

December 6, 2026 5 answers
Asked by Crisp Cracker

Qwen4 seems to hold its output speed much better at long context than earlier variants, and sometimes even gets faster during a response. Is that mostly down to the architecture, memory use, or the inference engine?

Answers

Scoutbook

Sparse attention is a big part of the explanation. Instead of reading the entire attention cache for every generated token, the model can select a limited set of relevant entries. That can keep the amount of cache data read per token from growing as quickly as context gets longer.

That is different from saying the cache stays small. The model may still need to retain information from a long context, so memory capacity can remain a constraint even when decode speed holds up.

Maribel:

And selecting those entries has a cost too. Sparse reads can reduce the long-context penalty without making context length completely free.

Reply to this answer
Theo M

The inference engine matters a lot here. Different engines can handle attention, memory transfers, and caching very differently, so the same model and hardware may show quite different slowdowns as context grows.

For a useful comparison, keep the engine, quantization, context lengths, and offloading settings consistent. Also measure prompt processing separately from output generation. Fast decoding does not necessarily mean a long prompt will process just as quickly.

Reply to this answer
Tennis

The speed rising during a response could be an engine effect rather than a property of sparse attention itself. If the model uses a mixture of experts, an expert cache may become better tuned to the current workload as generation proceeds.

Speculative decoding can also affect reported tokens per second. N-gram speculation or a multi-token prediction head might help, depending on what's enabled and how often proposed tokens are accepted. Those are possibilities to check, not proof of what happened in this run.

Birdsong:

Try the same prompt with speculation disabled, then enabled. That should help separate its contribution from changes in caching.

Reply to this answer
Slightly Late

Watch memory usage as well as tokens per second. A flatter speed curve doesn't mean you can add unlimited context. The cache still takes space, and whether it fits in GPU memory, system RAM, or shared memory can change performance. Leave some headroom rather than assuming all free memory is available for context.

Reply to this answer
Reilly

Qwen4 is not necessarily the first model to show this behavior. Other sparse-attention models have also been reported to maintain output speed at long contexts, though results vary with the engine and hardware.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions