一句话:提出可靠的自动循环向量化方法,用推测并行与不动点检查加速概率程序推断。
概率编程语言中的推断代价高昂,其瓶颈之一在于对大型数据集或长随机样本序列的逐项迭代。向量化可缓解该开销,但手工向量化易错,现有自动方法多为 ad-hoc 且受限,难以处理嵌套循环与数据依赖控制流。本文提出一种可靠有效的概率程序循环自动向量化方法:以推测式并行执行循环迭代提升吞吐,并通过不动点检查保持原循环语义;方法被形式化为从命令式 PPL 到带向量化原语的低层目标语言的翻译。作者在 Pyro 上实现,并在多个概率模型上评估,相较已有向量化基线取得 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× 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.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@article{abs-2511-11070,
title = {Optimising Density Computations in Probabilistic Programs via Automatic Loop Vectorisation},
author = {Sangho Lim and Hyoungjin Lim and Wonyeol Lee and Xavier Rival and Hongseok Yang},
journal = {Proceedings of the ACM on Programming Languages},
volume = {10},
number = {POPL},
year = {2026},
doi = {10.1145/3776663}
}