Perplexity embeds a 128-token query in 1.53 ms where vLLM takes 4.60 ms, on the same H200 and the same model. The GPU work is about the same. The win is on the host.
Pick a query length, then press Send. Watch the same request race through both engines. Then we take the host side apart, piece by piece: the arithmetic, the launches, the graphs, the overlap and the gateway.
You need what a vector embedding is and what one transformer forward pass does. We build the rest from zero.
Based on Perplexity Engineering, Fast Embeddings on GPUs (4 September 2026). Benchmark numbers come from the post's charts. GPU specs come from NVIDIA's H200 page, read on 22 November 2026. Part of the Embedding family, with Vector Embeddings and Embedding Ops.
Totals are the post's median (p50) latencies for BGE-M3 at batch size one. The split is ours. Teal is the token work from a three-point fit to Tulip's numbers (Chapter 3), drawn the same for both engines. Warm is the rest. We slow time about 400 times.
Chapter 0
Find where three times of speed can hide when the GPU side is already solved
You type a question into a search box. Before an answer comes back, a small neural network turns your sentence into a list of numbers, an embedding. A vector database then finds the documents whose embeddings sit closest to yours. Vector Embeddings builds that idea from zero.
On 4 September 2026, Perplexity Engineering published a tour of the servers that make those embeddings. It opens with a concession: the GPU side "has converged to a largely optimal implementation across various inference engines." Then it reports a median request three times faster than vLLM v0.22.0, on the same model, precision and GPU.
Same GPU work, three times faster. The gap lives on the host: the CPU that parses the request, tokenizes it, schedules it, launches GPU programs and copies the answer back.
| Pattern | Who waits | Goal | Benchmark shape |
|---|---|---|---|
| Batch embedding | Nobody: an index rebuild | Throughput, so low cost | 100 sequences per request, 4 senders |
| Scoring | A person, for a batch | A balance of both | 5, 25 or 50 sequences |
| Online embedding | A person, for one query | Low latency | 1 sequence, one at a time |
Blue is Perplexity's server, purple is vLLM. Pick a pattern and read the ratio.
Published BGE-M3 numbers from the post's charts. Batch: 512 tokens, embeddings per second. Scoring (batch 5) and online (128 tokens): p50 milliseconds.
The win is 1.12 times for bulk work and 3.0 times for one short query. A fixed host cost is a big share of a small request and a tiny share of a big one.
The failure this lesson cures. Symptom: the embedding call is wide in a trace while GPU utilisation reads under 10 percent. Measure: compare the device time of one forward pass with the request's wall clock. Fix: cut host cost; a bigger GPU changes nothing.
Chapter 1
Count FLOPs and bytes to see why an LLM engine's kernels already fit embedding work
Perplexity serves embeddings with its LLM kernels. Bulk embedding is "similar to compute-bound prefill"; a short query is "computationally similar to memory-bound decode." Prefill is an LLM reading a whole prompt at once, so many tokens share each read of a weight. Decode writes one token per step, so each weight read serves one token.
Take one dense layer: a weight matrix of d by d numbers, applied to T token vectors, in BF16 (2 bytes a number). Each output number is d multiplies and d adds, so the work is 2Td² FLOPs (floating point operations). The bytes are the weights, 2d², plus each token vector read and written, 4Td. Arithmetic intensity is FLOPs per byte moved; call it I.
I equals two T d squared, over two d squared plus four T d.
Count the FLOPs: two per weight per token. Count the bytes: the weights once, plus every token vector in and out. Divide the first by the second.
BGE-M3 has width d = 1024. One query token, T = 1: 2,097,152 FLOPs over 2,101,248 bytes, so I = 1.0. A batch of T = 512: 1,073,741,824 FLOPs over 4,194,304 bytes, so I = 256.
A GPU has a machine balance, B: the FLOPs it can do in the time it fetches one byte. The H200 SXM does 989.5 TFLOPS of dense BF16 (NVIDIA lists 1,979 with sparsity) over 4.8 TB/s of memory bandwidth. So B = 206. Below B, the layer waits on memory. Above B, it waits on arithmetic.
T-star equals B times d, over d minus two B.
Set I equal to B and solve for T. A batch with fewer than T-star tokens is memory-bound. More is compute-bound.
T* = 206 × 1024 / (1024 − 412) = 210,944 / 612 = 345 tokens. The post puts GPU saturation for a sub-billion model at about 512 tokens, the same order.
The slope is the memory roof, the flat line the arithmetic roof. Drag the token count and watch the dot cross the knee.
One dense layer in BF16 on H200 datasheet peaks (989.5 TFLOPS dense, 4.8 TB/s). Real kernels reach less than the roof.
The failure: symptom, buying faster compute does not raise tokens per second. Measure: compute I for your typical batch. Fix: if I is far below B, batch more tokens or stop chasing FLOPs.
Chapter 2
Follow one request through three services and see what crosses each wire
The post's diagram starts with one HTTP request: {"model": "pplx-embed", "input": ["Roses are red", "The quick brown fox"]}. At the GPU, the two strings are token ids, [3630, 288, 525, 2518] and [17823, 574, 1382, 38835], on two different replicas.
| Service | Built in | Its job | Passes on |
|---|---|---|---|
| Ivy | Rust, HTTP gateway | JSON parsing, tokenization, input templates, batch splitting, load balancing | Token ids over a custom gRPC protocol |
| Tulip | Rust, tokio, tonic | Request pool, scheduling, batching, returning results | Batches to ROSE's step() |
| ROSE | Python | Kernels, layers, forward passes, CUDA graph management | A LazyTensor: a handle to running GPU work |
Press Next hop. The packet moves one service on, and the read-out says what it carries.
Request and token ids are the ones in the post's architecture diagram. Box sizes are not to scale.
Why a separate gateway. Tokenizer settings and templates change often; weights and captured graphs do not. The post's reason: Ivy lets them change these "without having to touch the heavier inference instances." A template edit becomes a config rollout, not a restart that throws away every captured graph.
Why Rust for Tulip. Tokio is Rust's asynchronous runtime: one process holds thousands of waiting requests without a thread each. Tonic is the gRPC library on top. Waking a task and copying a buffer sit on the critical path, so they run without Python's interpreter lock.
Why Python for ROSE. New models get written there fast. The bridge is one function, step(batch), which "takes a batch and returns a reference to the computation it performs on the accelerator." Chapter 6 builds that reference.
The failure: symptom, p99 spikes for minutes after every template change. Measure: plot p99 against deploy times. Fix: move tokenization and templates out of the model server into a stateless gateway.
Chapter 3
Derive why a first-come, first-served scheduler is enough, then fit the model to published numbers
Tulip's scheduler is simple: requests pile up while the engine works, then sequences leave "on a first-come, first-served basis." No sorting by length. Why is that safe? Count the work in one transformer block for a sequence of L tokens.
The dense work is the four attention projections, 4 × 2Ld², plus a feed-forward layer of width 4d, 2 × 2Ld × 4d. That is 24Ld². The attention work is the score matrix, 2L²d, plus mixing the values, 2L²d: 4L²d.
Four L squared d, over twenty-four L d squared, equals L over six d.
Divide attention work by dense work. Most factors cancel. Attention catches up with dense work only when L reaches six times d.
d = 1024, L = 512: 512 / 6,144 = 0.083. Attention is 8 percent of the dense work. The two are equal at L = 6,144.
So time follows the total token count. Two sequences of 256 cost about what one of 512 costs. Check it on the post's numbers: Tulip's median for BGE-M3 at batch one is 1.53, 2.03 and 9.57 ms at 128, 512 and 4,096 tokens. Call the fixed cost c, the cost per token a, and the attention cost per squared token b.
t of L equals c, plus a times L, plus b times L squared.
Write the equation once for each of the three measurements. Solve the three equations for c, a and b.
c = 1.377 ms, a = 0.001173 ms per token, b = 0.000000202. At L = 512: aL = 0.600 ms and bL² = 0.053 ms, so attention is 8.1 percent of the token work. The hand count said 8 percent.
Warm is c, teal is dense work, the light teal tail is attention. Change how many sequences share the tokens. Then change the tokens.
The fitted model above, applied to equal-length sequences. It fits three published points exactly, so treat values far from them as estimates.
Cut 2,048 tokens into 1 or 32 sequences: 4.63 ms against 3.81 ms. The token count sets the price. And c is 1.38 of the 1.53 ms request: 90 percent of it does not depend on tokens at all. Chapters 4 to 8 shrink c.
pythonfrom collections import deque pool = deque() # (request_id, length) in arrival order def next_batch(budget=512, max_seqs=64): batch, used = [], 0 while pool and len(batch) < max_seqs: rid, L = pool[0] if batch and used + L > budget: break # waits for the next batch batch.append(pool.popleft()); used += L return batch, used # no sorting: tokens are the price
The failure: symptom, a short query waits behind a tightly packed batch of long ones. Measure: p99 of short requests under mixed load. Fix: first come, first served; packing saves nothing when the batch has no padding.
Chapter 4
Find the token count below which the GPU waits for Python
A kernel is one GPU program: a matrix multiply, a norm, an add. For each kernel, the host runs Python dispatch, works out shapes, allocates the output and calls the CUDA driver. That costs a few microseconds, whether the kernel then runs for 2 microseconds or 2 milliseconds.
The post's diagram shows six host calls in a row (rms_norm, linear, sdpa, rms_norm, linear, add). Under them sit the six kernels, with hatched blocks labelled GPU IDLE between them. The GPU finished and waits for the next launch.
Call the kernels in one forward pass N, the host time per launch ℓ, and the device time per token τ. The host time is fixed. The device time grows with tokens. Where they meet is the inflection point.
T-inf equals N times ell, over tau.
Multiply the kernel count N by the launch cost ell to get the host bill. Divide by tau. Below that many tokens, the GPU idles.
With made-up numbers: 24 layers of 6 kernels, N = 144, and ell = 5 µs, so the host needs 720 µs. With tau = 0.72 µs per token, Tinf = 720 / 0.72 = 1,000 tokens.
| Batch | Device time | Host launches | GPU idle |
|---|---|---|---|
| 128 tokens | 92 µs | 720 µs | 87% |
| 512 tokens | 369 µs | 720 µs | 49% |
| 1,000 tokens | 720 µs | 720 µs | 0%: the inflection |
The post measures this per model and finds the point "comes at batches of thousands of tokens and tens of sequences." Our toy says 1,000.
Warm boxes are launches, teal boxes are kernels, hatches are idle GPU. Raise the tokens, then switch to one graph replay.
Illustrative: 144 kernels with device time shared evenly, 0.72 µs per token, and 8 µs for one graph replay. The drawing shows the first 12 kernels; the read-out counts all 144.
One kernel can block the fix of Chapter 5. The post: some attention kernels "rely on dynamic host-side inputs to configure kernel launches." Perplexity changed those kernels and sent the changes upstream.
The failure: symptom, GPU utilisation near 8 percent while p99 triples under load. Measure: a profiler trace shows short kernels with white gaps between them; N times ell beats device time. Fix: replace the launches with one graph replay.
Chapter 5
Replace 144 launches with one call, then pay for the capture while serving
A CUDA graph is a recording of every kernel launch in a forward pass, with its arguments. One driver call replays the whole pass. The post: this removes "the need to re-run expensive Python and PyTorch code." On replay there is no dispatch, no shape work and no allocation.
A graph has two hard rules. Shapes are frozen: 4 sequences of 512 tokens need a different graph from 8 sequences of 512. Addresses are frozen: the graph reads a fixed input buffer and writes a fixed output buffer. So you copy new data into the input buffer, replay, and read the output buffer.
pythonstatic_in = torch.zeros(T, D, device="cuda") # fixed shape, fixed address forward(static_in) # eager warmup: kernels chosen, buffers made g = torch.cuda.CUDAGraph() with torch.cuda.graph(g): # capture: launches recorded, not run static_out = forward(static_in) static_in.copy_(next_batch); g.replay() # one driver call for the whole pass
One graph per configuration means one per pair of sequence count and token count. The post pads token counts up to a bucket, a multiple of 64 or 256. Call the real token count n and the bucket P.
w equals P minus n, over P.
Round n up to the next bucket P. The rounded-up part, P minus n, is filler. Divide by P to get its share.
n = 130 with 64-token steps: P = 192, w = 62 / 192 = 32 percent. n = 500: P = 512, w = 12 / 512 = 2.3 percent.
Teal is real tokens, yellow is padding. Pick a bucket step and drag the batch size.
Illustrative grid: one step size up to 8,192 tokens and 1 to 64 sequences, so the graph count is buckets times 64. The prose example mixes 64 and 256. The post says only "multiples of 64 or 256" and "thousands of graphs."
With 64-token steps to 1,024 and 256-token steps to 8,192, there are 44 buckets, so 44 × 64 = 2,816 graphs. At an illustrative 62 ms of warmup plus 41 ms of capture each, that is 4.8 minutes. The post: "thousands of graphs that might take multiple minutes."
So Perplexity captures lazily. Each configuration walks three states:
The cost, in the post's words: lazy capture "has an impact on p99 latencies during startup," but it spreads "multiple minutes of eager work across multiple hours." A replica joins the fleet in seconds.
The failure: symptom, scale-up lands minutes after the traffic spike. Measure: time from process start to first request served. Fix: capture lazily and accept a worse startup tail.
Chapter 6
Return a handle instead of a value, so the host prepares the next batch while the GPU works
A kernel launch only queues work. To read the result, the host must wait. Three CUDA pieces make the wait cheap:
ROSE's LazyTensor holds three things. A pinned host buffer, a device-to-host copy (cudaMemcpyAsync) queued after the forward pass on the same stream, and an event after the copy. The stream runs in order. So the event fires only when the pass has finished and the bytes have landed. One event covers both.
pythonclass LazyTensor: def __init__(self, src): # src: [batch, dim] on the GPU self.host = torch.empty_like(src, device="cpu", pin_memory=True) self.host.copy_(src, non_blocking=True) # queued behind the forward pass self.event = torch.cuda.Event(); self.event.record() def ready(self): return self.event.query() # never blocks def synchronize(self): # the only call that blocks self.event.synchronize(); return self.host
Now step() returns a LazyTensor and does not wait. The host builds the next batch while the GPU runs this one. Call the host time to prepare a batch p and the device time g. Call the time to collect a result k, and the number of batches N. A loop that waits on every step takes N(p + g + k).
T-ov equals p, plus N times g, plus k.
The GPU runs the N batches back to back, N times g. The host work hides under that, except the first prepare p and the last collect k.
With made-up numbers p = 3, g = 8, k = 1.5 ms and N = 6, waiting each step takes 6 × 12.5 = 75 ms. Overlap takes 3 + 48 + 1.5 = 52.5 ms, near the 48 ms floor.
Top lane: GPU passes. Bottom lane: host prepare and collect. Switch to blocking and watch the idle gaps open.
Illustrative times, collect fixed at 1.5 ms, six batches, one stream. When p plus k exceeds g, the host becomes the floor.
The failure: symptom, the host thread sits inside a stream synchronize for a third of the run. Measure: search the request path for .item() and .cpu() calls. Fix: return a handle and synchronize once, when you need the value.
Chapter 7
Find the three things that change when an LLM engine serves an embedding model
The post: "pplx-embed serving and Qwen3.5 LLM decoding all go through the same kernels." Dense layers need no change, because each token vector passes through them alone. Every weight sits in such a per-token layer. Only attention's score-and-mix step looks across tokens, so that is where the differences hide.
Why ragged? Real traffic mixes a title, a paragraph and a page. A padded batch stretches every sequence to the longest one. Call the number of sequences n, the length of sequence i ℓi, and the longest length ℓmax.
w equals one minus, the sum over i of ell-i, over n times ell-max.
The rectangle holds n times ell-max cells. The real tokens fill the sum of the ell-i. One minus their ratio is the filler.
With a made-up batch of 12 sequences from 39 to 484 tokens: the lengths sum to 3,677. The rectangle is 12 × 484 = 5,808. So w = 1 − 3,677 / 5,808 = 36.7 percent.
Top: the padded rectangle, yellow is filler. Bottom: the ragged strip with its offsets. Widen the length spread or deal a new batch.
Random illustrative batches of 9 sequences up to 512 tokens. The offsets list is the cu_seqlens layout that ragged attention kernels read.
The ragged layout keeps one offsets array, by convention cu_seqlens. Sequence i lives in rows cu[i] to cu[i+1], and the kernel never looks outside them. The KV saving is a second win. A made-up LLM with 24 layers and 8 key-value heads of size 128, in BF16, would hold 361 MB for those 3,677 tokens. The embedding pass holds none.
The failure: symptom, a model wins in evaluation and regresses in production. Measure: check whether the research server pads batches and production does not. Fix: evaluate on the production engine, which this sharing allows.
Chapter 8
Split large requests on a token budget so no replica holds the whole job
One caller sends a 9-token query. Another sends 100 documents of 512 tokens. A third sends 8 documents of 4,096. Time follows tokens, so the work differs by four orders of magnitude. The post: "routing individual requests to individual replicas can cause load imbalance."
Round robin balances the count of requests. Requests are not what costs. A short request that lands behind a large one waits for all of it. That is head-of-line blocking, and it hits p99, not p50, because only the unlucky see it.
Ivy's fix: it "splits large-batch requests into chunks and load-balances them between replicas." Two details make it work. Chunks are cut on a token budget, because tokens are the price. Each chunk goes to the least loaded replica.
Bars are token load per replica; the dashed line is a perfect split. Switch the routing and change the chunk budget.
Illustrative traffic: six requests, 136,064 tokens, on four replicas. The post gives the method, not a budget value.
Whole requests leave one replica with 83,968 tokens and another with 192. Chunks of at most 2,048 tokens bring the worst replica to 34,816, against a perfect 34,016. The slowest caller finishes 2.41 times sooner.
| Chunk budget | Balance | Overhead | GPU efficiency |
|---|---|---|---|
| Under 512 tokens | Very good | Many messages and schedules | Poor: under saturation |
| 1,000 to 4,000 tokens | Good | Small | Good |
| No chunking | Poor | None | Good on one replica, others idle |
Ivy also tokenizes, so the tokenizer is on the critical path of a 1.53 ms request. The post says its in-house unigram tokenizer "drastically improves latencies over off-the-shelf tokenizers."
The failure: symptom, p50 is healthy and p99 is four times worse under load. Measure: per-replica queue depth; one line stays high. Fix: chunk on tokens and route to the least loaded replica. More replicas do not cut size variance.
Chapter 9
Read a chart where two top attention kernels trade wins by a few percent
ROSE "integrated FlashInfer 2, FlashInfer 3 and FlashAttention 4 kernels to implement ragged attention." The post compares two of them across batch sizes and lengths. Its chart labels them FA4 and FA3. The text says FlashInfer 3 beats FlashAttention 4 on Qwen-based models at the longest lengths. The chart's FA3 wins sit there, so we read FA3 as FlashInfer 3.
| Model | Attention | Head size | FA3 wins |
|---|---|---|---|
| BGE-M3 | Multi-head: each query head has its own key and value head | 64 | 7 of 25 cells, at short lengths and large batches |
| pplx-embed-4b | Grouped-query: several query heads share one key and value head | 128 | 8 of 25 cells, every batch at 8,192 |
Rows are batch size, columns are length. Blue cells are FA4 wins, green cells FA3. Tap a cell; switch models.
Every cell is the post's chart: winner, margin over the slower kernel, and throughput in thousands of tokens per second. The chart gives ties within 0.1 percent to FA4.
The largest margin anywhere is 3.37 percent. On pplx-embed-4b, 12 of 25 cells differ by less than half a percent. That is what "converged" looks like up close. The host-side fixes of Chapters 4 to 8 bought up to three times.
The post's rule: "we maintain support for multiple configurations and make a case-by-case decision when serving." Head count and head size change the tiles a kernel wants.
The failure: symptom, a team spends a quarter on kernel tuning and p50 moves 2 percent. Measure: share of request time spent inside attention kernels. Fix: fix host cost first; keep several backends only if your traffic sits in cells one of them wins.
Chapter 10
Look hardest at the cells where the faster engine does not win
The setup: vLLM v0.22.0 as the baseline, BF16, real weights, inputs from evaluation datasets, one H200. Before timing, warmup runs checked that the two engines' embeddings differ by under 0.1 percent in cosine similarity. That check stops a benchmark from winning by computing something else. Copy it first.
Blue is Tulip, purple is vLLM. Pick a benchmark and a model. A red ring marks a tie or a loss.
Medians (p50) from the post's charts, 10,000 requests each for latency. Embed: batch 1, sequential. Scoring: length 512. Throughput: batches of 100, four concurrent senders, embeddings per second.
The trend is one story. On BGE-M3 the median win is 3.0 times at 128 tokens, 2.3 at 512 and 1.22 at 4,096. On pplx-embed-1-0.6b at 4,096 tokens it is 1.05 times, and Tulip's p99 (16.32 ms) sits above vLLM's median (16.15 ms).
Throughput goes the same way. BGE-M3 gains 1.12, 1.11 and 1.08 times. On pplx-embed-1-0.6b, 1,024 tokens is a tie (422.8 against 423.3) and vLLM wins at 4,096 (73.5 against 72.2). A batch of 100 sequences of 4,096 tokens leaves no host cost to remove.
A tighter tail is a separate win. Scoring at batch 5 on pplx-embed-1-0.6b: vLLM's p99 is 24.24 ms against a median of 13.93. Tulip's p99 of 10.21 is 7 percent above its median of 9.51.
What the speedup is worth, at an illustrative $3 per GPU-hour: one million BGE-M3 embeddings of 512 tokens take 667 s on Tulip (1,499.3 a second), about $0.56, and 745 s on vLLM, about $0.62. Bulk work saves 10 percent. Short queries gain far more in latency.
The fourth chart adds Ivy's tokenization and the network hop, so it is the only end-to-end figure. It is a line chart without labels. At one request and 512 tokens, BGE-M3 reads about 3 ms for Tulip and about 12.5 ms for vLLM.
The failure: symptom, a team adopts a "3 times faster" engine and its bulk jobs speed up 3 percent. Measure: place your traffic on the length and batch grid. Fix: expect the win of your own cells, not the headline.
Chapter 11
Keep the numbers, the diagnostic, the code and the sources in one place
The GPU side has converged, so the win moved to the host. Short requests are memory-bound and launch-bound. CUDA graphs cut the launches, lazy capture cuts startup, LazyTensor hides the host under the GPU, ragged batches cut padding, and Ivy cuts imbalance. The gains shrink to nothing where the GPU is the bottleneck.
| Term | Meaning | This lesson's number |
|---|---|---|
| Arithmetic intensity I | 2Td² / (2d² + 4Td) | 1.0 at T = 1; 256 at T = 512 |
| H200 balance B | dense BF16 FLOPS / bandwidth | 989.5 T / 4.8 T = 206 |
| Crossover T* | Bd / (d − 2B) | 345 tokens |
| Attention share | L / (6d) | 8% at L = 512 |
| Fixed cost c | fit to Tulip p50s | 1.377 ms of 1.53 |
| Inflection Tinf | Nℓ / τ | 1,000 tokens (toy) |
| Bucket waste w | (P − n) / P | 32% at n = 130 |
| Overlap Tov | p + Ng + k | 52.5 ms vs 75 (toy) |
| Ragged saving | 1 − Σℓi / (nℓmax) | 36.7% (toy) |
| Best published win | BGE-M3, 128 tokens, p50 | 4.60 / 1.53 = 3.0× |
pythonimport numpy as np d, B = 1024, 989.5e12 / 4.8e12 # BGE-M3 width; H200 balance, 206 I = lambda T: 2*T*d*d / (2*d*d + 4*T*d) # Chapter 1 print(I(1), I(512), B*d / (d - 2*B)) # 1.0 256.0 345 L = np.array([128., 512, 4096]); t = np.array([1.53, 2.03, 9.57]) c, a, b = np.linalg.solve(np.stack([np.ones(3), L, L**2], 1), t) print(c, a, b) # 1.377 ms, 0.001173, 2.02e-07 (Chapter 3) N, ell, tau = 144, 5.0, 0.72 # toy kernel count and costs (us) print(N * ell / tau) # 1000 tokens (Chapter 4) pad = lambda n, step: -(-n // step) * step print(1 - 130 / pad(130, 64)) # 0.323 (Chapter 5)
Now press Present or Teach. Explain from memory why a short query is memory-bound, where c comes from, and why one event covers both the pass and the copy. Then go back to the race, pick 4,096 tokens, and predict the gap before you press Send.