通过自动循环向量化优化概率程序中的密度计算
Optimising Density Computations in Probabilistic Programs via Automatic Loop Vectorisation
AI总结:
针对概率程序推理中循环迭代计算的性能瓶颈,提出基于推测并行执行与不动点检查的自动循环向量化方法,在Pyro上的实验显示其性能更优、适用模型更广。
摘要:
概率编程语言(PPL)是跨多领域进行高层建模的常用工具,提供了一系列概率推理算法,可通过从数据集学习模型参数或估计其后验分布来分析模型。但概率推理的计算成本极高,其瓶颈之一源于对大型数据集条目或长序列随机样本的迭代。向量化可降低该成本,但手动向量化易出错,现有自动技术往往是临时且受限的,若无大量用户干预则无法处理嵌套循环、含数据依赖控制流的循环等通用重复结构。为解决该瓶颈,我们提出一种可靠有效的方法,可对概率程序中的循环进行自动向量化。该方法通过对循环迭代进行推测性并行执行实现高吞吐量,同时通过不动点检查保留原始循环的语义。我们将该方法形式化为从命令式PPL到配备面向向量化原语的低级目标语言的转换。我们为Pyro PPL实现了该方法,并在一系列概率模型上开展评估。实验表明,相较于现有向量化基线方法,我们的方法取得了显著性能提升,实现了1.1-6倍的加速,且在多数场景下降低了GPU内存占用。基线方法仅适用于模型子集,而我们的方法可有效处理所有测试模型。
英文摘要:
Probabilistic programming languages (PPLs) are a popular tool for high-level modelling across many fields. They provide a range of algorithms for probabilistic inference, which analyse models by learning their parameters from a dataset or estimating their posterior distributions. However, probabilistic inference is known to be very costly. One of the bottlenecks of probabilistic inference stems from the iteration over entries of a large dataset or a long series of random samples. Vectorisation can mitigate this cost, but manual vectorisation is error-prone, and existing automatic techniques are often ad-hoc and limited, unable to handle general repetition structures, such as nested loops and loops with data-dependent control flow, without significant user intervention. To address this bottleneck, we propose a sound and effective method for automatically vectorising loops in probabilistic programs. Our method achieves high throughput using speculative parallel execution of loop iterations, while preserving the semantics of the original loop through a fixed-point check. We formalise our method as a translation from an imperative PPL into a lower-level target language with primitives geared towards vectorisation. We implemented our method for the Pyro PPL and evaluated it on a range of probabilistic models. Our experiments show significant performance gains against an existing vectorisation baseline, achieving $1.1$--$6\times$ speedups and reducing GPU memory usage in many cases. Unlike the baseline, which is limited to a subset of models, our method effectively handled all the tested models.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。