GRPO-style reinforcement learning for diffusion models
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI/ML design interview question asked in Google's first round (coding), last asked Dec 2025. It tests reinforcement learning, diffusion and post-training.
Explain how group relative policy optimisation (GRPO) fine-tunes a language model against a reward, then adapt it to fine-tune a text-to-image diffusion model against a reward such as human preference or prompt alignment. The interviewer wants the mechanics, not just the names: what the policy and the actions are, where the log-probabilities come from, how advantages are computed, and what keeps training from collapsing.
Requirements
- Functional: start from a pretrained diffusion model and a reward model that scores a (prompt, image) pair; produce a fine-tuned model whose samples score higher without losing quality or diversity.
- Non-functional: training cost (sampling many images per prompt is expensive), stability, and protection against reward hacking.
Clarifying questions
- Which sampler: a stochastic SDE sampler, or a deterministic ODE/DDIM sampler? A deterministic sampler has no per-step likelihood.
- Is the reward differentiable (an image model we can backpropagate through) or a black box?
- How many denoising steps, and can we train on a subset of them?
- Do we keep a frozen reference model for a KL penalty?
- How large can a group be per prompt, given the compute budget?
What a strong answer covers
- GRPO for LLMs: sample a group of
Gresponses per prompt, score them, use(r - mean) / stdwithin the group as the advantage, so no value network is needed; a PPO-style clipped ratio and a KL term to a reference model. - Diffusion as an MDP: the state is
(x_t, t, prompt), the action is the next latentx_{t-1}, the policy is the model's Gaussian transition, so each step has a log-probability. The reward arrives only at the final image. - Making likelihoods available: turn the ODE sampler into an SDE (or use a stochastic DDPM sampler) so the per-step Gaussian log-probabilities exist; every step of a trajectory shares the same group-normalised advantage.
- Grouping: all samples in a group share a prompt (and often an initial noise schedule), so the advantage compares like with like.
- Stability: clipped importance ratios, KL to the reference, small learning rates, training on a random subset of timesteps, and normalising rewards; how std near zero in a group is handled.
- Reward hacking: over-saturated images, text in the image, loss of diversity. Use held-out reward models, human eval, and early stopping.
- Compared with alternatives: DDPO, DPO-style preference losses for diffusion, and direct reward backpropagation when the reward is differentiable.
Follow-ups
- How would you cut the cost of sampling
Gfull trajectories per prompt? - Rewards from two models conflict (aesthetics against prompt fidelity). How do you combine them?
- How do you detect that the model is gaming the reward before humans notice?
Where it's asked
- Google · First round: coding · Last asked Dec 202545 min · Coding in a Google Doc, no syntax highlighting or autocomplete · No AI
What it tests
reinforcement learning · diffusion · post-training
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
