LearnQuestion bank

Your GRPO run generates rollouts with a fast inference engine and computes gradients in a separate FSDP trainer, partly asynchronously. Reward climbs for a few hundred steps and then training collapses, although the same weights are loaded in both places. Explain training–inference mismatch, how you would confirm it is the cause, and what you would change.

ML engineeringTechnicalHard

Answer it yourself first, out loud or on paper, then compare.

Answer

Model answer, written in a candidate's voice

In short

  • Same weights can still yield different token probabilities across engine and trainer, making rollouts off-policy.
  • Asynchrony adds stale-weight mismatch on top of numerical mismatch.
  • Log per-token and per-sequence engine-vs-trainer logprob gaps and implied KL/ratios over training; check whether spikes precede collapse.
  • Correct with truncated importance weights, masking/rejecting high-mismatch sequences, or sequence-level ratios such as GSPO.
  • Fix numerics and staleness: FP16 instead of BF16 in both engine and trainer (reported to largely remove the mismatch), matched/deterministic kernels, bounded staleness or more frequent weight resync.
  • Verify against a small zero-mismatch or synchronous reference run by comparing stability and final reward.

In full

The core point is that loading the same weights into the inference engine and the FSDP trainer does not guarantee the same token probabilities: different kernels, reduction order, BF16 rounding, MoE routing, and logprob computation make the rollouts slightly off-policy, and asynchrony adds a second mismatch from stale weights. I would confirm this by logging, per token and per sequence, the engine log-probability versus the trainer log-probability for the same prompts and completions, plus the implied KL or importance ratio, and by tracking those over training to see whether spikes precede the collapse and whether they correlate with weight-version lag. The fix is to stop treating the data as exactly on-policy: use truncated importance weighting, mask or reject sequences whose accumulated mismatch exceeds a threshold, or use sequence-level ratios as in GSPO. I would also shrink the numerical gap itself: a late-2025 paper reported that running both engine and trainer in FP16 instead of BF16, whose 7 mantissa bits cause larger rounding differences, largely removes the mismatch (FP16 brings back the need for loss scaling); matched or deterministic kernels help too, and in the async setup I would bound staleness or resynchronise weights more often. I would then validate at small scale against a zero-mismatch or synchronous reference run, comparing reward stability, final reward, and the logged mismatch rather than trusting the same-weights check alone.

Corrected by an independent AI reviewer.

What a strong answer covers

  • Explains that the engine and trainer compute slightly different token probabilities (different kernels, reduction order, BF16 rounding, MoE routing), so data treated as on-policy is actually off-policy; asynchrony adds a second source, stale weights.
  • Diagnoses by logging, per token and per sequence, the gap between engine and trainer log-probabilities (and the implied KL) over training, and checks whether spikes precede the collapse.
  • Proposes corrections: importance weighting with truncation (truncated importance sampling), masking or rejecting sequences whose accumulated mismatch exceeds a threshold, or sequence-level ratios as in GSPO.
  • Proposes numerical fixes: FP16 instead of BF16, matched or deterministic kernels, and bounding staleness or resynchronising weights in asynchronous setups.
  • Says how to verify the fix: compare stability and final reward against a zero-mismatch or synchronous reference run at small scale.

Common mistakes

  • Blaming only the learning rate or the reward function without measuring the probability gap.
  • Assuming identical weights guarantee identical probabilities.

Follow-ups

  • Why might the problem be worse for mixture-of-experts models?
  • What does truncation trade off in bias versus variance?