~/satyajit

Architectures

jsonmcp

The building-block architectures behind modern models — attention, MoE, state-space, positional, diffusion — each rated on how interesting and how unique it is, and many drawn as detailed distill-style diagrams.

sort12 of 12

Kimi K3 hybrid block + AttnRes

2026
AttentionEssentialinterest 5/5 · unique 5/5

A hybrid block — KDA (gated delta-rule linear attention) interleaved with Gated MLA (full attention) and Stable LatentMoE — plus Block Attention Residuals: each residual add reads a gated mix of every earlier block.

Kimi K3 · hybrid KDA / MLA / LatentMoE block + Block Attention Residuals (AttnRes)
OutputresidualbusKDAlinear attention+αStable LatentMoEsparse FFN+αGated MLAfull attention+αStable LatentMoEsparse FFN+αearlier blocksEmbeddingAttnRes: each α reads a gated mix of every earlier block on the bus

Read bottom‑to‑top. Kimi K3 stacks a hybrid block KDA (linear‑time attention), Gated MLA (full attention for exact recall) and Stable LatentMoE (shared + routed experts) — into the residual stream. The twist is Block Attention Residuals: every residual add pulls a gated read (α) off a bus carrying every earlier block’s output, not just the layer below — a learnable skip across the whole depth.

linear-attention · hybrid · cross-depth-residualread the explainer

Mamba / selective state space (SSM)

2023
SSM / RNNEssentialinterest 5/5 · unique 5/5

A selective state-space model: a fixed-size state carried by a linear-time recurrence whose transition parameters depend on the input, giving content-based routing of information — a leading attention-free alternative.

selective state space model (mamba) · recurrent scan
state  hₜ = Āₜ hₜ₋₁ + B̄ₜ xₜoutput  yₜ = Cₜ hₜh₀=0ĀₜĀₜĀₜx₁selectΔ, B, Ch₁y₁x₂selectΔ, B, Ch₂y₂x₃selectΔ, B, Ch₃y₃x₄selectΔ, B, Ch₄y₄Δ, B, C ← xₜ(input-selective)linear-time recurrence · input-selective · attention-free

Instead of attending over the whole sequence, Mamba scans it: a single fixed-size state is carried step to step by a linear recurrence, and the transition parameters (Δ, B, C) are computed from the input— so the model can selectively remember or forget while staying linear in length.

recurrent · selective · linear-time · attention-freepaper

Transformer (decoder block)

2017
TransformerEssentialinterest 5/5 · unique 5/5

The self-attention block that replaced recurrence: pre-norm → multi-head self-attention → residual, then pre-norm → MLP → residual, stacked N deep with a causal mask. Every architecture below is a variation on it.

pre-norm decoder-only transformer block
Inputtokens + positions → vectorsMixingtokens attend to the pastThinkingper-token MLP · d→4d→dstacked x N layersThecatsatoninput tokensToken Embedding + Positional EncodingLayerNormpre-normMulti-Head Self-Attentionh1h2h3h4causal (masked) attention over past tokensLayerNormFeed-Forward (MLP)d to 4d to d, per-tokenresidualresidualFinal LayerNormLM Headlogits over the vocabulary

Each block refines the token stream twice — self-attention lets positions mix, the MLP thinks per-token — and both sub-layers are wrapped in a normalize → transform → add residual, so the original signal (and its gradient) flows straight up through all N stacked layers.

self-attention · residual · foundationalread the explainer

Attention & KV-cache (MHA → MLA)

2019
AttentionEssentialinterest 5/5 · unique 4/5

How the Key/Value side collapses to shrink the KV cache: MHA (one KV per query head) → MQA (one shared) → GQA (a few groups) → MLA (a single compressed latent up-projected on the fly), at near-equal quality.

KV-head sharing · MHA → MQA → GQA → MLA
8 query heads (blue) share ever-fewer Key/Value heads (salmon) — shrinking the KV cacheMHA8 Q, 8 KV (1:1)8 query heads8 KV headsKV cache size8x cacheMQA8 Q, 1 KVKV8 query heads1 shared KVKV cache size1x cacheGQA8 Q, 2 KV groupsKV g1KV g28 query heads2 KV groupsKV cache size2x cacheMLA8 Q, latent KVc8 query headscompressed latent cup-projected to K, VKV cache sizetiny (latent)

The queries never change — only the Key/Value side collapses. Going MHA → MQA → GQA → MLA folds many KV heads into few, or into a single compressed latent, shrinking the per-token KV cache that dominates memory at long context while keeping quality nearly intact.

kv-cache · kv-sharing · mla · inferenceread the explainer

Mixture-of-Experts (sparse FFN)

2017
MoEEssentialinterest 5/5 · unique 4/5

Replace the dense FFN with many expert FFNs and a router that sends each token to only a few (plus an optional always-on shared expert). Parameters scale up while per-token compute stays flat.

mixture-of-experts FFN layer · router picks top-2
shared (always-on)routed, top-2idle (not selected)MoE outputgated weighted sumexperts (each a small FFN)SharedFFNalways onE1FFNidleE2FFNg = 0.66E3FFNidleE4FFNidleE5FFNg = 0.34E6FFNidleRouterlinear → softmax → keep top-2h · token

Only the top-2 routed experts (plus an always-on shared expert) fire for any given token, so a layer can hold a huge pile of parameters while each token pays the compute of just a few small FFNs.

sparse · router · conditional-computeread the explainer

Diffusion Transformer (DiT / MMDiT)

2022
DiffusionHighinterest 4/5 · unique 4/5

A diffusion denoiser that is a Transformer over image latent patches, conditioned on the timestep and text through adaptive LayerNorm; MMDiT carries text and image tokens in separate streams that attend jointly.

transformer denoiser · adaln conditioning · joint text+image attention
conditioningadaLN MLPpool(t, caption) → γ, βtimestep tcaptiontext promptadaLN γ,βDiT blockstacked × Nimage tokensown projtext tokensown projadaLN-Norm · scale γ, shift βJoint Self-Attentionimage + text tokens attend togetherMLPper-tokenMLPper-tokento next blockpredicted noise= ε (output)Patchify + Embedpatches → tokenscaption tokensnoisy latent z_t(3×3 patches)

A Diffusion Transformer denoises image latents by treating patches as tokens: a stack of blocks predicts the noise ε, while the timestep and caption are pooled through a small MLP that adaptively modulateseach block’s norm (adaLN). In the MMDiT variant, image and text tokens keep separate projections but mix through one joint self-attention.

diffusion · adaln · joint-attention · image-genread the explainer

Looped / recurrent-depth Transformer

2018
TransformerHighinterest 4/5 · unique 4/5

Reuse the same block for several passes to buy effective depth (and latent reasoning) without adding parameters — depth paid in FLOPs, not weights.

looped transformer · weight-tied recurrent depth
LM head → outputexit after ×KTransformer Blockself-attention + MLPweight-tied · sharedmergeinput embeddingslatent reasoning loop× K passes(same weights every pass)shared weights · depth paid in FLOPs, not parameters

A looped Transformer runs one shared block over and over — the output of a pass is fed back as the next pass’s input — so it gets the effective depth of a much taller model while storing the parameters of just a single layer. The extra reasoning is paid for in compute, not weights.

weight-sharing · recurrent-depth · latent-reasoningread the explainer

Masked-diffusion language model

2025
DiffusionHighinterest 4/5 · unique 4/5

A non-autoregressive language model that generates by iteratively unmasking tokens under bidirectional attention — denoising a fully masked sequence over several steps instead of left-to-right.

non-autoregressive · bidirectional · denoise a masked sequence over T steps
[M] maskedfilledjust unmaskedstep 0[M][M][M][M][M][M]all [M]step 1the[M][M]on[M][M]4× [M]step 2thecat[M]on[M]mat2× [M]step Tthecatsatonthemattext ✓unmask a fewre-predictunmask a fewre-predictunmask a fewre-predictbidirectional attentionthecatsatontheeach token attends both left & right (not causal)

Unlike a left-to-right autoregressive model that commits one token at a time, a masked-diffusion LM starts from an all-[M] sequence and, under bidirectionalattention, unmasks a few tokens each step and re-predicts the rest — refining the whole sentence in parallel over T steps.

diffusion · non-autoregressive · bidirectionalread the explainer

Rotary Position Embedding (RoPE)

2021
PositionalHighinterest 4/5 · unique 4/5

Encode position by rotating each query/key vector by an angle proportional to its index, so the attention score depends only on the relative offset. The de-facto positional scheme in modern LLMs.

rotary position embedding (rope) · position = rotation
position m rotates the query/key vector by an angle ∝ mthe rotation grows with position — here θ = m · 25°m = 1 · 25°m = 2 · 50°m = 3 · 75°+25°+25°the dot product of two rotated vectors depends only on (m − n)50°k · pos nq · pos mattention sees only relative distance⟨ q(m), k(n) ⟩ = g(q, k, m − n)the score depends only on the relative offset(m − n) — never on absolute position m or n.

RoPE encodes a position by rotating each pair of feature dimensions by an angle proportional to that position. Because a dot product only cares about the angle between two vectors, attention ends up reading the relative distance (m − n) for free.

relative · rotation · positionalread the explainer

Mixture-of-Depths

2024
OtherNotableinterest 3/5 · unique 4/5

A per-layer router lets each token either pass through the block or skip it via the residual, so compute is spent only where needed and effective depth becomes token-dependent under a fixed budget.

mixture-of-depths · per-token skip routing
tokens123456sequencerouter 1top-2 of 6skip · residual (bypass)block 1self-attn + MLPprocessedrouter 2top-2 of 6skip · residualblock 2self-attn + MLPprocessedrefined tokens123456outputsselected → through block (pays FLOPs)skipped → residual bypass (free)per-token, per-layer compute — only selected tokens pay

A router at every layer keeps only a fixed fraction of tokens for the block; the rest skip it through the residual connection. Because the selected set changes layer to layer, each token gets a different effective depth— and the network spends compute only where it helps.

conditional-compute · token-routing · dynamic-depthpaper

Bidirectional encoder (BERT)

2018
TransformerNotableinterest 4/5 · unique 3/5

An encoder-only stack with full (non-causal) attention, pretrained by masking tokens and predicting them — so every position sees the whole sequence. Still the default for embeddings and classification.

bidirectional encoder (bert) · masked language model
predict [MASK]→ “sat”MLM Headsoftmax over vocabularyencoder block × NAdd & NormFeed-Forward (MLP)per-token · d → 4d → dAdd & NormMulti-Head Self-Attentionbidirectional · no causal maskresidualresidualToken + Positional Embeddingsbidirectional — every token sees the whole sequence (no causal mask)thecat[MASK]onmat

BERT is a Transformer encoder: with no causal mask, every position attends to the whole sequence at once, so the hidden state for [MASK] is built from context on both sides. The MLM head then reads that position and predicts the missing word.

masked-lm · bidirectional · representationspaper

Encoder–decoder (seq2seq)

2017
TransformerNotableinterest 4/5 · unique 3/5

Two stacks: an encoder that reads the source bidirectionally, and a decoder that generates while cross-attending into the encoder's representations. The seq2seq form behind translation, T5 and BART.

encoder–decoder transformer (seq2seq) · t5 / bart
encoder × Ndecoder × NAdd & NormFeed-ForwardAdd & NormSelf-Attentionbidirectionalinput embedding + posderHundbelltsource · GermanAdd & NormFeed-ForwardAdd & NormCross-AttentionK,V from encoderAdd & NormMasked Self-Attentioncausal · past onlyoutput embedding + pos[BOS]thedogtarget · shifted rightLinear → Softmaxoutput: barksencoder output → K,V

The encoder reads the whole source at once and produces a set of vectors; the decoder generates the target left-to-right, and at each step its cross-attention queries that encoder output — the one wire that turns two stacks into a translator.

cross-attention · seq2seq · translationread the explainer