Skip to main content

Command Palette

Search for a command to run...

LLM Inference Explained: Runtime, Infrastructure, and Tooling

Updated
10 min readView as Markdown
G
Hi, I’m Gopal Gautam, a DevOps Engineer working with AWS, Kubernetes, Docker, Terraform, and CI/CD. I’m also exploring MLOps, Generative AI, and AI Infrastructure.

When we hear about Generative AI, we often hear about model training, GPUs, LLMs, RAG, agents, and AI applications.

But there is another important part that is becoming increasingly important as AI applications move into production:

Inference.

As someone coming from a DevOps background and learning more about MLOps and AI infrastructure, I found inference interesting because it connects machine learning with many concepts we already know from cloud and DevOps: compute, Kubernetes, scaling, monitoring, networking, cost optimization, and reliability.

In this article, let's understand LLM inference from a beginner's perspective.


What is Inference?

In simple terms:

Training teaches the model. Inference uses the trained model.

During training, a model learns patterns from huge amounts of data and its weights are updated.

During inference, we take those trained model weights and use them to generate an output for a new request.

For example:

User
  ↓
"What is Kubernetes?"
  ↓
LLM
  ↓
Generated response

The process of generating that response is inference.


Training vs Inference

It is useful to understand the difference.

Training

Large Dataset
     ↓
GPU Cluster
     ↓
Training
     ↓
Model Weights
     ↓
Trained Model

The goal is to teach the model.

Training can require a huge amount of compute, storage, GPUs, and time.

Inference

User Request
     ↓
Inference Server
     ↓
GPU
     ↓
Trained Model
     ↓
Generated Response

The goal is to serve the model to users.

And this is where things become interesting.


Why is LLM Inference Difficult?

For a traditional machine learning model such as an XGBoost model, inference can be relatively simple.

For example:

Input Data
    ↓
XGBoost Model
    ↓
Prediction

The model might run comfortably on a CPU.

But modern LLMs can contain billions of parameters and require significant GPU memory and compute.

And there is another important difference.

An LLM doesn't simply calculate one answer and return it.

It generates the response token by token.

For example:

Kubernetes
      ↓
is
      ↓
a
      ↓
container
      ↓
orchestration
      ↓
platform

Now imagine thousands of users doing this at the same time.

The problem becomes much bigger:

1 request
    ↓
Easy

1,000 requests
    ↓
Need efficient GPU utilization

100,000 requests
    ↓
Need serious inference infrastructure

So simply taking a model, putting it on a GPU, and exposing an API isn't enough for large-scale production.

We need to optimize the entire inference system.


The Three Layers of Production Inference

A useful way to understand production inference is through three layers:

             LLM INFERENCE
                   │
        ┌──────────┼──────────┐
        ↓          ↓          ↓
     Runtime  Infrastructure Tooling

Let's understand each one.


1. Runtime

Runtime is about:

How efficiently can we run a model on a GPU?

Suppose we have:

Qwen / Llama
     ↓
GPU
     ↓
Inference

We want the GPU to be used as efficiently as possible.

This is where techniques such as:

  • Batching

  • KV Cache

  • Quantization

  • Speculative Decoding

  • Efficient attention

  • GPU memory optimization

become important.


Batching

Imagine four users send requests at almost the same time.

Without efficient batching:

Request A → GPU
Request B → GPU
Request C → GPU
Request D → GPU

The inference engine may process requests less efficiently.

With batching, multiple requests can be processed together:

             ┌─ Request A
             ├─ Request B
GPU  ←───────┼─ Request C
             └─ Request D

Modern inference engines can dynamically combine requests and process them efficiently.

This improves GPU utilization and throughput.


KV Cache

LLMs use an attention mechanism while processing tokens.

During inference, the model generates tokens sequentially.

Some intermediate information from previous tokens can be stored in a KV cache.

Instead of repeatedly calculating the same information, the model can reuse cached information.

Conceptually:

First request
     ↓
Calculate
     ↓
KV Cache
     ↓
Reuse cached information
     ↓
Faster processing

This becomes especially important when handling long prompts and multiple requests.


Quantization

Large models require a lot of GPU memory.

Quantization reduces the precision used to represent model weights.

For example:

FP16
  ↓
INT8
  ↓
INT4

The exact memory savings depend on the model and implementation, but the general idea is:

Use fewer bits to represent the model so that it requires less memory.

This can allow a model to run on smaller or fewer GPUs.

The trade-off is that aggressive quantization can affect model quality.

So there is always a balance:

Memory ↓
Cost ↓
Potential speed ↑

vs.

Model quality may ↓

Speculative Decoding

This is another technique for improving generation speed.

Instead of asking the large model to generate every token one by one, a smaller model can first guess several tokens.

The larger model then validates those guesses.

Conceptually:

Small Model
     ↓
Generate several draft tokens
     ↓
Large Model
     ↓
Validate
     ↓
Accept valid tokens

If many guesses are correct, the large model can generate multiple tokens more efficiently.

The result can be lower inference latency.


2. Infrastructure

Runtime optimization is only one part of the problem.

Now imagine your application becomes popular.

You have:

1 GPU

But suddenly:

10,000 users

Now you need infrastructure that can scale.

A simplified architecture could look like:

                    Users
                      ↓
                Load Balancer
                      ↓
             Inference Service
                      ↓
        ┌─────────────┼─────────────┐
        ↓             ↓             ↓
      GPU 1         GPU 2         GPU 3
        ↓             ↓             ↓
      Model         Model         Model

Infrastructure is responsible for things such as:

  • GPU provisioning

  • Kubernetes

  • Autoscaling

  • Load balancing

  • Networking

  • Multi-GPU deployments

  • Multi-node deployments

  • Health checks

  • High availability

  • Monitoring

  • Cost management

This is where traditional DevOps knowledge becomes extremely useful.


Multi-GPU and Parallelism

Some models are too large to fit on a single GPU.

For example:

Large Model
     ↓
 ┌───┼───┐
 ↓   ↓   ↓
GPU1 GPU2 GPU3

The model can be distributed across multiple GPUs using different parallelism techniques.

The goal is to make multiple GPUs work together efficiently.

However, more GPUs also introduce challenges such as:

  • GPU-to-GPU communication

  • Network bandwidth

  • Synchronization

  • Increased cost

So simply adding GPUs does not automatically mean inference becomes faster.

The system has to use them efficiently.


Disaggregated Inference

LLM inference can be broadly divided into two important phases:

User Prompt
     ↓
  PREFILL
     ↓
   DECODE
     ↓
Generated Response

Prefill

The model processes the input prompt.

Think:

Reading and understanding the user's request.

Decode

The model generates the response token by token.

Think:

Writing the answer.

These two phases have different compute characteristics.

Instead of putting both on the same workers, modern inference architectures can separate them:

             User Requests
                   ↓
          ┌────────┴────────┐
          ↓                 ↓
   Prefill Workers     Decode Workers
          ↓                 ↓
        GPUs              GPUs

Now each side can scale independently.

For example, if decode workload increases:

Prefill GPUs: 10
Decode GPUs: 20

we could scale the decode side without scaling the prefill side equally.

This architecture is more complex, but can become useful at large scale.


3. Tooling

The third layer is tooling.

Imagine an ML engineer wants to deploy a model.

Without a good platform, they might need to understand:

Docker
CUDA
GPU types
Kubernetes
Helm
Networking
Autoscaling
Monitoring
Secrets
Load balancing
Model configuration

That's a lot of infrastructure knowledge.

Good tooling provides a higher-level interface.

For example:

Deploy Model

Model: Qwen
GPU: H100
Replicas: 3
Quantization: INT8

              ↓

            Deploy

Behind the scenes, the platform can handle:

Kubernetes
GPU scheduling
Networking
Autoscaling
Monitoring
Model serving

The goal is to give engineers the right balance between:

Control + Productivity

They shouldn't have to manually manage every infrastructure detail just to deploy a model.


How Everything Fits Together

Now we can connect the three layers.

                         USERS
                           ↓
                     API / Gateway
                           ↓
                  Inference Platform
                           ↓
        ┌──────────────────┼──────────────────┐
        ↓                  ↓                  ↓
     RUNTIME         INFRASTRUCTURE         TOOLING
        │                  │                  │
     vLLM               Kubernetes          APIs
     Batching           GPU Nodes            CLI
     KV Cache           Autoscaling          Dashboard
     Quantization       Load Balancing       Deployment
     CUDA               Multi-GPU            Monitoring
        │                  │                  │
        └──────────────────┼──────────────────┘
                           ↓
                       LLM Model
                           ↓
                     Generated Output

These three layers need to work together.

A highly optimized runtime isn't enough if the infrastructure can't scale.

A powerful infrastructure platform isn't enough if the model runtime is inefficient.

And even a technically excellent system isn't enough if engineers can't use it easily.


Where Does MLOps Fit?

This is where things get interesting for DevOps engineers.

Traditional DevOps already deals with:

Infrastructure
CI/CD
Containers
Kubernetes
Networking
Monitoring
Scaling
Security
Cost
Reliability

MLOps adds additional concerns:

Models
Model versions
Datasets
Model deployment
GPU infrastructure
Inference
Model monitoring
Experiment tracking
Feature/data pipelines

And GenAI adds another layer:

LLMs
Embeddings
RAG
Vector databases
Token usage
Inference optimization
AI agents
LLM observability

So the overlap looks something like:

              DevOps
                │
                ↓
              MLOps
                │
                ↓
        GenAI Infrastructure
                │
       ┌────────┼────────┐
       ↓        ↓        ↓
      GPU      LLM     Inference
   Platform   Serving  Optimization

A Practical GenAI Infrastructure Stack

A production system could look like this:

Developer
    ↓
GitHub
    ↓
CI/CD
    ↓
Docker
    ↓
Container Registry
    ↓
Kubernetes / EKS
    ↓
GPU Nodes
    ↓
Inference Runtime
    ↓
vLLM
    ↓
Qwen / Llama
    ↓
API
    ↓
Users

And around it:

Terraform
Helm
Prometheus
Grafana
OpenTelemetry
CloudWatch
Autoscaling
Security
Cost Optimization

MLOps / GenAI InfThis is where AI Platform Engineering / rastructure starts to overlap heavily with DevOps.


What Should a Beginner Learn First?

If you're starting with GenAI infrastructure, don't try to learn everything at once.

I would recommend:

Step 1 — GenAI basics

LLM
Tokens
Parameters
Model weights
Context window
Training
Inference

Step 2 — GPU basics

GPU
VRAM
CUDA
GPU utilization
GPU memory

Step 3 — Model serving

vLLM
Triton
Model APIs
OpenAI-compatible APIs

Step 4 — Inference optimization

Batching
KV Cache
Quantization
Speculative Decoding
Prefill
Decode

Step 5 — Infrastructure

Kubernetes
GPU nodes
Autoscaling
Multi-GPU
Load balancing
Observability
Cost optimization

Step 6 — GenAI applications

Embeddings
RAG
Vector databases
Agents
Tool calling
MCP

Final Takeaway

The easiest way to remember all of this is:

Training teaches the model. Inference serves the model.

And production inference has three major areas:

Runtime
   ↓
Make one model run efficiently

Infrastructure
   ↓
Scale that model reliably

Tooling
   ↓
Make it easy for engineers to deploy and manage

The optimization techniques we discussed earlier fit mainly into these areas:

Batching              → Runtime
KV Cache              → Runtime
Quantization          → Runtime
Speculative Decoding  → Runtime
Parallelism           → Runtime + Infrastructure
Disaggregation        → Runtime + Infrastructure
Autoscaling           → Infrastructure
Kubernetes            → Infrastructure
Deployment Platform   → Tooling

For someone coming from a DevOps background, this is an interesting area because GenAI infrastructure doesn't replace DevOps — it extends it into GPU, model serving, inference, and AI-specific workloads.

The goal isn't only to make an AI model work.

The real challenge is:

How do we make it fast, reliable, scalable, observable, secure, and cost-efficient in production?

That's where MLOps and AI infrastructure engineering become important.


Conclusion

Generative AI is moving from experimentation to production.

As that happens, inference becomes just as important as the model itself.

The future isn't only about building bigger models.

It's also about building better systems around those models.

And that's where skills in cloud, Kubernetes, GPUs, automation, observability, scaling, and cost optimization become extremely valuable.