论文标题
懒惰对象复制作为基于人群的概率编程的平台
Lazy object copy as a platform for population-based probabilistic programming
论文作者
论文摘要
这项工作考虑了基于人群的概率程序的动态内存管理,例如使用粒子方法进行推理的程序。这样的程序表现出通过连续几代人分配,复制,可能突变和处理相似物体的集合的模式。这些对象可能会组装数据结构,例如堆栈,队列,列表,破烂的数组和树,它们可能是随机的,并且可能是无界的大小。对于简单的$ n $粒子,$ t $代,$ d $对象和重新采样的简单情况,密集表示需要$ o(dnt)$内存,而稀疏表示只需要$ o(DT+dn \ log dn \ log dn)$内存,基于现有的理论结果。这项工作描述了一个对象复制的平台,以自动为程序员自动节省。核心想法是使用标记为有向多编码的标记的,顶点代表对象的标签,将指针与它们之间的指针相比,并标记必要的簿记。在激励模式下,提出了针对高性能的特定标签方案。该平台是为桦木概率编程语言实施的,使用智能指针,哈希表和参考计数垃圾收集。它在许多现实的概率程序上进行了经验测试,并以与理论期望一致的方式显着减少记忆使用和执行时间。这可以为命令式程序员,针对对象的程序员进行懒惰的深副本,并为函数程序员提供现场写作优化。
This work considers dynamic memory management for population-based probabilistic programs, such as those using particle methods for inference. Such programs exhibit a pattern of allocating, copying, potentially mutating, and deallocating collections of similar objects through successive generations. These objects may assemble data structures such as stacks, queues, lists, ragged arrays, and trees, which may be of random, and possibly unbounded, size. For the simple case of $N$ particles, $T$ generations, $D$ objects, and resampling at each generation, dense representation requires $O(DNT)$ memory, while sparse representation requires only $O(DT+DN\log DN)$ memory, based on existing theoretical results. This work describes an object copy-on-write platform to automate this saving for the programmer. The core idea is formalized using labeled directed multigraphs, where vertices represent objects, edges the pointers between them, and labels the necessary bookkeeping. A specific labeling scheme is proposed for high performance under the motivating pattern. The platform is implemented for the Birch probabilistic programming language, using smart pointers, hash tables, and reference-counting garbage collection. It is tested empirically on a number of realistic probabilistic programs, and shown to significantly reduce memory use and execution time in a manner consistent with theoretical expectations. This enables copy-on-write for the imperative programmer, lazy deep copies for the object-oriented programmer, and in-place write optimizations for the functional programmer.