M9-027M9: Senior ML & AI System DesignLLM Serving, RAG & Agent SysDesignHard
⚡Flashcard Drill➔Mastery:

Design a Distributed LLM Serving Cluster with Prefill-Decode Disaggregation

🎯 Active Recall Self-Check (Draft First, Verify After)
Login-free practice tracker: recall core answer, audit pitfalls, and log review status.
Step 1 · Draft your concise answer & assumptions
Step 2 · Check Pitfalls & Follow-up Inquiries
Next: M9-028 →
📐 Mathematical Definition
TTFTPrefill∝Lin⋅FmodelFLOPs,TPOTDecode∝Mweights+MKVBWHBM\text{TTFT}_{\text{Prefill}} \propto \frac{L_{\text{in}}\cdot F_{\text{model}}}{\text{FLOPs}},\quad \text{TPOT}_{\text{Decode}} \propto \frac{M_{\text{weights}}+M_{\text{KV}}}{\text{BW}_{\text{HBM}}}
⚡ One-Sentence Core Answer
Physically decouple compute-bound Prefill pools from HBM-bandwidth-bound Decode pools, transferring KV states over RDMA/NVLink to eliminate TTFT/TPOT interference.

📌 Key Takeaways

  • •
    L1 Interference Root Cause: co-located long-context prefills stall co-batched decode steps, spiking TPOT 5-10x
  • •
    L2 Pool Specialization: optimize Prefill nodes for peak Tensor-Core TFLOPS and Decode nodes for high-batch HBM bandwidth
  • •
    L2 Layerwise KV Transfer: overlap layer computation with GPUDirect RDMA/NVLink KV block streaming (Mooncake/NIXL style)
  • •
    L3 Elastic P:D Ratio: auto-scale Prefill-to-Decode node ratios dynamically from live input/output token ratios plus prefix-aware routing

📐 Mathematical Derivations

Per-layer KV payload is 2nkvdhLinb2 n_{\text{kv}} d_h L_{\text{in}} b; pipelining layerwise transfer hides network latency whenever tcomp(l)≥KV(l)/BWRDMAt_{\text{comp}}^{(l)} \ge \text{KV}^{(l)} / \text{BW}_{\text{RDMA}}.

🏭 Production Trade-offs

1) Route short prompts (<512 tokens) to colocated fallback pools to avoid RDMA handshake overhead; 2) Pre-allocate KV slots on Decode before starting Prefill.
⚠️ Common Interview Pitfalls
  • ✕
    Waiting until full prefill completion before sending KV blocks instead of pipelining layer-by-layer
  • ✕
    Missing decode memory reservation causing incoming KV transfers to trigger preemption thrashing
🎯 Interviewer Follow-up Inquiries
  • ?
    How do you compute the crossover prompt length where PD disaggregation pays off over slower Ethernet?
  • ?
    Where should Radix prefix cache live in multi-turn agent workloads—Prefill, Decode, or tiered DRAM?
⚡
Test muscle memory on this topic via 3-Layer Flashcards
Active Recall: Mentally formulate Prompt ➔ Math Derivation ➔ Benchmark Implementation in 3 minutes.
🎯 Drill This Card Now➔
📚

Associated Knowledge Base Guides & Mindmaps

← PreviousM9-026: Design a 100K-QPS Two-Tower + DLRM High-Concurrency RecSys Cascade📋 Back to BankNext →M9-028: Design a Billion-Scale Multimodal Video Frame-Level Embedding Search System