Inside Qwen3-4B's inference pipeline: 36 decoder blocks from token to sampling

Abhishekcur · x · 2026-11-27

A high-level walkthrough of Qwen3-4B's (4.02B params) inference pipeline: prompt → chat template → BPE tokenizer → embeddings; 36 decoder blocks each running RMSNorm, Q/K/V projections, QK-Norm, RoPE, KV cache update, causal grouped query attention, output projection, residuals and SwiGLU MLP; then final RMSNorm → LM head → logits → sampling. Autoregressive generation loops by feeding tokens back while reusing the KV cache.

Related event: Inside Qwen3-4B's Full Inference Pipeline(2 posts)→

Original post →

More from Models

Models channel →