Milestone 3 of 7

Overfit one sequence

Use one repeated sequence to test whether targets, loss, gradients, and parameter updates form a learnable path.

Before training the corpus, repeat one sequence until the decoder can fit it. This is a narrow diagnostic of the connected training path, not a test of generalization.

Milestone goal

Train only

input:  <bos> A B C
target: A     B C <eos>

for 500 updates with the frozen model, initialization, optimizer, learning rate, and clipping rule. Preserve the complete diagnostic record and make a GO/NO-GO decision for corpus training.

Record the update in dependency order

For every step:

  1. enter training mode;
  2. clear old gradients;
  3. calculate logits and aligned cross-entropy;
  4. run backward;
  5. record the global gradient norm before clipping;
  6. clip to 1.0 and record the norm after clipping;
  7. update parameters.

At selected steps, switch temporarily to evaluation mode and record full-batch loss, the probability assigned to each of the four targets, and the predicted token at each position.

Do not reuse a loss tensor after its parameters have changed. Label whether a measurement was taken before or after the update.

Establish the expected pattern

The initial loss should be in the neighborhood of the uniform baseline log82.0794\log 8\approx2.0794, although initialization can move it. A correct and expressive training path should reduce the loss close to zero on this single repeated row.

The checked reference reaches final loss 0.00186184. Treat that number as a regression clue, not a universal threshold: framework versions and floating- point kernels can change the last digits. What matters is a large, stable loss reduction and high probability on all four declared targets.

Preserve a diagnostic table

Use at least these fields:

steplossgradient norm before clipafter clipminimum target probabilityfour predicted tokens

Record steps 0, 1, 2, 5, 10, 25, 50, 100, 250, and 500. A final loss alone cannot show an unstable spike, permanently clipped gradients, or one target that never learned.

Diagnose a failed overfit

Check contracts before adding width, depth, or more steps:

ObservationFirst checks
loss does not movegradient existence, zero_grad, backward, and optimizer step
one position stays wronginput-target shift and causal visibility
loss is NaNlogits, mask rows, learning rate, and gradient norm
gradient is always zerodetached logits, frozen parameters, or saturated path
gradient is clipped every steppre-clip norm and learning-rate scale
training predictions are correct but loss is hightarget IDs, flattening, and reduction

Change one suspected cause at a time and preserve the failed trace. Silent trial-and-error destroys the evidence this milestone is meant to create.

Question. Interpret the diagnostic

The model overfits one repeated sequence but corpus validation remains poor. What has and has not been established?

Choose one

Select one choice, then check.

Hint
Ask whether validation examples participated in this diagnostic.
Solution
The model and update path can fit that repeated sequence. The test does not establish generalization to the corpus or validation split.
Not attempted
Review

Not marked done.

Acceptance gate

Issue GO only if:

  • the loss falls from its initialized value to a small, finite value;
  • every target probability rises and every final target prediction is correct;
  • gradients are present, finite, and recorded before and after clipping;
  • repeating the run with the same environment and seeds reproduces the trace within the declared tolerance;
  • the result is described only as a one-sequence training-path diagnostic.

Otherwise issue NO-GO, preserve the first failing check, and repair it before corpus training.

Deliverable: the diagnostic table, target-probability trace, final predictions, failed checks if any, and the signed GO/NO-GO decision.