On-policy distillation · film experiment 04

One mistake,
frame by frame.

The student sampled B. Keep that branch fixed while sample, prefix, teacher query, divergence, and update arrive one beat at a time.

Reader outcome
Classify trajectory provenance separately from divergence direction, then recompute one token-distribution KL.
Experiment status
The spatial-continuity hypothesis is unproven. This build contains no learner study and makes no mastery claim.

The student draws B. It may not be the branch we wish it had taken. But once the student visits xB, the teacher must respond at xB.

That one decision clears up most of the phrase on-policy distillation. “On-policy” identifies the source of generated trajectories or prefix states. It does not name the divergence. Reverse KL, forward KL, JSD, or another discrepancy is a separate design choice.

sourced OPD-CL-001, OPD-CL-003 · Agarwal et al.’s canonical GKD formulation exposes student-data fraction and divergence as separate choices. See ICLR 2024 author manuscript v3, §3.1 and the official proceedings record.

sample → visit a prefix → query the teacher there → compute a local loss → update the student

You should leave able to name each boundary, recompute the toy loss, and classify two changed cases. Watching or answering is a self-check, not evidence of mastery.

Notation, just in time

x
a fixed input prompt
pS(· | s)
student next-token distribution at prefix s
pT(· | s)
teacher next-token distribution at the same prefix
policy / prefix
distribution used to act / tokens already generated
Act 1

“On-policy” names a source.

The fixed prompt is not the crucial provenance question. Canonical GKD can draw x from a fixed set X and still sample the completion y | x freshly from the student.

sourced OPD-CL-006 · Agarwal et al., §3.1 Eq. 4 and Algorithm 1.

Two axes that should stay on separate lines.
AxisQuestionExamples
Trajectory provenanceWhich distribution generated the completion or prefix?current student; fixed teacher data; mixture
Training objectiveHow is the student changed at those states?forward KL; reverse KL; JSD; NLL; policy-gradient estimator

Putting reverse KL on a teacher-generated fixed prefix does not make the state on-policy. Putting forward KL on a freshly student-generated prefix does not make it off-policy.

OPD-TOY-001 · invented teaching fixture

Shared vocabulary (A, B). At the first prefix: pS(·|x)=(0.75,0.25) and pT(·|x)=(0.50,0.50).

These values are not real-model logits, a benchmark, or evidence that any method improves quality.

Act 2

Preserve the sampled branch.

Script-free prediction and answer

After the student samples B, query the teacher at xB. That is the visited prefix; xA remains off this trajectory.

FILM-CL-001 · The cumulative student intervals are [0,.75) for A and [.75,1) for B. The draw therefore selects B unambiguously, producing the visited prefix xB. Do not repair the trajectory before evaluating it.

Film FILM-VIDEO-001

Silent film with burned-in narration. A complete WebVTT track is available from the native captions menu but starts off to avoid duplicate text; when enabled, its cues sit at the top, away from the burned-in band. No autoplay.

02:08 · 1920×1080 · 30 fps · silent AAC trackBurned-in narration + optional WebVTT

Reduced-motion mode hides the moving film. The complete six-frame semantic version is expanded below.

Six inspectable beats FILM-EXP-001

The film is not the sole lesson. Every frame below includes the same branch, values, equation, narration, and relationship in selectable text.

Beat 1 · set up

“On-policy” names a source.

sourced + toy
Film keyframe showing fixed prompt x, student next-token bars, and separate axes for trajectory source and loss choice.

Static keyframe. Prompt x remains fixed; the student is the source of the completion.

A fixed prompt does not make a completion off-policy. Policy means the next-token distribution used to generate the trajectory; divergence is chosen later.

pS(·|x) = (0.75, 0.25) over (A, B)

Infer from the layout: provenance and objective occupy different axes.

Beat 2 · sample

The draw lands on B.

toy + derived
Film keyframe showing cumulative A and B intervals with a marker at u equals 0.80 inside B.

Static keyframe. The B branch appears in the lower lane and will stay there.

xABxA · not visitedxB · next
u = 0.80 → B

Sampling is data collection. In this canonical GKD-style fixture, the discrete draw is detached.

The draw chooses the path; it is not yet the teacher query or loss.

Beat 3 · visit

The visited prefix is xB.

derived
Film keyframe preserving B and xB in the lower lane while xA is crossed out as not visited.

Static keyframe. xA remains visible only as an excluded comparison.

xABxA · not visitedxB · visited

B makes xB the visited prefix. xA is a comparison branch, not part of this trajectory and not part of its canonical loss.

Do not swap in the branch the teacher might have preferred.

Beat 4 · query

Ask the teacher at xB.

sourced + toy
Film keyframe showing student and teacher A B distributions aligned at the visited prefix xB.

Static keyframe. The teacher’s dashed query line ends at the same xB prefix.

xABxA · not visitedxB · visitedteacher here
student (A,B)(0.60, 0.40)teacher (A,B)(0.90, 0.10)

The teacher supplies a distribution at the same prefix. It does not replace the trajectory.

Same-prefix evaluation is the relationship to preserve.

Beat 5 · divergence

Now measure disagreement.

toy + derived
Film keyframe showing reverse KL at xB, its A and B terms, x total, and the unrounded two-position mean.

Static keyframe. This is full-vocabulary feedback over the aligned toy tokens.

DKL(pS ∥ pT; xB) = Σv pS(v|xB) ln[pS(v|xB)/pT(v|xB)]
A term−0.243279B term+0.554518xB total0.311239 natsx total0.130812 natsunrounded mean0.221025 nats

Reverse KL is one objective choice. It is not what makes the state on-policy.

Reduce unrounded state totals; xA remains excluded.

Beat 6 · update

Only then: update the student.

canonical GKD-style
Film keyframe showing a stop marker at the discrete B draw and a separate gradient arrow from mean divergence to student parameters.

Static keyframe. The stop marker and update arrow are separate visual edges.

θ ← θ − η ∇θ[mean visited-prefix divergence]

No gradient passes through the discrete B draw in this canonical fixture. The local student distribution in the divergence is the differentiable part.

Transfer question OPD-XFER-B: student B + teacher at xB + forward KL. Is the state source still on-policy?

Yes. Forward KL changes the objective, not who generated xB.

sourced OPD-CL-002, OPD-CL-004, OPD-CL-005 · Canonical GKD compares teacher and student at intermediate prefixes and explicitly does not backpropagate through the sampling process. This stop-gradient boundary is not a universal definition of every method called OPD.

Act 3

Reverse KL is one objective.

At a visited prefix s, this film chooses the discrete reverse KL:

DKL(pS∥pT;s)=∑vpS(v|s)lnpS(v|s)pT(v|s)
Text: weight each natural-log probability ratio by the student probability, then sum over the aligned vocabulary.
Deterministic reverse-KL derivation at the student-visited prefix xB.
TokenContributionSix decimals
A0.60 ln(0.60/0.90)−0.243279
B0.40 ln(0.40/0.10)+0.554518
xB total0.311239 nats

An individual contribution can be negative; the complete KL is non-negative. At the first visited position x, the total is 0.130812 nats.

D¯=D(x)+D(xB)2=0.221025 nats
The unweighted mean uses the two unrounded visited-position totals, then rounds once.

FILM-CL-002 · rounding trap

Averaging the displayed 0.130812 and 0.311239 gives 0.221026. The contract’s 0.221025 is correct because the full-precision totals are averaged before display rounding.

What this toy assumes

toy boundary FILM-CL-007 · Canonical GKD reports student sampling temperature γ=1 during its experiments. This fixture also assumes aligned tokenization, two visited positions, no EOS, fresh behavior-policy sampling, and full-vocabulary feedback. None is treated here as a universal production default.

Runnable companion `FILM-LAB-001`. From the variant folder: python -B lab/opd_toy.py, then python -B -m unittest -v lab.test_opd_toy. The standard-library lab checks full-precision terms, branch selection, boundaries, xA exclusion, and forward/reverse anti-conflation.

Act 4

Stop at the update boundary.

Only after the local discrepancies have been reduced do we write the symbolic student update:

θ←θ−η∇θD¯
This marks the gradient boundary. The toy does not provide a parameterization, optimizer state, or learning rate, so no numeric post-update distribution is invented.

The sampled B is detached data in this canonical GKD-style estimator. MiniLLM is a different construction: it starts from sequence-level reverse KL and derives a policy-gradient optimizer with additional single-step, long-term, mixed-sampling, importance-weight, and length choices.

sourced distinction OPD-CL-007 · GKD: Agarwal et al., §3–3.1. MiniLLM: Gu et al., current author manuscript v6, §2.1–2.3; ICLR 2024 record.

FILM-FIG-002 · Neighboring methods classified without name collapse.
MethodState / sequence sourceTeacher feedbackObjective / updateStatus
Canonical on-policy GKD (`λ=1`)current student completion from fixed promptsfull next-token distribution at visited prefixeschosen token-distribution divergence; sampling detachedICLR 2024
FILM-CL-003
Fixed teacher SeqKD
teacher-decoded static sequenceshard teacher sequencesupervised NLL / cross-entropyEMNLP 2016
FILM-CL-004
ImitKD
configurable fixed/student mixture; pool may lagteacher argmax or distribution at those prefixesimitation-learning updateEMNLP 2020
MiniLLMstudent / teacher-mixed sequence samplingsequence-level teacher likelihood and derived termsreverse-KL policy-gradient formulationICLR 2024
Scalar-reward RLusually student rolloutsscalar reward / returnpolicy-gradient familydifferent signal; combinable
FILM-CL-005
Thinking Machines recipe
student trajectoriesteacher/student log-probability for realized tokensnegative log-ratio advantage via RL importance sampling2025 engineering report

Feedback granularity is another axis. Full-vocabulary feedback exposes every aligned token probability. Sampled-token feedback observes the realized token. Top-k feedback retains only a subset. A 2026 paper formalizes these variants; it is recent preprint evidence, not peer-reviewed proof that one universally wins.

recent preprint FILM-CL-006 · Li et al., arXiv:2604.13016v2, §2.2. The 2025 engineering report explicitly says its experiments did not use top-k/logit distillation.

FILM-CL-008 · local evidence boundary

Three claims this signal does not earn.

  1. Teacher confidence is not proof of correctness.
  2. Tokenwise conditional feedback is not automatically causal attribution or process supervision.
  3. A stronger teacher does not guarantee a better student, and OPD does not universally beat SFT, offline distillation, or RL.
Transfer

Separate the axes yourself.

OPD-XFER-A

A learner uses reverse KL on a fixed teacher-generated xA prefix. Is the divergence reverse KL, and is the state sampling on-policy? Explain both axes separately.

Model reasoning

The objective is reverse KL. The response prefix is fixed and teacher-generated rather than sampled by the current student, so its state provenance is not on-policy.

OPD-XFER-B

A learner samples B from the student, queries the teacher at xB, and computes forward KL. Is this on-policy distillation? Explain why divergence direction does not change the state source.

Model reasoning

Yes: the visited prefix is on-policy because the student generated B. Forward KL is the independently chosen objective. No gradient through the discrete draw is implied.

These are transfer-oriented self-checks, not a validated assessment and not evidence of durable learning.

The compact mental model. The student created xB. The teacher was evaluated at xB. Reverse KL was chosen separately. The draw was detached in this canonical fixture. The local loss then defined the parameter-gradient boundary.

Sources

Primary sources and status.