Many of today's probabilistic programming languages (PPLs) have brittle inference performance: the performance of the underlying inference algorithm is very sensitive to the precise way in which the probabilistic program is written. A standard way of addressing this challenge in traditional programming languages is via program optimizations, which seek to unburden the programmer from writing low-level performant code, freeing them to work at a higher-level of abstraction. The arsenal of applicable program optimizations for PPLs to choose from is scarce in comparison to traditional programs; few of today's PPLs offer significant forms of automated program optimization. In this work we develop a new family of program optimizations specific to discrete-valued knowledge compilation based PPLs. We identify a particular form of program structure unique to these PPLs that tangibly affects exact inference performance in these programs: redundant random variables -- variables with repeated parameters and inconsistent path conditions. We develop a new program analysis and associated optimization called flip-hoisting that identifies these redundancies and optimizes them into a single random variable. We show that flip-hoisting yields inference speedups of up to 60% on applications of probabilistic programs such as Bayesian networks and probabilistic verification.
翻译:当今许多概率编程语言(PPL)的推理性能较为脆弱:底层推理算法的性能对概率程序的具体编写方式极其敏感。传统编程语言中解决这一挑战的标准途径是通过程序优化,旨在减轻程序员编写底层高性能代码的负担,使其能够专注于更高层次的抽象。与传统程序相比,PPL中可选择的适用程序优化工具较为匮乏;当今很少有PPL能提供显著形式的自动化程序优化。在本工作中,我们开发了一系列专用于基于离散值知识编译的PPL的程序优化方法。我们识别出这些PPL特有的一种程序结构形式,它切实影响这些程序的精确推理性能:冗余随机变量——即具有重复参数和不一致路径条件的变量。我们提出了一种新的程序分析及其关联优化方法,称为翻转提升,该方法能够识别这些冗余并将其优化为单一随机变量。我们证明,翻转提升在贝叶斯网络和概率验证等概率程序应用中可实现高达60%的推理加速。