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%的推理加速。