一句话:结合约束优化与领域知识,用启发式搜索和求解器加速ML加速器片上内存分配,并在Pixel 6与TPUv4落地。
面向ML加速器的片上内存缓冲区分配是编译中的关键问题:分配器需为静态控制流图中已知的缓冲区选择器件内存位置,使总用量不超过片上容量;该问题高维且NP难。现有启发式难以处理复杂实例,ILP求解器方法虽能处理却代价高昂,在手机端按需编译等关键路径场景不可行。TelaMalloc结合约束优化与领域知识,用启发式搜索并由求解器指导决策,还利用ML持续改进长尾工作负载搜索。评估表明,简单输入上可媲美启发式,复杂输入上显著快于最佳ILP方法;系统已部署于Pixel 6与TPUv4,实际工作负载上分配时间相对生产ILP方法加速最高两个数量级,并支持原本无法支持的重要模型。
Memory buffer allocation for on-chip memories is a major challenge in modern machine learning systems that target ML accelerators. In interactive systems such as mobile phones, it is on the critical path of launching ML-enabled applications. In data centers, it is part of complex optimization loops that run many times and are the limiting factor for the quality of compilation results. In contrast to the traditional memory allocation problem in languages such as C++, where allocation requests dynamically arrive as the application is executing, ML systems typically execute a static control flow graph that is known in advance. The task of the memory allocator is to choose buffer locations in device memory such that the total amount of used memory never exceeds the total memory available on-device. This is a high dimensional, NP-hard optimization problem that is challenging to solve. Today, ML frameworks approach this problem either using ad-hoc heuristics or solver-based methods. Heuristic solutions work for simple cases but fail for more complex instances of this problem. Solver-based solutions can handle these more complex instances, but are expensive and impractical in scenarios where memory allocation is on the critical path, such as on mobile devices that compile models on-the-fly. We encountered this problem in the development of Google's Pixel 6 phone, where some important models took prohibitively long to compile. We introduce an approach that solves this challenge by combining constraint optimization with domain-specific knowledge to achieve the best properties of both. We combine a heuristic-based search with a solver to guide its decision making. Our approach matches heuristics for simple inputs while being significantly faster than the best Integer Linear Program (ILP) solver-based approach for complex inputs. We also show how ML can be used to continuously improve the search for the long tail of workloads. Our approach is shipping in two production systems: Google's Pixel 6 phone and TPUv4. It achieves up to two orders of magnitude allocation time speed-up on real ML workloads compared to a highly-tuned production ILP approach that it replaces and enables important real-world models that could not otherwise be supported.
@inproceedings{0001B0I23,
title = {TelaMalloc: Efficient On-Chip Memory Allocation for Production Machine Learning Accelerators},
author = {Martin Maas and Ulysse Beaugnon and Arun Chauhan and Berkin Ilbeyi},
booktitle = {ASPLOS},
year = {2022},
doi = {10.1145/3567955.3567961}
}