AI Model Wiki

    Skip to main content
    15 min read
    Lesson 3 of 5

    GPU Optimization & Cost Management

    From the course AI Infrastructure & MLOps

    GPU compute is the biggest cost in AI infrastructure. Optimizing utilization and choosing the right hardware directly impacts both performance and budget.

    GPU Selection Guide

    GPUVRAMBest ForCloud Cost (approx/hr)
    NVIDIA T416 GBInference (small models)$0.50-1.00
    NVIDIA A10G24 GBInference (medium models)$1.00-1.50
    NVIDIA L424 GBInference (efficient)$0.70-1.20
    NVIDIA A100 40GB40 GBTraining & large inference$3.00-4.00
    NVIDIA A100 80GB80 GBLarge model training$4.00-5.00
    NVIDIA H10080 GBFrontier model training$8.00-12.00

    Optimization Techniques

    Quantization: Reduce precision for faster inference

    • FP16 → INT8: ~2× speedup, minimal quality loss
    • FP16 → INT4 (GPTQ/AWQ): ~4× speedup, slight quality loss
    • Always benchmark quality after quantization on your specific tasks

    Speculative Decoding: Use a small "draft" model to predict multiple tokens, then verify with the large model in one pass. Can achieve 2-3× speedup for generation.

    Flash Attention: Optimized attention computation that's 2-4× faster and uses significantly less memory. Supported by vLLM, TGI, and most modern frameworks.

    Key-Value Cache Compression: Compress cached attention states to reduce memory usage during long-context generation.

    Cost Management Strategies

    1. Right-size instances: Don't use an H100 for a 7B model. Match GPU to model size.
    2. Spot/preemptible instances: 60-90% savings for fault-tolerant workloads (batch processing, training)
    3. Auto-scaling: Scale GPU instances to zero during low-traffic periods
    4. Model distillation: Train a smaller model that mimics your large model. 10× cheaper to serve.
    5. Caching: Cache frequent responses to avoid redundant inference
    6. Request routing: Route simple queries to small models, complex ones to large models

    Cost Calculation Framework

    Monthly cost = (GPU cost/hr) × (hours/day) × 30 × (number of GPUs)
    Cost per query = Monthly cost / Monthly query volume
    Target: < $0.01 per query for most applications
    

    Key Takeaways

    • •Match GPU to model size — over-provisioning wastes budget, under-provisioning kills latency
    • •Quantization (INT4/INT8) and Flash Attention provide the biggest performance gains
    • •Spot instances, auto-scaling, and caching dramatically reduce costs
    • •Model distillation can reduce serving costs 10× while maintaining acceptable quality
    0 of 5 lessons marked complete

    Progress is kept in this browser only.