Navigation
🏭 Platform & Infrastructure· 10 min read

Dynamic Allocation

Auto-scaling inference replicas, elastic training, spot instance integration, and resource-aware scheduling.

dynamic-allocationautoscalingelasticspot-instancesscaling

Static GPU allocation wastes money β€” inference load varies 5Γ— between peak and trough, training jobs don’t run 24/7, and spot instances offer 60-80% savings. Dynamic allocation adjusts GPU assignment in real-time.


1. Auto-Scaling Inference

Scaling Signals

Not all signals are equal for LLM inference:

SignalMeasuresResponse timeRecommended?
GPU utilizationCompute usageLagging (already saturated when high)⚠️ Too late
Request queue depthPending requestsLeading (predicts saturation)βœ… Best
TTFT P99User experienceDirect SLA metricβœ… Best
KV cache utilizationMemory pressureLeading (OOM before GPU saturates)βœ… Good
Throughput (tok/s)System capacityLagging⚠️ Supplementary

Kubernetes HPA Configuration

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: vllm-autoscaler
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: vllm-serving
  minReplicas: 2        # always keep 2 replicas warm
  maxReplicas: 16
  behavior:
    scaleUp:
      stabilizationWindowSeconds: 60   # wait 60s before scaling up
      policies:
      - type: Pods
        value: 2          # add max 2 pods at a time
        periodSeconds: 120
    scaleDown:
      stabilizationWindowSeconds: 300  # wait 5 min before scaling down
      policies:
      - type: Pods
        value: 1
        periodSeconds: 300
  metrics:
  - type: Pods
    pods:
      metric:
        name: vllm_num_requests_waiting  # custom DCGM/Prometheus metric
      target:
        type: AverageValue
        averageValue: "5"   # scale up when >5 requests queued per pod

Scale-up fast, scale-down slow: You want to respond quickly to load spikes (add pods in 60s) but avoid oscillation on temporary dips (wait 5 min before removing).

Cold Start Problem

New inference pods take 1-5 minutes to load the model:

MitigationHowLatency
Pre-cached model on NVMeModel already on node disk~30s (load to GPU)
Warm standby podsIdle pods with model loaded, 0 traffic~0s (route traffic immediately)
Predictive scalingScale up before peak (based on time-of-day pattern)0s (already scaled)

2. Spot/Preemptible Instances

Cloud spot instances cost 60-80% less but can be reclaimed with 30s-2min warning:

Spot-Friendly Workloads

WorkloadSpot viable?Interruption strategy
Pre-trainingβœ…Checkpoint every 10 min, resume from last checkpoint
Fine-tuningβœ…Same β€” short runs, frequent checkpoints
Batch inferenceβœ…Retry failed batches on new instance
Online inference❌User-facing β€” can’t tolerate random interruption
Data preprocessingβœ…Stateless, easily retried

Spot Integration Architecture

Spot instance pool (70% of training GPUs):
  β”œβ”€β”€ On-demand fallback: 30% always-on GPUs
  β”œβ”€β”€ Checkpoint service: save every 10 min to S3
  β”œβ”€β”€ Spot interruption handler:
  β”‚     When 2-min warning received:
  β”‚       1. Save emergency checkpoint
  β”‚       2. Gracefully exit training
  β”‚       3. Re-queue job on available capacity
  └── Auto-scaling group: request new spots when capacity available

Cost Savings

ConfigurationGPU cost/hourSavings vs on-demand
AWS p5.48xlarge on-demand~$98 (8Γ—H100)Baseline
AWS p5.48xlarge 1yr reserved~$6237%
AWS p5 spot (when available)~$30-5050-70%
Mix: 30% reserved + 70% spot~$42 average57%

3. Elastic Training

Resize a training job without restarting:

Hour 0:  48 GPUs available β†’ start with DP=6, TP=8
Hour 3:  16 GPUs reclaimed (spot) β†’ shrink to DP=4, TP=8 (32 GPUs)
Hour 5:  64 GPUs available β†’ expand to DP=8, TP=8 (64 GPUs)

Requirements for Elastic Training

RequirementWhyImplementation
Elastic launch (torchrun)Adjust world_size at runtime--nnodes=min:max
FSDP/ZeRO that reshardsRedistribute parameters when DP changesPyTorch DCP
Frequent checkpointsSurvive resize without losing progressEvery 5-10 min
Batch size adjustmentEffective batch = micro_batch Γ— DP Γ— accum_stepsAdjust accum_steps when DP changes

For the cluster managers that implement these policies, see Cluster Managers.


Self-Check

  • Choose auto-scaling signals for LLM inference (why queue depth > GPU utilization)
  • Configure Kubernetes HPA with scale-up fast / scale-down slow behavior
  • Design a spot instance strategy for pre-training (checkpoint + fallback)
  • Calculate cost savings from a 30% reserved + 70% spot mix
  • List the requirements for elastic training

References