Zero Labs
Industry News / AI

The vLLM Optimization Playbook for L40S (Backed by 83 Experiments)

Source · Towards AI By Vedanti

From the publisher’s feed, collected in the ZeroLabs newsroom.

I spent the last two weeks measuring vLLM’s optimizations myself on an NVIDIA L40S, running Llama 3.1 8B Instruct across 83 configurations and 4 production style workloads. The result is vllm-optimization-bench, an open source benchmark harness that produces real numbers on how vLLM optimizations behave in practice.Most vLLM benchmarks you find online are on H100 or A100, focus on throughput, and skip energy entirely. This one runs on the L40S (a very common serving GPU that gets almost no published data), measures tokens per joule as a first class metric, and includes a quality gate so the FP8 speed wins are not hiding silent degradation. I am here to layout everything I learnt while doing this :)What I built (briefly)The tool runs a batch of experiments one after the other. Each experiment does the same thing: spin up a vLLM server with one specific configuration, hit it with realistic traffic using vLLM’s built in benchmark client, measure everything I care about, tear it down, move to the next configuration.For every run I capture the usual metrics (TTFT, TPOT, throughput) plus GPU telemetry from DCGM which includes power draw, GPU utilization, clock speeds, throttle warnings. All pinned to my specific GPU so shared cluster neighbors do not contaminate the measurements.The experimental design is simple: start from a baseline configuration, then change one thing at a time (precision, speculative decoding, batching, etc). That way I can attribute any change in the numbers to the one knob I turned. I also added a few interaction experiments where two knobs change together, and the energy measurements are repeated 5 times each so I can report a real median instead of trusting a single number.I tested this across four workloads:Chat: short prompts, short outputs. Your typical assistant conversation.Long prompt: long input, short output. Think RAG or document Q&A.Long decode: short input, long output. Code generation, essay writing.Saturation: offline batch inference at maximum throughput.Each workload stresses different parts of the system, which is where the interesting differences show up.The whole thing ran on the Carnegie Mellon University Babel shared cluster on an L40S with driver 575.51.03, CUDA 12.9, vLLM 0.24.0 cu129 wheel variant. Every FP8 variant was quality checked with a perplexity gate before I trusted any speed number from it.Enough about the setup, here is what I inferred from the data that I collected.Finding 1: Continuous batching is the biggest lever by a huge marginI ran the chat workload at concurrency 1, then again at 256. Throughput went from 47 tokens per second to 3415. That is a 73x jump from turning just one knob. Energy efficiency told the same story: tokens per joule went from about 0.14 at concurrency 1 to 14.5 at concurrency 256. Basically with continuous batching, the GPU stopped burning power on nothing.And this matters because when you look at the other optimizations, nothing else is even in the same league. FP8 gets you 50%. Speculative decoding gets you up to 76% on the right workload. Batching gets you 73x. So honestly, if your inference system is not running at high concurrency, no other optimization is going to get you close on this hardware.Finding 2: FP8 is a legitimate free lunch on L40SFP8 quantization shrinks every weight from 16 bits to 8 bits, so the model takes half the memory and should, in theory, run faster with barely any quality loss. That’s the claim in most papers. I wanted actual numbers instead of taking that on faith.At concurrency 16, chat throughput goes from 633 tokens per second on bf16 to somewhere between 949 and 971 on FP8. That’s a 50 to 53% jump, and it’s not a fluke: saturation shows the same pattern, 666 on bf16 up to 1011 to 1025 on FP8.Higher throughput on its own doesn’t tell you if you’re actually being efficient though, so I checked tokens per joule too. On saturation it goes from 2.17 to 3.98. That’s 83% more tokens generated per unit of energy, using the exact same GPU.Here’s the part that made me double check the numbers: FP8 doesn’t trade latency for throughput, it improves both at once. Chat decode latency (TPOT) drops from 23 ms to about 15. Long_decode drops from 25 to 16 or 18. Usually you get one or the other. Here you get both.So the speed and efficiency gains are real. But none of that matters if FP8 is quietly making the model worse to get there. That’s the actual risk with quantization, so I checked it directly.I ran perplexity on 40 held out prompts, bf16 against each FP8 variant. I used 5% as the cutoff, a common threshold in quantization literature for ‘no meaningful degradation.’ It’s not a hard scientific line, just a reasonable bar to hold the speed claims to. Anything above 5% and I’d throw out the speed numbers as untrustworthy.bf16: 7.95 (baseline)fp8-dynamic: 8.22 (+3.4%)fp8-static: 8.26 (+3.9%)fp8-kv: 8.31 (+4.5%)All three landed under the cutoff.So on L40S, with these specific checkpoints, FP8 really is close to a free lunch: less memory, more throughput, better energy efficiency, and quality that holds up.One variant deserves its own callout: fp8-kv. This one quantizes not just the model weights but the KV cache too, and it wins specifically on long_decode, hitting 888 tokens per second versus 826 for fp8-static.Long_decode means short input, long output, so the model spends most of its time generating tokens one at a time. Every token generated adds to the KV cache, so by the time you’ve generated hundreds of tokens the KV cache has grown huge. At that point the KV cache itself becomes the bottleneck sitting in GPU memory, competing for the same bandwidth everything else needs.Quantizing the KV cache to FP8 cuts its size in half. Smaller cache means less memory traffic per step, which means faster decoding. That’s exactly the bottleneck long_decode is hitting, so it’s exactly the workload where fp8-kv has room to help the most. On a workload with short outputs, like chat, the KV cache never gets big enough for this to matter as much, which is consistent with fp8-kv not being the standout variant there.Finding 3: Speculative decoding is workload dependentSpeculative decoding usually gets pitched as a free win, just flip it on and get faster generation. My data says that’s only true some of the time. Here’s throughput at concurrency 16 on bf16, across all four workloads and both draft strategies:Starting with long_decode, because that’s where speculative decoding actually delivers: Ngram takes throughput from 570 to 1004, a 76% jump. EAGLE-3 lands at 855 which is still a solid 50%. Long decode is exactly the setup speculative decoding is built for: a small draft model proposes a few tokens ahead, the big model verifies them in one pass, and you save real time whenever the guesses land.Now looking at chat: Ngram still gives a 26% throughput bump, but tokens per joule actually drops a little, from 2.87 to 2.61. EAGLE-3 does worse: almost no throughput gain and lower energy efficiency than not using speculative decoding at all. Chat prompts are short and outputs are short, so there’s just less room for a draft model to get ahead before the real generation catches up.Saturation is the clearest warning sign. Here, EAGLE-3 actively hurts throughput, 623 tokens per second versus 666 without it. Saturation is offline batch inference at maximum load, meaning the GPU is already busy doing useful work for many requests at once. Speculative decoding adds verification overhead on top of that, and when the GPU has no idle capacity to hide that overhead in, it just becomes a tax.All of this matches the theory, which is reassuring. Speculative decoding wins when a draft model can guess several tokens ahead cheaply and the target model can verify them cheaply too. That is a decode heavy story. It loses when compute is already saturated, because there’s no slack left to exploit, or when prefill dominates, because there aren’t enough decode steps for the draft model to get ahead in the first place.Practically, that means: if you’re running a chat product where decode time dominates the request, which is most user facing chat, speculative decoding is worth turning on. If you’re running offline batch inference for maximum throughput, it might be quietly working against you.One more thing that I feel is worth flagging: EAGLE-3 combined with long_prompt is missing from the table, marked pruned rather than measured. That combination crashes the vLLM engine on this version, so there are no real numbers to report.Finding 4: Long prompts do not scale with batchingThe concurrency scaling story from Finding 1 has one exception, and it matters.Long_prompt (4k to 8k input tokens, short output) barely moves during the experiments. Throughput goes from about 47 at concurrency 1 to only 250 at concurrency 256. That’s roughly 5x. Compare that to 73x for chat and 91x for saturation, and something is clearly different about this workload.This is because Long_prompt spends almost all its time in prefill, and prefill is compute bound, not memory bound (I went deep on this in my prefill/decode disaggregation post). Continuous batching gets its speedup by interleaving requests during the decode phase, letting one request use the GPU while another is waiting. But long_prompt barely has a decode phase. There’s nothing to interleave, so batching runs out of things to do.Practically, this means if your workload is prefill heavy, long context RAG, document Q&A, code review, cranking up concurrency will not save you. That lever is already maxed out for this kind of traffic. What actually helps here is chunked prefill, prefix caching, or disaggregation, since those attack the prefill bottleneck directly instead of trying to batch around it.The energy efficiency frontierOne question I wanted to answer: does energy efficiency track throughput, or are they separate dials?Across all 83 cells, tokens per joule tracks throughput almost linearly. You can’t get one without the other. Whatever makes your GPU busier per unit time is the same thing that makes it more efficient per joule.The highest points on that frontier are all bf16 at high concurrency, not FP8. That’s not because FP8 is worse, it’s because the concurrency sweep went all the way to 256 while the FP8 sweep didn’t push that far. Reading the two trends together, the story is: batching is what moves you along the frontier, and precision gives you a smaller boost upward at whatever concurrency you’re already at.So if you’re picking where to spend your effort, batching is the primary lever. Precision is a secondary one, worth doing, but it won’t get you nearly as far on its own.TakeawayThe biggest takeaway surprised me. I expected optimizations like FP8 or speculative decoding to matter the most, but they weren’t the dominant factor. On this L40S, nothing else came close to Continuous batching, not even in the same order of magnitude. If you’re only going to optimize one thing for serving throughput, make it batching.The second biggest win was FP8. On this hardware it consistently improved throughput and energy efficiency while staying comfortably within the 5% perplexity quality gate. That means it wasn’t just a speed optimization. At least for Llama 3.1 8B on an L40S, it improved performance without a meaningful quality penalty.Speculative decoding was much more workload dependent. It paid off when decoding dominated the request, like chat or code generation, because there was enough decode work to amortize the speculative overhead. On long prompt workloads like RAG or document QA, where prefill dominates, it provided little benefit on this setup. That’s where disaggregating prefill and decode looks like the more promising optimization.One pattern that also became obvious is that energy efficiency wasn’t really an independent optimization target. Almost every time throughput increased, tokens per joule increased as well. Keeping the GPU busier meant getting more useful work out of every watt.Of course, these results come with important caveats. Everything in this post comes from one model (Llama 3.1 8B Instruct) running on one GPU (an NVIDIA L40S). Different GPUs, larger models, or different serving workloads could change the tradeoffs completely. These aren’t universal rules. They’re measurements from one carefully controlled experimental setup.If you’ve followed this blog series from the beginning, this is where all the pieces finally come together. Continuous batching, FP8 quantization, speculative decoding, KV cache optimizations, and prefill decode disaggregation all moved from theory into measured results on real hardware. Some ideas delivered exactly as expected. Others were more nuanced. The only reliable way to know which optimization is worth your engineering effort is to measure it. The repo where I tried this is public (https://github.com/vedanti02/vllm-optimization-bench), leave a star if you like it!The vLLM Optimization Playbook for L40S (Backed by 83 Experiments) was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.