Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 4 1 HPC at Scale

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🍌 Bananas are berries, but strawberries are not.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🐙 Octopuses have three hearts and blue blood.
kubernetes

    AI-AgenticAI

    AI-DeepLearning

    AI-GenAI

    AI-Infrastructure

    AI-Machine-Learning

    AI-Math

    AWS

    Azure

    Hobbies

    kubernetes
    • Kubernetes: Control Loops, Scheduling, and GPUs

    • Image Internals: From OCI Layers to a Running Container

    • Container Internals: What a Container Really Is

    • Kubernetes Pod Internals: What a Pod Really Is

    • Kubernetes API Server Internals

    • etcd Architecture Explained

    • Kubernetes Scheduler Internals

    • Kubernetes Informers & Controllers Explained

    • Kubernetes Networking: Pods, Services, Ingress, and CNI

    • Kubernetes Storage: PV, PVC, StorageClass, and CSI

    • Helm: Kubernetes Package Manager

    • Cloud Native Observability: Prometheus, Grafana, OpenTelemetry, and Tracing

    • Kubernetes Resource Allocation: Requests, Limits, QoS, and Quotas

    • GPU Scheduling in Kubernetes: Device Plugins, GPU Operator & MIG

    • NVIDIA Network Operator: InfiniBand, SR-IOV, RDMA, and Multus

    • Dynamic Resource Allocation: The Future of GPU Scheduling in Kubernetes

    • Kubernetes Performance at Scale

    • Optimizing AI Inference at Scale: The Full Stack

    • Kueue: Kubernetes-Native Job Queuing and Quota Management

    • Multi-Node Distributed Training on Kubernetes

    • Kubernetes Topology Manager: NUMA-Aware GPU Scheduling

    • NVIDIA NIM: Optimized Inference Microservices on Kubernetes

    • GPU Autoscaling on Kubernetes: KEDA, HPA, and Cluster Autoscaler

    • Fine-Tuning LLMs: LoRA, QLoRA, PEFT, and NeMo on Kubernetes

    • Flash Attention: Fast, Memory-Efficient Attention for LLMs

    • Kubernetes and Cloud Native Certification Path

    • kubernetes Index


    Management

    Programming

    Terraform

    Z_Appendix

    0-root

Cover Image for Optimizing AI Inference at Scale: The Full Stack
kubernetes

Optimizing AI Inference at Scale: The Full Stack

There is no single technique to keep GPUs busy. A layer-by-layer map of AI inference optimization — from quantization and inference engines through KV cache, continuous batching, GPU sharing, scheduling, and cache-aware routing up to parallelism, autoscaling, and the networking underneath.

AI Infrastructure
GPU
Inference
LLM
Kubernetes
MLOps
← Previous

Kubernetes Resource Allocation: Requests, Limits, QoS, and Quotas

Next →

Fine-Tuning LLMs: LoRA, QLoRA, PEFT, and NeMo on Kubernetes

Optimizing AI Inference at Scale

Modern AI infrastructure is a stack of optimizations, with each layer solving a different bottleneck.

Think of it like building a Formula 1 car.

A better engine alone won't win the race.

You also need better aerodynamics, suspension, tires, strategy, and pit stops.

Case: OPEN-AI ChatGPT inference

flowchart TD

%% ---------- Clients ----------
    subgraph Clients
        User1["User A"]
        User2["User B"]
        User3["User C"]
        User4["User D"]
    end

    User1 --> LB
    User2 --> LB
    User3 --> LB
    User4 --> LB
    LB["🌍 Global Load Balancer"]
    LB --> Gateway
    Gateway["🚪 API Gateway <br/><br/>Authentication<br/>Rate Limits<br/>Billing"]
    
    Gateway --> Router
    
    Router["🔀 Inference Router <br/><br/>Model Selection <br/>Load Balancing <br/>KV-aware Routing"]
    
    %% ---------- GPT-5 ----------
    Router --> GPT5
    
    subgraph GPT5["GPT-5 Deployment Pool"]
    
    Queue1["Request Queue"]
    
    Queue1 --> Batch1["Continuous Batching"]
    
    Batch1 --> Replica1
    Batch1 --> Replica2
    Batch1 --> Replica3
    
    Replica1["GPU Replica"]
    Replica2["GPU Replica"]
    Replica3["GPU Replica"]
    
    KV1["💾 KV Cache"]
    
    Replica1 --- KV1
    Replica2 --- KV1
    Replica3 --- KV1
    
    Metrics1["📊 Metrics<br/>Latency<br/>GPU Utilization<br/>Tokens/sec"]
    
    end
    
    %% ---------- GPT-4.1 ----------
    Router --> GPT41
    
    subgraph GPT41["GPT-4.1 Deployment Pool"]
    
    Queue2["Request Queue"]
    
    Queue2 --> Batch2["Continuous Batching"]
    
    Batch2 --> GPU4
    Batch2 --> GPU5
    
    GPU4["GPU Replica"]
    GPU5["GPU Replica"]
    
    KV2["💾 KV Cache"]
    
    GPU4 --- KV2
    GPU5 --- KV2
    
    Metrics2["📊 Metrics<br/>Latency<br/>GPU Utilization<br/>Tokens/sec"]
    
    end
    
    %% ---------- o-series ----------
    Router --> OSeries
    
    subgraph OSeries["o-series Reasoning Pool"]
    
    Queue3["Request Queue"]
    
    Queue3 --> Batch3["Continuous Batching"]
    
    Batch3 --> GPU6
    Batch3 --> GPU7
    
    GPU6["GPU Replica"]
    GPU7["GPU Replica"]
    
    KV3["💾 KV Cache"]
    
    GPU6 --- KV3
    GPU7 --- KV3
    
    Metrics3["📊 Metrics<br/>Latency<br/>GPU Utilization<br/>Tokens/sec"]
    
    end
    
    %% ---------- Autoscaling ----------
    Autoscaler["📈 Autoscaler"]
    
    GPT5 <--> Autoscaler
    GPT41 <--> Autoscaler
    OSeries <--> Autoscaler


The key idea is that the model weights are shared, while your context, conversation, and (if enabled) memory are specific to you. This architecture lets providers serve millions of users efficiently without needing a separate GPT model instance for every person.

Component Responsibility
Load Balancer Distributes traffic across regions and services
API Gateway Authentication, rate limiting, and request validation
Inference Router Chooses the appropriate model deployment and replica
Continuous Batching Groups requests to maximize GPU utilization
GPU Cluster Executes inference on shared model replicas
KV Cache Reuses computations within active requests or conversations
Conversation Context Provides personalization without requiring a dedicated model

The same is true for AI infrastructure.

There is no single technique to optimize GPU utilization for AI inference.


The AI Inference Optimization Stack

flowchart TB
    
    A["Model Optimization 🧠 <br/>(Quantization, Pruning, Distillation)"]
    A--> B["Inference Engine ⚡ <br/>(vLLM, TensorRT-LLM, SGLang)"]
    B--> C["KV Cache 💾 <br/>(Prefix Cache, PagedAttention)"]
    C--> D["Continuous Batching 📦 <br/>(Dynamic Request Batching)"]
    D--> E["Distributed Inference 🚀 <br/>(Tensor / Pipeline / Expert Parallelism)"]
    E-->F["GPU Sharing 🧮 <br/>(MIG, Time Slicing, DAS)"]
    F --> G["Job Scheduling 🕘  <br/>(Kubernetes, Slurm, Kueue)"]
    G -->  H["Intelligent Request Routing 🔀 <br/>(KV-aware Routing, Load Balancing)"]
    H --> I["Autoscaling 📈 <br/>(HPA, KEDA, Cluster Autoscaler)"]
    I -->  J["Hardware & Networking 🖥️ <br/>(NVLink, NVSwitch, InfiniBand, RDMA, EFA)"]
   

Each layer contributes to one goal:

Maximize Throughput\textbf{Maximize Throughput}Maximize Throughput

while minimizing

LatencyCostGPU Idle Time\textbf{Latency} \qquad \textbf{Cost} \qquad \textbf{GPU Idle Time}LatencyCostGPU Idle Time

1. Model Optimization 🧠

The cheapest GPU cycle is the one you never have to execute.

Instead of optimizing infrastructure, optimize the model itself.

Techniques include:

1. Quantization

Instead of using 16-bit floating point numbers (FP16), use:

  • INT8
  • FP8
  • INT4

Memory consumption changes from

16-bit→8-bit16\text{-bit} \rightarrow 8\text{-bit}16-bit→8-bit

8/16=50% 8/16 = 50\%8/16=50%

which immediately halves memory usage.

Or even

16-bit→4-bit16\text{-bit} \rightarrow 4\text{-bit}16-bit→4-bit

4/16=25% 4/16 = 25\%4/16=25%

reducing memory requirements by 75%.

Popular tools include:

  • TensorRT-LLM
  • GPTQ
  • AWQ
  • SmoothQuant

2. Smaller Models

Use a smaller model if it meets your accuracy requirements.

Instead of 70B model

run 8B model

or 3B model

Latency and memory drop dramatically.

3. Model Distillation

Train a smaller model that imitates a larger one.

Distilled models require less memory and fewer computing operations per request, delivering faster response times for end users.

flowchart LR
    Teacher[Large Model] <--> Student[Small Model]

4. Structured Pruning

Structured pruning is a neural network compression technique that removes entire groups of parameters—such as neurons, channels, filters, attention heads, or layers—rather than individual weights.

  • arxiv: https://arxiv.org/abs/2305.17180

This produces a smaller, dense sub-network that runs faster on standard hardware without needing specialized sparse libraries


2. Faster Inference Engines ⚡

Even with the same model, different inference engines produce dramatically different performance.

Popular runtimes include:

These optimize:

  • CUDA kernels
  • Memory allocation
  • Continuous batching
  • KV Cache management

Popular Inference Engines Include:

A lot of people think these are competitors, but they're actually focused on different layers of the LLM inference stack. Some overlap, but they solve different problems.

TensorRT-LLM

Nvidia's open-sourced library for optimizing LLM and Visual Gen inference

Goal: Maximize inference speed on NVIDIA GPUs.

Best when

  • Running on NVIDIA GPUs
  • Lowest latency
  • Highest throughput
  • Production inference

Typical users

  • NVIDIA NIM
  • DGX Cloud
  • Enterprise AI

vLLM

Open sources high-throughput and memory-efficient inference and serving engine for Large Language Models (LLMs).

Goal: Serve thousands of concurrent requests efficiently.

vLLM optimizes serving efficiency

it uses virtual-memory-style paging.

Benefits

  • Huge memory savings
  • Larger batch sizes
  • Better GPU utilization

It also introduced

  • Continuous batching
  • Prefix caching
  • OpenAI-compatible API

SGLang

high-performance serving framework for large language models and multimodal models

SGLang goes beyond inference. It is designed for

  • Agents
  • Tool calling
  • Structured outputs
  • Long reasoning chains
  • Multimodal applications

SGLang optimizes this entire workflow.

Features

  • Continuous batching
  • KV cache reuse
  • Structured decoding
  • Multi-turn optimization
  • Agent runtime

Very popular for

  • AI agents
  • Coding assistants
  • Research systems

LMDeploy

toolkit for compressing, deploying, and serving LLM,

LMDeploy focuses on deployment. Popular in the InternLM ecosystem.

DeepSpeed-Inference

deep learning optimization library that makes distributed training and inference easy, efficient, and effective

DeepSpeed originally solved Training Later it added inference.

Its strength is very large distributed models.

Think 500B parameter models running across many GPUs.

Features

  • Tensor Parallelism
  • Pipeline Parallelism
  • Kernel fusion
  • CUDA optimization

Often used in research and large enterprise deployments.

Inference Engine Comparison Analogy

Tool Like... Strength Main Focus
TensorRT-LLM Formula 1 engine Lowest latency Make one model run as fast as possible on NVIDIA GPUs
vLLM Taxi dispatch system Highest throughput Serve thousands of user requests efficiently
SGLang AI workflow engine Best for Agents Serve complex LLM/Agent applications efficiently
LMDeploy Deployment toolkit Best Deployment Experience Compress, optimize, and deploy models
DeepSpeed-Inference Supercomputer runtime Huge Multi-GPU Models Run very large models across many GPUs

Inference Engine Feature Comparison

TensorRT-LLM vs vLLM vs SGLang vs LMDeploy vs DeepSpeed

Feature TensorRT-LLM vLLM SGLang LMDeploy DeepSpeed-Inference
Primary goal GPU optimization High-throughput serving Agent & workflow serving Deployment toolkit Distributed inference
NVIDIA optimized ✅ Excellent ✅ Good ✅ Good ✅ Good ✅ Excellent
Continuous batching Limited ✅ Excellent ✅ Excellent ✅ Yes Partial
Paged KV Cache ❌ ✅ Invented it ✅ Similar ideas ✅ Partial
Quantization ✅ Excellent Limited Limited ✅ Excellent ✅
Tensor Parallelism ✅ ✅ ✅ ✅ ✅ Excellent
Pipeline Parallelism ✅ Limited Limited Limited ✅ Excellent
Multi-node inference ✅ ✅ ✅ Limited ✅ Excellent
Agent workflows ❌ ❌ ✅ Excellent ❌ ❌
OpenAI API Via serving stack ✅ ✅ ✅ Usually via wrappers

3. KV Cache Optimization 💾

The LLM spends time understanding the concept. It stores that understanding inside memory (the KV Cache).

Transformer models spend most of their time processing the prompt.

Conceptually,

Inference=Prefill+DecodeInference = Prefill + DecodeInference=Prefill+Decode

The expensive part is Prefill.

Instead of recomputing previous tokens,

modern systems reuse a KV Cache.

flowchart LR
    Prompt-->Prefill
    Prefill--> KVCache
    KVCache--> Decode

The larger the cache hit rate, the lower the latency.

Techniques include

  • Prefix caching
  • Shared KV cache
  • PagedAttention (vLLM)
  • Cache-aware scheduling (llm-d)

Example

Suppose someone asks:

Explain Kubernetes.

Now another user asks:

Explain Kubernetes scheduling.

Much of the work has already been done.

Instead of recomputing everything, the model reuses its cached information. That saves GPU computation.


4. Continuous Batching 📦

Instead of serving one request at a time, modern inference engines continuously merge incoming requests into a single batch.

Traditional inference serves one request at a time.

flowchart LR
    Request1["Request 1 📁"] --> GPU["GPU 🧮"]
    Request2["Request 2 📁"] --> GPU
    Request3["Request 3 📁"] --> GPU

Modern inference engines continuously merge incoming requests.

flowchart LR
    Request1["Request 1 📁"] --> Batch["Batch 🗃️"]
    Request2["Request 2 📁"] --> Batch
    Request3["Request 3 📁"] --> Batch
    Request4["Request 4 📁"] --> Batch
    Batch --> GPU["GPU 🧮"]

The GPU stays busy instead of waiting.

Higher utilization means better throughput.


5. GPU Sharing 🧮

Allow multiple workloads to safely share the same GPU.

Imagine GPU as Bus with 40 seats. Giving entire bus to one user is wasteful.

Similarly, One inference request rarely consumes an entire GPU.

Without sharing, large portions of the GPU remain idle while jobs wait in a queue.

flowchart TD
    GPU["GPU 🧮"] --> Workload1["Workload 1 🏃"]
    Waiting["Waiting ⏳"] --> Workload2["Workload 2 🏃🏻‍♂️‍➡️"]
    Waiting["Waiting ⏳"] --> Workload3["Workload 3 🏃‍♀️‍➡️"]
    Waiting["Waiting ⏳"] --> Workload4["Workload 4 🏃🏼‍♀️"]

We can share the bus with other users.

flowchart TD
    GPU["GPU 🧮"]
    GPU --> Slice1["Slice 1 🧩"] --> Workload1["Workload 1 🏃"]
    GPU --> Slice2["Slice 2 🧩"] --> Workload2["Workload 2 🏃🏻‍♂️‍➡️"]
    GPU --> Slice3["Slice 3 🧩"] --> Workload3["Workload 3 🏃‍♀️‍➡️"]
    GPU --> Slice4["Slice 4 🧩"] --> Workload4["Workload 4 🏃🏼‍♀️"]

Technologies like

  • NVIDIA MIG: Hardware partitioning.
  • Time Slicing: Multiple processes share the GPU.
  • Dynamic Accelerator Slicer (DAS): Automatically creates GPU slices when needed.

Sharing a GPU: MIG vs. time-slicing vs MPS

A whole A100/H100 per Pod is wasteful for small inference jobs. Three ways to share:

MIG (Multi-Instance GPU)

Hardware partitioning, up to 7 isolated instances per A100/H100, each with dedicated memory and compute.

  • Real Isolation: The isolation is real hardware isolation: one instance can't touch another's memory, can't steal its bandwidth, and can't crash it
  • Quantum: You pick from fixed profiles (1g.5gb, 2g.10gb, 3g.20gb, 7g.40gb…), you can't get arbitrary fractions, and reconfiguring means draining the instance.
  • Hardware bound: it only exists on datacenter silicon — A100, A30, H100, H200, Blackwell.

Time-slicing

. The scheduler round-robins: each process gets the whole GPU for a quantum, then context-switches to the next.

  • Virtual Isolation: No memory isolation and no fault isolation
  • Flexible: It runs on any GPU including consumer cards
  • fine for dev or bursty low-priority work, dangerous for anything that needs guarantees.

MPS (Multi-Process Service)

MPS is also spatial like MIG, but soft: multiple processes submit into a shared CUDA context so their kernels run concurrently on the SMs — no round-robin context-switch overhead.

  • "Spatial soft": Isolation is weaker than MIG (memory isn't hard-fenced, fault isolation is limited, though newer CUDA versions improved both)
  • Flexible: It runs on any GPU including consumer cards
  • Useful for many concurrent small inference requests

6. Better Scheduling 🕘

Instead of improving the GPU itself, improve how jobs enter the cluster.

  • Think of it as a traffic controller for GPUs.

Imagine a busy restaurant. There are only eight tables.

Without a receptionist:

  • Everyone rushes inside
  • People compete for tables
  • Some customers wait randomly
flowchart LR
    Customer1["Customer 1 🙍‍♂️"] --> Table1["Table 1 🍽️"]
    Customer2["Customer 2 🙍🏻‍♂️"] --> Table2["Table 2 🍽️"]
    Customer3["Customer 3 👩🏻‍💼"] --> Table1["Table 1 🍽️"]
    Customer4["Customer 4 👭👫"] --> Waiting["Waiting ⏳"]

Similar to having 8 GPUs, 1000 AI Jobs. Many jobs simply sit around waiting. Scheduling becomes unpredictable.

With a receptionist:

flowchart LR
    Receptionist["Receptionist 🧑‍💼"]
    Customer1["Customer 1 🙍‍♂️"] --> Receptionist
    Customer2["Customer 2 🙍🏻‍♂️"] --> Receptionist
    Customer3["Customer 3 👩🏻‍💼"] --> Receptionist
    Customer4["Customer 4 👭👫"] --> Receptionist
    Receptionist --> Queue["Queue ⏳"]
    Queue --> Table1["Table 1 🍽️"]
    Queue --> Table2["Table 2 🍽️"]

This is exactly what Kueue does.

Instead of immediately creating every Kubernetes Job, it decides:

  • Which jobs should wait
  • Which jobs should run first
  • Which jobs are more important

Scheduling answers a completely different question.

Not

How fast should a job run?

Instead,

Which job should run first?

Popular approaches include:

1. Kubernetes Scheduler

default scheduler for Kubernetes and runs as part of the control plane.

Its responsibility is to assign Pods to Nodes based on available resources and scheduling constraints.

Responsibilities

  • Pod placement
  • Resource-aware scheduling
  • Node affinity & anti-affinity
  • Taints & tolerations
  • Topology-aware scheduling
  • GPU allocation via Device Plugins

Best For

  • Microservices
  • Web applications
  • AI inference services
  • General Kubernetes workloads

2. Kueue

It is a job-level manager that decides when a job should be admitted to start (as in pods can be created) and when it

Kueue operates above the Kubernetes Scheduler.

Instead of deciding where Pods run, it decides when a Job is allowed to start.

A Job waits in a queue until sufficient cluster resources are available.

Responsibilities

  • Job admission control
  • Resource quotas
  • Fair sharing
  • Batch queues
  • AI/ML job scheduling

Best For

  • AI training jobs
  • Batch inference
  • HPC jobs on Kubernetes
  • Shared GPU clusters

3. Volcano

Kubernetes-native batch scheduling system, extending and enhancing the capabilities of the standard kube-scheduler.

Volcano extends Kubernetes with advanced scheduling capabilities designed for batch and AI workloads.

Features

  • Gang Scheduling
  • Queue management
  • Fair-share scheduling
  • Priority scheduling
  • GPU scheduling
  • Distributed AI training

Best For

  • Distributed PyTorch
  • TensorFlow
  • MPI jobs
  • HPC workloads
  • Large-scale AI training

4. Apache YuniKorn

light-weight, universal resource scheduler for container orchestrator systems.

Originally inspired by Hadoop YARN scheduling concepts, Apache YuniKorn focuses on efficient resource sharing across multiple teams and applications.

Features

  • Hierarchical queues
  • Fair resource allocation
  • Multi-tenant scheduling
  • Elastic resource sharing

Best For

  • Enterprise Kubernetes
  • Multi-tenant AI platforms
  • Shared GPU infrastructure

5. Slurm

Open-source HPC workload manager.

Slurm is not a Kubernetes scheduler.

It is the de facto scheduler used in supercomputers and High-Performance Computing (HPC) clusters.

It manages compute nodes, GPUs, memory, and networking for large scientific and AI workloads.

Features

  • HPC job scheduling
  • GPU allocation
  • Multi-node jobs
  • MPI support
  • Fair-share scheduling
  • Job priorities
  • Resource reservations

Best For

  • Supercomputers
  • National laboratories
  • Large AI clusters
  • Scientific computing

Job Scheduler Comparison

Scheduler Schedules Primary Use Case Kubernetes Native
Kubernetes Scheduler Pods General workloads ✅
Kueue Jobs Batch & AI job admission ✅
Volcano Pods & Batch Jobs Distributed AI & HPC ✅
Apache YuniKorn Pods & Queues Multi-tenant resource scheduling ✅
Slurm HPC Jobs Supercomputers & AI clusters ❌

7. Intelligent Request Routing 🔀

The problem with random routing is that similar prompts may end up on different servers. Both servers repeat the same expensive work.

Traditional Kubernetes Services distribute requests randomly. That works well for stateless applications.

flowchart LR
    User["User 👤"] --> Pod1["Pod1 🐋"]
    User["User 👤"] --> Pod2["Pod2 🐋"]
    User["User 👤"] --> Pod3["Pod3 🐋"]

LLMs are not stateless. Similar prompts often share the same prefix. Modern inference platforms use cache-aware routing.

Instead of acting like a normal load balancer & asking

Which server is free?

they ask

Which server already knows most of this prompt?

Then send similar requests to the same server whenever possible.

It considers:

  • Current queue length
  • GPU load
  • Cache availability
  • Response time
flowchart LR
    User["User 👤"]
    User--> InferenceGateway["Inference Gateway 🔀"] 
    InferenceGateway-->InferencePool["Inference Pool ⏳"] 
    InferencePool-->BestReplica["Best Replica 🏆"]

This dramatically improves efficiency.

Popular Intelligent Request Routing include:

These projects are often complementary rather than competing.

  • GAIE manages ingress and intelligently selects an inference service.
  • llm-d performs cache-aware routing, scheduling, and distributed inference within that service.

1. LLLM-d

llm-d is a Cloud Native Computing Foundation (CNCF) sandbox project, founded by Red Hat, Google Cloud, IBM Research, CoreWeave, and NVIDIA.

Its goal is to build a Kubernetes-native distributed inference platform for serving Large Language Models efficiently.

Suppose two GPU replicas are available.

Replica A
KV Cache: "Write a blog about Kubernetes..."

Replica B
Empty Cache

If the next request starts with the same prompt,

Write a blog about Kubernetes...

llm-d routes it to Replica A, allowing the existing KV cache to be reused instead of recomputing the entire prompt.

This significantly reduces:

  • Time To First Token (TTFT)
  • GPU compute
  • Memory bandwidth

2. Gateway API Inference Extension (GAIE)

A proxy/load-balancer which has been coupled with an Endpoint Picker.

The Gateway API Inference Extension (GAIE) extends the Kubernetes Gateway API with AI-specific routing capabilities.

Instead of simply forwarding traffic,

it intelligently selects the best inference endpoint. Unlike a traditional load balancer,

the Endpoint Picker considers factors such as:

  • GPU load
  • Queue length
  • KV cache locality
  • Replica health
  • Available capacity

LLM-d vs GAIE

Feature LLM-d Gateway API Inference Extension
Purpose Distributed LLM inference platform AI-aware ingress and routing
CNCF Project ✅ Sandbox Kubernetes SIG Gateway project
Prefix-aware routing ✅ Backend dependent
KV Cache locality ✅ Primary feature Supported through endpoint selection
Load balancing ✅ ✅
Kubernetes-native ✅ ✅
Acts as Gateway ❌ ✅
Distributed inference ✅ ❌ (focuses on routing)

8. Parallelism

Large models often don't fit on one GPU.

Some models simply don't fit on one GPU.

They must be distributed.

flowchart LR
    LLM["Large Model 🔢"]
    LLM --> Layer1["Layer 1 🔣"] --> GPU1["GPU1 🧮"]
    LLM --> Layer2["Layer 2 🔣"] --> GPU2["GPU2 🧮"]
    LLM --> Layer3["Layer 3 🔣"] --> GPU3["GPU3 🧮"]
    LLM --> Layer4["Layer 4 🔣"] --> GPU4["GPU4 🧮"]

Popular approaches include:

  • Tensor Parallelism
  • Pipeline Parallelism
  • Expert Parallelism (MoE)
  • Sequence Parallelism

Libraries:

  • Megatron-LM
  • DeepSpeed
  • TensorRT-LLM

9. Autoscaling ↔️

Horizontally Scale up/down Pods as per demand/matrics

Running 100 GPUs all day is expensive.

Instead,

Morning = 10 GPUs
Noon    = 50 GPUs
Evening = 20 GPUs
Night   = 5 GPUs

Resources scale with demand.

Popular AutoScaler choices include:

1. HPA :: Horizontal Pod Autoscaling

Default Kubernetes AutoScaler

  • Automatically updates a workload resource (such as a Deployment or StatefulSet), with the aim of automatically scaling capacity to match demand

How it Works

Every 15 seconds (by default), HPA:

  1. Reads metrics from the Metrics API.
  2. Compares them against the target value.
  3. Increases or decreases the replica count.

For example,

CPU Target = 70%
Current CPU = 92%

Scale
5 Pods → 8 Pods

Common Metrics

  • CPU Utilization
  • Memory Utilization
  • Prometheus Custom Metrics

Best For

  • REST APIs
  • Web Applications
  • Microservices
  • Traditional Kubernetes workloads

2. KEDA:: K8 Event-driven Autoscaling

Scale based on events instead of resource utilization

  • Allows users to define autoscaling rules using a dedicated Kubernetes custom resource definition.
  • Can scale to Zero when no request and save cloud cost

Scale when:

  • Kafka topic has 10,000 messages
  • RabbitMQ queue grows
  • Azure Service Bus backlog increases
  • AWS SQS queue length exceeds a threshold
  • Prometheus metric crosses a limit

Best For

  • Event-driven applications
  • Background workers
  • Queue consumers
  • Batch processing
  • Asynchronous inference

3. KServe

Request-based autoscaling capabilities optimized for generative workload patterns

  • AI-native autoscaling for model serving

  • Single platform that unifies Generative and Predictive AI inference on Kubernetes

Unlike HPA, KServe understands concepts such as:

  • Request concurrency
  • Queue length
  • Token generation
  • Cold starts
  • GPU-backed inference

Features

  • Request-based autoscaling
  • Scale-to-zero
  • Multi-model serving
  • Canary deployments
  • Serverless inference
  • OpenAI-compatible endpoints (depending on the serving backend)

Best For

  • Large Language Models
  • Vision Models
  • Embedding Models
  • Generative AI platforms
Feature HPA KEDA KServe
Primary Goal Resource-based scaling Event-driven scaling AI inference scaling
Built into Kubernetes ✅ ❌ ❌
Scale Metric CPU, Memory, Custom Metrics External Events Requests, Concurrency, AI Metrics
Scale to Zero ❌ (native HPA) ✅ ✅
Queue Awareness ❌ ✅ ✅
GPU Awareness ❌ ❌ ✅
AI Model Management ❌ ❌ ✅
Typical Workloads Web APIs Workers & Queues LLM & ML Inference

10. Hardware & Networking 🖥️

Distributed inference spends significant time communicating.

Sometimes software isn't the bottleneck.

Hardware matters.

GPU Typical Use
L4 Small inference
L40S Medium inference
A100 Enterprise inference and training
H100 High-performance LLM inference
B200 Next-generation large-scale inference

For distributed inference, networking becomes equally important.

Technologies include:

  • NVLink
  • NVSwitch
  • RDMA
  • GPUDirect RDMA
  • AWS Elastic Fabric Adapter (EFA)

There is a whole section about this hardware technologies in AI-Infrastructure posts


The Bigger Picture

AI infrastructure is evolving in the same way cloud infrastructure evolved a decade ago.

It's no longer enough to build better models.

We also need:

  • Better schedulers
  • Better inference engines
  • Better GPU sharing
  • Better request routing
  • Better networking
  • Better orchestration

The future isn't about one breakthrough.

It's about combining dozens of optimizations across the stack.

That's exactly why Kubernetes is becoming more than a container orchestrator.

It's rapidly evolving into the operating system for AI infrastructure.


Related Posts

  • NVIDIA Triton Inference Server — the inference server behind most production GPU serving: dynamic batching, model ensembles, concurrent execution, and Kubernetes integration
  • TensorRT and High-Performance AI Inference — how graph optimization, kernel fusion, and INT8/FP8 quantization produce the throughput numbers this post targets
  • NVIDIA NIM: Optimized Inference Microservices — pre-packaged inference with auto-selected TRT-LLM profiles; the production deployment path for the optimization stack covered here
  • Using LLMs in Production — product-level patterns: cost control, latency budgets, hallucination mitigation, and when to use which deployment strategy
  • GPU Autoscaling: KEDA, HPA, Cluster Autoscaler — scaling inference replicas based on GPU utilization and request queue depth
  • Flash Attention: Fast, Memory-Efficient Attention for LLMs — deep dive into the tiling algorithm behind KV cache, GQA, and PagedAttention mentioned here; explains why FA3 makes H100 profiles faster than A100
Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Tue Jul 21 2026

Share This on

← Previous

Kubernetes Resource Allocation: Requests, Limits, QoS, and Quotas

Next →

Fine-Tuning LLMs: LoRA, QLoRA, PEFT, and NeMo on Kubernetes

kubernetes/4-1-HPC-at-Scale
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2026 All rights reserved.