Scaling & Efficient Architectures
Time limit: 45 minutes Total marks: 60 Instructions: Show all derivations. Where code is requested, write it from memory (pseudocode acceptable if semantically correct). Use for math.
Q1. Chinchilla compute-optimal derivation (12 marks)
The Chinchilla loss model is where = parameters, = training tokens, and total compute is approximated by .
(a) Set up the constrained optimization to minimize subject to fixed compute , and derive the relation between the optimal and (express the ratio of the two variable loss terms at the optimum). (6)
(b) Show that and and give in terms of . Verify . (4)
(c) For the Chinchilla fitted values , state the numeric exponents and explain in one sentence what this means for scaling data vs parameters. (2)
Q2. MoE routing & load balancing (12 marks)
(a) Write from memory the top- gating computation for a token over experts: the router logits, softmax, top- selection, and the combined output. (5)
(b) Define the auxiliary load-balancing loss used in Switch Transformer style routing. Give the formula with (fraction of tokens dispatched to expert ) and (mean routing probability to expert ), and explain why both terms are needed rather than penalizing alone. (5)
(c) A batch has 4 tokens routed (top-1) to experts with these dispatch fractions and mean probs over experts. Compute the aux loss with . (2)
Q3. KV-cache memory & speculative decoding (12 marks)
(a) Derive the KV-cache memory (in bytes) for a decoder with layers, hidden dim , heads, sequence length , batch , stored in fp16. State the formula and explain each factor. (4)
(b) A model has , , , , fp16. Compute the KV-cache size in GB. (3)
(c) Explain speculative decoding: how a small draft model and large target model interact, and state the accept/reject rule that guarantees the output distribution equals the target model's distribution. (5)
Q4. Explain-out-loud: parallelism & sharding (12 marks)
Answer concisely (2–4 sentences each):
(a) Contrast tensor parallelism vs pipeline parallelism — what dimension of the model is split, and what is the main communication cost of each. (4)
(b) Explain the three ZeRO stages and what each shards across data-parallel ranks. (4)
(c) FSDP: what happens to a layer's parameters in the forward pass (all-gather / free) and why this trades communication for memory. (4)
Q5. State-space models (7 marks)
(a) Write the continuous linear SSM equations and the discretized recurrence. State why the recurrence can also be computed as a convolution, giving the kernel form. (4)
(b) In one sentence each: what is the key innovation of Mamba (selective SSM) over S4, and why does it break the simple convolution view? (3)
Q6. Emergent abilities (5 marks)
Define "emergent ability" in the scaling context. Give one concrete example, and state the main critique (from the "Are emergent abilities a mirage?" argument) about why some emergence may be an artifact of the chosen metric. (5)
Answer keyMark scheme & solutions
Q1 (12 marks)
(a) Minimize s.t. fixed. (1) Substitute : (1) Differentiate and set to 0: (2) So , i.e. at the optimum (2) (The two variable loss terms are balanced in proportion .)
(b) From the balance: with gives , so : (2) (1) Thus , and . ✓ (1)
(c) With : . (1) Meaning: parameters and tokens should be scaled equally with compute — roughly double data whenever you double model size (the Chinchilla correction to earlier param-heavy scaling). (1)
Q2 (12 marks)
(a) For token , router weights : (1)
- logits (1)
- gate probs , (1)
- top-: keep set ; renormalize (1)
- output where is expert 's FFN. (1)
(b) (2) where (dispatch fraction, non-differentiable) and (mean soft prob, differentiable). (1) Why both: carries the true load but has no gradient (it's an argmax count); is the differentiable surrogate. Multiplying makes overloaded experts receive gradient pressure to lower their routing probability. Penalizing alone gives no gradient; penalizing alone ignores actual dispatch imbalance. (2)
(c) . (1) . (1)
Q3 (12 marks)
(a) KV-cache stores K and V for every layer, every token, every head: (2) Factor 2 = keys + values; so summing over heads = full hidden dim; fp16 = 2 bytes. (2) (So for fp16.)
(b) bytes bytes GB (using ). (3)
(c) Speculative decoding: a cheap draft model autoregressively proposes tokens; the target model then scores all in a single parallel forward pass. (2) Accept/reject rule: for proposed token with draft prob and target prob , accept with probability . (2) On the first rejection, resample from the normalized residual distribution ; this makes the marginal output distribution exactly the target's, while amortizing the target's cost over several tokens. (1)
Q4 (12 marks)
(a) Tensor parallelism splits the model within a layer — e.g. weight matrices sharded across the hidden/head dimension; requires an all-reduce per layer (high-bandwidth, intra-node). Pipeline parallelism splits across layers into stages; main cost is pipeline bubble/idle time and point-to-point activation transfers between stages. (4) (2 each)
(b) ZeRO-1 shards optimizer states; ZeRO-2 additionally shards gradients; ZeRO-3 additionally shards parameters — each rank holds only its slice and gathers others on demand. (4)
(c) In FSDP, each rank stores only a shard of a layer's params. Before the forward of that layer, an all-gather reconstructs the full weights; after use they are freed (re-gathered again in backward). This holds full weights only momentarily, cutting memory to , at the cost of extra all-gather communication each pass. (4)
Q5 (7 marks)
(a) Continuous: . (1) Discretized (step ): with , . (1) Because are time-invariant, unrolling gives , a convolution with kernel (1) (1)
(b) Mamba makes input-dependent (selective), so the model can gate/forget based on content. (1.5) This makes the SSM time-varying, so no longer factors into a fixed kernel — the convolution view breaks, and Mamba instead uses a hardware-aware parallel scan. (1.5)
Q6 (5 marks)
An emergent ability is a capability absent in smaller models that appears (often sharply) once scale crosses a threshold, not predictable by smooth extrapolation from small models. (2) Example: few-shot arithmetic / multi-step reasoning / instruction following appearing only past some parameter count. (1) Critique (Schaeffer et al., "mirage"): apparent sharp emergence can be an artifact of discontinuous/nonlinear metrics (e.g. exact-match accuracy that is 0 until the whole answer is right); switching to a smooth metric (token edit distance, log-likelihood) shows steady, predictable improvement — the ability was scaling continuously all along. (2)
[
{"claim":"Chinchilla optimal exponents a=b=0.5 for alpha=beta=0.34, and a+b=1",
"code":"alpha=Rational(34,100); beta=Rational(34,100); a=beta/(alpha+beta); b=alpha/(alpha+beta); result=(a==Rational(1,2)) and (b==Rational(1,2)) and (a+b==1)"},
{"claim":"MoE aux loss = 1.3 for given f,P,E=4,alpha=1",
"code":"f=[Rational(1,2),Rational(1,4),Rational(1,4),0]; P=[Rational(4,10),Rational(3,10),Rational(2,10),Rational(1,10)]; E=4; alpha=1; L=alpha*E*sum(fi*Pi for fi,Pi in zip(f,P)); result=(L==Rational(13,10))"},
{"claim":"KV cache = 4 GB for L=32,d=4096,S=8192,B=1,fp16 (bytes=4*B*L*S*d)",
"code":"B=1; L=32; S=8192; d=4096; by=4*B*L*S*d; result=(by==2**32) and (by/2**30==4)"}
]