There is a growing demand for supporting inference queries that combine Structured Query Language (SQL) and Artificial Intelligence / Machine Learning (AI/ML) model inferences in database systems, to avoid data denormalization and transfer, facilitate management, and alleviate privacy concerns. Co-optimization techniques for executing inference queries in database systems without accuracy loss fall into four categories: (O1) Relational algebra optimization treating AI/ML models as black-box user-defined functions (UDFs); (O2) Factorized AI/ML inferences; (O3) Tensor-relational transformation; and (O4) General cross-optimization techniques. However, we found none of the existing database systems support all these techniques simultaneously, resulting in suboptimal performance. In this work, we identify two key challenges to address the above problem: (1) the difficulty of unifying all co-optimization techniques that involve disparate data and computation abstractions in one system; and (2) the lack of an optimizer that can effectively explore the exponential search space. To address these challenges, we present CactusDB, a novel system built atop Velox - a high-performance, UDF-centric database engine, open-sourced by Meta. CactusDB features a three-level Intermediate Representations (IR) that supports relational operators, expression operators, and ML functions to enable flexible optimization of arbitrary sub-computations. Additionally, we propose a novel Monte-Carlo Tree Search (MCTS)-based optimizer with query embedding, co-designed with our unique three-level IR, enabling shared and reusable optimization knowledge across different queries. Evaluation of 12 representative inference workloads and 2,000 randomly generated inference queries on well-known datasets, such as MovieLens and TPCx-AI, shows that CactusDB achieves up to 441 times speedup compared to alternative systems.
翻译:在数据库系统中,支持结合结构化查询语言(SQL)与人工智能/机器学习(AI/ML)模型推理的查询需求日益增长,这有助于避免数据反规范化与传输、简化管理并缓解隐私担忧。在数据库系统中执行此类推理查询且不损失准确性的协同优化技术可分为四类:(O1)将AI/ML模型视为黑盒用户定义函数(UDF)的关系代数优化;(O2)因子化AI/ML推理;(O3)张量-关系转换;以及(O4)通用的交叉优化技术。然而,我们发现现有数据库系统均无法同时支持所有这些技术,导致性能未能达到最优。在本工作中,我们识别出解决上述问题的两个关键挑战:(1)在单一系统中统一涉及异构数据与计算抽象的协同优化技术存在困难;(2)缺乏能有效探索指数级搜索空间的优化器。为应对这些挑战,我们提出了CactusDB——一个构建于Meta开源的高性能、以UDF为中心的数据库引擎Velox之上的新型系统。CactusDB采用三层中间表示(IR),支持关系运算符、表达式运算符及ML函数,从而实现对任意子计算的灵活优化。此外,我们提出了一种基于蒙特卡洛树搜索(MCTS)的新型优化器,结合查询嵌入技术,并与我们独特的三层IR协同设计,实现了跨不同查询的共享与可复用优化知识。在MovieLens和TPCx-AI等知名数据集上对12个代表性推理工作负载及2,000个随机生成的推理查询进行评估的结果表明,CactusDB相比其他系统最高可实现441倍的加速。