# Query Processing on Tensor Computation Runtimes

arXiv: https://arxiv.org/abs/2203.01877 · HTML: https://mlsanity.com/paper/2203.01877/

## Key facts

- Cited by 12 papers in the map (data through 14 Oct 2026).
- Builds on 20 of its 136 references that are in the map.
- First posted on arXiv 3 Mar 2022.

## Builds on (most cited first, 20 of 20)

- [In-Datacenter Performance Analysis of a Tensor Processing Unit](https://mlsanity.com/paper/1704.04760/) (2017)
- [MLIR: A Compiler Infrastructure for the End of Moore's Law](https://mlsanity.com/paper/2002.11054/) (2020)
- [TVM: An Automated End-to-End Optimizing Compiler for Deep Learning](https://mlsanity.com/paper/1802.04799/) (2018)
- [MLlib: Machine Learning in Apache Spark](https://mlsanity.com/paper/1505.06807/) (2015)
- [Apache Calcite: A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sources](https://mlsanity.com/paper/1802.10233/) (2018)
- [SystemDS: A Declarative Machine Learning System for the End-to-End Data Science Lifecycle](https://mlsanity.com/paper/1909.02976/) (2019)
- [A Tensor Compiler for Unified Machine Learning Prediction Serving](https://mlsanity.com/paper/2010.04804/) (2020)
- [Towards Scalable Dataframe Systems](https://mlsanity.com/paper/2001.00888/) (2020)
- [The CoRa Tensor Compiler: Compilation for Ragged Tensors with Minimal Padding](https://mlsanity.com/paper/2110.10221/) (2021)
- [Cortex: A Compiler for Recursive Deep Learning Models](https://mlsanity.com/paper/2011.01383/) (2020)
- [Extending Relational Query Processing with ML Inference](https://mlsanity.com/paper/1911.00231/) (2019)
- [Declarative Recursive Computation on an RDBMS, or, Why You Should Use a Database For Distributed Machine Learning](https://mlsanity.com/paper/1904.11121/) (2019)
- [Tensor Relational Algebra for Machine Learning System Design](https://mlsanity.com/paper/2009.00524/) (2020)
- [SPORES: Sum-Product Optimization via Relational Equality Saturation for Large Scale Linear Algebra](https://mlsanity.com/paper/2002.07951/) (2020)
- [Fixpoint Semantics and Optimization of Recursive Datalog Programs with Aggregates](https://mlsanity.com/paper/1707.05681/) (2017)
- [JANUS: Fast and Flexible Deep Learning via Symbolic Graph Execution of Imperative Programs](https://mlsanity.com/paper/1812.01329/) (2018)
- [TCUDB: Accelerating Database with Tensor Processors](https://mlsanity.com/paper/2112.07552/) (2021)
- [Generating Custom Code for Efficient Query Execution on Heterogeneous Processors](https://mlsanity.com/paper/1709.00700/) (2017)
- [A Study of the Fundamental Performance Characteristics of GPUs and CPUs for Database Analytics (Extended Version)](https://mlsanity.com/paper/2003.01178/) (2020)
- [Modularis: Modular Relational Analytics over Heterogeneous Distributed Platforms](https://mlsanity.com/paper/2004.03488/) (2020)

## Built on by (most cited first, 12 of 12)

- [Deep Lake: a Lakehouse for Deep Learning](https://mlsanity.com/paper/2209.10785/) (2022)
- [Share the Tensor Tea: How Databases can Leverage the Machine Learning Ecosystem](https://mlsanity.com/paper/2209.04579/) (2022)
- [Analytical Engines With Context-Rich Processing: Towards Efficient Next-Generation Analytics](https://mlsanity.com/paper/2212.07517/) (2022)
- [The Tensor Data Platform: Towards an AI-centric Database System](https://mlsanity.com/paper/2211.02753/) (2022)
- [The Duck's Brain: Training and Inference of Neural Networks in Modern Database Engines](https://mlsanity.com/paper/2312.17355/) (2023)
- [Biathlon: Harnessing Model Resilience for Accelerating ML Inference Pipelines](https://mlsanity.com/paper/2405.11191/) (2024)
- [Auto-Differentiation of Relational Computations for Very Large Scale Machine Learning](https://mlsanity.com/paper/2306.00088/) (2023)
- [Optimizing Context-Enhanced Relational Joins](https://mlsanity.com/paper/2312.01476/) (2023)
- [Bullion: A Column Store for Machine Learning](https://mlsanity.com/paper/2404.08901/) (2024)
- [DataKernelBench: Can LLMs Optimize Database Queries on GPUs?](https://mlsanity.com/paper/2608.25061/) (2026)
- [MaskSearch: Querying Image Masks at Scale](https://mlsanity.com/paper/2305.02375/) (2023)
- [MLSkip: Data Skipping for ML Filters via Lightweight Metadata](https://mlsanity.com/paper/2606.03946/) (2026)

## Abstract (arXiv)

The huge demand for computation in artificial intelligence (AI) is driving unparalleled investments in hardware and software systems for AI. This leads to an explosion in the number of specialized hardware devices, which are now offered by major cloud vendors. By hiding the low-level complexity through a tensor-based interface, tensor computation runtimes (TCRs) such as PyTorch allow data scientists to efficiently exploit the exciting capabilities offered by the new hardware. In this paper, we explore how database management systems can ride the wave of innovation happening in the AI space. We design, build, and evaluate Tensor Query Processor (TQP): TQP transforms SQL queries into tensor programs and executes them on TCRs. TQP is able to run the full TPC-H benchmark by implementing novel algorithms for relational operators on the tensor routines. At the same time, TQP can support various hardware while only requiring a fraction of the usual development effort. Experiments show that TQP can improve query execution time by up to 10× over specialized CPU- and GPU-only systems. Finally, TQP can accelerate queries mixing ML predictions and SQL end-to-end, and deliver up to 9× speedup over CPU baselines.
