Lesson 127 — Advanced

Open-Weight Model Platforms

Open weights ka matlab yeh nahi ki GPU khud chalane padenge. Is lesson mein hum hosting ladder samjhenge — kisi aur ki API se lekar apne GPUs tak — aur har rung ka cost, latency, control aur effort ka trade-off dekhenge: model card trust se lekar vLLM ke continuous batching aur hardware sizing tak.

⏱ 20 min• Advanced• Capacity, Quotas & Cost

Open-weight hosting ladder

Kya hai?

Ek spectrum hai: kisi aur ki API call karo (serverless inference, per token), kisi aur ke GPUs pe apna serving stack chalao (GPU platform, per GPU-hour), ya apne hi servers pe chalao. Neeche sabse aasaan, upar sabse zyada control — aur responsibility.

Kab kaam aata hai?

Jab tum open model apne project mein laane ka decision lo — prototype ho, ya production with predictable load, ya data boundary non-negotiable ho. Har open-weight adoption ka pehla sawaal yahi hota hai ki model kahan chalega.

Kahan milta hai?

Model hubs (model card + licence), inference provider ke docs, GPU platform ke pricing pages, aur tumhare vLLM/Ollama deployment configs mein. Paper par decide nahi — actual serving setup isi se banta hai.

Ladder ka logic: jaise-jaise control badhta hai, billing per-token se per-GPU-hour badalti hai aur kaam tumhare sar aata hai. Serverless pe tum sirf call karo; GPU platform pe tumhara container chalta hai unke hardware pe; apne servers pe batching, scaling, updates sab tumhare. Koi rung "best" nahi — tumhare volume, latency budget aur boundary pe depend karta hai.

Rule of thumb: Shuruaat serverless inference se karo — zero infra, per token. Steady load ya custom tuning chahiye toh GPU platform pe jao. High utilisation ya data boundary compulsory ho toh apne servers. Har decision reversible rakho: client code same rakho, sirf endpoint config badlo.

Model hubs aur checkpoint trust

model card mein padhne wala sab kuch:
  base model / architecture   -> kis family ka model hai
  licence                     -> commercial use allowed? conditions kya hain
  gated access                -> pehle terms/approval, phir download
  intended use + limitations  -> tumhare use case se match karta hai?
  card ke eval numbers        -> apne task pe khud phir bhi test karo
  official repo vs re-upload  -> checkpoint ki provenance check karo
Card = contract: Intended use, limitations aur licence version — ye teeno apne records mein rakho (model name, revision hash, licence name). Baad mein "tumne model ko kaise verify kiya" wale sawaal ka yahi jawab hai.

Serverless inference vs GPU compute platforms

# Rung 1: serverless inference provider — per token, GPU kabhi dikhta nahi
resp = inference_provider.chat(
    model="open-model-id",
    messages=[{"role": "user", "content": "Ek chhota summary do"}],
)
# billing: input + output tokens
# scaling, batching, hardware: sab provider ka

# Rung 2: GPU compute platform — tum serving stack laate ho
# image tumhara (vLLM/TGI container), schedule/scale/bill platform ka
# billing: GPU-hour, utilisation tumhari zimmedaari
Decision: Custom tuning abhi nahi chahiye toh serverless. Latency targets, specific GPU types, custom endpoints ya per-hour predictability chahiye toh GPU platform. Prototype se production jaana aksar in do rungon ke beech hi travel karta hai.

Khud serve karna — vLLM, TGI, Ollama

# Local dev ke liye (chhota model, laptop pe)
ollama serve
ollama run <model-name>

# GPU box pe production-style serving
vllm serve <model-name> --port 8000
# TGI ka bhi wahi shape: model path + port + limit flags

# client: tumhara app dono se OpenAI-style endpoint se baat karta hai
Pehla test: Serving stack chalu karo, phir do test: ek request ki latency, aur 8 concurrent requests ki throughput. Agar throughput barabar scale nahi hui toh batching/parallelism set nahi hai — GPU kharch ho raha hai, kaam nahi.

Per-token vs per-GPU-hour — utilization point

# Dono hisaab apne numbers pe chalao — vendor example pe nahi
def per_token_cost(in_tok, out_tok, rate_in, rate_out):
    return in_tok * rate_in + out_tok * rate_out

def per_hour_cost(gpu_hours, rate_per_hour):
    return gpu_hours * rate_per_hour

# crossover: volume badhne par per-hour fixed cost per token girta hai
# sawaal hamesha yahi: mera actual monthly volume kitna hai
# aur mera utilisation (idle hours) kitna?
Honest math: Crossover nikalte waqt idle time mat bhoolo: 24x7 chalne wala GPU 100% utilised nahi hota. Effective cost = monthly bill ÷ actual tokens served — yahi number per-token rate se compare karo.

Cold starts, scale-to-zero aur hardware sizing

sizing ka basic math (weights ke liye):
  params (billions) x bytes-per-param = weight memory
  fp16 / bf16  -> ~2 bytes per param
  int8         -> ~1 byte
  int4         -> ~0.5 byte (quantized, quality validate karo)

upar se:
  KV-cache -> context length aur batch ke saath badhta hai
  overhead   -> runtime, activations, headroom

matlab: memory hi decide karta hai kaunsa GPU chahiye
Interview favourite: Q: "Ye model kaunsa GPU lega?" A: params × bytes-per-param se weights, phir KV-cache growth with context, phir headroom — aur phir bhi load test se validate. Ratte hue GPU naam dene se behtar hai ye teen-step math chalana.

Hosting ka asli kharcha — open vs closed apne task pe

Sabse bada trap: "open hai isliye sasta" ya "closed hai isliye behtar" — dono assumptions hain. Asli numbers tabhi aate hain jab tumne dono ko apne corpus, apne prompts aur apne latency budget pe chala kar dekha ho.

Decision rule: Chhota volume + zero ops toh serverless per token. Steady volume + control chahiye toh GPU platform. Bahut high volume ya boundary toh apne GPUs. Teeno ka comparison apne weekly traffic pe chalao, pricing page ke example pe nahi.

Exercise

Question: Model hub se checkpoint download se pehle licence, intended use aur limitations kahan padhi jaati hain?

Question: Serverless inference provider per token charge karta hai ya per GPU-hour?

Question: vLLM jaise servers jo har nayi request ko chal rahi batch mein add karte hain, us technique ka kya naam hai?

Question: 7 billion params wala model fp16 precision mein lagbhag kitne GB ka weights rakhta hai? Sirf number daalo.

Common mistakes

Desi example: Sawari vs apna vehicle — hosting ladder

Office jaana hai: Uber se jao (serverless, per ride), monthly rent pe car lo (GPU platform, per hour), ya apni car kharido (own servers). Apni car roz sasti padti hai — par maintenance bhi tumhara kaam hai:

text
kam traffic + kabhi kabhi   -> Uber (serverless, per token)
steady daily use            -> rental (GPU platform, per hour)
roz 24x7 + control chahiye  -> apni car (own servers)
sawaal: mileage kitna hai, aur maintenance kaun karega?
Interview angle — yahan se sawaal aate hain
  • Q: Open-weight hosting ladder ke rung batao? — Serverless inference provider, GPU compute platform, aur apne khud ke servers.
  • Q: Continuous batching kyun matter karta hai? — Nayi request running batch mein jaati hai, GPU idle nahi hota; naive serial loop mein utilisation gir jaata hai.
  • Q: Per-token aur per-GPU-hour kab jeette hain? — Kam/variable traffic pe per-token; high steady utilisation pe per-GPU-hour — crossover apne volume pe nikalte hain.
  • Q: Cold start kyun hota hai aur kaise kam karo? — Scale-to-zero pe pehli request pe model load hota hai; minimum instances rakho ya warm-up call maaro.
  • Q: Hardware sizing kaise karoge? — Params × bytes-per-param (weights), phir KV-cache growth with context, phir headroom — load test se validate.
Lesson complete?

Hosting ladder clear — ab tum open model ko sahi rung par chala sakte ho aur per-token vs per-GPU-hour ka math apne volume pe chala sakte ho. Agla lesson — Model Routers & LLM Gateways — mein dekhenge ek endpoint se kai providers ko kaise route karte hain.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course