Your RL loop samples rollouts with a fast inference engine and trains with FSDP. Why do the two disagree on token log-probs, and what do you do about it?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Because they are different programs computing the "same" policy. The sampler and the trainer use different kernels, different reduction orders, often different precision (FP8 weights or a quantized KV cache in the sampler, bf16 in the trainer), plus prefix caching and batch-dependent numerics. In MoE models they can also route borderline tokens to different experts. So the probability of a sampled token under the sampler, mu, is not the probability under the trainer, pi, even with identical weights. Your on-policy algorithm is silently off-policy.
Full worked answer with diagram
Because they are different programs computing the "same" policy. The sampler and the trainer use different kernels, different reduction orders, often different precision (FP8 weights or a quantized KV cache in the sampler, bf16 in the trainer), plus prefix caching and batch-dependent numerics. In MoE models they can also route borderline tokens to different experts. So the probability of a sampled token under the sampler, mu, is not the probability under the trainer, pi, even with identical weights. Your on-policy algorithm is silently off-policy.
Why it matters: PPO and GRPO compute ratios and advantages assuming the samples came from pi. When they came from mu, the gradient is biased. Small per-token gaps compound over long reasoning traces and multi-turn agent episodes, and the typical symptom is a run that trains normally for a while, then collapses with exploding gradients, which is easily misdiagnosed as a learning-rate problem. Asynchronous pipelines, where the sampler runs one or more policy versions behind the trainer to keep GPUs busy, add deliberate staleness on top.
What I do, in order:
- Measure it. Recompute trainer log-probs for the sampled tokens and log the per-token gap and its tail. Without this you cannot separate mismatch from a bad hyperparameter.
- Correct with importance weights. Weight each token's loss by pi_old over mu, where pi_old is the trainer's probability under the weights that generated the sample, truncated at a cap so a few extreme tokens cannot dominate. Mask sequences whose ratio is wildly off.
- Shrink the gap at source. Match precision where you can (some teams report FP16 beats bf16 here), make sampler numerics deterministic, and for MoE replay the sampler's routing decisions in the trainer.
- Bound staleness. Cap how many versions behind the sampler may run, and treat the correction as mandatory once you go async.
Worth sketching. where the two sets of log-probs come from and where the correction slots in.
sequenceDiagram
participant T as Trainer
participant S as Sampler
participant V as Verifier
participant L as Metrics log
T->>S: Push weights, version k
S->>V: Rollouts sampled under mu
V->>T: Rewards plus sampler log-probs
T->>T: Recompute pi log-probs on the same tokens
T->>L: Per-token gap between pi and mu
T->>T: Loss weighted by pi over mu, truncated at a cap
T->>S: Push weights, version k plus 1
What a good answer covers
- Because they are different programs computing the "same" policy
- The sampler and the trainer use different kernels, different reduction orders, often different precision…
- In MoE models they can also route borderline tokens to different experts
- So the probability of a sampled token under the sampler, mu, is not the probability under the trainer,…
- Your on-policy algorithm is silently off-policy
Key terms: Measure it · Correct with importance weights · Shrink the gap at source · Bound staleness
In the glossary: FP8 / INT8 · KV cache · Prefix caching · MoE · PPO · GRPO
Interviewer follow-ups to expect
How would you tell training-inference mismatch apart from a learning rate that is simply too high?
What does going fully asynchronous buy you in throughput, and what does it cost in correctness?
Why is mismatch worse for MoE models?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep