Transformer-Lite: モバイルGPUにおける大規模言語モデルの高効率デプロイメント
Transformer-Lite: High-efficiency Deployment of Large Language Models on Mobile Phone GPUs
March 29, 2024
著者: Luchang Li, Sheng Qian, Jie Lu, Lunxi Yuan, Rui Wang, Qin Xie
cs.AI
要旨
大規模言語モデル(LLM)は、スマートアシスタント、テキスト要約、翻訳、モバイル端末におけるマルチモーダリティなど、幅広いタスクに活用されています。しかし、現状のオンデバイスLLM展開手法では推論速度が遅く、ユーザーエクスペリエンスの低下を招いています。デバイスGPU上での高効率なLLM展開を実現するため、我々は以下の4つの最適化技術を提案します:(a) 動的形状モデル推論をサポートするシンボリック式ベースのアプローチ、(b) 推論速度の向上と端末のラグ低減のための演算子最適化と実行優先度設定、(c) 逆量子化オーバーヘッドを削減するFP4量子化手法M0E4、(d) LLM推論後のKVキャッシュコピーを不要にするサブテンソルベースの技術。さらに、これらの手法をモバイル推論エンジン「Transformer-Lite」に実装しました。Transformer-Liteは、QualcommとMTKの両プロセッサに対応しています。我々は、2Bから14Bまでの多様なアーキテクチャとパラメータを持つLLMを用いてTransformer-Liteの性能を評価しました。具体的には、ChatGLM2 6Bにおいてプレフィル速度121トークン/秒、デコード速度14トークン/秒を、より小規模なGemma 2Bではプレフィル速度330トークン/秒、デコード速度30トークン/秒を達成しました。CPUベースのFastLLMおよびGPUベースのMLC-LLMと比較して、我々のエンジンはプレフィル速度で10倍以上、デコード速度で2~3倍の高速化を実現しています。
English
The Large Language Model (LLM) is widely employed for tasks such as
intelligent assistants, text summarization, translation, and multi-modality on
mobile phones. However, the current methods for on-device LLM deployment
maintain slow inference speed, which causes poor user experience. To facilitate
high-efficiency LLM deployment on device GPUs, we propose four optimization
techniques: (a) a symbolic expression-based approach to support dynamic shape
model inference; (b) operator optimizations and execution priority setting to
enhance inference speed and reduce phone lagging; (c) an FP4 quantization
method termed M0E4 to reduce dequantization overhead; (d) a sub-tensor-based
technique to eliminate the need for copying KV cache after LLM inference.
Furthermore, we implement these methods in our mobile inference engine,
Transformer-Lite, which is compatible with both Qualcomm and MTK processors. We
evaluated Transformer-Lite's performance using LLMs with varied architectures
and parameters ranging from 2B to 14B. Specifically, we achieved prefill and
decoding speeds of 121 token/s and 14 token/s for ChatGLM2 6B, and 330 token/s
and 30 token/s for smaller Gemma 2B, respectively. Compared with CPU-based
FastLLM and GPU-based MLC-LLM, our engine attains over 10x speedup for the
prefill speed and 2~3x speedup for the decoding speed.Summary
AI-Generated Summary