T-MAN:通过统一查表在NPU上实现端到端低位宽大语言模型推理
T-MAN: Enabling End-to-End Low-Bit LLM Inference on NPUs via Unified Table Lookup
AI总结:
针对NPU上低位宽LLM推理因非GEMM运算效率低导致速度慢、现有方案存在精度损失或需拆分计算阶段的问题,提出T-MAN统一查表方案,实现端到端NPU推理,显著提升速度并降低能耗。
摘要:
大语言模型(LLM)正越来越多地部署在用户设备上。为支撑这类模型运行,当前设备普遍采用搭载神经网络处理单元(NPU)的片上系统(SoC)。尽管NPU被寄予高性能期望,但NPU上的LLM推理速度反而慢于CPU端推理,原因在于NPU在通用矩阵乘法(GEMM)之外的计算(如反量化)上性能较差。现有方案要么将预填充阶段拆分到NPU执行、解码阶段放到CPU执行,要么将两个阶段都放在NPU上运行但会带来精度损失。为解决该问题,我们基于“低位宽可将目标计算编码到大小可接受的查表中”的核心洞察,提出用查表操作涵盖原本硬件不支持的运算。为实现这一目标,我们克服预填充与解码阶段的硬件行为冲突,通过两项技术设计统一的表布局与分块方案:一是融合式两级基于查表的反量化,二是并发层级引导的分块。在此基础上,我们通过三阶段流水线实现预填充阶段,并将基于查表的解码阶段映射到NPU的向量单元上。实验结果显示,与基准NPU方法相比,该方案在预填充阶段实现1.4倍加速、解码阶段实现3.1倍加速,同时能耗降低84%。代码已开源:https://github.com/microsoft/T-MAC/tree/main/t-man。
英文摘要:
Large language models (LLMs) are increasingly deployed on customer devices. To support them, current devices are adopting SoCs (System on Chip) with NPUs (Neural Processing Unit) installed. Although high performance is expected, LLM inference on NPUs is slower than its CPU counterpart. The reason is that NPUs have poor performance on computations other than GEMM, like dequantization. Current works either disaggregate prefill on the NPUs and decoding on the CPUs, or put both on the NPUs but with an accuracy loss. To solve this issue, based on the insight that low-bit can enable target computation encoded within an acceptably sized table, we propose table lookup to subsume hardware operations otherwise unsupported. To realize this, we overcome the conflicting hardware behavior of prefill and decoding to design a unified table layout and tiling through (1) fused two-level table-based dequantization and (2) concurrency-hierarchy-guided tiling. Based on that, we implement the prefill phase by three-stage pipeline and map the table-lookup-based decoding to NPU's vector units. Results show 1.4x and 3.1x speedup for prefill and decoding respectively, and 84% energy savings compared to the baseline NPU methods. The code is available at https://github.com/microsoft/T-MAC/tree/main/t-man.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。