Skip to content
tezvyn:
Menu

Three ways to cut LLM inference cost

Source: interviewMediumHow cards are made

Summary

LLM inference cost reduction.

Key points

quantization to shrink the model, continuous batching with paged attention to raise GPU utilization, and distillation or smaller routed models for easy queries.

What's really being asked

Whether you know real LLM serving optimizations at the model and infrastructure level, not just hardware swaps.

Technique one quantization

Quantize model weights and activations from sixteen-bit to int8 or int4. This shrinks memory footprint, lets the model fit on smaller or fewer GPUs, and speeds memory-bound inference, usually with small accuracy loss when done with calibration. Lower precision directly lowers cost per token.

TECHNIQUE TWO CONTINUOUS BATCHING WITH PAGED ATTENTION LLM serving is dominated by GPU underutilization when requests are processed one at a time. Continuous, or in-flight, batching interleaves many concurrent requests at the token level so the GPU stays busy, and paged attention, popularized by vLLM, manages the KV cache in noncontiguous pages to eliminate memory fragmentation and fit more concurrent sequences. Together they sharply raise throughput per GPU, lowering cost per request.

Technique three compression or routing

Distill the large model into a smaller student for the common case, or use a router that sends easy queries to a small cheap model and reserves the large model for hard ones. Speculative decoding, where a small draft model proposes tokens the big model verifies, similarly cuts cost while preserving quality. Caching repeated prompts and prefixes avoids recompute.

The mistakes people make

Only suggesting a cheaper GPU, generic horizontal autoscaling without raising per-GPU efficiency, or claiming quantization is free with no quality consideration.

What usually comes next

How much quality quantization costs, how paged attention reduces KV-cache waste, and when distillation is worth the effort.

A concrete example

Serving on vLLM with int4 weights and continuous batching lifts a single GPU from a handful of concurrent requests to dozens, and routing short factual queries to a distilled small model means the expensive large model only runs for genuinely hard prompts, cutting average cost per inference substantially.

Interview question

Which technique reduces LLM serving cost primarily by raising GPU utilization across concurrent requests?

  • a.Quantizing weights from 16-bit to int4
  • b.Continuous batching with paged attentionCorrect
  • c.Distilling the model into a smaller student
  • d.Adding more replicas behind a load balancer
Why?

Continuous batching with paged attention interleaves many requests and manages the KV cache efficiently, keeping the GPU busy and raising throughput per device. Quantization shrinks the model and distillation makes a smaller model, but neither is about packing concurrent requests onto one GPU.

Just read this? Test yourself on what you have been reading.

Read the original → dev.to

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles