How to fine-tune Qwen1.5 (LoRA, QLoRA)
Chat template, Transformers requirement and Tongyi Qianwen license limits to check before fine-tuning Qwen1.5 with LoRA or QLoRA.
This guide covers adapting the Qwen1.5 family. Memory per method and GPU counts appear below, and the training cost calculator estimates runtime. For method background see fine-tuning, LoRA and QLoRA.
Setup
- Use
transformers>=4.37.0, per the Qwen1.5-7B-Chat card, to avoidKeyError: 'qwen2'. - No
trust_remote_codeis needed, according to the card. - Format training data with the tokenizer's chat template (
apply_chat_template) so it matches serving. - The card does not document LoRA target modules, so use your trainer's defaults.
- Training context beyond 32K is not covered by the card, which states 32K for all sizes.
License
The Chat card lists the tongyi-qianwen license. The LICENSE text for that checkpoint says:
- Commercial use with more than 100 million monthly active users requires requesting a license from Alibaba Cloud.
- You may not use the Materials or any output to improve any other large language model (excluding Tongyi Qianwen or derivative works thereof).
- Recipients must receive a copy of the agreement, modified files must carry notices of changes, and distributed copies must retain the line "Tongyi Qianwen is licensed under the Tongyi Qianwen LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."
Fine-tuned weights are derivatives, so these terms travel with your adapter or merged model. Check the license field on the exact size you adapt, since other sizes may differ.
Memory to fine-tune Qwen1.5, by size
Model state in GB before activations, for a full fine-tune, LoRA and QLoRA, with the cheapest live GPU set that has that much memory. One model per size.
| Model | Parameters | Full fine-tune | LoRA | QLoRA | Compute per 1B tokens |
|---|---|---|---|---|---|
| Qwen1.5-0.5B-Chat | 620M | 9.2 GBRTX 4070 Super · $0.121/hr | 1.2 GBRTX 4070 Super · $0.121/hr | 0.3 GBRTX 4070 Super · $0.121/hr | 3.7 × 10^18 FLOPs |
| Qwen1.5-1.8B-Chat | 1.8B | 27.4 GBRTX 4080 Super · $0.338/hr | 3.4 GBRTX 4070 Super · $0.121/hr | 0.9 GBRTX 4070 Super · $0.121/hr | 1.1 × 10^19 FLOPs |
| Qwen1.5-4B | 4.0B | 58.9 GBA100 · $1.21/hr | 7.4 GBRTX 4070 Super · $0.121/hr | 1.9 GBRTX 4070 Super · $0.121/hr | 2.4 × 10^19 FLOPs |
| CodeQwen1.5-7B-Chat | 7.3B | 108 GBRTX A5000 × 5 · $0.880/hr | 13.5 GBRTX A4000 · $0.167/hr | 3.5 GBRTX 4070 Super · $0.121/hr | 4.4 × 10^19 FLOPs |
| Qwen1.5-7B | 7.7B | 115 GBRTX A5000 × 5 · $0.880/hr | 14.4 GBRTX A4000 · $0.167/hr | 3.7 GBRTX 4070 Super · $0.121/hr | 4.6 × 10^19 FLOPs |
| Qwen1.5-14B | 14.2B | 211 GBRTX A6000 × 5 · $1.81/hr | 26.4 GBRTX 4080 Super · $0.338/hr | 6.8 GBRTX 4070 Super · $0.121/hr | 8.5 × 10^19 FLOPs |
| Qwen1.5-MoE-A2.7B | 14.3B | 213 GBRTX A6000 × 5 · $1.81/hr | 26.7 GBRTX 4080 Super · $0.338/hr | 6.9 GBRTX 4070 Super · $0.121/hr | 8.6 × 10^19 FLOPs |
| Qwen1.5-32B-Chat | 32.5B | 484 GBRTX PRO 6000 × 6 · $8.25/hr | 60.6 GBA100 · $1.21/hr | 15.6 GBRTX A4000 · $0.167/hr | 2.0 × 10^20 FLOPs |
| Qwen1.5-72B-Chat | 72.3B | 1077 GBNo live fit | 135 GBRTX A5000 × 6 · $1.06/hr | 34.7 GBRTX A6000 · $0.363/hr | 4.3 × 10^20 FLOPs |
Full fine-tune counts 16 bytes per parameter (mixed-precision Adam, as counted in the ZeRO paper). LoRA keeps the frozen base in BF16 at 2 bytes per parameter. QLoRA stores the base in 4-bit NormalFloat with double quantization at 4.127 bits per parameter (QLoRA paper). Adapters and activations are not counted: activations depend on your batch size and sequence length, so leave headroom. Compute is the training-cost calculator's 6 × parameters × tokens for a dense model; mixture-of-experts models use fewer. These are estimates from formulas, not measurements of a run.
Estimate a full run
Turn the compute column into time and cost with the training cost calculator. For the methods themselves, read LoRA and QLoRA, and see how fine-tuning works on Aquanode at fine-tuning.
Sources
- https://huggingface.co/Qwen/Qwen1.5-7B-Chat
- https://huggingface.co/Qwen/Qwen1.5-7B-Chat/blob/main/LICENSE
Updated 2026-10-07.