Skip to content

feat(ai): high-throughput LLM gateway and distributed model router fronting Ollama and vLLM servers #142

Closed

Description

@dan-petty

Summary & Problem Statement

Currently, devops-cli AI workloads connect directly to individual Ollama daemonset pods or nodes (e.g. hawk.lan:11434, condor:11434), requiring manual node routing, static model mappings, and risk of GPU OOM or eviction when multiple tasks contend for VRAM.

Proposed Architecture & Capabilities

  1. Unified LLM Gateway & Routing Service (k8s/llm/gateway/, devops ai gateway):
    • Deploy LiteLLM Proxy / AI Gateway in llm namespace with single cluster-internal endpoint (http://llm-gateway.llm.svc.cluster.local:4000/v1).
    • Least-latency and least-busy load balancing across heterogeneous Ollama nodes and vLLM instances.
    • Automatic retry loops, exponential backoff, health-probe-driven failover, and circuit breakers.
    • Virtual tiering and model aliases (devops-chat, devops-coder, devops-reasoning, devops-embedding).
    • Distributed token-bucket rate limiting via Valkey and outbound caching via Squid proxy.
  2. vLLM Continuous Batching & Tensor Parallelism (k8s/llm/vllm/):
    • Multi-GPU Tensor Parallelism ($TP=2$) on condor dual RTX 3090 (48GB VRAM) for 70B models (llama-3.3-70b-instruct, qwen2.5-coder-32b).
    • PagedAttention and continuous batching for 5-10x throughput over Ollama during multi-file reviews.
  3. Context-Window & VRAM-Aware Dynamic Model Router (devops_cli.ai.router.gateway):
    • Automatic context-size inspection: $\le 16\text{k}$ to fast single-GPU nodes, $\ge 32\text{k}-64\text{k}$ to multi-GPU vLLM.
  4. FastMCP Gateway Tools & Telemetry:
    • FastMCP tools (ai_gateway_status, ai_gateway_routes, ai_gateway_failover, ai_vllm_scale) and cluster GPU resource.
    • OpenTelemetry tracing spans and Prometheus metrics.

Acceptance Criteria

  • LiteLLM / AI Gateway Helm/K8s manifests authored under k8s/llm/gateway/.
  • vLLM Tensor Parallelism manifests authored under k8s/llm/vllm/.
  • Client dynamic routing and fallback implemented in src/devops_cli/ai/client/.
  • FastMCP tools and system resource exposed.
  • Full CI suite passing with $\ge 90%$ code coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p0-criticalscope/aiscope/k8stype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions