Does quantization affect models' performance on long-context tasks?

Anmol Mekala, Anirudh Atmakuru, Yixiao Song, Marzena Karpinska, Mohit Iyyer

TL;DR

This paper systematically evaluates how different quantization methods affect the performance of large language models (LLMs) on tasks requiring long contexts and long-form outputs. They found that while 8-bit quantization is largely lossless, 4-bit methods can significantly degrade performance, especially for non-English languages and specific model architectures, highlighting the need for careful, task-specific evaluation.

What Problem Does This Paper Address?

Modern LLMs are increasingly supporting massive context windows (over 128K tokens), enabling them to process complex documents like codebases or legal texts. However, this comes at a steep cost in terms of memory and inference latency. Quantization, a technique to reduce model size and speed up inference by using lower-precision numbers, is a promising solution. While it's known that 8-bit quantization generally preserves performance, and 4-bit quantization offers significant efficiency gains, there's a critical gap in understanding how these methods impact LLMs on tasks that specifically leverage these long contexts and generate lengthy outputs. Previous studies often focused on shorter inputs, potentially masking performance degradations that become apparent only with extended contexts. This paper aims to fill that gap by providing a comprehensive evaluation.

Methods

The researchers conducted a systematic evaluation of five LLMs (Llama-3.1 8B/70B and Qwen-2.5 7B/32B/72B) across five quantization methods: FP8, GPTQ-int8 (8-bit), AWQ-int4, GPTQ-int4, and BNB-nf4 (all 4-bit). They compared these quantized models against their BF16 (full-precision) baselines. The evaluation focused on tasks involving long inputs (≥64K tokens) and long-form outputs. They used established benchmarks for retrieval, reasoning, and generation tasks, carefully analyzing performance variations based on context length, language, model family, and specific quantization techniques.

Datasets

The paper evaluated models on five benchmark tasks:

  • RULER: For English long-context retrieval, using needle-in-a-haystack tasks with varying context lengths (8K, 64K, 128K).
  • ONERULER: Extends RULER to include retrieval tasks across 26 languages and "no-needle" scenarios.
  • NOCHA: For long-context reasoning, involving verifying claims against book-length texts (up to 128K tokens).
  • FACTSCORE: For factual biography generation, evaluating the accuracy of generated long-form text.
  • CS4: For constrained creative story generation, measuring instruction-following and coherence.

Key Insights and Ideas

  • Long-context is a stress test for quantization: The paper's core insight is that quantization's impact is significantly amplified when dealing with long contexts. What might be negligible on short inputs can lead to substantial performance drops on longer ones.
  • 8-bit is (mostly) safe, 4-bit is a gamble: While 8-bit quantization methods like FP8 and GPTQ-int8 show minimal performance degradation, 4-bit methods, especially BNB-nf4, can be highly detrimental, particularly for tasks requiring precise retrieval or reasoning over extended text.
  • Language matters, a lot: The degradation caused by quantization is much more pronounced in languages other than English. This suggests that current quantization strategies might not be universally applicable across linguistic diversity.
  • Model and method synergy is crucial: The impact of quantization is not uniform. Different models (even of similar size) and different quantization methods interact in complex ways. A method that works well for one model might fail spectacularly for another, underscoring the need for task- and model-specific tuning.
  • BNB-nf4's popularity comes with a caveat: The paper highlights that BNB-nf4, a popular default 4-bit quantization method in libraries like HuggingFace and vLLM, can lead to significant performance drops, urging caution in its deployment for long-context tasks.

Key Results

  • 8-bit quantization: On average, 8-bit quantization (FP8, GPTQ-int8) resulted in a minimal performance drop of around 0.2% to 0.8%.
  • 4-bit quantization: 4-bit methods showed average drops ranging from 1.8% (AWQ-int4) to 6.9% (BNB-nf4).
  • Long-context input tasks: For tasks like retrieval (RULER, ONERULER), 4-bit quantization led to drops of up to 16% at 128K context lengths, with some specific cases showing losses as high as 59% (Llama-3.1 70B on ONERULER with BNB-nf4).
  • Non-English languages: Accuracy drops for non-English languages were up to five times larger than for English.
  • Model heterogeneity: Qwen-2.5 72B remained robust under BNB-nf4, while Llama-3.1 70B experienced a 32% drop on the same task.
  • Long-form output tasks: Factuality (FACTSCORE) was largely preserved by 8-bit methods but saw drops with 4-bit methods. Constraint satisfaction (CS4) was generally well-preserved, though FP8 and BNB-nf4 showed significant drops. Story coherence declined with quantization, especially for smaller models.

Limitations and Future Work

The authors acknowledge several limitations:

  • Scope of experiments: They evaluated five quantization methods and five LLMs, and their findings might not generalize to other models or techniques. They did not explore further tuning of quantization methods.
  • Limited output lengths: While input contexts up to 128K tokens were tested, generated outputs were limited to <650 tokens. This was due to the unreliability of automated metrics for very long text, and human annotation would be needed for a more comprehensive evaluation of long-form output quality.
  • Quantization recipe variations: For AWQ and GPTQ, the Llama-3.1 and Qwen-2.5 models might have originated from different sources and been quantized with different calibration sets, potentially influencing results.

Future work could explore strategies to mitigate quantization errors in long-context scenarios, such as using long-context samples during calibration, multilingual calibration data, and attention-calibration techniques like "found-in-the-middle."

Summary updated

Abstract

Large language models (LLMs) now support context windows exceeding 128K tokens, but this comes with significant memory requirements and high inference latency. Quantization can mitigate these costs, but may degrade performance. In this work, we present the first systematic evaluation of quantized LLMs on tasks with long inputs (>64K tokens) and long-form outputs. Our evaluation spans 9.7K test examples, five quantization methods (FP8, GPTQ-int8, AWQ-int4, GPTQ-int4, BNB-nf4), and five models (Llama-3.1 8B and 70B; Qwen-2.5 7B, 32B, and 72B). We find that, on average, 8-bit quantization preserves accuracy (~0.8% drop), whereas 4-bit methods lead to substantial losses, especially for tasks involving long-context inputs (drops of up to 59%). This degradation tends to worsen when the input is in a language other than English. Crucially, the effects of quantization depend heavily on the quantization method, model, and task. For instance, while Qwen-2.5 72B remains robust under BNB-nf4, Llama-3.1 70B experiences a 32% performance drop on the same task. These findings highlight the importance of a careful, task-specific evaluation before deploying quantized LLMs, particularly in long-context scenarios and for languages other than English.
BibTeX
@misc{mekala2025does,
  author = {Anmol Mekala and Anirudh Atmakuru and Yixiao Song and Marzena Karpinska and Mohit Iyyer},
  title = {{Does quantization affect models' performance on long-context tasks?}},
  year = {2025},
  eprint = {2505.20276},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.20276},
}
Figure