The Rabbit Hole / AI / Model architectures
Sarvam AI · Architecture mapSarvam 30B
A grouped-query attention MoE decoder with 18 routed layers after a dense opening.
Sarvam 30B, March 2026 · Sarvam release timeline
Inside Sarvam 30B
Inside grouped-query attention · Opening dense layer
Earlier context dimmed · current token bright · dashed regions contain cached entries.
Model-specific details
- Opening dense layer · 1 repetitions
- Dense feed-forward intermediate width 8192.
- Routed layers · 18 repetitions
- 128 routed SwiGLU experts of width 1024, six selected per token, plus an always-active shared SwiGLU expert of width 1024.
- Attention and positions
- 64 query heads share four KV heads of width 64 (16 queries per KV head). Q and K receive per-head RMSNorm before full-width RoPE (base 8,000,000). The fused QKV projection splits into 64 query, four key and four value heads.
- Memory
- Each of 19 layers stores four 64-coordinate keys and four 64-coordinate values per token: 512 values per layer per token. Full causal history; no sliding window.
Share the keys, route the feed-forward computation
A full attention history need not store the same number of key/value heads as query heads. Sarvam 30B uses 64 queries per token but only four keys and four values, so each KV head serves 16 query heads. The reference implementation normalises each query and key before rotating its 64 coordinates. The cache stores the four key and four value heads before expanding them for attention.
The first layer has an 8,192-wide dense SwiGLU network. The remaining 18 use six selected 1,024-wide routed experts and one shared expert of the same width. The router adds correction bias only when choosing experts; the original sigmoid scores determine their normalised weights. The routed sum is scaled before the shared output is added.
At 8,192 tokens and 16-bit precision the backbone KV cache holds 152 MiB (19 × 512 × 8,192 × 2 bytes), excluding allocator overhead.
Explore the components
- Embeddings: giving every token a meaning
- Residual connections: when more layers made things worse
- A whole LLM, layer by layer
- RMSNorm: keeping a token's scale under control
- Grouped-query attention (GQA): sharing keys and values in groups
- Mixture of experts (MoE): a big model that uses only part of itself
- Routing: selecting experts and weighting their work
- QK normalisation (QK-Norm) and soft-capping
- RoPE scaling: stretching context beyond the training length
- Attention, from scratch
- The KV cache: why LLMs remember every key and value
- RoPE: position as a rotation
- Transformer layers: attention is only half of what you need