Skip to main content
This guide covers the hardware requirements for running Qwen models across different sizes, precision levels, and use cases.

Minimum Requirements

Software Prerequisites

  • Python: 3.8 and above
  • PyTorch: 1.12 and above (2.0+ recommended)
  • Transformers: 4.32.0 and above
  • CUDA: 11.4 and above (for GPU users)

Optional Dependencies

Flash Attention (recommended for fp16/bf16):
Flash Attention 2 is now supported and provides significant speed improvements. It requires NVIDIA GPUs with Turing, Ampere, Ada, or Hopper architecture (e.g., H100, A100, RTX 3090, T4, RTX 2080).

GPU Requirements by Model Size

Qwen-1.8B

Recommended GPU: RTX 3060 12GB or better

Qwen-7B

Recommended GPU: RTX 3090 24GB, RTX 4090 24GB, or A100 40GB

Qwen-14B

Recommended GPU: A100 40GB or A100 80GB

Qwen-72B

Recommended GPU: 2× A100 80GB or 4× A100 40GB

Inference Performance

Benchmarked on A100-SXM4-80G GPU with PyTorch 2.0.1, CUDA 11.8, Flash Attention 2:
Inference speed is averaged over encoded and generated tokens.

Finetuning Memory Requirements

Profiling on single A100-SXM4-80G with CUDA 11.8, PyTorch 2.0, Flash Attention 2: Batch size: 1, Gradient accumulation: 8

Qwen-1.8B

Qwen-7B

Qwen-14B

Qwen-72B

“LoRA (emb)” refers to training with embedding and output layers as trainable parameters.

KV Cache Quantization Impact

With KV cache quantization enabled, memory usage for different configurations:

Batch Size Scaling (Qwen-7B BF16, 1024 tokens)

Sequence Length Scaling (Qwen-7B BF16, batch size=1)

Multi-GPU Configurations

Pipeline Parallelism

For models that don’t fit on a single GPU, use automatic device mapping:
Native pipeline parallelism has lower efficiency. For production, consider using vLLM with FastChat.

CPU-Only Deployment

Qwen can run on CPU, but with significantly lower performance. For efficient CPU deployment, use qwen.cpp:
  • Pure C++ implementation
  • Optimized for CPU inference
  • Supports quantization

Direct CPU Inference

Direct CPU inference is extremely slow and not recommended for production use.

Cloud and API Deployment

DashScope API

The simplest deployment option through Alibaba Cloud:
  • qwen-turbo: Faster responses
  • qwen-plus: Better performance
  • No hardware management required
  • Scalable inference
See the DashScope documentation for details.

Specialized Hardware

Ascend 910: Supported for inference Hygon DCU: Supported for inference
x86 with OpenVINO: Supported on Core™/Xeon® Scalable Processors and Arc™ GPU

Docker Deployments

Pre-built Docker images are available to simplify environment setup. See the main documentation for Docker usage.

Optimization Recommendations

Int4 Quantization when:
  • Memory is the primary constraint
  • Inference speed is important
  • Slight quality degradation is acceptable
Int8 Quantization when:
  • Balance between memory and quality needed
  • Memory is moderately constrained
BF16/FP16 when:
  • Maximum quality is required
  • Sufficient GPU memory available
  • Training or fine-tuning
Flash Attention 2 provides:
  • 40% speedup for batch inference
  • Lower memory consumption
  • Better scaling with sequence length
Requires compatible GPU architecture (Ampere, Ada, Hopper).
Enable for:
  • Longer sequences (4096+ tokens)
  • Larger batch sizes
  • Memory-constrained scenarios
Not compatible with Flash Attention (will auto-disable Flash Attention if both enabled).
  • DeepSpeed ZeRO 3 requires high inter-node communication bandwidth
  • ZeRO 2 recommended for multinode LoRA fine-tuning
  • Test network throughput before scaling to multiple nodes

Model Specifications Summary

Troubleshooting

For common hardware-related issues, see the Troubleshooting and FAQ pages.