← Latest papers
🤖 AI

Qrita: High-performance Top-k and Top-p using Pivot-based Truncation and Selection

The paper introduces Qrita, a high-performance, deterministic Top-k and Top-p sampling algorithm for large vocabularies that utilizes pivot-based truncation and selection to achieve up to 1.4x throughput improvement and 50% memory reduction compared to existing GPU kernels, leading to its adoption as the default sampler in vLLM.

Original authors: Jongseok Park, Sunga Kim, Alvin Cheung, Ion Stoica

Published 2026-05-27
📖 4 min read☕ Coffee break read

Original authors: Jongseok Park, Sunga Kim, Alvin Cheung, Ion Stoica

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a chef running a massive kitchen (a Large Language Model) with a pantry containing 100,000 different ingredients (the vocabulary). Every time you need to cook a dish (generate a word), you have to pick the best few ingredients from that giant pantry to ensure the meal tastes good but isn't boring.

In the world of AI, this picking process is called Top-k (picking the top k best ingredients) and Top-p (picking the smallest group of ingredients that adds up to a certain "flavor score").

The Problem: The Slow, Cluttered Kitchen

Currently, most kitchens handle this by dumping all 100,000 ingredients onto a giant counter, sorting them by "taste score" from best to worst, and then grabbing the top ones.

  • The Issue: Sorting 100,000 items is slow and messy. It takes up a huge amount of counter space (memory) and the chef's hands get tired (computation overhead).
  • The Alternative: Some chefs try to just grab a random handful of ingredients that might be good. But this is risky; sometimes you miss the best ingredients, and sometimes the dish turns out different every time you cook it (non-deterministic), which is bad if you need to replicate a recipe exactly.

The Solution: Qrita (The Smart Sous-Chef)

The paper introduces Qrita, a new, high-speed method for picking ingredients. Think of Qrita as a super-smart sous-chef who uses two clever tricks to skip the messy sorting entirely.

Trick 1: The "Gaussian Sigma-Truncation" (The Noise Filter)

Imagine that in your 100,000-ingredient pantry, 99,000 of them are just "noise" (like salt, sugar, and flour that are all roughly the same bland taste). Only a few hundred are the "star ingredients" (like truffles or saffron).

Instead of looking at every single jar, Qrita does a quick sniff test. It calculates the average taste and the "spiciness" (standard deviation) of the pantry. It then draws a line: "Anything below this line is just noise; we don't need to look at it."

  • The Result: It instantly throws away 99% of the pantry, leaving only the 200 or so interesting jars. This happens in a single, lightning-fast pass.

Trick 2: The "Quaternary Pivot Search" (The Four-Way Split)

Now, the chef has a small pile of 200 interesting ingredients. They still need to find the exact top 50.

  • Old Way: Check one by one (too slow) or split the pile in half (binary search).
  • Qrita's Way: Instead of splitting the pile in half, Qrita splits it into four sections at once. It asks: "Is the best ingredient in the first quarter, second, third, or fourth?"
  • The Bonus: It also has a special rule for duplicate ingredients. If three jars of "Saffron" have the exact same score, Qrita knows exactly how many to keep to ensure the recipe is identical every time (deterministic). This prevents the chef from getting stuck in an endless loop trying to decide between identical jars.

Why This Matters (The Results)

The authors built Qrita using a specialized tool called Triton (a language for programming graphics cards/GPUs) and tested it against the current best methods used by major AI engines like vLLM and SGLang.

  • Speed: Qrita is up to 1.4 times faster in real-world serving scenarios and up to 2 times faster in raw speed tests.
  • Memory: It uses half the memory because it doesn't need to store the whole sorted list of 100,000 items.
  • Accuracy: Unlike some fast methods that guess, Qrita gives you the exact same result as the slow, perfect sorting method. It doesn't change the output; it just finds it much faster.

The Bottom Line

Qrita is like upgrading from a chef who manually sorts every single spice in the world to a smart assistant who instantly ignores the boring stuff, splits the interesting stuff into four piles at once, and handles duplicates perfectly. It makes AI generation faster and more efficient without changing the quality of the answers.

Note: The paper mentions that Qrita is now the default method for the GPU path in vLLM, a popular tool for running AI models, and the code is available for others to use.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →