Rockmate:一种用于 PyTorch 重物化的高效、快速、自动且通用的工具
Rockmate: an Efficient, Fast, Automatic and Generic Tool for Re-materialization in PyTorch
AI总结:
Rockmate 通过将 PyTorch 模型重写为复杂块序列,并结合 Checkmate 与 Rotor 的改编方法,以少量重计算和可忽略开销显著降低激活内存消耗。
摘要:
我们提出 Rockmate,用于在训练 PyTorch DNN 模型时控制内存需求。Rockmate 是一个自动工具,它从模型代码出发,以少量重新计算为代价,使用预定义数量的激活内存生成一个等价模型。Rockmate 自动检测计算和数据依赖的结构,并将初始模型重写为一系列复杂块。我们表明,这种结构广泛存在,可以在文献中的许多模型中找到(基于 Transformer 的模型、ResNet、RegNets 等)。这种结构使我们能够以快速且高效的方式解决问题,在单个块的层面使用 Checkmate 的一种改编(在整个模型上太慢但具有通用性),并在序列本身的层面使用 Rotor 的一种改编(速度快但仅限于顺序模型)。我们通过在多个模型上的实验表明,Rockmate 与 Rotor 一样快,与 Checkmate 一样高效,并且在许多情况下,它能以相当可忽略的开销(约 10% 到 20%)显著降低激活的内存消耗(降低 2 到 5 倍)。Rockmate 是开源的,可在 https://github.com/topal-team/rockmate 获取。
英文摘要:
We propose Rockmate to control the memory requirements when training PyTorch DNN models. Rockmate is an automatic tool that starts from the model code and generates an equivalent model, using a predefined amount of memory for activations, at the cost of a few re-computations. Rockmate automatically detects the structure of computational and data dependencies and rewrites the initial model as a sequence of complex blocks. We show that such a structure is widespread and can be found in many models in the literature (Transformer based models, ResNet, RegNets,...). This structure allows us to solve the problem in a fast and efficient way, using an adaptation of Checkmate (too slow on the whole model but general) at the level of individual blocks and an adaptation of Rotor (fast but limited to sequential models) at the level of the sequence itself. We show through experiments on many models that Rockmate is as fast as Rotor and as efficient as Checkmate, and that it allows in many cases to obtain a significantly lower memory consumption for activations (by a factor of 2 to 5) for a rather negligible overhead (of the order of 10% to 20%). Rockmate is open source and available at https://github.com/topal-team/rockmate.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。