STI:通过弹性流水线在边缘进行涡轮增压NLP推断
STI: Turbocharge NLP Inference at the Edge via Elastic Pipelining
摘要:
自然语言处理(NLP)推理越来越多地被移动应用所采用,其中设备上的推理对于保护用户数据隐私和避免网络往返至关重要。然而,NLP模型的空前规模同时强调了延迟和内存,在移动终端的两个关键资源之间造成了紧张。为了满足目标延迟,将整个模型保存在内存中可以尽快启动执行,但会使一个应用的内存占用量增加数倍,从而将其优势限制在由移动存储管理回收之前的几个推论上。另一方面,按需从存储加载模型会导致IO长达几秒,远远超过用户满意的延迟范围;由于IO和计算延迟之间的高偏斜度,流水线分层模型加载和执行也不会隐藏IO。为此,我们提出了快速Transformer推理(STI)。STI基于最大化模型最重要部分的IO/计算资源利用率的关键理念,通过两种新的技术记忆张力。首先,模型分片。STI将模型参数作为独立可调的分片进行管理,并分析其对精度的重要性。第二,带预加载缓冲区的弹性管线规划。STI实例化IO/计算流水线,并使用小缓冲区预加载分片以引导执行,而不会在早期阶段停止;它根据分片的重要性明智地选择,调整和组装分片,以实现资源弹性执行,最大限度地提高推理准确性。在两个商品SoC上,我们构建了STI,并在CPU和GPU上针对各种NLP任务,在实际的目标范围内进行了评估。我们证明,STI提供高精度与1-2个数量级的内存较低,优于竞争对手的基线。
英文摘要:
Natural Language Processing (NLP) inference is seeing increasing adoption by mobile applications, where on-device inference is desirable for crucially preserving user data privacy and avoiding network roundtrips. Yet, the unprecedented size of an NLP model stresses both latency and memory, creating a tension between the two key resources of a mobile device. To meet a target latency, holding the whole model in memory launches execution as soon as possible but increases one app's memory footprints by several times, limiting its benefits to only a few inferences before being recycled by mobile memory management. On the other hand, loading the model from storage on demand incurs IO as long as a few seconds, far exceeding the delay range satisfying to a user; pipelining layerwise model loading and execution does not hide IO either, due to the high skewness between IO and computation delays. To this end, we propose Speedy Transformer Inference (STI). Built on the key idea of maximizing IO/compute resource utilization on the most important parts of a model, STI reconciles the latency v.s. memory tension via two novel techniques. First, model sharding. STI manages model parameters as independently tunable shards, and profiles their importance to accuracy. Second, elastic pipeline planning with a preload buffer. STI instantiates an IO/compute pipeline and uses a small buffer for preload shards to bootstrap execution without stalling at early stages; it judiciously selects, tunes, and assembles shards per their importance for resource-elastic execution, maximizing inference accuracy. Atop two commodity SoCs, we build STI and evaluate it against a wide range of NLP tasks, under a practical range of target latencies, and on both CPU and GPU. We demonstrate that STI delivers high accuracies with 1-2 orders of magnitude lower memory, outperforming competitive baselines.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。