Qwen Model Architecture: From Transformer to MoE, What Developers Should Understand
Qwen Model Architecture: From Transformer to MoE, What Developers Should Understand
Many developers use Qwen without asking how it is built internally. That is fine for most scenarios, but when you need to choose a quantization tier, judge VRAM requirements, or understand why the local deployment bar for 27B and 2.4T differs so much, a bit of architecture knowledge saves a lot of trial and error. This article skips the math and explains the core components of Qwen's architecture in plain language.
The short version
The Transformer is Qwen's skeleton: attention decides "what to look at", KV cache handles "what to remember", RoPE handles "position", and layer count determines depth. MoE is an upgrade: each token only goes through a subset of experts, so a 2.4T model has far lower inference overhead than its total size suggests. With these concepts, VRAM planning and quantization choices are no longer a black box.
Transformer is Qwen's skeleton
The Qwen family is built on the Transformer architecture. The core idea: the model does not process tokens sequentially; instead, each token "sees" all other tokens simultaneously, and attention decides which information matters most.
This design, introduced in 2017, became the standard for large language models, and Qwen follows it completely. Understanding a few core Transformer components unlocks most of Qwen's architecture parameters.
Why Transformer suits language models
Transformer's parallelism is far stronger than RNN/LSTM β RNN must process one token at a time, while Transformer can process the whole sequence at once, which is extremely GPU-efficient. This is why nearly all large models use Transformer.
Attention: what the model is "looking at"
Attention is the core of Transformer. It works like this:
Each token computes a relevance score against every other token in the sequence. High-relevance tokens get high weight; low-relevance tokens get low weight. The model's response for each token is a weighted combination of all other tokens.
In Qwen's architecture, attention uses three matrices: Q (query), K (key), V (value):
Q: what the current token is askingK: what other tokens are providingV: the content of other tokens
Q and K are dot-producted to get relevance scores, then V is weighted-summed. This is "attention".
Multi-head attention
Qwen uses multi-head attention, splitting attention into multiple heads, each focusing on different features. One head might focus on syntax, another on semantics. The outputs of multiple heads are combined, so the model can attend to multiple kinds of information simultaneously.
KV cache: the memory key for long contexts
KV cache is the key to understanding long-context VRAM usage.
When the model processes a sequence, it stores the K and V matrices of previous tokens, so that when generating the next token, it can compute attention over the whole history. The longer the sequence, the larger the KV cache, and the higher the VRAM usage.
This is why long-context deployment needs more VRAM β not because the model itself gets bigger, but because KV cache grows with context.
KV cache is the hidden cost of long contexts
A 27B model at 4096 context might use a few hundred MB of KV cache; at 32768 context it might use several GB. This is why the answer to "why does longer context eat more VRAM" is not the model getting bigger, but KV cache expanding.
RoPE: letting the model understand position
The Transformer does not inherently know where a token is in the sequence. RoPE (Rotary Position Embedding) is a method that gives the model relative position awareness.
RoPE works by applying a "rotation" to the position encoding, so the model can distinguish "cat chases dog" from "dog chases cat". The farther apart two tokens are, the larger the encoding difference, and the stronger the model's perception of relative distance.
Qwen has used RoPE since early versions, and this is one reason it stays stable in long contexts.
Layers and heads: depth and width
In Qwen's architecture parameters, layer count and attention head count are the most intuitive:
| Parameter | Meaning | Impact |
|---|---|---|
| Layers | How many Transformer layers are stacked | More layers = deeper model, can handle more complex logic |
| Heads | How many attention heads per layer | More heads = more features each layer can focus on |
| Hidden dimension | Size of each layer's vectors | Larger = more capacity |
These parameters jointly determine the model's "capability ceiling". Qwen3.8-27B and 2.4T-A95B have completely different architectures β the latter's total parameter count is about 100x larger, so the design is radically different.
Parameter count is not capability
2.4T-A95B has about 100x the total parameters of 27B, but only about 95B per token active, which is about 3.5x of 27B. This means the inference compute gap is far smaller than the total parameter gap β this is the core value of MoE.
MoE: changing the computation path, not the total
MoE (Mixture of Experts) is the architecture used in Qwen flagship models like 2.4T-A95B. The core idea: split the model into several "expert" sub-networks, and route each token through only a small subset of them.
A dense model processes every token through the full forward computation; a MoE model routes each token to a few selected experts. This means:
- Total parameter count is huge (knowledge capacity is large)
- Per-token active parameters are small (inference overhead is controlled)
- VRAM usage is determined by active parameters, not total parameters
This is why 2.4T-A95B's inference overhead is far lower than a same-total-parameter dense model. A95B means roughly 95B parameters are activated per token, and that is what actually determines compute.
The first MoE deployment misconception
Many people assume a 2.4T model must be slow to infer. In reality, MoE inference speed mainly depends on active parameters (A95B), not total parameters (2.4T). FP8 further compresses VRAM, making deployment feasible.
What architectural differences mean in deployment
After understanding architecture, you can make smarter deployment decisions:
| Architecture feature | Deployment implication |
|---|---|
| Dense 27B | All parameters participate in inference; VRAM demand is stable |
| MoE 2.4T-A95B | Only ~95B runs per token, but full 2.4T weights must be stored |
| FP8 quantization | Weight size halved, lowering deployment threshold |
| Large KV cache | Long-context deployment needs more VRAM |
A common misconception is "a 2.4T model can never run". In reality, MoE's inference overhead is far below a same-total dense model, and FP8 further compresses weights. What really determines deployment viability is active parameters and KV cache, not total parameters.
How architecture choices affect your selection
Understanding architecture helps you select the right Qwen model and tier:
- If you need low latency: pick a dense model with fewer active parameters (Qwen3.8-flash)
- If you need high quality for complex reasoning: pick a dense flagship (Qwen3.8-max) or a large MoE with high active parameters (Qwen3.8-2.4T-A95B)
- If you need to run locally: pick a model whose active parameters fit your VRAM; a 3B-active MoE is friendlier than a 95B-active one
- If you need long contexts: check the KV cache size at your target context length, not just the model size
Architecture knowledge is not academic β it directly determines what your deployment will cost, what VRAM it will need, and how you should quantize.
Selection advice: start from architecture
Apply architecture knowledge back to selection:
- Everyday chat, code completion: Qwen3.8-flash, dense and lightweight, low latency
- Complex reasoning, long documents: Qwen3.8-max, dense flagship, quality-first
- Local MoE deployment: Qwen-AgentWorld-35B-A3B, 35B total, 3B active, VRAM-friendly
- Server-side flagship MoE: Qwen3.8-2.4T-A95B-FP8, needs large-memory nodes
When selecting, do not just read the parameter name β look at architecture (dense vs MoE) and active parameters (A95B vs 3B).
FAQ
Are more layers always better?
Can KV cache be compressed?
What is the difference between RoPE and traditional position encoding?
Is more MoE experts always better?
Does understanding architecture help in daily use?
Related reading
- Qwen3.8-2.4T-A95B Deep Analysis β flagship MoE deployment details
- Which Qwen Model to Use β from architecture to selection
- Qwen KV Cache and Long Contexts β KV cache deep dive
- Qwen Cost Optimization β reducing inference cost
- Qwen GGUF Local Deployment Primer β local deployment basics