Tempo:基于符号依赖图的编译型动态深度学习
Tempo: Compiled Dynamic Deep Learning with Symbolic Dependence Graphs
AI总结:
Tempo通过符号依赖图结合即时动态性与编译优化,实现动态深度学习加速,在Llama解码和强化学习上分别获得7倍和54倍加速。
摘要:
深度学习(DL)算法通常以时间关系来定义:一个时间步的张量可能依赖于更早或更晚时间步的张量。这种动态依赖(以及相应的动态张量形状)难以表达和优化:虽然即时(eager)DL系统支持这种动态性,但它们无法应用基于编译器的优化;基于图(graph)的系统需要静态张量形状,这迫使用户对张量进行填充或将程序拆分为多个静态图。我们描述了Tempo,一种新的DL系统,它结合了即时执行的动态性与基于图的编译的整程序优化。Tempo通过一种声明式编程模型实现这一点,该模型包含循环张量(recurrent tensors),这些张量具有显式的时间维度。时间维度可以使用符号表达式进行索引,以表达对过去和未来张量的动态依赖。基于此,Tempo构建一个符号依赖图(symbolic dependence graph),该图简洁地编码了算子之间的动态依赖,并应用整程序优化,如代数简化、向量化、分块(tiling)和融合(fusion)。通过将动态依赖分块为静态大小的块,Tempo还可以重用现有的静态代码生成器。然后,它使用多面体模型(polyhedral model)来寻找可行的执行调度,该调度包括内存管理操作。我们展示了Tempo在Llama-3.2-3B解码上比JAX实现了7倍加速;对于强化学习算法,Tempo实现了54倍加速,峰值内存使用量降低了16倍。
英文摘要:
Deep learning (DL) algorithms are often defined in terms of temporal relationships: a tensor at one timestep may depend on tensors from earlier or later timesteps. Such dynamic dependencies (and corresponding dynamic tensor shapes) are difficult to express and optimize: while eager DL systems support such dynamism, they cannot apply compiler-based optimizations; graph-based systems require static tensor shapes, which forces users to pad tensors or break-up programs into multiple static graphs. We describe Tempo, a new DL system that combines the dynamism of eager execution with the whole-program optimizations of graph-based compilation. Tempo achieves this through a declarative programming model with recurrent tensors, which include explicit temporal dimensions. Temporal dimensions can be indexed using symbolic expressions to express dynamic dependencies on past and future tensors. Based on this, Tempo constructs a symbolic dependence graph, which concisely encodes dynamic dependencies between operators, and applies whole-program optimizations, such as algebraic simplifications, vectorization, tiling, and fusion. By tiling dynamic dependencies into static-size blocks, Tempo can also reuse existing static code-generators. It then uses a polyhedral model to find a feasible execution schedule, which includes memory management operations. We show that Tempo achieves a 7$\times$ speedup over JAX for Llama-3.2-3B decoding; for reinforcement learning algorithms, Tempo achieves a 54$\times$ speedup, with 16$\times$ lower peak memory usage.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。