Lesson deck

Training practice and distributed training flashcards

Reviewing needs JavaScript. You can read every card in the list below.

Loading your cards...

Back to the lesson13 cards in this deck

Read all 13 cards as a list
  1. Front
    Which tokens carry the loss in a typical SFT run, and why?
    Back
    The response (completion or assistant) tokens, so the number measures the behaviour you want to teach. Padding is excluded by an ignore index. Check that the prompt is masked and the end token is present.
  2. Front
    Why not pick the checkpoint by validation loss alone?
    Back
    Cross-entropy measures imitation, not the task. Choose by a held-out task metric (JSON-valid rate, exact match, rubric score), and use validation loss as a sanity check.
  3. Front
    Name two quiet setup errors that give a healthy-looking SFT curve.
    Back
    A length limit that truncates the answer away, and an end token that is missing or does not match the chat template so the model never stops. Loss on prompt tokens is a third.
  4. Front
    Effective batch size with accumulation and several GPUs?
    Back
    Sequences per pass x accumulation steps x data-parallel GPUs. Accumulation saves activation memory and costs wall-clock time; the update is the same as one large batch.
  5. Front
    What does gradient checkpointing save, and what does it cost?
    Back
    It saves activation memory by not storing them all, and costs extra compute because they are recomputed in the backward pass. It does not shrink weights, gradients or optimiser state.
  6. Front
    Which memory levers attack activations, and which attack model states?
    Back
    Activations: smaller per-pass batch (accumulation), checkpointing, shorter sequences, activation offloading. States: LoRA or QLoRA, sharding (ZeRO or FSDP), offloading states to CPU or NVMe.
  7. Front
    The accumulation loss trap for token-level losses?
    Back
    Correct loss = total loss over the accumulation step divided by the total non-padding tokens in it, not the average of per-batch averages. Averaging the averages over-weights short sequences.
  8. Front
    Per-GPU model states with Adam in mixed precision, P parameters, N GPUs?
    Back
    Replicated: 16P. ZeRO-1: 4P + 12P/N. ZeRO-2: 2P + 14P/N. ZeRO-3 or FSDP full shard: 16P/N. Floors, before activations and temporary gathered layers.
  9. Front
    What does full sharding pay for its memory saving?
    Back
    More communication: parameters are all-gathered around the forward and backward passes and gradients reduce-scattered. The ZeRO paper counts 1.5 times the data-parallel volume for stage 3.
  10. Front
    When should you not shard?
    Back
    When weights, gradients, optimiser state and activations already fit on one GPU. Plain data parallelism is simpler and avoids the gathering traffic. Offload only after sharding is not enough.
  11. Front
    Training loss falls, validation loss rises, task metric falls. What is it and what do you do?
    Back
    Overfitting. Restore an earlier checkpoint or train fewer epochs, and consider more varied data. It is different from forgetting, which validation loss on your own data does not show.
  12. Front
    The debugging order for a misbehaving run?
    Back
    Decode what the model sees (inputs and labels), overfit a tiny batch, compare training and serving prompts, run the base model for a true baseline, then change one variable at a time with seed, versions and data hash pinned.
  13. Front
    Loss flat from step 0: first checks?
    Back
    Decode a batch to see whether the labels are all masked, count trainable parameters, and try to overfit eight examples. Only then look at learning rate.