PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Machine Learning/Anthropic

Debug a GRPO training loop and explain ratios

Last updated: Apr 28, 2026

Quick Overview

This question evaluates debugging and implementation knowledge for on-policy reinforcement learning, focusing on GRPO/PPO-style training loops, importance-sampling ratios, log-prob computations, masking, and advantage normalization.

  • medium
  • Anthropic
  • Machine Learning
  • Software Engineer

Debug a GRPO training loop and explain ratios

Company: Anthropic

Role: Software Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

You are given a simplified implementation of a **GRPO (Group Relative Policy Optimization)** training step for an RLHF-style policy model. The training is supposed to be **strictly on-policy**, meaning rollouts are generated by the same policy that is being updated. Tasks: 1. Walk through the **end-to-end GRPO training flow**: sampling prompts, generating rollouts, computing group-based advantages (relative within a group of completions), computing the policy gradient loss, and updating the policy. 2. You find that training is unstable due to several straightforward implementation issues. Describe **three common, easy-to-miss bugs** in a GRPO/PPO-like training loop that would cause incorrect learning (e.g., wrong log-prob computation, incorrect masking, advantage normalization mistakes, mixing policies, etc.). For each, explain how you would detect it and how to fix it. 3. During debugging you notice the importance-sampling ratio \[ \text{ratio} = \exp(\log \pi_{\theta}(a|s) - \log \pi_{\text{old}}(a|s)) \] is **not always 1**, even though you expected the method to be strictly on-policy. Explain **why the ratio might deviate from 1** in practice. List the most likely causes and what to check in the training pipeline to confirm each cause.

Quick Answer: This question evaluates debugging and implementation knowledge for on-policy reinforcement learning, focusing on GRPO/PPO-style training loops, importance-sampling ratios, log-prob computations, masking, and advantage normalization.

Related Interview Questions

  • Design a Double Descent Experiment - Anthropic (medium)
  • Explain batch inference design - Anthropic (medium)
  • Implement and derive backprop from scratch - Anthropic (medium)
  • Implement and analyze custom attention - Anthropic (hard)
Anthropic logo
Anthropic
Feb 19, 2026, 12:00 AM
Software Engineer
Technical Screen
Machine Learning
65
0

You are given a simplified implementation of a GRPO (Group Relative Policy Optimization) training step for an RLHF-style policy model. The training is supposed to be strictly on-policy, meaning rollouts are generated by the same policy that is being updated.

Tasks:

  1. Walk through the end-to-end GRPO training flow : sampling prompts, generating rollouts, computing group-based advantages (relative within a group of completions), computing the policy gradient loss, and updating the policy.
  2. You find that training is unstable due to several straightforward implementation issues. Describe three common, easy-to-miss bugs in a GRPO/PPO-like training loop that would cause incorrect learning (e.g., wrong log-prob computation, incorrect masking, advantage normalization mistakes, mixing policies, etc.). For each, explain how you would detect it and how to fix it.
  3. During debugging you notice the importance-sampling ratio

ratio=exp⁡(log⁡πθ(a∣s)−log⁡πold(a∣s))\text{ratio} = \exp(\log \pi_{\theta}(a|s) - \log \pi_{\text{old}}(a|s))ratio=exp(logπθ​(a∣s)−logπold​(a∣s))

is not always 1, even though you expected the method to be strictly on-policy. Explain why the ratio might deviate from 1 in practice. List the most likely causes and what to check in the training pipeline to confirm each cause.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More Anthropic•More Software Engineer•Anthropic Software Engineer•Anthropic Machine Learning•Software Engineer Machine Learning
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.