Inside Qwen3-4B's inference pipeline: 36 decoder blocks from tokens to logits
Abhishekcur · x · 2026-11-27
Abhishekcur walks through the full inference pipeline of Qwen3-4B (4.02B parameters), layer by layer, and plans to follow up with deeper dives into each component.
Preprocessing: the prompt goes through a chat template and BPE tokenizer to produce token embeddings.
The core is 36 Transformer decoder blocks, each performing: RMSNorm → Q/K/V projections → QK-Norm → RoPE applied to Q and K → KV cache update → Causal Grouped Query Attention → output projection + residual addition → RMSNorm → SwiGLU MLP → residual addition.
The output path is a final RMSNorm followed by the LM head producing logits. The breakdown is a handy map of the standard component stack (QK-Norm, RoPE, GQA, SwiGLU) in modern small open-source models.
Related event: Inside Qwen3-4B's Full Inference Pipeline(2 posts)→
More from Models
- _xjdr: With Neon and DSv4.1 Flash around, paying Anthropic is inexcusable — _xjdr · 2026-11-28
- Dev laments: two months without Opus 5.6 makes Claude feel stagnant already — casper_hansen_ · 2026-11-28
- Task-specific AI models can trade off where general models won't — but for how long? — nathanbenaich · 2026-11-28
- Auditing 260+ sessions: Opus 5.5 shows zero sabotage of ML research, just conservative behavior — casper_hansen_ · 2026-11-28
- ChatGPT Still Best for Everyday Tasks; Tester Says Gemini Can't See Amazon Prices — rickasaurus · 2026-11-28
- LlamaIndex Open-Sources OCRia-1 Weights, 4B SOTA OCR Model Runs on a Mac mini — llama_index · 2026-11-28