Your LLM Crashed in Production. Here’s Why
Your state-of-the-art LLM works perfectly in testing. The results are flawless. But the moment you deploy it in production, it crashes…
Your LLM Crashed in Production. Here’s Why
Your state-of-the-art LLM works perfectly in testing. The results are flawless. But the moment you deploy it in production, it crashes. Why? Because it demands 80GB of GPU memory and your server only has 24GB.
This is where quantization saves the day. By reducing the precision of numbers inside the model, you can run it on smaller, cheaper hardware sometimes at 4× lower memory cost while keeping performance nearly identical.
What Is Quantization?
Quantization compresses model numbers from fp16/fp32 into int8/int4. You trade a tiny amount of numeric precision for big wins in memory and speed.
- 8-bit → ~2× memory reduction vs fp16
- 4-bit → ~4× memory reduction on weights (often weight-only)
Where it applies:
- Weight-only PTQ (post-training): AWQ, GPTQ
- Activations too: LLM.int8, SmoothQuant (W8A8)
Before/After: Memory & Speed (for a 7B model)
Memory Usage: fp16 vs int8 vs int4

Inference Speed: fp16 vs int8 vs int4

Types of Quantization

AWQ Deep Dive
Activation-aware Weight Quantization (AWQ) identifies salient (important) weights/channels to keep more precise while quantizing the rest more aggressively.
- Strong practical trade-off at 4-bit
- Works well across many LLM layers

GPTQ Deep Dive
GPTQ (Gradient Post-Training Quantization) performs row-wise, second-order-aware rounding to minimize layer error.
- Often the best 4-bit accuracy
- Heavier setup and calibration than simple RTN

Choosing Your Precision
Use this to pick 4-bit vs 8-bit and decide whether to quantize activations.

Quantization Pipeline
From model to production with evaluation loops

Quick Start
8-bit (LLM.int8) with bitsandbytes
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
model_id = "meta-llama/Llama-2-7b-hf"
bnb = BitsAndBytesConfig(load_in_8bit=True)
model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb, device_map="auto")
tok = AutoTokenizer.from_pretrained(model_id)
4-bit GPTQ (pre-quantized checkpoint)
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "TheBloke/Llama-2-7B-GPTQ"
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
tok = AutoTokenizer.from_pretrained(model_id)
4-bit AWQ (pre-quantized checkpoint)
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "TheBloke/Llama-2-7B-AWQ"
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
tok = AutoTokenizer.from_pretrained(model_id)
When To Use What

Performance Testing Workflow
Make perf decisions with real data, not vibes.

Hardware Considerations (What Fits Where)

Real-World Benchmarks (Example Setup)
- Model: 7B parameter LLM
- Context: 1024 tokens, batch size 1
- Hardware: Single 24GB GPU (e.g., L4/A10)
- Results (representative): see Memory/Speed charts above
- Accuracy proxy: lm-eval harness (perplexity / task score) on a small validation slice
Cost Analysis (Cloud Savings)
- A100 80GB: roughly $3–$5/hr
- A10/L4 24GB–24GB class: roughly $0.6–$1/hr
If 4-bit weight-only lets a 30B model fit on an A10/L4 instead of an A100, running 1,000 hours could look like $700 vs $3,300+ — a multi-thousand-dollar saving with minimal accuracy loss.
“Quantization can cut your cloud bill by up to 75% while keeping accuracy almost intact.”
Common Pitfalls & Fixes
- “4-bit is always faster.” Not if kernels aren’t optimized; test on your hardware.
- Aggressive activation quantization without LLM.int8/SmoothQuant → quality cliff.
- Per-tensor scaling everywhere → prefer per-channel for sensitive layers.
- Ignoring KV cache → activations & cache can dominate memory at long contexts.
- No calibration set → use a small, representative slice of real traffic.
Tools and Libraries
- bitsandbytes (8-bit, 4-bit)
- AutoGPTQ (GPTQ quantization)
- AutoAWQ (AWQ quantization)
- Hugging Face Transformers Quantization Docs
- QLoRA Paper
- GPTQ Paper
- AWQ Paper
메타데이터
- post_id
- 359a4a2016c2
- slug
- your-llm-crashed-in-production-heres-why-359a4a2016c2
- url
- https://medium.com/@rkuma18/your-llm-crashed-in-production-heres-why-359a4a2016c2
- canonical_url
- https://medium.com/@rkuma18/your-llm-crashed-in-production-heres-why-359a4a2016c2
- author_url
- https://medium.com/@rkuma18
- status
- ok
- fetched_at
- 2026-06-25 07:00:49