Explore the research collection
2 entries · Follow this search
- Paper
A Circuit for In-Context Learning
A complete, causally traced circuit for in-context learning in its cleanest setting: few-shot sentence classification with ARBITRARY labels, where the label mapping cannot have been memorized, so the learning must happen inside a single forward pass. Studied in three 3-4B-parameter transformers. The composition: the model builds a key-value memory over the label-token positions. Each label token's residual stream encodes the label's identity (the value), and middle-layer attention heads write into that position the class of the preceding demonstration (the key) - induction-head-style binding, but storing class rather than token identity. At the query, upper-layer reader heads match the query's class representation against the stored keys and copy out the label attached to the matching key. Two control components complete the circuit: an early-layer signal encoding whether any label has REPEATED anywhere in the prompt gates the readout - without it, the reader heads attend to the start of the prompt and no label is favored, so the lookup only fires once the prompt actually contains a repeated-label structure to look up - and a separate set of heads suppresses the most recently seen label, countering a pure recency/copy bias. Every step is established causally, not correlationally: activation patching, head ablations benchmarked against random-head baselines, and steering with the model's own signals; and a softmax model of the readout with just two fitted constants per head, fit on one prompt distribution, predicts behavior on a different distribution. Generality claims: the computation is conserved across all three models; the named heads alone reproduce the behavior; a transformer trained from scratch grows the same parts (the circuit is an attractor of training, not an artifact of one checkpoint); it transfers from arbitrary labels to semantic concepts and labels with meaning; and within one model family the same parts with the causal gate appear from 0.6B to 8B parameters and survive instruction tuning. Caveats: abstract-level evidence; the setting is few-shot classification - the most lookup-like form of ICL - and says nothing directly about many-shot, regression-style, or open-ended generative ICL; the three main models are not named in the abstract. Catalog placement: the mechanism counterpart to ID 1765 (LIDAS), which argued grown/looped models share a context-over-weights inductive bias rooted in induction heads - this paper shows what a mature version of that bias looks like as an explicit circuit: bind demonstrations into a key-value store in the residual stream, gate the lookup on prompt structure, and read by class match. The gating signal is also the architecturally interesting part: the model checks a global prompt property (has any label repeated?) before trusting its own associative memory.
- Paper
bf16 Rounding Silently Discards Most RL Policy Updates: A Hidden Training-Inference Mismatch and an Unbiased One-Line Fix
RL post-training keeps fp32 master weights in the optimizer and serves rollouts from a bf16 copy made by round-to-nearest conversion - the export rule in every open-source framework the authors examined (verl, TRL, OpenRLHF, slime, prime-rl, AReaL). Near a weight of magnitude |w| the bf16 grid spacing is u ~ |w|/128, so round-to-nearest discards any update smaller than u/2 ~ |w|/256; at common RL learning rates (eta ~ 1e-6) almost every update is that small. Measured on Qwen3-1.7B: only 0.4-0.5% of served weights change per optimizer step (0.13% at eta = 3e-7), a weight crosses a rounding boundary only every ~50-200 steps, and under a decaying LR schedule the sampler effectively freezes while the optimizer keeps moving - the data-generating policy lags the optimizer by 50-150 steps. Muon is worse: its per-element updates are nearly uniform in magnitude, so at eta = 1e-6 almost none cross a boundary. The mismatch is invisible to existing corrections (PPO clipping, truncated importance sampling, IcePop) because the ratio they form compares the trainer's bf16 forward pass with the sampler, and both sit downstream of the same rounding: the visible per-token |log rho| stays ~0.01 all training while the hidden master-versus-served ratio - never formed by any framework - grows to 0.10-0.16 on MATH and ~0.45 on knights-and-knaves, with per-token effective sample size between master and served policy falling to 0.2-0.35 on 2,000-token tasks. Fix (Fair Cast): export with an unbiased rounding rule - stochastic rounding (E[q] = theta exactly) or error feedback (a sigma-delta-style residual keeping accumulated export error bounded by u) - AND compute the training loss on the served copy; both halves are necessary, either alone fails. One line at the export call, no hyperparameters, 22-38 ms per export of 1.7B parameters. Results across 25 matched seed-pairs (Qwen3-0.6B to 4B, AdamW and Muon, GRPO on logic/game/math/code tasks): Fair Cast ahead on 18, tied on 6, behind on 1, mean gain 6.1 points; zebra puzzles 0.57 +/- 0.16 over four runs vs round-to-nearest collapsing to 0.33 +/- 0.10; on knights-and-knaves the round-to-nearest sampler stays frozen for the first ~20 steps (0.12 -> 0.15 -> 0.22) where Fair Cast moves immediately (0.12 -> 0.51 -> 0.79), and a single optimizer step moves an fp32 sampler 0.17 -> 0.84 while the bf16 round-to-nearest sampler stays at 0.19 across three steps. Two further findings: under round-to-nearest the saved fp32 checkpoint can score 12-50 points BELOW its own served export (the checkpoint is not the model; any finer export inherits the gap), and the round-to-nearest lag is an uncontrolled low-pass filter on the served policy that acts as a regularizer - exporting an EMA of the master with the same unbiased rounding restores it as a single explicit knob and surpasses round-to-nearest on the one task where the filter helps. Relation to prior diagnostics: Dirhoussi, Gallouedec et al. derived the same dead-zone threshold and PULSE measured the resulting update sparsity, but both treated it as a communication artefact and made the trainer agree with the stale sampler; this paper instead makes the served copy track the master and trains on the served copy. Code and full training harness public (MIT). Joins the precision thread and the train-inference-mismatch cluster (IDs 1588/1589): it identifies a mismatch upstream of every correction in that cluster, since they all compare copies downstream of the rounding.