llm-d-workload-variant-autoscaler

module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: Apache-2.0

README

Workload-Variant-Autoscaler (WVA)

Go Report Card License FOSSA Status

The Workload Variant Autoscaler (WVA) is a Kubernetes-based global autoscaler for inference model servers serving LLMs. WVA works alongside the standard Kubernetes HPA and external autoscalers like KEDA to drive the scale subresource of inference deployments. The high-level details of the algorithms are documented here. It determines optimal replica counts for a given request traffic load by considering constraints such as GPU availability, energy budget, and performance budget (latency/throughput).

What is a Variant?

WVA introduces the concept of variants — multiple model servers in an InferencePool that all serve the same base model but differ in hardware configuration (e.g., GPU type), serving configuration (e.g., tensor parallelism, max batch size, quantization), or both.

Use cases include:

  • P/D disaggregation: prefill is one variant, decode is another — variant = role in a disaggregated pipeline.
  • batch-gateway: variants distinguish batch vs. interactive workloads sharing the same pool.
  • Autoscaler: a costed serving configuration the autoscaler chooses among.

Key Features

  • Intelligent Autoscaling: Optimizes replica count by observing the current state of the system
  • Cost Optimization: Minimizes infrastructure costs by picking the correct accelerator variant

Documentation

See the architecture and autoscaling design docs for high-level algorithm details.

See the docs directory for design docs, developer guide, and more.

How It Works

Prerequisites: deploy llm-d infrastructure (model servers) and create an HPA or KEDA object targeting each deployment.

WVA then:

  1. Continuously monitors request rates and server performance via Prometheus metrics
  2. Capacity model obtains KV cache utilization and queue depth to determine desired replica counts
  3. Actuator emits optimization metrics to Prometheus
  4. External autoscaler (HPA/KEDA) reads the metrics and scales the deployment accordingly

Example

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: llama-8b-autoscaler
  namespace: llm-inference
  annotations:
    llm-d.ai/managed: "true"  # Opt-in to WVA management
    llm-d.ai/variant-cost: "10.0"  # Optional, defaults to "10.0"
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: llama-8b
  # minReplicas: 0  # scale to zero - alpha feature
  maxReplicas: 2
  behavior:
    scaleUp:
      stabilizationWindowSeconds: 60
      policies:
      - type: Pods
        value: 10
        periodSeconds: 15
    scaleDown:
      stabilizationWindowSeconds: 60
      policies:
      - type: Pods
        value: 10
        periodSeconds: 15
  metrics:
  - type: External
    external:
      metric:
        name: wva_desired_replicas
        selector:
          matchLabels:
            variant_name: llama-8b
            exported_namespace: llm-inference
      target:
        type: AverageValue
        averageValue: "1"

More examples in config/samples/hpa/ and config/samples/keda/.

Upgrading

Upgrading to v0.9.0 — V2 saturation analyzer is now the default

Behavioral change. The default saturation analyzer changes from V1 (percentage/spare-capacity-based) to V2 (token/capacity-based). The shipped default entry in the saturation ConfigMap now includes an analyzers: section, which selects V2. No code change or image rebuild is involved — analyzer selection is driven entirely by config.

V2 may produce different scaling decisions than V1 for the same workload. Review your dashboards and alert thresholds after upgrading.

Staying on V1 (opt-out). Remove the analyzers: section (and the V2-only scaleUpThreshold / scaleDownBoundary fields) from the default entry of your saturation ConfigMap. The remaining kvCacheThreshold, queueLengthThreshold, kvSpareTrigger, and queueSpareTrigger fields drive V1:

data:
  default: |
    kvCacheThreshold: 0.80
    queueLengthThreshold: 5
    kvSpareTrigger: 0.1
    queueSpareTrigger: 3

Apply with kubectl apply -f deploy/configmap-saturation-scaling.yaml; the change takes effect immediately (the controller watches the ConfigMap).

V1 is deprecated and scheduled for removal in a future release. See the saturation scaling configuration guide for threshold ownership (which fields each analyzer reads) and migration details.

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

Join the llm-d autoscaling community meetings to get involved.

License

Apache 2.0 - see LICENSE for details.

FOSSA Status

References

Directories

Path Synopsis
internal
annotations
Package annotations defines the WVA annotation schema used for annotation-based discovery on KEDA ScaledObjects and Kubernetes HPAs.
Package annotations defines the WVA annotation schema used for annotation-based discovery on KEDA ScaledObjects and Kubernetes HPAs.
collector
Package collector provides metrics collection functionality.
Package collector provides metrics collection functionality.
collector/registration
This file provides queueing model analyzer metrics collection using the source infrastructure with registered query templates.
This file provides queueing model analyzer metrics collection using the source infrastructure with registered query templates.
collector/source
Package source provides metrics collection functionality.
Package source provides metrics collection functionality.
collector/source/pod
Package pod provides the Pod scraping metrics source implementation.
Package pod provides the Pod scraping metrics source implementation.
collector/source/prometheus
Package prometheus provides the Prometheus metrics source implementation.
Package prometheus provides the Prometheus metrics source implementation.
constants
Package constants provides centralized constant definitions for the autoscaler.
Package constants provides centralized constant definitions for the autoscaler.
coordinator
Package coordinator hosts the Coordinator component: a leader-elected, periodic loop that computes the set of scale targets (HPAs and KEDA ScaledObjects) under Coordinator control and dispatches them to a registered set of plugins.
Package coordinator hosts the Coordinator component: a leader-elected, periodic loop that computes the set of scale targets (HPAs and KEDA ScaledObjects) under Coordinator control and dispatches them to a registered set of plugins.
engines/aggregation
Package aggregation provides pure helper functions for aggregating per-variant capacity data into model-level and per-role totals.
Package aggregation provides pure helper functions for aggregating per-variant capacity data into model-level and per-role totals.
engines/executor
Package executor provides task execution strategies.
Package executor provides task execution strategies.
engines/pipeline
Limiter interfaces for resource limiting algorithms.
Limiter interfaces for resource limiting algorithms.
inferenceengine
Package inferenceengine identifies which LLM inference engine (vLLM, SGLang) a scale target runs.
Package inferenceengine identifies which LLM inference engine (vLLM, SGLang) a scale target runs.
variant
Package variant defines the in-memory VariantAutoscaling representation used by the WVA optimization pipeline (collector, analyzers, engines, actuator).
Package variant defines the in-memory VariantAutoscaling representation used by the WVA optimization pipeline (collector, analyzers, engines, actuator).
test
e2e
e2e/fixtures
Package fixtures provides shared Kubernetes helpers for the consolidated e2e suite.
Package fixtures provides shared Kubernetes helpers for the consolidated e2e suite.
utils
Package utils provides test utilities for PodScrapingSource e2e tests.
Package utils provides test utilities for PodScrapingSource e2e tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL