Scaling & Efficient Architectures
Time limit: 2 hours 30 minutes Total marks: 100 Instructions: Answer ALL three questions. Show full derivations. Calculators/handwritten pseudocode permitted. Partial credit awarded for correct reasoning.
Question 1 — Chinchilla Compute-Optimal Allocation (36 marks)
The Chinchilla parametric loss law is
where is parameter count, is training tokens, and . Training FLOPs are approximated by .
(a) [8] Using a Lagrange multiplier, derive the compute-optimal allocation: minimize subject to . Show that at the optimum
(b) [8] Hence show that the optimal parameter count scales as and tokens as , and derive the exponents in terms of . Verify and explain why this must hold.
(c) [6] For the published Chinchilla estimates , , compute and numerically to 3 decimal places. Comment on whether they are approximately equal and what practical guideline ("tokens per parameter") this supports.
(d) [8] A lab has trained a model with B parameters on T tokens. They obtain a compute budget increase of . Using the exponents from (c), by what factor should and each grow to stay compute-optimal? Give numeric factors.
(e) [6] Critically discuss one assumption in the FLOP model that breaks for a Mixture-of-Experts model with experts and top- routing. Give the corrected effective active-parameter count and its effect on the scaling calculation.
Question 2 — Mixture-of-Experts Routing & Load Balancing (32 marks)
Consider an MoE layer with experts and a top-1 gating network. For token the router produces logits and softmax probabilities . A batch has tokens.
(a) [6] Define = fraction of tokens routed to expert , and = mean router probability mass on expert . Write the Switch-Transformer auxiliary load-balancing loss . Prove that is minimized (over the simplex) when the load is uniform, and state its minimum value.
(b) [8] Prove that with equality iff for all . (Hint: relate to a Cauchy–Schwarz / variance argument, noting .)
(c) [8] With top-1 routing over experts and tokens, an expert-capacity with capacity factor is enforced. Compute the capacity per expert. If one expert receives 900 tokens, how many are dropped (overflow)? Explain the throughput vs. quality tradeoff of raising .
(d) [10] Write pseudocode (any language) for a top-1 gating forward pass that (i) computes routing, (ii) applies capacity with token dropping, and (iii) returns the combined output and the auxiliary loss. Annotate the tensor shapes at each step for a batch of tokens, model dim , and experts.
Question 3 — State-Space Models & Speculative Decoding (32 marks)
Part A — SSM recurrence (16 marks)
A discrete linear state-space layer (S4/Mamba-style) obeys
with state and scalar input .
(a) [6] By unrolling the recurrence from , show that , and identify the convolution kernel . Explain how this yields the parallel (convolutional) training mode vs. the sequential (recurrent) inference mode.
(b) [6] Given the continuous parameter (scalar, ) and step , the Zero-Order-Hold discretization gives and . For , , , compute and to 4 decimals. State the stability condition on for a bounded output and confirm it holds.
(c) [4] Contrast the inference-time memory and compute per token of this SSM against a standard attention layer with a KV-cache, as sequence length . Give asymptotic () expressions for both.
Part B — Speculative decoding (16 marks)
A small draft model proposes tokens per step; the large target model verifies them in parallel. Let = per-token acceptance probability (assume i.i.d. for tractability).
(d) [8] Show that the expected number of tokens accepted per verification step (including the one bonus/corrected token) is
Derive this from the geometric structure of accepting a prefix.
(e) [8] Let = cost ratio (draft-forward-pass cost / target-forward-pass cost per step), with one target verification pass per step. The expected speedup over vanilla autoregressive decoding is
For , , , compute to 3 decimals. State whether speculative decoding is beneficial here and identify the regime in where it fails to help.
Answer keyMark scheme & solutions
Question 1
(a) [8] Lagrangian . Stationarity:
- → [2]
- → [2]
Right-hand sides equal (), so Why: both marginal loss reductions must balance the same shadow cost of compute.
(b) [8] From (a): (∗). Using : So , giving Symmetrically (substitute ): . [2] Why it must hold: ; taking forces for dimensional consistency.
(c) [6] . [2] [2] They are close to each ⇒ Chinchilla guideline: scale and roughly equally with compute, giving an approximately fixed ~20 tokens per parameter rule of thumb. [2]
(d) [8] For compute: factor [3] factor [3] Check product ✓ (must equal compute factor). [2]
(e) [6] The model assumes all parameters are active per token. In top- MoE only of experts fire, so active params . [3] Training/inference FLOPs scale with , not , so an MoE gets more "loss-reducing capacity" (total params) per unit compute — the compute-optimal frontier shifts, and one should use in while counting quality against . [3]
Question 2
(a) [6] . Since it is (up to constant) a dot product of two probability vectors on the simplex, minimizing it drives mass away from correlating high-load and high-probability experts. The uniform point gives , so . [4] The differentiable surrogate uses the soft (gradient path) with the hard (detached), so gradients push toward uniform when experts are overloaded. [2]
(b) [8] Let be probability vectors (). By Cauchy–Schwarz, is not tight enough; instead use the tighter route: [2] Consider . Actually the clean bound: minimize subject to (as they converge under the balancing pressure). Then by Cauchy–Schwarz / power-mean, [4] with equality iff all equal . Since at balance , , equality iff . [2]
(c) [8] Capacity . [3] Expert with 900 tokens: drops tokens. [3] Raising reduces dropped tokens (better quality/less info loss) but increases per-expert buffer size → more compute & memory and padding waste (lower throughput). [2]
(d) [10] Pseudocode with shapes:
# x: [T, d]
logits = router(x) # [T, E]
probs = softmax(logits, axis=-1)# [T, E]
expert = argmax(probs, axis=-1) # [T] top-1 choice
gate = max(probs, axis=-1) # [T] gating weight
# load-balancing stats
f = bincount(expert, E) / T # [E] hard fraction
P = mean(probs, axis=0) # [E] soft mass
L_aux = alpha_aux * E * sum(f * P) # scalar
# capacity with dropping
cap = ceil((T/E) * c_f)
y = zeros([T, d])
for e in range(E):
idx = where(expert == e)[:cap] # keep first `cap`, drop rest
out = experts[e](x[idx]) # [<=cap, d]
y[idx] = gate[idx][:,None] * out # scaled combine
return y, L_aux
Marks: routing+softmax [3], f/P & aux loss [3], capacity/drop logic [2], gated combine + shapes annotated [2].
Question 3
Part A
(a) [6] Unrolling: , , and by induction . Then . [3] This is a convolution with kernel . Training: compute the full kernel and use FFT/parallel convolution over the whole sequence at once (parallel). Inference: keep the -dim state and update recurrently per token (sequential). [3]
(b) [6] . [2] . [2] Stability: ; here ✓, so the impulse response decays and output is bounded. [2]
(c) [4] SSM: memory (fixed state, independent of ), compute per token → in . [2] Attention + KV-cache: memory (cache grows with length), compute per token. [2] SSM wins asymptotically as .
Part B
(d) [8] Number of accepted drafted tokens if the first are accepted and the -th rejected: for ; all accepted with prob . On any rejection the target supplies 1 corrected token; if all accepted, 1 bonus token. So tokens . [3] This telescopes; equivalently the number of tokens is with $E=\sum_{