LLM Serving & Inference: Complete Learning Repository
A comprehensive, hands-on guide to learning LLM serving and inference from fundamentals to production deployment.
π― What Youβll Learn
This repository teaches you everything about serving Large Language Models in production:
- How LLM inference works (tokenization, attention, generation)
- Basic serving (FastAPI, model loading, endpoints)
- Containerization (Docker for ML workloads)
- Kubernetes deployment (production infrastructure)
- Performance optimization (vLLM, batching, GPU utilization)
- Scaling (autoscaling, load balancing)
- Production practices (monitoring, versioning, drift detection)
π Repository Structure
mlops_serving/
βββ LEARNING_PATH.md # Start here! Complete learning guide
βββ docs/ # Detailed concept explanations
β βββ llm_inference_fundamentals.md
β βββ serving_architectures.md
β βββ optimization_techniques.md
βββ 01_basic_serving/ # FastAPI + HuggingFace serving
βββ 02_docker/ # Containerization
βββ 03_kubernetes/ # K8s deployment
βββ 04_load_testing/ # Performance testing
βββ 05_vllm_serving/ # High-performance serving
βββ 06_autoscaling/ # K8s autoscaling
βββ 07_canary_deployments/ # Gradual rollouts
βββ 08_monitoring/ # Prometheus + Grafana
βββ 09_model_versioning/ # Version management
βββ 10_drift_detection/ # Evidently integration
βββ 11_triton/ # Multi-model serving
π Quick Start
π START HERE: Read HOW_TO_START.md for a complete step-by-step guide!
Quick Commands
# 1. Set up environment
cd 01_basic_serving
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
# 2. Start the server
python app.py
# 3. Test it (in another terminal)
python test_api.py
# OR visit http://localhost:8000/docs for interactive API docs
π Learning Approach
This is a hands-on, topic-based learning path:
- Each topic is self-contained with code, docs, and exercises
- Build incrementally - each topic builds on previous concepts
- Learn by doing - run code, modify it, break it, fix it
- Focus on understanding - not just copying code
π Prerequisites
- Python 3.9+
- Basic Python knowledge
- Understanding of REST APIs
- Docker (for containerization topics)
- Kubernetes cluster (minikube/kind for K8s topics)
- GPU (optional, helpful for vLLM)
π Topics Covered
Core Concepts
- LLM architecture and inference pipeline
- Tokenization and vocabulary
- Attention mechanisms and KV caching
- Memory and computation requirements
Serving Basics
- Model loading and initialization
- API endpoint design
- Request/response handling
- Error handling and validation
Infrastructure
- Docker containerization
- Kubernetes deployment
- Health checks and probes
- Resource management
Performance
- Load testing and benchmarking
- Latency vs throughput
- vLLM optimization
- GPU utilization
Production
- Autoscaling strategies
- Canary deployments
- Monitoring and observability
- Model versioning
- Drift detection
π§ Technologies
- FastAPI: Web framework
- HuggingFace Transformers: Model loading
- vLLM: High-performance inference
- Docker: Containerization
- Kubernetes: Orchestration
- Locust: Load testing
- Prometheus: Metrics
- Grafana: Visualization
- Evidently: Drift detection
- Triton: Multi-model serving
π How to Use This Repository
- Start with LEARNING_PATH.md - Understand the structure
- Read the fundamentals - docs/llm_inference_fundamentals.md
- Work through topics in order - Each numbered topic builds on the last
- Experiment and modify - Donβt just run code, change it and learn
- Read the code comments - They explain the βwhyβ not just the βwhatβ
- Check solutions - See EXERCISE_SOLUTIONS.md for exercise answers
- Prepare for interviews - Review INTERVIEW_QA.md for common questions
π― Learning Goals
By completing this repository, youβll be able to:
- Understand how LLM inference works internally
- Build production-ready serving APIs
- Deploy models to Kubernetes
- Optimize for performance and cost
- Monitor and debug serving systems
- Handle model updates and drift
π€ Contributing
This is a learning repository. Feel free to:
- Add more examples
- Improve documentation
- Fix bugs
- Share your learnings
π License
MIT License - Feel free to use this for learning and teaching.
π Getting Started
- New to this? β Read
HOW_TO_START.mdfor step-by-step instructions - Want overview? β Read
LEARNING_PATH.mdto see all topics - Ready to code? β Start with
01_basic_serving/ - Need help? β Check
EXERCISE_SOLUTIONS.mdfor exercise answers - Interview prep? β Review
INTERVIEW_QA.mdfor common questions
Ready to start? Open HOW_TO_START.md and begin your journey! π
π Additional Resources
- Exercise Solutions:
EXERCISE_SOLUTIONS.md- Answers to all exercises - Interview Q&A:
INTERVIEW_QA.md- 23+ interview questions with detailed answers - Quick Reference:
QUICK_REFERENCE.md- Quick commands and tips - Complete Topics:
COMPLETE_TOPICS.md- Overview of all 12 topics - Industry Boilerplate: Each topic README includes industry-standard code and use cases
π Industry Focus
Each topic now includes:
- Why We Need This: Business and technical justification
- Industry Use Cases: Real-world applications (5+ examples per topic)
- Boilerplate Code: Production-ready, industry-standard implementations
- Company Examples: How major companies use these technologies
Topics updated with industry content:
- β Topic 1: Basic Serving (Customer support, content generation)
- β Topic 2: Docker (Multi-cloud, CI/CD, edge deployment)
- β Topic 3: Kubernetes (Large-scale platforms, enterprise ML)
- β Topic 5: vLLM (High-throughput APIs, cost optimization)
- β Topic 8: Monitoring (Production observability, incident response)