Qwen 2.5 LLM vLLM High-Concurrency Inference Throughput & Memory Tuning Guide
Alibaba Qwen 2.5 covers 0.5B to 72B. Complete mirror pulling guide with vLLM PagedAttention, Chunked Prefill, and KV cache utilization for 3x throughput speedups.
π Qwen 2.5 series technological innovations
Qwen 2.5 released by Alibaba Tongyi Lab is one of the most comprehensive multi-language large model families in the current open source ecosystem. Its flagship 72B weight and small and medium-sized 7B/14B/32B have achieved outstanding results in multiple rigorous benchmark tests.
Compared with the previous generation, Qwen 2.5 has comprehensively upgraded the following architectural features:
- Native 128K ultra-long context: Supports context windows up to 131,072 tokens and can generate coherent long text up to 8K tokens.
- Full-size Grouped-Query Attention (GQA): GQA is enabled even at the 7B/14B parameter level, which greatly reduces the memory usage of the KV Cache in the inference stage.
- SwiGLU activation and RoPE rotational positional encoding optimization: More robust performance for multi-language, long code and structured table reasoning.
π₯ Full steps to pull Qwen 2.5 weight from image
For production environment deployment, we usually pull the official Instruct instruction aligned version:
# Environment variable configuration
export HF_ENDPOINT="https://hf-mirror.net"
# Pull 7B-Instruct basic model (about 15GB)
huggingface-cli download Qwen/Qwen2.5-7B-Instruct \
--local-dir /data/models/Qwen2.5-7B-Instruct \
--local-dir-use-symlinks False
# Or pull the flagship 72B-Instruct (about 145GB, recommended for multi-core servers)
huggingface-cli download Qwen/Qwen2.5-72B-Instruct \
--local-dir /data/models/Qwen2.5-72B-Instruct \
--local-dir-use-symlinks False \
--resume-download
βοΈ vLLM inference throughput extreme compression and configuration tuning
Directly using native PyTorch / Hugging Face pipeline can only achieve extremely limited concurrent throughput (usually around 10~20 req/s). Using vLLM combined with modern CUDA operators and continuous batching, service throughput can be easily increased by 3 to 5 times.
π 1. In-depth analysis of key startup parameters
| Parameter options | default value | Recommended tuning values | underlying effectiveness mechanism |
|---|---|---|---|
| --gpu-memory-utilization | 0.90 | 0.94 ~ 0.96 | The proportion of video memory reserved for model weights and KV Cache. Increasing it can significantly increase the number of concurrent requests that can be accommodated. |
| --max-model-len | 131072 | 32768 or 16384 | Limit the maximum length of a single context. If there is no need for extremely long text in production, setting it to 32k can prevent extreme input from occupying too much video memory. |
| --enable-chunked-prefill | False | True | Enable block pre-filling to avoid interrupting the existing Token stream being generated when a burst of long Prompt arrives, greatly reducing TTFT jitter. |
| --kv-cache-dtype | auto (fp16) | fp8 | Compress KV Cache to FP8 on Ada Lovelace (RTX 4090/L40) or Hopper (H100/H800) with half the video memory and no precision loss. |
π 2. Production-level multi-card service startup example
# Deploy 72B flagship model for 4-card A800/A100 (80G)
vllm serve /data/models/Qwen2.5-72B-Instruct \
--tensor-parallel-size 4 \
--gpu-memory-utilization 0.95 \
--max-model-len 32768 \
--enable-chunked-prefill True \
--max-num-batched-tokens 8192 \
--trust-remote-code \
--port 8000
π§ͺ FastAPI asynchronous streaming client integration
After deployment, vLLM natively provides a REST API that is compatible with the OpenAI specification. The following is a complete Python code that calls Qwen 2.5 asynchronous streaming output in the production business gateway:
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(
base_url="http://localhost:8000/v1",
api_key="none_required"
)
async def stream_qwen_chat(prompt: str):
response = await client.chat.completions.create(
model="Qwen2.5-72B-Instruct",
messages=[
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
{"role": "user", "content": prompt}
],
temperature=0.7,
max_tokens=2048,
stream=True
)
async for chunk in response:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
if __name__ == "__main__":
asyncio.run(stream_qwen_chat("Please briefly describe the basic principles of memory virtualization in modern operating systems."))