FlashTrie: A GPU-Accelerated Constrained Beam Search for Generative Retrieval

Dakshitha Anandakumar, Anurag Mukkara, Wenxiang Hu, Jiusheng Chen, M Akash Kumar, Ting Ye, Qiang Lou, Jian JiaoarXiv 2026

TL;DR

FlashTrie introduces a GPU-native framework for trie-constrained beam search in generative retrieval, overcoming traditional CPU serving bottlenecks. By redesigning succinct trie layouts for large integer-token vocabularies and executing the entire search loop within a single cooperative CUDA kernel, it achieves up to a 24× speedup over optimized CPU baselines. This latency reduction allows production search engines to scale beam widths by 5×, translating to a +0.71% revenue lift in live online deployment.

What Problem Does This Paper Address?

Generative retrieval is an emerging paradigm that replaces traditional dual-encoder document retrieval by training a sequence-to-sequence model to map a query directly to a unique document identifier (docID). However, because these models generate identifiers token-by-token, they frequently output invalid docIDs. To prevent this, systems enforce constrained decoding using a trie (prefix tree) of valid docIDs to mask out invalid token choices during beam search.

As document libraries scale to millions or billions of entries, trie-constrained beam search becomes a massive computational bottleneck. Standard pointer-based tries suffer from irregular memory access patterns that map poorly to GPUs, forcing production systems to rely on multi-threaded CPU implementations. Unfortunately, CPUs lack the massive parallelism required to scale as beam width grows, forcing a strict trade-off between search quality (wider beams) and online serving latency constraints.

Methods

FlashTrie bridges this gap by jointly optimizing the trie data structure and the decoding algorithm specifically for GPU architectures:

  • Narrow LOUDS for Integer Tokens: Traditional succinct tries (like MARISA) are optimized for 8-bit character alphabets. FlashTrie extends this to 32-bit integer tokens to support large vocabularies. To maintain space efficiency, it splits the token labels into a 2-byte low part stored in a base array and a bit-packed high part in a secondary array. This compression allows an 800M-keyword index to occupy just 3.1 GB, fitting entirely within GPU High-Bandwidth Memory (HBM).
  • Persistent Cooperative CUDA Kernel: Rather than launching separate GPU kernels for each decoding step—which introduces severe CPU-GPU orchestration overhead—FlashTrie executes the entire multi-step decoding loop inside a single persistent kernel.
  • Hierarchical Parallelism: The framework exploits two levels of concurrency: beam-parallel expansion across all active beams, and proposal-parallel validation within each beam. Threads within a CUDA thread block cooperatively perform parallel binary searches to validate language model proposals against sorted trie child labels.
  • Heap-Free Pruning: FlashTrie replaces traditional CPU-style min-heaps with an append-only candidate buffer and an on-device parallel block merge sort to efficiently trim and select the top active beams.
Figure 1: Overview of FlashTrie pipeline. At each de- coding step, active beam states are mapped to thread blocks (CTAs) and processed in parallel across the threads of a CTA for trie-based validation and beam expansion all executed on-device. (Inset) FlashTrie ex- tends Narrow-LOUDS representation to integer tokens stored in compact structured arrays.

Datasets

The authors evaluated FlashTrie using two primary workloads:

  1. Production Dataset: A large-scale commercial dataset consisting of 13,000 retrieval requests evaluated against a constraint trie built from 800 million keyword sequences with a 2.2M-token vocabulary.
  2. Public Benchmark: For reproducibility, the authors synthesized a workload using 3,600 NQ-Open validation queries, the GENRE-KILT BART-large model checkpoint, and a constraint library of ~6 million KILT Wikipedia titles.

Key Insights and Ideas

  • Data Structures Must Adapt to Accelerators: Tries are notoriously difficult to accelerate on GPUs due to pointer chasing and warp divergence. FlashTrie demonstrates that flattening and bit-packing the data structure into structured arrays allows developers to maximize warp utilization and eliminate memory stalls.
  • Algorithmic Efficiency Still Matters on GPU: A common pitfall is assuming GPU parallelism can compensate for brute-force algorithms. FlashTrie’s ablation studies revealed that swapping its inner-loop binary search for a linear scan caused a massive 71×–209× slowdown, proving that logarithmic child lookup remains essential even on massively parallel hardware.
  • Converting Latency Headroom to Revenue: In production systems, beam width is often artificially capped to satisfy strict online latency Service Level Agreements (SLAs). By reducing trie-search latency to a negligible fraction of the budget, FlashTrie unlocks the ability to run wider beam searches in real-time, directly improving downstream retrieval quality and business metrics.

Key Results

  • Sub-3ms Latency & 24× Speedup: On the 800M keyword library, FlashTrie reduced trie-search latency to under 3 ms for beam widths up to 1000, achieving up to a 24× speedup over a highly optimized multi-threaded CPU baseline (MARISA-Opt).
  • Efficient Index Construction: FlashTrie built the 800M-key index 3.4× faster and required 22% less disk space (3.1 GB vs 4.0 GB) than the CPU baseline, making it practical to deploy on smaller commodity GPUs.
Figure 3: Per-request trie-search latency and GPU speedup vs. beam width BW at b=1 ( |V|=2.2M, 800M- key trie). (Left) Mean (solid) and p95 (dashed) latency. CPU mean rises from 9.0 ms (BW=100) to 46.3 ms (BW=1000), with p95 65.5 ms and p99 76.7 ms at the top end. GPU mean stays sub-2 ms across the sweep (0.55–1.91 ms), with p95 ≤2.79 ms and p99 ≤3.31 ms. (Right) Mean GPU speedup climbs from 16× to 24×. Full per-percentile table: Appendix F.
  • Production A/B Test Success: In a 16-day randomized online A/B test on a commercial search engine, FlashTrie allowed the system to scale its operational beam width from 200 to 600 within the same latency budget. This wider search capability delivered a statistically significant +0.71% revenue lift and increased user clicks by up to 0.20% without degrading ad quality.

Limitations and Future Work

  • Single-GPU Memory Bound: The current design requires the entire constraint trie to reside within a single GPU's VRAM. While 3.1 GB easily accommodates 800M keywords, multi-billion-scale libraries will require extending the framework to shard subtrees across multiple GPUs via NVLink/NVSwitch.
  • Fixed Thread Partitioning: FlashTrie's batch scheduler allocates a fixed streaming multiprocessor (SM) partition to each query. Developing dynamic work-stealing schedulers that preserve persistent-kernel coherence could further optimize multi-query throughput.
  • Hardware Generalization: All experiments were conducted on NVIDIA A100 GPUs; evaluating performance characteristics on newer architectures like H100 or B100 remains an item for future work.

Summary updated

BibTeX
@misc{anandakumar2026flashtrie,
  author = {Dakshitha Anandakumar and Anurag Mukkara and Wenxiang Hu and Jiusheng Chen and M Akash Kumar and Ting Ye and Qiang Lou and Jian Jiao},
  title = {{FlashTrie: A GPU-Accelerated Constrained Beam Search for Generative Retrieval}},
  year = {2026},
  eprint = {2607.10044},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.10044},
}
Figure