按文件大小与每解决任务能耗选择量化代码大语言模型
研究论文 · 2026/11/20
开发者在笔记本电脑上运行代码助手时,本地推理将每个请求的能耗转移到该机器上。常见规则认为,较低精度的大模型往往优于较高精度的小模型。我们在无风扇的MacBook Air M2上运行了Qwen2.5-Coder的24个GGUF文件(四种尺寸),并以每个解决任务的能量消耗为指标,在542个EvalPlus任务上进行了评估。结果是一个按Ollama列出的文件大小索引的选择指南,每个选择都带有证据标签。在1GB和2GB时,指南选择1.5B和3B模型的q4_K_M文件,它们在所有核算下都处于正确性和能量前沿。在列出的3GB时,较大模型规则选择7B-q2_K,这是唯一适合的已测量7B文件,但在这里并不划算。该文件在解决任务上相比2GB选择(3B-q4_K_M)没有显著增益,90%置信区间将3B-q4_K_M的不足限制在2.4个百分点内。然而,7B-q2_K在CPU、GPU和内存轨上每个解决任务需要2.03倍的能量,或在全系统功率上需要1.66至1.81倍。在HumanEval+上,五个交替会话对给出的比率为1.925,而主网格中为1.956。在8GB时,7B-q6_K以更高的能量价格为代价,比2GB选择获得了显著增益。从1.5B起,q4_K_M在其尺寸下与最高精度测量值相差不到3个百分点(90%置信区间)。我们发布了每个任务的结果、功率日志和分析脚本。
该研究为在本地运行代码助手的开发者提供了基于实际能耗和正确性的量化选择指南,挑战了“大模型低精度优于小模型高精度”的常见规则,并提供了可重复的分析数据。
A developer running a code assistant on a laptop downloads one model file, and local inference moves the energy of every request onto that machine. A common rule says a larger model at lower precision tends to beat a smaller one at higher precision. We ran 24 GGUF files of Qwen2.5-Coder at four sizes on a fanless MacBook Air M2 and priced each in energy per solved task on 542 EvalPlus tasks. The result is a selection guide indexed by Ollama's listed file size, with an evidence label on each pick. At 1 and 2 GB it picks the q4_K_M files of the 1.5B and 3B models, both on the correctness and energy frontier under every accounting. At 3 GB as listed, the larger-model rule picks 7B-q2_K, the only measured 7B file that fits, and there it does not pay. That file brings no significant gain in solves over the 2 GB pick, 3B-q4_K_M, and the 90% CI limits any 3B-q4_K_M deficit to 2.4 points. Yet 7B-q2_K needs 2.03 times the energy per solved task on CPU, GPU and memory rails, or 1.66 to 1.81 times on whole-system power. On HumanEval+, five alternating session pairs give a ratio of 1.925 against 1.956 in the main grid. At 8 GB, 7B-q6_K buys a significant gain over the 2 GB pick at a higher energy price. From 1.5B up, q4_K_M trails the highest precision measured at its size by less than 3 points (90% CI). We release per-task results, power logs and the analysis script.