Skip to content

Instantly share code, notes, and snippets.

@eevmanu
Created July 21, 2026 21:20
Show Gist options
  • Select an option

  • Save eevmanu/4d3266d9e96b1e902f8ce9f7e04d107c to your computer and use it in GitHub Desktop.

Select an option

Save eevmanu/4d3266d9e96b1e902f8ce9f7e04d107c to your computer and use it in GitHub Desktop.
The Rise of LLM Inference and AI Systems Engineering: A Deep Dive into Distributed Serving, Architectural Co-design, and Low-Level Optimizations -- LLM Inference Engineering / Inference Systems Engineering -- LLMOps / MLOps

The Rise of LLM Inference and AI Systems Engineering: A Deep Dive into Distributed Serving, Architectural Co-design, and Low-Level Optimizations


Executive Summary

The transition of artificial intelligence from exploratory training paradigms to high-throughput, low-latency, and cost-efficient production serving has catalyzed the birth of two highly specialized, deeply technical engineering disciplines: AI/ML Systems Engineering and LLM Inference Engineering (often grouped under Inference Systems Engineering).

Historically, machine learning was cleanly partitioned: ML researchers designed model architectures in Python, while software engineers deployed them as monolithic black-box containers behind simple HTTP/gRPC gateways. Today, as Large Language Models (LLMs) scale to hundreds of billions of parameters, and as autoregressive generation imposes severe memory, bandwidth, and compute constraints, this clean separation has collapsed.

In its place stands the necessity for systems-model co-design. Maximizing hardware utilization (e.g., NVIDIA H100s, Google TPUs) and minimizing the cost of inference requires deep expertise in computer systems, compilers, and distributed architectures, paired with a granular understanding of deep learning models (e.g., Transformer attention, Mixture of Experts routing, KV-cache dynamics). This report formalizes these disciplines, maps their academic and industry origins, analyzes foundational low-level optimization papers, details the CNCF cloud-native distributed inference orchestration engine (llm-d), and outlines the sovereign, specialized deployment paradigm defining the future of enterprise AI.


1. Taxonomic Clarification: Defining the Frontiers

To navigate this career landscape, one must distinguish systems-level engineering from application-level and client-facing integration. The table below provides a structured, comparative analysis of these roles across critical dimensions.

1.1 Comparative Role Matrix

Dimension LLM Inference Engineering / Inference Systems Engineering AI/ML Systems Engineering LLMOps / MLOps Forward Deployed Engineering (FDE)
Core Focus Low-level serving, GPU memory management, and latency/throughput token-level optimizations. Compiler design, hardware-software co-design, distributed systems training, and inference engines. Application lifecycle, RAG pipelines, fine-tuning orchestrations, semantic monitoring, and drift detection. Client-facing custom integrations, product-market-fit engineering, and custom application wrappers.
Primary Venues & Repos vllm, sglang, DeepEP, LMCache, SOSP, OSDI. NVIDIA/Megatron-LM, triton, tvm, xla, MLSys, NeurIPS (Systems). LangChain, LlamaIndex, KServe, MLflow, Prometheus, CNCF. Private customer repos, custom SDKs, internal middleware, enterprise API integrations.
Hardware & Compilers Intimate knowledge of GPU memory hierarchies (SRAM vs. HBM), NVLink, PCIe bandwidth. Direct development of compilers (Triton, TVM, XLA), customized CUDA kernels, ROCm, custom TPUs. Abstracted behind Kubernetes, standard container images, and cloud provider managed instances. Completely abstracted; interacts strictly via black-box web APIs (OpenAI, Anthropic).
Model Architecture Depth Deep. Understands KV cache size, prefill vs. decode shapes, MoE routing, prefix patterns. Medium-to-Deep. Focuses on parallelizability (TP/PP/EP), tensor operator compilation, graph scheduling. Medium-to-Low. Focuses on API integration, prompt templates, chunking strategies, and basic LoRA. Low. Focuses on model behavior, output parsing, prompt injection defense, and agentic workflows.
Key Metrics Optimized TTFT (Time to First Token), TPOT (Time Per Output Token), KV-cache hit rate, GPU HBM utilization. FLOPS utilization (MFU), compilation time, all-to-all communication overhead, multi-node bandwidth. Request success rate, end-to-down user latency, API cost-per-million tokens, semantic accuracy. Client integration speed, NPS, system adoption, functional domain-specific utility.

1.2 LLM Inference Engineering vs. AI/ML Systems Engineering

While closely related, these two disciplines diverge in scope and operational target:

  • AI/ML Systems Engineering is the broader umbrella. It is deeply rooted in computer systems, compiler technology, and hardware architecture. These engineers build the compilers (like Triton), runtime frameworks, and distributed execution libraries (like Megatron-LM) that compile and run ML mathematical graphs on physical silicon. They address the general question: How do we build compilers and systems that maximize FLOPS for any neural network graph during training or inference?
  • LLM Inference Engineering is a highly specialized vertical under AI Systems. It focuses explicitly on the serving phase of autoregressive models. These engineers analyze the unique operational bottlenecks of Transformers—namely, the memory-bound nature of token generation and the compute-bound nature of prompt processing. They write cache-aware schedulers, manage physical-to-virtual GPU memory mappings, design disaggregated prefill-decode systems, and write custom kernels for low-precision quantization (FP8, INT4).

1.3 LLMOps vs. Forward Deployed Engineering (FDE)

In contrast to systems engineering, LLMOps and FDE operate at higher levels of abstraction:

  • LLMOps is an extension of DevOps. It assumes the model is a pre-trained, pre-optimized artifact. The LLMOps engineer's role is to wrap this model in an API, set up vector databases for Retrieval-Augmented Generation (RAG), manage prompts, implement guardrails, and monitor operational health (CPU/GPU metrics, cost, drift, token usage).
  • Forward Deployed Engineering (FDE) is a highly consultative, customer-centric engineering role popularized by companies like Palantir and Scale AI. FDEs work on-site or directly with enterprise clients to integrate models into the client's legacy systems. They do not write CUDA kernels or build distributed orchestrators; they build the business logic, UI, and integration layers that make the AI system useful to a business.

Note

The Ultimate Distinction: If you are writing a custom GPU kernel to overlap communication and computation during a Mixture-of-Experts (MoE) dispatch, you are an AI/ML Systems Engineer. If you are restructuring an engine's memory scheduler to dynamically share a radix-tree-based KV-cache across different requests, you are an LLM Inference Engineer. If you are setting up a vector database index and configuring Prometheus metrics for an API gateway, you are in LLMOps. If you are building a custom CRM dashboard for an enterprise client using a third-party LLM API, you are a Forward Deployed Engineer.


2. Canonical Academic and Technical Foundations

The state of the art in LLM serving is not driven by traditional enterprise software patterns, but by a highly symbiotic relationship between top-tier academic systems conferences and industrial research labs.

2.1 The Academic Centers of Gravity

Systems-level machine learning research has shifted away from purely algorithmic machine learning conferences (like ICML or NeurIPS main tracks) and found its core home in prestigious systems conferences:

  1. MLSys (Conference on Machine Learning and Systems) (https://mlsys.org/): Established explicitly at the intersection of systems and machine learning, this venue is the premier showcase for co-designed runtimes, compiler optimizations, and large-scale infrastructure frameworks.
  2. SOSP (Symposium on Operating Systems Principles) and OSDI (USENIX Symposium on Operating Systems Design and Implementation): These are the absolute gold standards of systems engineering research. They have historically birthed foundational technologies like MapReduce and Spark. In recent years, they have become the primary publishers of breakthrough LLM serving and memory systems.
  3. FAST (USENIX Conference on File and Storage Technologies): As KV caches grow to occupy terabytes of memory across distributed clusters, storage-centric systems research has migrated here, focusing on hierarchical, distributed memory and storage architectures.

2.2 Breakthrough Research Papers & Core Mechanics

graph TD
    subgraph Client Layer
        A[Inference Request] --> B[Inference API Gateway / llm-d]
    end

    subgraph Orchestration & Routing Layer [llm-d CNCF Sandbox]
        B -->|Endpoint Picker Protocol IPP| C[Endpoint Picker EPP]
        C -->|Cache-Aware SLO Routing| D[Prefill Worker Pool GPU Node]
        C -->|Cache-Aware SLO Routing| E[Decode Worker Pool GPU Node]
        F[KEDA Autoscaler] -->|Metrics-Driven SLO Autoscaling| D
        F -->|Metrics-Driven SLO Autoscaling| E
    end

    subgraph Low-Level Model Runtime [vLLM / SGLang Engine]
        D -->|RadixAttention Prefix Cache Lookup| G[Model Execution Engine]
        E -->|PagedAttention Virtual-Physical Block Mapping| G
        G -->|Low-Level Tensor Operator| H[NVIDIA CUDA / ROCm Kernel Layer]
    end

    subgraph Distributed Cache & Storage [LMCache / Mooncake]
        I[(Distributed Tiered KV Cache: DRAM -> SSD -> Redis)] <-->|KVCache Transfer| D
        I <-->|KVCache Transfer| E
    end

    subgraph Hardware Layer
        H -->|Direct Memory Access| J[Physical GPU Memory HBM]
        H -->|High-Speed Interconnect| K[NVLink / InfiniBand Fabric]
    end

    style B fill:#1e293b,stroke:#3b82f6,stroke-width:2px,color:#fff
    style C fill:#1e293b,stroke:#3b82f6,stroke-width:2px,color:#fff
    style G fill:#0f172a,stroke:#10b981,stroke-width:2px,color:#fff
    style I fill:#1e1b4b,stroke:#ec4899,stroke-width:2px,color:#fff
    style J fill:#451a03,stroke:#f97316,stroke-width:2px,color:#fff
    style K fill:#451a03,stroke:#f97316,stroke-width:2px,color:#fff
Loading

2.2.1 PagedAttention (vLLM) [SOSP 2023]

  • Paper Reference: Efficient Memory Management for Large Language Model Serving with PagedAttention (Kwon et al., SOSP 2023).
  • The Bottleneck: In autoregressive generation, the Key-Value (KV) cache grows dynamically with context length and can consume massive amounts of GPU memory. Standard frameworks pre-allocated contiguous memory blocks based on the maximum possible context length (e.g., 2048 tokens). This resulted in severe memory waste due to:
    1. Internal Fragmentation: Unused allocated space because the actual generation was shorter than the maximum length.
    2. External Fragmentation: Memory allocated to other requests that could not be consolidated.
    3. Reservation Waste: Pre-allocated space for tokens that had not been generated yet. Together, these wastes accounted for up to 60% to 80% of total GPU memory, strictly limiting batch sizes.
  • The Innovation: PagedAttention borrows the concept of virtual memory and paging from operating systems. It partitions the KV cache of a request into fixed-size physical memory blocks (representing, for example, 16 tokens). These blocks are not required to be physically contiguous. Instead, a virtual-to-physical block mapping table tracks the logical sequence of tokens. This reduces internal fragmentation to the very last block of a request (under 4%), completely eliminates external fragmentation, and allows the framework to dynamically allocate and share memory on-the-fly, increasing throughput by 2x to 4x under identical hardware configurations.

2.2.2 RadixAttention (SGLang) [NeurIPS 2024]

  • Paper Reference: SGLang: Efficient Execution of Structured Language Model Programs (Zheng et al., NeurIPS 2024).
  • The Bottleneck: In multi-turn chat dialogues, Retrieval-Augmented Generation (RAG) tasks, or few-shot prompt templates, subsequent queries repeat massive chunks of identical text (system prompts, documents, historical messages). Standard serving engines discard the KV cache when a request finishes, forcing the engine to recompute the KV cache for the same prefixes repeatedly, causing massive compute and latency overhead.
  • The Innovation: SGLang introduces RadixAttention, which treats the KV cache as a LRU (Least Recently Used) cache structured as a Radix Tree. The Radix Tree maps the sequence of tokens to their physical KV cache locations in GPU memory. When a request is completed, its KV cache blocks are not freed; they remain in memory and are indexed by the Radix Tree. When a new request arrives:
    1. The engine performs a prefix lookup in the Radix Tree.
    2. If a match is found (e.g., a shared system prompt), the engine directly reuses the existing physical KV cache blocks, bypassing the compute-intensive "prefill" phase.
    3. If memory is full, the tree evicts leaf nodes (inactive completed requests) using an LRU policy. This enables seamless, automatic, and dynamic KV cache sharing across multi-turn chats, parallel decoding, and agentic workflows.

2.2.3 Prefill-Decode Serving Disaggregation

Traditional Serving (Interfered):
GPU 1: [Prefill (High FLOPs)] -> [Decode (Low FLOPs/High BW)] -> [Prefill] (High Latency Variance)

Disaggregated Serving (Symmetric):
Prefill Pool (Compute Optimized): [Prefill Node 1] -> [Prefill Node 2]
                                      | (KV-Cache Transfer via NIXL / PCIe / InfiniBand)
                                      v
Decode Pool (Memory BW Optimized):  [Decode Node 1] -> [Decode Node 2]
  • The Bottleneck: LLM generation consists of two highly asymmetric phases:
    1. Prefill Phase: Processes the input prompt. It is highly compute-bound (matrix-matrix multiplications, high FLOPS utilization) and benefits from large tensor parallelism.
    2. Decode Phase: Generates output tokens one by one. It is highly memory-bandwidth-bound (matrix-vector multiplications, low FLOPS, high I/O overhead) and sensitive to NVLink/PCIe speeds. Running both phases on the same GPU leads to severe resource contention and inter-phase interference. High-compute prefill steps preempt active decoding steps, leading to spikes in Time-Per-Output-Token (TPOT) and making it difficult to meet strict latency Service Level Objectives (SLOs).
  • The Solutions (Primary Papers):
    • DistServe (DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving, OSDI 2024): DistServe formally pioneered prefill-decode disaggregation. It splits the serving cluster into distinct Prefill Nodes and Decode Nodes. The prefill node processes the input prompt and transmits the resulting KV cache to a decode node via high-speed interconnects (InfiniBand, NVLink) to perform the decoding step. This decoupling completely eliminates interference, allowing independent tuning of Tensor Parallelism (TP) and Pipeline Parallelism (PP) for each phase, resulting in a 10x improvement in Goodput (requests served within latency SLOs).
    • Mooncake (Mooncake: Trading More Storage for Less Computation — A KVCache-centric Architecture for Serving LLM Chatbot, FAST 2025): Mooncake expands disaggregation by implementing a KVCache-centric hierarchical storage pool. Rather than treating the KV cache as temporary model memory, Mooncake views it as a primary, persistent storage asset. It pools underutilized CPU DRAM, local SSDs, and remote storage nodes across the cluster. When a prefill node finishes processing, it streams the KV cache blocks to this distributed pool. Decode nodes retrieve needed blocks on-demand. By scheduling requests based on KV cache locality across this distributed storage tier, Mooncake drastically reduces re-computation cost and latency.
    • LMCache (LMCache: An Efficient KV Cache Layer for Enterprise-Scale LLM Inference, 2025): LMCache serves as an open-source, vendor-neutral middleware layer that decouples KV cache management from specific model servers (vLLM, SGLang). It operates as a local daemon, persisting, compressing, and offloading KV caches to tiered storage (Local CPU RAM -> Local SSD -> Remote Redis). It provides "prefill-once, retrieve-anywhere" semantics, allowing a KV cache created on one physical node to be seamlessly transferred and reused on another node in a completely different part of the cluster.

2.2.4 Mixture of Experts (MoE) Optimizations

  • The Bottleneck: MoE models (e.g., Mixtral, DeepSeek-V3) route different tokens to different specialized subnetworks ("experts"). This architecture introduces unique systems bottlenecks:
    1. Communication Overhead (All-to-All): Tokens must be dispatched to physical nodes hosting the selected experts and then combined back. This causes massive network bottlenecks (all-to-all collectives).
    2. Load Imbalance: Popular experts receive many tokens, while others sit idle, causing GPU starvation and bottlenecking pipeline execution.
  • The Solutions & Frameworks:
    • DeepSeek's DeepEP & EPLB (DeepSeek-V3 Technical Report): DeepSeek revolutionized MoE serving through extreme systems engineering:
      • DeepEP: A low-level CUDA communication library providing highly optimized all-to-all GPU kernels customized for MoE dispatch and combine. It directly optimizes communication across asymmetric bandwidth domains (NVLink inside a node vs. InfiniBand/RDMA between nodes), leveraging FP8 precision to halve network bandwidth requirements and overlapping communication with GEMM compute kernels.
      • EPLB (Expert Parallelism Load Balancer): Because expert token distribution is highly dynamic and unbalanced, EPLB acts as a global scheduler. It replicates frequently used "hot" experts across multiple GPUs and dynamically schedules token routing to balance the compute load, ensuring near-perfect GPU utilization.
    • Megatron-LM Core MoE (NVIDIA Megatron-LM): NVIDIA’s flagship framework implements fine-grained expert parallelism. It overlaps expert routing communication with self-attention computation, uses specialized grouping algorithms to minimize the size of all-to-all transfers, and features "activation offloading" to handle massive MoE parameters on limited memory.
    • DeepSpeed-MoE (DeepSpeed-MoE: Advancing Mixture-of-Experts Inference and Training): Microsoft's DeepSpeed optimizes MoE inference via AutoEP (which automatically splits and arranges experts across GPU configurations) and Pyramid-Residual MoE (PR-MoE), which structures experts hierarchically to optimize parameters vs. accuracy.

3. Kubernetes-Native Distributed Orchestration: llm-d

While frameworks like vLLM and SGLang manage single-instance or single-model-replica optimization, serving enterprise workloads requires cluster-scale management. This is the domain of llm-d (Large Language Model Distributed), a highly specialized CNCF Sandbox project backed by Red Hat, Google Cloud, NVIDIA, IBM Research, and CoreWeave.

Incoming Request (HTTPS) 
      |
      v
[ Envoy / Gateway API ] <---ext-proc---> [ Endpoint Picker (EPP) ] 
      |                                       | (Queries Cluster State)
      |                                       v
      | <----Route to Selected Pod-----------[ Tracking KV Cache, Load, SLOs ]
      v
[ Selected Pod (vLLM Node) ]

3.1 What is llm-d?

Standard Kubernetes ingress and load balancers are "inference-blind." They distribute HTTP requests using simple round-robin or least-connections logic. For LLM serving, this is highly inefficient because it ignores:

  1. KV-Cache Locality: A request routed to a random node forces that node to re-compute or fetch the KV cache, destroying the latency benefits of SGLang's RadixAttention or LMCache.
  2. Inference State: Node load is defined by available GPU memory and token queue depth, which are invisible to standard CPU/memory metrics.

llm-d solves this by introducing a Kubernetes-native, inference-aware routing and scheduling control plane.


3.2 Core Architectural Components

3.2.1 Endpoint Picker (EPP)

The Endpoint Picker (EPP) is the central intelligence engine of the llm-d router. It maintains a real-time, low-latency state map of all active inference pods in the cluster, tracking their:

  • Cached prefixes (via radix tree integration).
  • Active queue size (tokens/requests in flight).
  • GPU memory usage.
  • Hardware characteristics (NVIDIA vs. AMD vs. TPU).

When a request arrives, the EPP scores all eligible endpoints and selects the absolute optimal pod to handle the request based on cache locality and latency budgets.

3.2.2 Endpoint Picker Protocol (IPP)

The Endpoint Picker Protocol (IPP) is the standardized communication specification designed to connect Gateway APIs to the EPP.

  • Mechanism: It implements the Gateway API Inference Extension (GAIE) and leverages the Envoy External Processing (ext-proc) protocol.
  • The Flow: When an incoming HTTP request hits the cluster's ingress layer (e.g., Envoy or Istio), the proxy intercepts the request and sends its headers/metadata to the EPP via the IPP. The EPP returns the selected pod destination, and Envoy forwards the raw data stream directly to that pod. This ensures that the high-volume data plane (tokens) remains fast and lightweight, decoupled from the complex routing control plane.

3.2.3 SLO-Aware Autoscale and KEDA Integration

In traditional Kubernetes, autoscaling (Horizontal Pod Autoscaler - HPA) is triggered by CPU or memory utilization. For GPUs, these metrics are useless: a GPU running an idle model server can report 99% memory utilization (due to pre-allocated KV caches) while processing zero requests.

llm-d integrates directly with KEDA (Kubernetes Event-driven Autoscaling) to implement SLO-Aware Autoscaling:

  • Inference Metrics: It exposes custom metrics such as Queue Depth, Time to First Token (TTFT) violation rates, and GPU Memory Pressure directly to KEDA.
  • Predictive Scheduling: It uses lightweight latency-prediction models (e.g., XGBoost classifiers) to project whether current capacity will violate strict latency SLOs. If a violation is projected, KEDA proactively spins up new replicas.
  • Scale-to-Zero: For enterprise cost control, llm-d supports scale-to-zero capabilities. When traffic ceases, idle model replicas are completely shut down, freeing up extremely expensive GPU resources for other workloads.

4. The Enterprise Sovereign Deployment Paradigm

The systems-level engineering developments described above have enabled a major architectural shift in the enterprise landscape: The Sovereign Deployment Paradigm.

4.1 Monolithic vs. Sovereign Specialized Models

Historically, enterprises relied on external, monolithic APIs (such as OpenAI's GPT-4) as a "silver bullet" for all tasks. This approach has proven structurally unsustainable for production due to critical concerns:

  1. Data Sovereignty & Privacy: Sensitive IP, financial records, and medical data cannot be transmitted to external third-party servers.
  2. Uncontrolled Latency & Drift: Monolithic APIs exhibit highly volatile response latencies and frequent silent model updates ("drift") that break production downstream logic.
  3. Severe Unit Economics: Paying per-token on a massive scale for simple tasks (e.g., entity extraction, routing) is financially non-viable.

4.2 The Sovereign Stack

To achieve data independence and optimal unit economics, enterprises are deploying a tiered hierarchy of custom, optimized, smaller specialized models (e.g., Llama-3-8B/70B, DeepSeek-R1-Distill, Qwen-2.5-Coder) hosted entirely on private infrastructure (on-premise or virtual private clouds).

Important

Enterprise Trade-off Analysis: Running a custom, optimized small model on a private sovereign stack changes the optimization game:

  • Intelligence vs. Task Complexity: A Mistral-7B or Llama-3-8B, fine-tuned on custom domain-specific data, frequently outperforms a monolithic GPT-4 on specialized tasks (classification, SQL generation, structured extractions) at a fraction of the parameter size.
  • The Latency-Throughput-Cost Triangle: By leveraging RadixAttention (for system prompt cache), vLLM (for PagedAttention memory efficiency), DistServe (decoupling high-volume prefill from fast decode), and llm-d with KEDA (scale-to-zero), a sovereign cluster can serve millions of specialized queries with sub-10ms TTFT and 50% lower total cost of ownership (TCO) compared to public SaaS APIs.

5. Technical Synthesis: Citing the Primary Sources

For the professional navigating this landscape, the canonical literature is summarized below:


Tip

Career Recommendation: If you are an engineer looking to specialize in this frontier, focus on:

  1. Writing and optimizing custom GPU kernels using Triton Compiler or raw CUDA/C++.
  2. Mastering the internal mechanics of state-of-the-art serving runtimes (vllm, sglang).
  3. Gaining hands-on knowledge of distributed networking fabrics (InfiniBand/RDMA, RoCE) and multi-GPU memory synchronization.
  4. Architecting Kubernetes-native systems using Gateway API Inference Extensions and llm-d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment