भाग 3 · डिप्लॉय और उपयोग करें अध्याय 7
Inference aur deployment
Decoding aur sampling, KV cache, quantization, serving, continuous batching aur speculative decoding: LLM ko tez aur sasta chalana, aur latency, throughput aur memory ke beech trade-off samajhna।
यह अध्याय पूरा करने पर आप
- Batayein temperature, top-k, top-p distribution ke kaun sa hissa badalte hain, aur alag tasks ke liye decoding parameters chunein।
- Ek model ka KV cache memory निकालें, aur samjhayein yeh concurrency kyun tay karta hai।
- INT8, INT4, GPTQ aur AWQ ke trade-off तुलना करें, aur quantization experiments mein error ke srot padhein।
- TTFT, TPOT aur throughput se ek inference service describe karein, aur continuous batching aur paged attention hardware utilization kaise badhate hain, samjhayein।
- Batayein speculative decoding lossless kyun hai, aur speedup kis par nirbhar karta hai।
Model interface se pehla sampark karne ke liye pehle pehla inference service chalayein, aur ek request ka poora raasta apne computer par samjhein।
Ek baar train karo, karodo baar infer karo। Asli business mein inference ki lagat aksar training se bahut zyada hoti hai, isliye is adhyay ka content lagbhag tay karta hai ki ek LLM application munafey de sakti hai ya nahi।
Yeh adhyay “ek request kaise process hoti hai” ke kram mein phailta hai: pehle decoding ka step waqai kya karta hai, phir usse tez karne wala cache, phir model ko chhota karne wali quantization, aur aakhir mein ek hi hardware par kai requests rakhne wali serving systems aur speculative decoding; cache aur serving ke beech prefix caching aur PD separation khada hai — pehla requests ke beech repeat hone wali computation ek hi baar karata hai, doosra do alag resource profile wale phases ko apni-apni jagah deta hai। Aage compute aur systems mein padha roofline aur bandwidth is adhyay ki har optimization ko samajhne ki kunji hai: decoding bandwidth-bound hai, isliye lagbhag sabhi optimizations har token ke liye le jaaye jaane wale bytes ghataane ki koshish hain।
अध्याय मार्ग
- 7.1
Pehla inference service: model function ko HTTP requests lena
Python se apne computer par ek inference endpoint chalayein, JSON bhejein aur status code padhein। Toy decoder se samjhein model, runner, server aur client kya karte hain, phir streaming responses aur deployment ki taraf badhein।
पूर्वापेक्षाएँ4.1बड़े मॉडलों का hardware परिचय
- 7.2
Decoding aur sampling: temperature, Top-k, Top-p aur beam search
Decoding probability ko token banata hai: greedy sabse bada chunta hai, temperature dhaar badalti hai, Top-k/Top-p tail kaatte hain, beam search kai candidates rakhta hai; yeh output ki certainty, diversity aur quality tay karte hain।
पूर्वापेक्षाएँ2.2भाषा मॉडलिंग से अगले टोकन की भविष्यवाणी तक
- 7.3
KV cache aur inference performance optimization
Samjhein KV cache autoregressive decoding ke repeat computation kaise ghataata hai, aur latency, throughput, memory aur service scheduling ke beech ke trade-off systematically pakdein।
पूर्वापेक्षाएँ3.2Transformer attention तंत्र की शुरुआत
- 7.4
Prefix caching aur PD separation: repeat computation ek hi baar
Prefix caching system prompt, multi-turn history aur shared docs ki KV cache requests ke beech reuse karta hai; RadixAttention aur LMCache reuse ka organization solve karte hain. PD separation prefill aur decode ko alag hardware par rakhta hai - kab faydemand, DistServe batata hai।
पूर्वापेक्षाएँ7.3KV cache aur inference performance optimization
- 7.5
Model quantization: INT8, INT4, GPTQ aur AWQ ka siddhant aur measurement
Quantization weights, activations ya KV cache ko kam bits mein rakhta hai. Yeh page memory aur bandwidth ka hisaab lagata hai, Qwen2.5-0.5B par INT8 aur INT4 ki perplexity naapta hai, SmoothQuant, AWQ, GPTQ aur KV cache quantization implement karta hai, aur selection table deta hai।
पूर्वापेक्षाएँ7.3KV cache aur inference performance optimization
- 7.6
LLM inference service: latency metrics, measurement aur engine selection
Inference service ko first-token latency, token interval aur throughput ek saath manage karna hota hai. Yeh page llama.cpp se naapta hai ek request ka time kahan jaata hai, warm-up kyun zaroori hai, aur llama.cpp, Ollama, vLLM, SGLang ki positioning aur metrics compare karta hai।
पूर्वापेक्षाएँ7.3KV cache aur inference performance optimization7.1Pehla inference service
- 7.7
Continuous batching aur PagedAttention: service kai requests ek saath kaise
Decode har step saare weights padhta hai; batching throughput lagbhag free badhata hai. Yeh page llama.cpp se concurrency, continuous batching, KV cache paging aur prefix caching naapta hai, aur dikhata hai service kai requests kaise serve karti hai।
पूर्वापेक्षाएँ7.3KV cache aur inference performance optimization7.6LLM inference service
- 7.8
Speculative decoding
Speculative decoding chhote draft model se tokens guess karwata hai, bada model ek forward pass se verify karta hai; accept aur correction sampling rules output distribution same rakhte hain. Yeh page expected speedup derive karta hai aur interactive widget deta hai।
पूर्वापेक्षाएँ7.2Decoding aur sampling7.3KV cache aur inference performance optimization