AI-SQL operators let analysts classify and join unstructured text inside SQL queries using natural-language prompts, yet firing an LLM call per row or per join pair quickly racks up hundreds of thousands of inferences. Quail tackles this bottleneck by co-optimizing the relational query plan and the LLM inference engine together.

Letting the Query Plan Drive Inference

Sending row-by-row HTTP requests to a general-purpose LLM server bottlenecks on CPU request scheduling and redundant prompt prefill. Quail couples SQL execution directly with model memory management to cut repeated HBM reads. During semantic joins, it pins an anchor document’s KV states in memory across multiple candidate comparisons and uses KV rewinding to discard per-pair suffixes while keeping shared prefixes intact. CPU batch preparation overlaps with active GPU execution in a pipelined loop to minimize idle gaps.

SQL Compatibility and Benchmark Results

Users register Arrow tables or datasets and query them via SQL or a pandas-style Python API. Quail supports Snowflake AI_FILTER and BigQuery AI.IF syntax alongside AI filters, joins, projections, and LIMIT clauses. On an internal benchmark running Qwen3 4B FP8 on a single H100 GPU, Quail outperformed vLLM on 27 out of 29 queries, posting a 1.84x geometric mean speedup with especially large gains on multi-pair tasks like clinical report comparisons.

Practical Trade-Offs

Data engineers and analysts running bulk LLM predicates at table scale stand to benefit most, though standard serving engines can still edge ahead on certain simple scan shapes depending on workload selectivity and prompt structure.

Summary

  • Co-optimizes relational SQL query plans with LLM inference to accelerate bulk AI-SQL workloads
  • Uses anchor pinning and KV cache rewinding on semantic joins to eliminate redundant memory reads, achieving a 1.84x geomean speedup over vLLM
  • Supports Snowflake AI_FILTER and BigQuery AI.IF syntax over Arrow datasets via SQL and Python