TL;DR
Data analysts increasingly want to run SQL queries that mix traditional relational operations with AI-powered "semantic" tasks—like filtering customer reviews by sentiment or joining product photos to descriptions—over text, images, and audio. Until now, semantic query engines ran the SQL part on CPUs and shipped AI work to slow, expensive multimodal LLMs, while GPU databases ignored semantic operators altogether. GSQ bridges this gap by running both the relational engine and lightweight, task-specialized AI "proxy" models in-process on the same GPU, achieving a 49× median speedup (and up to 496×) over served multimodal LLMs.
What Problem Does This Paper Address?
Modern enterprises sit on mountains of unstructured data—scanned invoices, product images, call recordings, and text reviews. "Semantic operators" let analysts query this data declaratively using SQL functions like AI_FILTER, AI_CLASSIFY, or AI_EXTRACT.
However, existing semantic query systems (such as Snowflake Cortex AISQL, LOTUS, and ThalamusDB) share a structural bottleneck: they run the relational engine on the CPU and treat the GPU merely as a remote model server for large, autoregressive multimodal LLMs (MLLMs). Conversely, GPU databases (like HeavyDB or cuDF/RAPIDS) accelerate relational scans, joins, and aggregations on the GPU, but have no first-class support for semantic operators.
Methods
GSQ (GPU Semantic Query) unifies both worlds on a single GPU:
- GPU-Native Relational + Proxy Execution: GSQ parses T-SQL, lowers relational operations to
cuDFon the GPU, and evaluates semantic operators using small, non-generative proxy models (classifiers, embedding models, cross-encoders) that run in-process on the same GPU. Unlike autoregressive LLMs, proxies answer in a single forward pass without token-by-token decoding. - Static Proxy Routing: Using 13 off-the-shelf public models (e.g., DistilBERT for sentiment, CLIP/BiomedCLIP for images, CLAP/Wav2CLIP for audio, MiniLM/cross-encoders for ranking) plus a literal substring rule, GSQ routes each operator at plan time based on modality and predicate intent. Operators without a proxy (like free-form document OCR) fall back to a served MLLM with concurrent dispatch and output-token caps.
- GPU-Native Input Preparation: GSQ tokenizes text (via
cuDFWordPiece), decodes JPEGs (via hardwarenvImageCodec), and extracts audio spectrograms directly on the GPU, eliminating CPU-to-GPU bottlenecks. - Modality-Aware Semantic Joins: To avoid intractable $|L| \times |R|$ cross-products, GSQ uses a GPU-accelerated blocking-plus-rerank operator: it embeds both sides (e.g., with MiniLM or CLIP), selects top-$k$ candidates via matrix multiplication, and reranks only those pairs.
- Memory-Bounded Co-location: To ensure proxies never starve the relational engine of GPU memory, GSQ subtracts resident model weights from a fixed memory budget, sizes batches dynamically, and bounds oversized inputs (e.g., downscaling huge images on decode or windowing long text/audio).
Datasets
GSQ is evaluated on 85 semantic-SQL workloads spanning text, image, audio, and cross-modal queries across seven semantic operator classes:
- SemBench (
movie,mmqa,medical,cars,animals): 56 workloads covering sentiment, multimodal QA, patient diagnosis, vehicle faults, and animal detection. - Cortex AISQL & Public Benchmarks (
cortex,clinical,invoice_ocr): NLP benchmarks, clinical notes, and invoice OCR. - Classification & Ranking (
amazon,imdb,bbc news,emotion,toxic,fever,BEIRsubset,hellaswag): Following Chung et al., covering sentiment, topic/emotion classification, fact-checking, retrieval, and commonsense ranking.
Key Insights and Ideas
- The Serving-Throughput Roofline: By adapting the classic hardware roofline model to LLM serving, the authors show that even short-answer semantic operators (like
AI_FILTER) are capped by a served MLLM's prefill roof (~686 inferences/s on an A100). Non-generative proxies bypass autoregressive decoding altogether, sitting well above this ceiling. - Proxies Shift the Bottleneck: When an MLLM takes 99.86% of query time, relational speed barely matters. Once GPU proxies accelerate inference by orders of magnitude, relational operators can suddenly jump from 0.14% to 52% of execution time, making GPU-native relational execution essential.
- CPU Proxies Aren't Enough: Running proxies on a CPU only beats served MLLMs on a few image/audio workloads; moving proxies to the GPU yields 19–138× speedups on text and 8.8–46× on images/audio over CPU proxies.
- Co-location and GPU Input Prep Matter: Keeping proxies in-process avoids serialization overhead (1.04–1.8× faster for images/audio), while GPU-native tokenization, decoding, and audio feature extraction add up to 4.5× speedups over CPU input prep.
Key Results
- Throughput vs. Served MLLMs: Across the 80 workloads a proxy can serve (on an NVIDIA A100), GSQ achieves a 49× median speedup (and up to 496×) over the faster of two served MLLMs (
Qwen2.5-Omni-7BandPhi-4-multimodal-instruct). - Throughput vs. SOTA Systems: On 54 SemBench workloads, GSQ is a median 118× faster than LOTUS (up to 2,784×) and 63× faster than ThalamusDB (up to 1,665×), while supporting audio and multi-column predicates that those systems miss.
- Accuracy: Evaluated at the strict per-operator level across 68 scored workloads, GSQ's proxies stay within 10 percentage points of (or exceed)
omnion 55 workloads andphi4on 64 workloads. On BEIR retrieval ranking, the cross-encoder proxy beatsphi4on 4 of 5 datasets. - Memory Safety: Under a 2 GiB memory budget, GSQ keeps peak GPU memory below 0.65 GiB even when fed synthetic 24K × 24K pixel images (which otherwise consume 50.2 GiB).
Limitations and Future Work
- Coverage & Generalization: GSQ uses off-the-shelf public checkpoints with zero training. If no public proxy covers a task (e.g., free-form OCR, country/continent geography, or commonsense benchmarks like HellaSwag), GSQ must fall back to a served MLLM or accept lower accuracy.
- User Guidance & Cascades: Proxy accuracy can be sensitive to how prompts are mapped to class texts or entailment hypotheses; user guidance could improve this. Additionally, GSQ currently runs proxies alone rather than using confidence-based cascades to escalate uncertain rows to an MLLM.
- Single-GPU Scope: The current prototype runs on a single GPU; extending it to multi-GPU or distributed setups is left for future work.
Summary updated