Back to Projects
High-Throughput Distributed AI Inference

vLLM Distributed Serving & PagedAttention Engine

Scalable model inference cluster serving 70B+ parameter models across 8Γ— NVIDIA H100 GPUs with PagedAttention v2, FlashAttention-3 chunked prefill, and sub-18ms TTFT.

πŸ“– Project Overview

Serving modern Large Language Models at enterprise scale faces a core bottleneck: Key-Value (KV) cache memory fragmentation. Traditional inference engines allocate contiguous blocks of High-Bandwidth Memory (HBM) for worst-case sequence lengths, wasting 60% to 80% of scarce GPU VRAM on unused capacity.

This platform deploys a production vLLM inference cluster utilizing PagedAttention v2β€”an algorithm inspired by operating system virtual memory paging that splits KV cache tensors into discrete, non-contiguous physical memory blocks.

Combined with FlashAttention-3 chunked prefill, AWQ 4-bit and FP8 quantization, and tensor parallelism orchestrated over Ray Core, the cluster delivers 2.8Γ— higher concurrent query throughput, cuts Time-to-First-Token (TTFT) to under 18ms, and enables multi-node serving of 70B and MoE models with zero wasted memory.

βš™οΈ Deployment Checklist & Runbook

1

Initialize vLLM Distributed Async Engine

Configure the asynchronous vLLM engine with tensor parallelism and PagedAttention settings:

python
from vllm import AsyncLLMEngine, AsyncEngineArgs, SamplingParams

engine_args = AsyncEngineArgs(
    model="deepseek-ai/DeepSeek-V2.5",
    tensor_parallel_size=8,
    gpu_memory_utilization=0.92,
    max_model_len=32768,
    kv_cache_dtype="fp8_e4m3",
    block_size=16,  # PagedAttention block size
    enable_chunked_prefill=True,
    max_num_batched_tokens=8192
)
engine = AsyncLLMEngine.from_engine_args(engine_args)
2

Deploy Ray Cluster DaemonSet

Provision the multi-node Ray operator on Kubernetes across GPU node pools:

yaml
apiVersion: ray.io/v1
kind: RayCluster
metadata:
  name: vllm-h100-cluster
spec:
  rayVersion: '2.34.0'
  headGroupSpec:
    rayStartParams:
      dashboard-host: '0.0.0.0'
    template:
      spec:
        containers:
        - name: ray-head
          image: vllm/vllm-openai:latest
          resources:
            limits:
              cpu: "16"
              memory: "64Gi"
  workerGroupSpecs:
  - groupName: gpu-workers
    replicas: 4
    template:
      spec:
        containers:
        - name: ray-worker
          image: vllm/vllm-openai:latest
          resources:
            limits:
              nvidia.com/gpu: "8"
3

Configure Triton & Prometheus Metrics Exporter

Export real-time TTFT, KV-cache usage, and token generation latencies to Prometheus:

bash
# Scrape vLLM native metrics endpoint:
curl http://vllm-engine.ai-serving.svc:8000/metrics | grep vllm:
# Metrics:
# vllm:num_requests_running
# vllm:num_requests_waiting
# vllm:gpu_cache_usage_factor
# vllm:time_to_first_token_seconds

πŸ”„ Configuration & Environment Keys

Environment Variable Description Suggested Value
TENSOR_PARALLEL_SIZE Number of GPUs to partition model layers across. 8 (for 70B+ weights)
GPU_MEMORY_UTILIZATION Fraction of VRAM reserved for weights + KV-cache. 0.92
KV_CACHE_DTYPE Data format for KV cache tokens. fp8_e4m3 (50% VRAM saving)
MAX_NUM_BATCHED_TOKENS Chunked prefill batching threshold. 8192

πŸ“Š Architectural Workflow

graph TD
    Client([Client Application]) -->|OpenAI-Compatible Streaming| LiteLLM[LiteLLM Smart Router]
    LiteLLM -->|Batch Dispatch| Scheduler[vLLM Iteration-Level Scheduler]
    Scheduler -->|Prefill Chunking| FlashAttn[FlashAttention-3 Engine]
    Scheduler -->|Allocate KV Pages| MemoryManager[PagedAttention v2 Block Table]
    MemoryManager -->|Map Virtual Pages| PhysicalVRAM[(8x H100 Physical VRAM)]
    PhysicalVRAM -->|Tensor Parallel Compute| RayWorkerPool[Ray GPU Worker Pool]
    RayWorkerPool -->|Yield Next Token| StreamBuffer[SSE Event Buffer]
    StreamBuffer -->|Sub-18ms TTFT Stream| Client
            

πŸ› οΈ Useful CLI Reference

# Launch production vLLM serving container: python3 -m vllm.entrypoints.openai.api_server \ --model deepseek-ai/DeepSeek-V2.5 \ --tensor-parallel-size 8 \ --gpu-memory-utilization 0.92 \ --kv-cache-dtype fp8_e4m3 \ --port 8000 # Benchmark concurrency and tokens/second: python3 -m vllm.benchmarks.benchmark_serving \ --backend vllm \ --model deepseek-ai/DeepSeek-V2.5 \ --num-prompts 500 \ --request-rate 25
πŸ“‹ Code copied to clipboard!