TensoriumInterview preparation
← Home

Core concepts · 62 topics

A guided path through the ideas behind modern LLMs.

Read the stages in order: how text becomes a prediction, what happens inside the Transformer block, how a model learns, then serving, scale, and post-training. Every topic names what to know first, then gives the intuition, the math with concrete numbers, the common misconception, and a self-check. Already comfortable with the basics? Switch to By area and jump straight to a topic.

New to machine learning? Start here instead.

These topics work best as a refresher; they assume ideas like probability and loss. Begin with three short beginner lessons (tokens, embeddings, next-token prediction), then the visual walkthrough for attention and the Transformer.

Finish line: You can explain how text becomes a prediction and what training does to improve that prediction.

Topic 53 of 62 · Wider ML toolkit

GroupNorm: small-batch channel groups

Medium

How does GroupNorm avoid batch dependence, and when is it useful instead of LayerNorm or BatchNorm?

Practice choosing normalization methods · 8 scenarios ↓

1 · Start with the intuition

A high-resolution image model may fit only one or two examples per device. Instead of borrowing statistics from other examples, GroupNorm divides the feature channels into groups and pools values within each sample and group. The number of groups controls how much information each statistic shares.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Partition channels

Choose G dividing C. Each group contains C/G channels; group count is a hyperparameter, not the number of attention heads.

Next, we will look at: Pool within the sample. Move on when this operation makes sense.

Visualize which values share statistics

Derived toy tensor [B=2,T=3,C=4]. Select any cell: orange outlines your selection; teal cells contribute to its normalization statistics. Each cell shows input ↓ output. Training behavior, ε=10⁻⁵, γ=1, β=0; learned affine transforms are omitted.

Within each sample: channels in one group and all positions T.

Sample 0 · rows = positions T

c0c1c2c3t0t1t2

Sample 1 · rows = positions T

c0c1c2c3t0t1t2

Selected: sample 0, position 0, channel 0 · 6 values share statistics

One sample, one channel group, all positions

(x − mean_group,T) / √(var_group,T + ε)

μ=3.000, variance=2.667, √(variance+ε)=1.633

(1 − 3.000) / 1.633 = -1.225

Try selecting sample 0, then moving “Shift sample 1 only”: only BatchNorm changes sample 0’s output. A global offset cancels in the centered norms but not RMSNorm. Variance uses the population denominator; rounded displays may differ slightly from the full-precision calculation.

# x is [B,T,C]; C=4, G=2
nn.GroupNorm(G, C)(x.transpose(1, 2)).transpose(1, 2)

Which one do I need?

Normalization controls the scale seen by sublayers; it does not replace a task loss or an explicit generalization regularizer. Preserve the norm used by a pretrained checkpoint rather than swapping it at inference.

MethodChoose it when…Train → eval
BatchNormCNN feature maps with adequate batch statistics. Not the usual decoder norm: sequence-wide training statistics can leak future-token information.Usually frozen running mean/variance in eval; with track_running_stats=False, uses batch statistics even in eval.
LayerNormA standard Transformer choice when per-token centering and scaling are wanted; independent of batch size and sequence neighbors.Current token statistics in both train and eval; no running averages.
GroupNormCNNs and convolutional diffusion blocks with small batches. Standard sequence-wide GroupNorm is not a causal per-token decoder norm.Current sample/group statistics in both train and eval; no running averages.
RMSNormCommon in modern decoder-only Transformers when controlling activation scale without centering is sufficient; fewer normalization operations, not a guaranteed speedup.Current token RMS in both train and eval; no running averages.

For tensors [B,T,C], token-local LayerNorm(C)/RMSNorm(C) do not read future positions. BatchNorm1d and GroupNorm after transposing to [B,C,T] do. A causal attention mask does not undo leakage introduced by a sequence-wide normalization.