arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.06728cs.LGcs.ARcs.CL
收藏

Orion: 为大语言模型训练和推理表征和编程苹果的神经引擎

Orion: Characterizing and Programming Apple's Neural Engine for LLM Training and Inference

Ramchand Kumaresan

AI总结:

Orion通过直接编程苹果神经引擎实现LLM训练和推理,提供高效的编译器和运行时,显著提升训练速度并支持动态适配器更新。

摘要:

超过20亿台苹果设备配备了神经处理单元(NPU)——即苹果神经引擎(ANE),但这种加速器在大型语言模型工作负载中仍被大量未使用。CoreML,苹果的公开机器学习框架,施加了不透明的抽象,阻止了直接的ANE编程,并不支持设备上的训练。我们提出了Orion,据我们所知,这是第一个开源的端到端系统,它结合了直接的ANE执行、编译器流水线和稳定的多步骤训练与检查点恢复,所有这些都在一个原生运行时中完成,通过苹果私有的_ANEClient和_ANECompiler接口完全绕过CoreML。\n在maderix先前的特性化工作基础上,我们扩展了对ANE约束的公开知识,将其扩展为对MIL IR程序、内存布局、编译限制和数值行为的20条限制清单,包括在Orion开发过程中发现的14条此前未记录的限制。Orion包括一个将图IR通过五个优化步骤降低到ANE原生MIL的编译器,以及一个管理IOSurface背的零拷贝张量I/O、程序缓存和用于权重更新的delta编译的运行时。\n由于ANE在编译时固定权重,朴素的训练通常需要每个步骤重新编译整个程序(约4.2秒)。我们展示了编译后的程序可以通过卸载、修补权重文件和重新加载来更新,绕过了ANECCompile(),将重新编译时间从4,200毫秒减少到494毫秒每步骤(8.5倍),从而获得3.8倍的训练加速。在M4 Max上,Orion实现了每秒170+个token的GPT-2 124M推理速度,并在TinyStories上展示了在1,000步内稳定训练110M参数的变压器,且没有出现NaN。我们还提出了LoRA适配器作为输入,通过IOSurface输入实现适配器的热交换,而无需重新编译。

英文摘要:

Over two billion Apple devices ship with a Neural Processing Unit (NPU) - the Apple Neural Engine (ANE) - yet this accelerator remains largely unused for large language model workloads. CoreML, Apple's public ML framework, imposes opaque abstractions that prevent direct ANE programming and do not support on-device training. We present Orion, to our knowledge the first open end-to-end system that combines direct ANE execution, a compiler pipeline, and stable multi-step training with checkpoint resume in a single native runtime, bypassing CoreML entirely via Apple's private _ANEClient and _ANECompiler APIs. Building on prior characterization work by maderix, we extend public knowledge of ANE constraints to a catalog of 20 restrictions on MIL IR programs, memory layout, compilation limits, and numerical behavior, including 14 previously undocumented constraints discovered during Orion development. Orion includes a compiler that lowers a graph IR through five optimization passes to ANE-native MIL and a runtime that manages IOSurface-backed zero-copy tensor I/O, program caching, and delta compilation for weight updates. Because the ANE bakes weights at compile time, naive training normally requires full recompilation per step (~4.2 s). We show that compiled programs can instead be updated by unloading, patching weight files, and reloading, bypassing ANECCompile() and reducing recompilation from 4,200 ms to 494 ms per step (8.5x), yielding a 3.8x training speedup. On an M4 Max, Orion achieves 170+ tokens/s for GPT-2 124M inference and demonstrates stable training of a 110M-parameter transformer on TinyStories for 1,000 steps in 22 minutes with zero NaN occurrences. We also present LoRA adapter-as-input, enabling hot-swap of adapters via IOSurface inputs without recompilation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑