Skip to main content
Back

Alibaba's Qwen2.5-Coder Shrinks to 4-bit so Developers Run It on a 12GB GPU

A 4-bit AWQ quantized build of Qwen2.5-Coder-7B-Instruct shrinks memory needs while keeping HumanEval and MBPP performance close to the full model.

Pro

  • AWQ 4-bit build of Qwen2.5-Coder-7B-Instruct runs on a single 12 GB GPU.
  • Base model hits 88.4% HumanEval and 83.5% MBPP, strong for a 7B coder.
  • 28 layers, GQA with 28 Q heads and 4 KV heads, 7.61B parameters total.
  • Context up to 131,072 tokens via YaRN, default config caps at 32,768.
  • Deployable through Transformers, vLLM, SGLang, or Docker Model Runner.
  • Apache 2.0 license, free weights, works as an agent backbone for text-to-SQL and repo tasks.

Alibaba’s Qwen team publishes an official AWQ checkpoint of Qwen2.5-Coder-7B-Instruct under the Apache 2.0 license. The 4-bit release targets developers who want a local coding assistant on a single consumer GPU, with lower memory use than FP16 and a smaller accuracy trade-off than many basic quantization methods.

Specification Value
Parameters 7.61 billion
Weight format 4-bit AWQ
Configured context 32,768 tokens
Extended context Up to 131,072 tokens with YaRN
Architecture 28-layer causal transformer
Attention 28 query heads and 4 key-value heads
License Apache 2.0

Four bits change the deployment math

AWQ, short for Activation-aware Weight Quantization, uses calibration activations to identify sensitive weights and choose scaling factors that reduce quantization error. The model still uses the same RoPE positions, SwiGLU feed-forward layers, RMSNorm, QKV bias, and grouped-query attention as the unquantized checkpoint.

Raw FP16 weights for 7.61 billion parameters require about 15.2 GB in decimal units. Four-bit values require about 3.8 GB before scales, metadata, unquantized tensors, and runtime allocations are counted. A 12 GB GPU is therefore a practical target for moderate context lengths and low concurrency, although the maximum context can exceed that budget.

Optimized AWQ kernels can also improve throughput by reducing memory traffic. Actual gains depend on the GPU, inference engine, batch size, prompt length, and generated-token count.

Budget VRAM for cache and runtime

Model weights consume only part of the GPU allocation. The key-value cache grows with every token and active sequence, while CUDA graphs, temporary buffers, and the inference engine add further overhead. Grouped-query attention limits cache growth by sharing four key-value heads across 28 query heads, but a 131K-token request can still consume several additional gigabytes.

  • For 12 GB cards: start with a 16K or 32K context and one active sequence.
  • For higher concurrency: shorten the context limit or use a GPU with more memory.
  • For predictable latency: cap prompt length, output length, and simultaneous requests.
  • For vLLM tuning: adjust --max-model-len, --max-num-seqs, and --gpu-memory-utilization.

131K context requires YaRN

The checkpoint’s shipped config.json sets max_position_embeddings to 32,768. Reaching the model family’s 131,072-token limit requires YaRN, a RoPE scaling method that extrapolates positional embeddings beyond the original training window. Add this block to a local copy of the configuration:

{
  "rope_scaling": {
    "factor": 4.0,
    "original_max_position_embeddings": 32768,
    "type": "yarn"
  }
}

vLLM currently applies static YaRN scaling across all input lengths. That constant factor can reduce quality on short prompts, so separate short-context and long-context deployments may produce better results than one configuration serving every request.

Reference scores have limits

Published benchmark results describe the unquantized Qwen2.5-Coder-7B-Instruct checkpoint and provide an approximate ceiling for the AWQ release. Quantization, prompt templates, decoding settings, and evaluation harnesses can change the measured result.

Benchmark Reported score What it measures
HumanEval 88.4% Function generation from Python specifications
MBPP 83.5% Short Python programming problems
GSM8K 83.9% Grade-school mathematical reasoning
ExecRepoBench 44.2 pass@1 Repository-level code completion

The broader Qwen2.5-Coder training corpus contains 5.5 trillion tokens drawn from source code, text-code grounding data, and synthetic examples. Production selection should still rely on an internal evaluation containing the target languages, repository layouts, prompt templates, and tool calls.

Choose the checkpoint by workload

Workload Fit Deployment note
Code chat and function generation Strong Use the instruction checkpoint and its chat template.
Repository-aware editing Strong with retrieval The application must select and supply relevant files.
Bug fixes and small refactors Good Validate changes with tests, linters, and type checks.
Raw IDE completion Workload-dependent Compare the instruction checkpoint with the base Coder model.
General chat and broad reasoning Mixed Qwen2.5-7B-Instruct leads the coder variant on several general benchmarks.
Long autonomous workflows Requires orchestration Provide tools, state management, retries, and execution limits.

The model can generate edits from repository context, but it has no built-in index, file access, test runner, or memory between requests. Those capabilities belong in the surrounding application. Generated commands and code should run in a sandbox with restricted credentials and network access.

Launch an OpenAI-compatible server

vLLM can detect the checkpoint’s AWQ configuration and expose the model through an OpenAI-compatible API on supported GPUs. A minimal launch uses:

pip install -U vllm
vllm serve Qwen/Qwen2.5-Coder-7B-Instruct-AWQ

A chat request can then be sent to the local endpoint:

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen2.5-Coder-7B-Instruct-AWQ",
    "messages": [
      {
        "role": "user",
        "content": "Write a Python function that merges overlapping intervals."
      }
    ],
    "temperature": 0.2,
    "max_tokens": 512
  }'

SGLang provides a similar OpenAI-compatible serving path. Hugging Face Transformers can load AWQ checkpoints when a compatible quantization backend is installed, while vLLM is generally the simpler route for a persistent GPU service. Docker Model Runner also offers a compact launch command on supported systems:

docker model run hf.co/Qwen/Qwen2.5-Coder-7B-Instruct-AWQ

A practical local default

The AWQ release gives teams a compact checkpoint for private code chat, retrieval-assisted editing, CI analysis, and on-premises review tools. Apache 2.0 permits commercial use, modification, and redistribution subject to the license terms, while local inference gives operators direct control over retention, access, and infrastructure costs.

The wider family overview spans models from 0.5B to 32B. Teams can prototype with the 7B AWQ checkpoint, preserve the same Qwen-oriented serving interface, and move to a larger model when internal evaluations justify the added memory and latency.